You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now promise handling works well, but can be a bit confusing to people just starting out. I think it would be nice to make some tweaks to improve the learning curve and get the syntax a bit more in line with the rust sdk. I was thinking something like this:
Looks good to me! I've been wondering about adding something similar to the external contract interface in the rust sdk.
@externalContractinterfaceOtherContract{
...
}
Where the interface would become a namespace and each method would return a promise.
The issue I've had with a lot of these ideas is that they tend not to play well with TS.
However, since TS allows decorators your example in TS we could define it in the as_types.d.ts file such that it will alter the function's type so that the IDE will be happy and still help to type check any arguments passed. If this works, then perhaps it would just mean adding each function independently instead of an interface.
That's a really good point @willemneal, about getting these things to play well with TS. I've been experimenting, and decorators are not allowed on functions like in my proof of concept above.
Right now promise handling works well, but can be a bit confusing to people just starting out. I think it would be nice to make some tweaks to improve the learning curve and get the syntax a bit more in line with the rust sdk. I was thinking something like this:
To accomplish the above:
env.promise_return
has to be called ingenerateWrapperFunction
instead ofenv.value_return
if aBatchPromise
is returned@callback
decorator and wrap the function in aBatchPromise
so it can be passed to.then
I have a little proof of concept for this right now, but I'm not sure this syntax is perfect yet and would love to discuss how to improve this.
In any case, I am happy to work on this improvement and make a PR.
The text was updated successfully, but these errors were encountered: