diff --git a/README.md b/README.md index 6354a7fc..9dd3146b 100644 --- a/README.md +++ b/README.md @@ -43,16 +43,16 @@ yarn add bnc-assist #### Script Tag The library uses [semantic versioning](https://semver.org/spec/v2.0.0.html). -The current version is 0.10.2. +The current version is 0.10.3. There are minified and non-minified versions. Put this script at the top of your `
` ```html - + - + ``` ### Initialize the Library @@ -194,6 +194,8 @@ var config = { txSent: Function, // Transaction has been sent to the network txPending: Function, // Transaction is pending and has been detected in the mempool txSendFail: Function, // Transaction failed to be sent to the network + txUnderpriced: Function, // Transaction gas limit was set too low + txError: Function, // An unknown MetaMask / JSON RPC error occurred when trying to send the transaction txStallPending: Function, // Transaction was sent to the network but has not been detected in the txPool txStallConfirmed: Function, // Transaction has been detected in the mempool but hasn't been confirmed txFailed: Function, // Transaction failed diff --git a/package.json b/package.json index 8f39e750..8782e305 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bnc-assist", - "version": "0.10.2", + "version": "0.10.3", "description": "Blocknative Assist js library for Dapp developers", "main": "lib/assist.min.js", "scripts": { diff --git a/src/js/helpers/utilities.js b/src/js/helpers/utilities.js index 70a1ef69..283d3e53 100644 --- a/src/js/helpers/utilities.js +++ b/src/js/helpers/utilities.js @@ -131,14 +131,16 @@ export function assistLog(log) { console.log('Assist:', log) // eslint-disable-line no-console } -export function extractMessageFromError(message) { - if (!message) { +export function extractMessageFromError(error) { + if (!error.stack || !error.message) { return { eventCode: 'txError', errorMsg: undefined } } + const message = error.stack || error.message + if (message.includes('User denied transaction signature')) { return { eventCode: 'txSendFail', @@ -177,6 +179,7 @@ export function eventCodeToType(eventCode) { case 'txAwaitingApproval': case 'txConfirmReminder': case 'txUnderpriced': + case 'txError': case 'error': return 'failed' case 'txConfirmed': diff --git a/src/js/logic/send-transaction.js b/src/js/logic/send-transaction.js index e1d9a79d..fdf3fdbf 100644 --- a/src/js/logic/send-transaction.js +++ b/src/js/logic/send-transaction.js @@ -386,7 +386,7 @@ async function onTxReceipt(id, categoryCode, receipt) { } function onTxError(id, error, categoryCode) { - const { errorMsg, eventCode } = extractMessageFromError(error.message) + const { errorMsg, eventCode } = extractMessageFromError(error) let txObj = getTxObjFromQueue(id) diff --git a/src/js/views/content.js b/src/js/views/content.js index 03f1ecc8..dba696e4 100644 --- a/src/js/views/content.js +++ b/src/js/views/content.js @@ -381,5 +381,7 @@ export const transactionMsgs = { txCancel: ({ transaction }) => `Your transaction ID: ${transaction.nonce} is being canceled`, txUnderpriced: () => - 'The gas price for your transaction is too low, try again with a higher gas price' + 'The gas price for your transaction is too low, try again with a higher gas price', + txError: () => + 'An unknown error has occurred with your transaction, please try again' } diff --git a/src/js/views/event-to-ui.js b/src/js/views/event-to-ui.js index 0e46049f..7a59c3f6 100644 --- a/src/js/views/event-to-ui.js +++ b/src/js/views/event-to-ui.js @@ -79,7 +79,8 @@ const eventToUI = { txFailed: notificationsUI, txSpeedUp: notificationsUI, txCancel: notificationsUI, - txUnderpriced: notificationsUI + txUnderpriced: notificationsUI, + txError: notificationsUI }, activeContract: { txAwaitingApproval: notificationsUI, @@ -95,7 +96,8 @@ const eventToUI = { txFailed: notificationsUI, txSpeedUp: notificationsUI, txCancel: notificationsUI, - txUnderpriced: notificationsUI + txUnderpriced: notificationsUI, + txError: notificationsUI }, userInitiatedNotify: { success: notificationsUI,