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

Custom revert errors not showing w/ TypeScript SDK #1836

Closed
theausicist opened this issue Mar 6, 2024 · 1 comment
Closed

Custom revert errors not showing w/ TypeScript SDK #1836

theausicist opened this issue Mar 6, 2024 · 1 comment
Assignees
Labels
bug Issue is a bug

Comments

@theausicist
Copy link
Contributor

What version of fuels-ts are you using?

0.76.0

Steps to Reproduce

use the following contract:

contract;
  
abi Tester {
    fn fail_implicity();
}

enum Error {
    FailImplicitly: ()
}

impl Tester for Contract {
    fn fail_implicity() {
        require(false, Error::FailImplicitly);
    }
}
 

using the Typescript SDK to deploy the contract (via local node) and execute:

await tester.functions.fail_implicitly().call()

results in the following error:

     RequireRevertError: The script reverted with reason RequireFailed
      at revertErrorFactory (node_modules/@fuel-ts/program/src/revert/revert-error.ts:178:10)
      at RevertErrorCodes.getError (node_modules/@fuel-ts/program/src/errors.ts:7:7)
      at RevertErrorCodes.assert (node_modules/@fuel-ts/program/src/revert/revert-error-codes.ts:30:30)
      at new ScriptResultDecoderError (node_modules/@fuel-ts/program/src/functions/base-invocation-scope.ts:15:30)
      at decodeCallResult (node_modules/@fuel-ts/program/src/script-request.ts:162:7)
      at decodeContractCallScriptResult (node_modules/@fuel-ts/program/src/contract-call-script.ts:219:7)
      at FunctionInvocationResult.getDecodedValue (node_modules/@fuel-ts/program/src/functions/invocation-results.ts:146:5)
      at new InvocationResult (node_modules/@fuel-ts/program/src/functions/invocation-results.ts:100:3)
      at new FunctionInvocationResult (node_modules/@fuel-ts/program/src/functions/invocation-results.ts:208:3)
      at Function.build (node_modules/@fuel-ts/program/src/functions/base-invocation-scope.ts:39:10)

Expected Behavior

Fail with proper reason: FailImplicitly. Imo, something like the following:

RequireRevertError: The script reverted: RequireFailed (reason: "FailImplicitly")

Actual Behavior

Motivation (and related to): https://forum.fuel.network/t/custom-revert-errors-not-showing-w-typescript-sdk/4416/5

@theausicist
Copy link
Contributor Author

this is related to: #823

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is a bug
Projects
None yet
Development

No branches or pull requests

1 participant