diff --git a/CHANGELOG.md b/CHANGELOG.md index 683086248b8..6740d7aa638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -596,6 +596,7 @@ Released with 1.0.0-beta.37 code base. - Update node version on actions to fix breaking mosaic test (#5354) - Start incrementing jsonrpc.id from random number (#5327) - `web3-eth-contract`'s `call` and `send` methods no longer mutate `options` argument (#5394) +- Improvement using provided gas options in web3-eth-accounts for eip-1559 transactions (#5012) ### Added - Add missing function type "receive" in `AbiType` (#5165) diff --git a/packages/web3-eth-accounts/src/index.js b/packages/web3-eth-accounts/src/index.js index a2393348497..39ecaa7f747 100644 --- a/packages/web3-eth-accounts/src/index.js +++ b/packages/web3-eth-accounts/src/index.js @@ -397,7 +397,12 @@ function _handleTxPricing(_this, tx) { ) { // Legacy transaction, return provided gasPrice resolve({ gasPrice: tx.gasPrice }) - } else { + } + else if (tx.type === '0x2' && tx.maxFeePerGas && tx.maxPriorityFeePerGas) { + // EIP-1559 transaction, return provided maxFeePerGas and maxPriorityFeePerGas + resolve({ maxFeePerGas: tx.maxFeePerGas, maxPriorityFeePerGas: tx.maxPriorityFeePerGas }) + } + else { Promise.all([ _this._ethereumCall.getBlockByNumber(), _this._ethereumCall.getGasPrice() diff --git a/test/eth.accounts.signTransaction.js b/test/eth.accounts.signTransaction.js index 105f7d9a105..5d1361b66e0 100644 --- a/test/eth.accounts.signTransaction.js +++ b/test/eth.accounts.signTransaction.js @@ -745,7 +745,31 @@ var tests = [ oldSignature: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833", transactionHash: "0x488a813f2286f7c015947aa13133bdae49ec75ae1c8f5eba80034d71a038dca8", messageHash: "0xcd6d6dee80ecc38f1b22f2d128bf6043dc41079fc913183a8995b5b3e187df61" - } + }, + { + // test #32 + address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', + iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', + privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', + transaction: { + chainId: 1, + nonce: 0, + type: '0x2', + maxPriorityFeePerGas: '1000000000', + maxFeePerGas: '3000000000', + gasLimit: '0x6A40', + to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', + toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test + value: "1000000000", + data: "", + common: commonLondon + }, + // signature from eth_signTransaction + rawTransaction: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36", + oldSignature: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36", + transactionHash: "0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e", + messageHash: "0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b" + }, ]; describe("eth", function () {