pendulum-chain / api-solang

This is the code for the npm package @pendulum-chain/api-solang
0 stars 0 forks source link

Stricter typing for message execution #19

Open TorstenStueber opened 1 month ago

TorstenStueber commented 1 month ago

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

TorstenStueber commented 1 month ago

@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 commented 1 month ago

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