From 891509392919d9dc40c5b3e6b71e8e12a04f766f Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Thu, 26 Aug 2021 18:53:42 -1000 Subject: [PATCH 1/4] Add tx.type check to _handleTxPricing --- packages/web3-core-method/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index fddedbd0136..34eaa945121 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -850,7 +850,10 @@ function _handleTxPricing(method, tx) { getGasPrice() ]).then(responses => { const [block, gasPrice] = responses; - if (block && block.baseFeePerGas) { + if ( + (tx.type === '0x2' || tx.type === undefined) && + (block && block.baseFeePerGas) + ) { // The network supports EIP-1559 // Taken from https://github.com/ethers-io/ethers.js/blob/ba6854bdd5a912fe873d5da494cb5c62c190adde/packages/abstract-provider/src.ts/index.ts#L230 From 2e94f37cc70e85252cdcf548f6f935a1139f0583 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 30 Aug 2021 15:17:37 -1000 Subject: [PATCH 2/4] Add fix to CHAGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ae2d55bff1..6771bb570e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -434,6 +434,12 @@ Released with 1.0.0-beta.37 code base. ## [Unreleased] +## [1.5.3] + +### Fixed + +- Unable to send legacy transaction if network supported EIP-1559 (#4277w) + ### Changed - ethers from 5.1.4 to 5.4.4 (#4231) From 154908bfb6fd335b409d88a1e00c1a5db931c423 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 30 Aug 2021 15:40:01 -1000 Subject: [PATCH 3/4] Add test for issue --- test/method.buildCall.js | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/test/method.buildCall.js b/test/method.buildCall.js index 2454399c25c..a30cb8e38b6 100644 --- a/test/method.buildCall.js +++ b/test/method.buildCall.js @@ -227,6 +227,79 @@ describe('lib/web3/method', function () { }); + it('should send legacy tx even though network supports EIP-1559', function (done) { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getBlockByNumber'); + assert.deepEqual(payload.params, ['latest', false]); + }); + provider.injectResult({ + baseFeePerGas: "0x7", + difficulty: "0x6cd6be3a", + extraData: "0x796f75747562652e636f6d2f77617463683f763d6451773477395767586351", + gasLimit: "0x1c9c381", + gasUsed: "0x8dc073", + hash: "0x846880b1158f434884f3637802ed09bac77eafc35b5f03b881ac88ce38a54907", + logsBloom: "0x4020001000000000000000008000010000000000400200000001002140000008000000010000810020000840000204304000081000000b00400010000822200004200020020140000001000882000064000021303200020000400008800000000002202102000084010000090020a8000800002000000010000030300000000000000006001005000040080001010000010040018100004c0050004000000000420000000021000200000010020008100000004000080000000000000040000900080102004002000080210201081014004030200148101000002020108025000018020020102040000204240500010000002200048000401300080088000002", + miner: "0x86864f1edf10eaf105b1bdc6e9aa8232b4c6aa00", + mixHash: "0xa29afb1fa1aea9eeac72ff435a8fc420bbc1fa1be08223eb61f294ee32250bde", + nonce: "0x122af1a5ccd78f3b", + number: "0xa0d600", + parentHash: "0x28f49150e1fe6f245655925b290f59e707d1e5c646dadaa22937169433b30294", + receiptsRoot: "0xc97d4f9980d680053606318a5820261a1dccb556d1056b70f0d48fb384986be5", + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + size: "0x2042", + stateRoot: "0x116981b10423133ade5bd44f03c54cc3c57f4467a1c3d4b0c6d8d33a76c361ad", + timestamp: "0x60dc24ec", + totalDifficulty: "0x78828f2d886cbb", + transactions: [], + transactionsRoot: "0x738f53f745d58169da93ebbd52cc49e0c979d6ca68a6513007b546b19ab78ba4", + uncles: [] + }); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_gasPrice'); + assert.deepEqual(payload.params, []); + }); + provider.injectResult('0xffffdddd'); // gas price + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456', + type: '0x0', + gasPrice: '0xffffdddd', + }]); + + done(); + + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456', + type: '0x0' + }); + + }); + var succeedOnReceipt = function () { var provider = new FakeIpcProvider(); var eth = new Eth(provider); From 9669ef9394c07b2fbae3e8f52d978ed3d09180d2 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 1 Sep 2021 21:16:56 -0500 Subject: [PATCH 4/4] Fix typo --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6771bb570e6..b756ef321c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -438,11 +438,11 @@ Released with 1.0.0-beta.37 code base. ### Fixed -- Unable to send legacy transaction if network supported EIP-1559 (#4277w) +- Unable to send legacy transaction if network supported EIP-1559 (#4277) ### Changed - ethers from 5.1.4 to 5.4.4 (#4231) - karma from 5.2.3 to 6.3.4 (#4231) - lerna from 3.22.1 to 4.0.0 (#4231) -- Droped build tests in CI for Node v8 and v10, and added support for Node v14 \ No newline at end of file +- Droped build tests in CI for Node v8 and v10, and added support for Node v14