js-algorand-sdk icon indicating copy to clipboard operation
js-algorand-sdk copied to clipboard

ATC: addMethodCall, addTransaction returns this

Open joe-p opened this issue 2 years ago • 1 comments

This simply changes the return type of addTransaction and addMethodCall from void to AtomicTransactionCompose so these methods return the ATC.

The goal is to allow chaining of methods when using the ATC rather than having to instantiate an object and call the methods on that object each time.

For example:

  const atc = new algosdk.AtomicTransactionComposer();
  atc.addTransaction();
  atc.addMethodCall();
  atc.execute();

vs

  new algosdk.AtomicTransactionComposer()
    .addTransaction()
    .addMethodCall()
    .execute();

No major reason other than a nice minor QOL improvement

joe-p avatar Jun 28 '23 00:06 joe-p

Note that this is in conflict with @robdmoore's desire to have addMethodCall() return the newly created transaction: https://github.com/algorand/js-algorand-sdk/issues/759#issuecomment-1505550812

jasonpaulos avatar Jun 28 '23 00:06 jasonpaulos