capsule-corp-ternoa / ternoa-js

Ternoa JavaScript SDK to build on top of the Ternoa Chain ⚙️
https://docs.ternoa.network
Apache License 2.0
24 stars 10 forks source link

Solid Error Catching on Batch Operations #110

Closed ogous closed 1 year ago

ogous commented 2 years ago

Is your feature request related to a problem? Please describe.

We need to manage balance transfers from a master account to customer's accounts. We have to use batch operations and log and record every transaction. When we develop handling possible status of transactions, we discovered that we could not get which transactions are failed from the batch. submitTxBlocking returns Promise< BlockchainEvents >, Ternoa EventType has only ExtrinsicFailed and BatchInterrupted but no type for item fails (for example anything like ItemInterrupted)

I tried to create an error by not giving necessary field value to balancesTransferKeepAliveTx for one of the batch item. For a batch that has two balancesTransferKeepAliveTx, it returns 2 ItemCompleted and 1 BatchCompleted events. Actually only one balancesTransferKeepAliveTx has success, other should have failed. The one with missing parameter did not executed at all, but has info about it.

Existing response does not give us any stable information which items are failed or done successfully in the batch.

Describe the solution you'd like

The response of batch operations should give us list of failed & successed items.

For example, the response of MongoDB's write errors of bulk responses

Describe alternatives you've considered

  1. batch response can give us transaction Ids for items that failed. We can use those ids for querying indexer with transferEntities, so we can get exact status of transaction items.
  2. an options like MongoDB's ordered feature. It can give error for the first item that fails, and not continue to execute remaining ordered list, so we can know which one is failed and remaining 'pending' items.

Additional context

No response

ipapandinas commented 1 year ago

Thank you for opening this issue @ogous. It has allowed us to greatly improve our error logging and our flow on batch operations. These improvements are available in the fresh deployed version 1.3.1-r0 🚀