Skip to content

Commit

Permalink
Update: using provided gas options for eip-1559 tx (#5012) (#5418)
Browse files Browse the repository at this point in the history
* Update: using provided gas options for eip-1559 tx

* Add test and CHANGELOG for eth.accounts.signTransaction eip-1559 tx

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Junaid <86780488+jdevcs@users.noreply.github.com>

Co-authored-by: Tony Chen <31647753@qq.com>
  • Loading branch information
jdevcs and chendatony31 committed Sep 6, 2022
1 parent 67f7413 commit f07bae2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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)
7 changes: 6 additions & 1 deletion packages/web3-eth-accounts/src/index.js
Expand Up @@ -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()
Expand Down
26 changes: 25 additions & 1 deletion test/eth.accounts.signTransaction.js
Expand Up @@ -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 () {
Expand Down

0 comments on commit f07bae2

Please sign in to comment.