Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit d0d82b4

Browse files
GregTheGreekGreg Markouspacesailor24
authored
Closes #4210, 4211 - allow non-hex values for eip1559 gas params (#4217)
* Closes #4210 - allow non-hex values for eip1559 gas params * Add tests for 4210 * Closes #4211 * Add tests for 4210 (#4218) * Update CHANGELOG Co-authored-by: Greg Markou <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]>
1 parent 458a47a commit d0d82b4

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,8 @@ Released with 1.0.0-beta.37 code base.
419419
## [Unreleased]
420420

421421
## [1.5.1]
422+
423+
### Added
424+
425+
- `maxPriorityFeePerGas` and `maxFeePerGas` now included in `_txInputFormatter` (#4217)
426+
- If `maxPriorityFeePerGas` of `maxFeePerGas` present `_txInputFormatter` deletes `tx.gasPrice` (fixes #4211) (#4217)

packages/web3-core-helpers/src/formatters.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ var _txInputFormatter = function (options) {
157157
if (options.gas || options.gasLimit) {
158158
options.gas = options.gas || options.gasLimit;
159159
}
160+
161+
if (options.maxPriorityFeePerGas || options.maxFeePerGas) {
162+
delete options.gasPrice;
163+
}
160164

161-
['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
165+
['gasPrice', 'gas', 'value', 'maxPriorityFeePerGas', 'maxFeePerGas', 'nonce'].filter(function (key) {
162166
return options[key] !== undefined;
163167
}).forEach(function (key) {
164168
options[key] = utils.numberToHex(options[key]);

test/eth.accounts.signTransaction.js

+47
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var Web3 = require('../packages/web3');
33
var Accounts = require("./../packages/web3-eth-accounts");
44
var chai = require('chai');
55
var assert = chai.assert;
6+
var bn = require('bn.js');
67

78
var common = {
89
baseChain: 'mainnet',
@@ -649,6 +650,52 @@ var tests = [
649650
transactionHash: "0xbc2c9edab3d4e3a795fa402b52d6149e874de15f0cc6c0858eb34e1fe1ef31fe",
650651
messageHash: "0xa3a2cdc45e9cefb9a614ead90ce65f68bcf8a90dbe0ccbd84c1b62403bd05346"
651652
},
653+
{
654+
// test #28
655+
address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23',
656+
iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV',
657+
privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318',
658+
transaction: {
659+
chainId: 1,
660+
nonce: 0,
661+
maxPriorityFeePerGas: new bn('0x3B9ACA00'),
662+
maxFeePerGas: new bn('0xB2D05E00'),
663+
gasLimit: '0x6A40',
664+
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
665+
toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test
666+
value: "1000000000",
667+
data: "",
668+
common: commonLondon
669+
},
670+
// signature from eth_signTransaction
671+
rawTransaction: "0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3",
672+
oldSignature: "0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3",
673+
transactionHash: "0xd5b7290a477b9c421d39e61d0f566ec33276fb49b9ff85cfd6152a18f1c92dab",
674+
messageHash: "0x17e20e530a889ce52057de228b5b97edcad6002468d723346cd0b6b7a9943457"
675+
},
676+
{
677+
// test #29
678+
address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23',
679+
iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV',
680+
privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318',
681+
transaction: {
682+
chainId: 1,
683+
nonce: 0,
684+
maxPriorityFeePerGas: '1000000000',
685+
maxFeePerGas: '3000000000',
686+
gasLimit: '0x6A40',
687+
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
688+
toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test
689+
value: "1000000000",
690+
data: "",
691+
common: commonLondon
692+
},
693+
// signature from eth_signTransaction
694+
rawTransaction: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36",
695+
oldSignature: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36",
696+
transactionHash: "0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e",
697+
messageHash: "0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b"
698+
},
652699
];
653700

654701
describe("eth", function () {

test/formatters.inputTransactionFormatter.js

+53
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
var bn = require('bn.js');
12
var chai = require('chai');
23
var assert = chai.assert;
4+
35
var formatters = require('../packages/web3-core-helpers/src/formatters.js');
46

57
var tests = [{
@@ -98,6 +100,57 @@ var tests = [{
98100
gas: '0x3e8',
99101
gasPrice: '0x3e8'
100102
}
103+
}, {
104+
input: {
105+
data: '0x34234bf23bf4234',
106+
value: '0x64',
107+
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
108+
gas: '0x3e8',
109+
maxPriorityFeePerGas: '1000',
110+
maxFeePerGas: '1000'
111+
},
112+
result: {
113+
data: '0x34234bf23bf4234',
114+
value: '0x64',
115+
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
116+
gas: '0x3e8',
117+
maxPriorityFeePerGas: '0x3e8',
118+
maxFeePerGas: '0x3e8'
119+
}
120+
}, {
121+
input: {
122+
data: '0x34234bf23bf4234',
123+
value: '0x64',
124+
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
125+
gas: '0x3e8',
126+
maxPriorityFeePerGas: 1000,
127+
maxFeePerGas: 1000
128+
},
129+
result: {
130+
data: '0x34234bf23bf4234',
131+
value: '0x64',
132+
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
133+
gas: '0x3e8',
134+
maxPriorityFeePerGas: '0x3e8',
135+
maxFeePerGas: '0x3e8'
136+
}
137+
}, {
138+
input: {
139+
data: '0x34234bf23bf4234',
140+
value: '0x64',
141+
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
142+
gas: '0x3e8',
143+
maxPriorityFeePerGas: new bn(1000),
144+
maxFeePerGas: new bn(1000)
145+
},
146+
result: {
147+
data: '0x34234bf23bf4234',
148+
value: '0x64',
149+
from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8',
150+
gas: '0x3e8',
151+
maxPriorityFeePerGas: '0x3e8',
152+
maxFeePerGas: '0x3e8'
153+
}
101154
}];
102155

103156
describe('formatters', function () {

0 commit comments

Comments
 (0)