Closed
Description
🚀 Feature - Client Side Await for Aleo Futures
Motivation
Futures have been introduced into Aleo Instructions. However on the client side, currently the client would have to implement their own logic in order to check if a future leading to a finalize scope was successful. Optimally, if an Aleo instructions function leads returns a future type it should return a promise that resolves when the future has completed executing on chain.
This will allow users to allow their apps to react directly to on-chain state
Implementation
- If a function return type is of type
future
, create javascript promise that polls the for a finalize transaction matching the transaction id on chain. The future resolves when it detects a succcess, rejection, or a timeout. - Add the inputs the finalize block was called on to the promise. If the inputs were also futures, add those to the data in the promise
- Add a typescript interface in order to allow SDK users to extend this promise type to enable custom behavior (i.e. like checking the resulting mapping, or triggering another action, etc.) so that users have an interface to reacting to updates in on-chain state