Skip to content

Commit

Permalink
Merge pull request #48 from tonlabs/SDK-4249-do-not-hide-exit-code-in…
Browse files Browse the repository at this point in the history
…-flex-sdk

Sdk 4249 do not hide exit code in flex sdk
  • Loading branch information
melsomino authored Feb 10, 2023
2 parents f3350c7 + 63dcbfc commit f33fb49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ All notable changes to this project will be documented in this file.
1) hex string with `0x` prefix;
2) hex string of 64 char length without `0x` prefix;
3) decimal string.

- `Trader.deployEverWallet` accepts token parameters as `TokenValue` instead of `number`'s.

- Changed contract errors: "<contract-name> failed with exit code <exit-code>. <known-contract-error-message>.".

## [0.10.2] – 2022-12-14

### Fixed
Expand Down
12 changes: 5 additions & 7 deletions contracts/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export function errorFromExitCode(contract: AccountClass, exitCode: number): Con
exitCode < 0 ? `_cpp_${Math.abs(exitCode)}` : exitCode.toString()
}`,
exitCode,
message: `${contract.name} failed with exit code ${exitCode}. See contract documentation or contact contract developers for details.`,
message: `See contract documentation or contact contract developers for details.`,
};
const error: ContractError = new Error(contractError.message);
const error: ContractError = new Error(
`${contract.name} failed with exit code ${exitCode}. ${contractError.message}.`,
);
error.code = ProcessingErrorCode.MessageRejected;
error.data = {
...error.data,
Expand Down Expand Up @@ -59,11 +61,7 @@ export function findTransactionError(
contract: AccountClass,
altErrorCode: number = 0,
): Error | undefined {
const {
id,
aborted,
account_addr,
} = transaction;
const { id, aborted, account_addr } = transaction;
const exitCode = transaction.compute?.exit_code ?? 0;
const errorCode = exitCode !== 0 ? exitCode : altErrorCode;
if (!aborted && errorCode === 0) {
Expand Down
8 changes: 8 additions & 0 deletions tests/web3.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from "@playwright/test";
import { errorFromExitCode, FlexWalletAccount } from "../contracts";

test("error from exit code", () => {
expect(errorFromExitCode(FlexWalletAccount, 102).message).toBe(
"FlexWalletAccount failed with exit code 102. Message sender is not RootTokenContract address.",
);
});

0 comments on commit f33fb49

Please sign in to comment.