Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdk 4249 do not hide exit code in flex sdk #48

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
NEW: Changed contract errors: "<contract-name> failed with exit code …
…<exit-code>. <known-contract-error-message>.".

SDK-4249
  • Loading branch information
melsomino committed Jan 12, 2023
commit 63dcbfca8f1d00740f0a241f9383df9d216b6f39
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.",
);
});