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

Stricter typing for message execution #19

Open
TorstenStueber opened this issue Sep 29, 2024 · 2 comments
Open

Stricter typing for message execution #19

TorstenStueber opened this issue Sep 29, 2024 · 2 comments
Assignees

Comments

@TorstenStueber
Copy link
Member

Since the addition of a "skip dry running feature" for message calls, every call to executeMessage or createExecuteMessageExtrinsic can have one of three execution paths:

  1. first dry run via RPC, then submit/create the extrinsic
    • this happens when the option skipDryRunning isn't true and the RPC call was successful
  2. only dry run via RPC
    • this happens when the option skipDryRunning isn't true and the RPC call was a failure
  3. only submit/create the extrinsic
    • this happens when the option skipDryRunning is `true.

The return type of these functions (ExecuteMessageResult for executeMessage and CreateExecuteMessageExtrinsicResult for createExecuteMessageExtrinsic) have an entry result which is defined to optional.

However, this value is always defined whenever skipDryRunning isn't true and is always undefined whenever skipDryRunning is true.

That means that whenever the caller does want to skip dry running, they can be ensured that result is defined. This is not reflected in the TypeScript typings. Right now they would either have to use the non-null assertion operator ! or would need to add a code path for the option that result is undefined.

TODO

  • either separate the functions executeMessage and createExecuteMessageExtrinsic into two versions, where one skips dry running and the other doesn't and add the proper typings
  • or add type overloading declarations to the calls executeMessage and createExecuteMessageExtrinsic
@TorstenStueber
Copy link
Member Author

@pendulum-chain/product this is a low priority feature to improve the usability of our library api-solang that we use in wasm-deploy, the Portal and Vortex.

@TorstenStueber
Copy link
Member Author

Hey team! Please add your planning poker estimate with Zenhub @b-yap @bogdanS98 @ebma @gianfra-t @Sharqiewicz

@b-yap b-yap self-assigned this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants