diff --git a/CHANGELOG.md b/CHANGELOG.md index 23365ae7665..1db79cb90ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,5 +89,6 @@ Released with 1.0.0-beta.37 code base. ### Fixed +- Fix incorrectly errors on tx success when using perfect gas estimates (#3175) - Fix TS types for eth.subscribe syncing, newBlockHeaders, pendingTransactions (#3159) - Improve web3-eth-abi decodeParameters error message (#3134) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index 611cd91d12b..0a7bdb881da 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -393,9 +393,13 @@ Method.prototype._confirmTransaction = function(defer, result, payload) { // CHECK for normal tx check for receipt only .then(function(receipt) { if (!isContractDeployment && !promiseResolved) { + + var hasStatus = receipt.status === false || receipt.status === true; + var isOOG = !hasStatus && gasProvided === utils.numberToHex(receipt.gasUsed); + if (!receipt.outOfGas && - (!gasProvided || gasProvided !== utils.numberToHex(receipt.gasUsed)) && - (receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined')) { + (!gasProvided || !isOOG) && + (receipt.status === true || typeof receipt.status === 'undefined')) { defer.eventEmitter.emit('receipt', receipt); defer.resolve(receipt); diff --git a/test/e2e.method.send.js b/test/e2e.method.send.js index d9bfa9f1713..723f8cf3647 100644 --- a/test/e2e.method.send.js +++ b/test/e2e.method.send.js @@ -35,6 +35,20 @@ describe('method.send [ @E2E ]', function() { assert(web3.utils.isHexStrict(receipt.transactionHash)); }); + it('succeeds when using a perfect estimate', async function(){ + var estimate = await instance + .methods + .setValue('1') + .estimateGas(); + + var receipt = await instance + .methods + .setValue('1') + .send({from: accounts[0], gas: estimate}); + + assert(receipt.status === true); + }); + it('errors on OOG', async function(){ try { await instance