I'd like to get if the extrinsic completed without any extrinsic errors and get the errors if any. result.isError
returns false when there's an error.
Could this be because I return DispatchResult
instead of DispatchResultWithPostInfo
in my pallet?
As this GitHub issue comment suggests, it can be done by getting the block details. But, I'm looking for a more simplified answer.
myTx.signAndSend(pair, (result) => {
console.log(`Current status is ${result.status}`);
console.log('has error', result.isError); // false
if (result.isError) {
console.log('dispatchError', result.dispatchError?.toHuman())
console.log('internalError', result.internalError)
}
if (result.status.isInBlock) {
console.log(`Transaction included at blockHash ${result.status.asInBlock}`);
} else if (result.status.isFinalized) {
console.log(`Transaction finalized at blockHash ${result.status.asFinalized}`);
}
});