--- a/tests/src/substrate/substrate-api.ts +++ b/tests/src/substrate/substrate-api.ts @@ -169,13 +169,24 @@ /* eslint no-async-promise-executor: "off" */ return new Promise(async (resolve, reject) => { try { - await transaction.signAndSend(sender, ({events = [], status}) => { + await transaction.signAndSend(sender, ({events = [], status, dispatchError}) => { const transactionStatus = getTransactionStatus(events, status); if (transactionStatus === TransactionStatus.Success) { resolve(events); } else if (transactionStatus === TransactionStatus.Fail) { - console.log(`Something went wrong with transaction. Status: ${status}`); + let moduleError = null; + + if (dispatchError) { + if (dispatchError.isModule) { + const modErr = dispatchError.asModule; + const errorMeta = dispatchError.registry.findMetaError(modErr); + + moduleError = JSON.stringify(errorMeta, null, 4); + } + } + + console.log(`Something went wrong with transaction. Status: ${status}\nModule error: ${moduleError}`); reject(events); } });