@appliedblockchain/parity-revert-reason
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -15,3 +15,3 @@ const debug = require('debug')('parity-revert-reason') | ||
const throwWithRevertReason = async (web3, rawTxHash, defaultMsg = 'Transaction failed.') => { | ||
const throwWithRevertReason = async (web3, rawTxHash, fallbackMsg = 'Transaction failed.') => { | ||
return new Promise((resolve, reject) => { | ||
@@ -44,3 +44,3 @@ debug('rawTxHash', rawTxHash) | ||
return reject(new Error(defaultMsg)) | ||
return reject(new Error(fallbackMsg)) | ||
}) | ||
@@ -47,0 +47,0 @@ }) |
{ | ||
"name": "@appliedblockchain/parity-revert-reason", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Small function and tests for retrieving Solidity revert reason from require()", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,6 +13,22 @@ # Get EVM revert reason on Parity | ||
# Run the tests | ||
## Usage | ||
```js | ||
const { throwWithRevertReason } = require('@appliedblockchain/parity-revert-reason') | ||
const method = 'myMethod' | ||
const args = [] | ||
const contract = new web3.eth.Contract(abi, address) | ||
const txParams = {...} | ||
const tx = await web3.eth.signTransaction(txParams) | ||
await web3.eth.sendSignedTransaction(tx.raw).catch(async () => { | ||
const fallbackErrMsg = `Transaction ${method}(${inspect(args)}) (nonce: ${txParams.nonce}) failed.` | ||
await throwWithRevertReason(web3, tx.raw) | ||
}) | ||
``` | ||
## Run the tests | ||
`docker run --rm -d -p 8545:8545 appliedblockchain/parity-solo:v4.0.0` | ||
`npm test` |
4209
34