joticajulian / koilib

JS Koinos Library
MIT License
11 stars 7 forks source link

create a Transaction Class #20

Closed joticajulian closed 1 year ago

joticajulian commented 1 year ago

Consider adding a transaction class. Example:

const transaction = new Transaction(signer, provider);
for (let item of items) {
  transaction.pushOperation(
    nameService.functions.mint({
      params
    })
  );
}
transaction.send();
joticajulian commented 1 year ago

With the current implementation this can be done with a similar code:

const transaction: TransactionJSON = {
  header: { ... },
  operations: [],
};
for (let item of items) {
  transaction.operations.push(
    (await nameService.functions.mint({
        params
     })
    ).operation
  );
}
transaction = await signer.prepareTransaction(transaction);
await signer.sendTransaction(transaction);