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

Commit c70722b

Browse files
EIP-1559 Fix Issue #4258 (#4277)
* Add tx.type check to _handleTxPricing * Add fix to CHAGELOG * Add test for issue * Fix typo
1 parent 1547b18 commit c70722b

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ Released with 1.0.0-beta.37 code base.
434434

435435
## [Unreleased]
436436

437+
## [1.5.3]
438+
439+
### Fixed
440+
441+
- Unable to send legacy transaction if network supported EIP-1559 (#4277)
442+
437443
### Changed
438444

439445
- ethers from 5.1.4 to 5.4.4 (#4231)

packages/web3-core-method/src/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,10 @@ function _handleTxPricing(method, tx) {
850850
getGasPrice()
851851
]).then(responses => {
852852
const [block, gasPrice] = responses;
853-
if (block && block.baseFeePerGas) {
853+
if (
854+
(tx.type === '0x2' || tx.type === undefined) &&
855+
(block && block.baseFeePerGas)
856+
) {
854857
// The network supports EIP-1559
855858

856859
// Taken from https://github.com/ethers-io/ethers.js/blob/ba6854bdd5a912fe873d5da494cb5c62c190adde/packages/abstract-provider/src.ts/index.ts#L230

test/method.buildCall.js

+73
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,79 @@ describe('lib/web3/method', function () {
227227

228228
});
229229

230+
it('should send legacy tx even though network supports EIP-1559', function (done) {
231+
var provider = new FakeHttpProvider();
232+
var eth = new Eth(provider);
233+
var method = new Method({
234+
name: 'sendTransaction',
235+
call: 'eth_sendTransaction',
236+
params: 1,
237+
inputFormatter: [formatters.inputTransactionFormatter]
238+
});
239+
method.setRequestManager(eth._requestManager, eth);
240+
241+
// generate send function
242+
var send = method.buildCall();
243+
244+
provider.injectValidation(function (payload) {
245+
assert.equal(payload.method, 'eth_getBlockByNumber');
246+
assert.deepEqual(payload.params, ['latest', false]);
247+
});
248+
provider.injectResult({
249+
baseFeePerGas: "0x7",
250+
difficulty: "0x6cd6be3a",
251+
extraData: "0x796f75747562652e636f6d2f77617463683f763d6451773477395767586351",
252+
gasLimit: "0x1c9c381",
253+
gasUsed: "0x8dc073",
254+
hash: "0x846880b1158f434884f3637802ed09bac77eafc35b5f03b881ac88ce38a54907",
255+
logsBloom: "0x4020001000000000000000008000010000000000400200000001002140000008000000010000810020000840000204304000081000000b00400010000822200004200020020140000001000882000064000021303200020000400008800000000002202102000084010000090020a8000800002000000010000030300000000000000006001005000040080001010000010040018100004c0050004000000000420000000021000200000010020008100000004000080000000000000040000900080102004002000080210201081014004030200148101000002020108025000018020020102040000204240500010000002200048000401300080088000002",
256+
miner: "0x86864f1edf10eaf105b1bdc6e9aa8232b4c6aa00",
257+
mixHash: "0xa29afb1fa1aea9eeac72ff435a8fc420bbc1fa1be08223eb61f294ee32250bde",
258+
nonce: "0x122af1a5ccd78f3b",
259+
number: "0xa0d600",
260+
parentHash: "0x28f49150e1fe6f245655925b290f59e707d1e5c646dadaa22937169433b30294",
261+
receiptsRoot: "0xc97d4f9980d680053606318a5820261a1dccb556d1056b70f0d48fb384986be5",
262+
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
263+
size: "0x2042",
264+
stateRoot: "0x116981b10423133ade5bd44f03c54cc3c57f4467a1c3d4b0c6d8d33a76c361ad",
265+
timestamp: "0x60dc24ec",
266+
totalDifficulty: "0x78828f2d886cbb",
267+
transactions: [],
268+
transactionsRoot: "0x738f53f745d58169da93ebbd52cc49e0c979d6ca68a6513007b546b19ab78ba4",
269+
uncles: []
270+
});
271+
272+
// add results
273+
provider.injectValidation(function (payload) {
274+
assert.equal(payload.method, 'eth_gasPrice');
275+
assert.deepEqual(payload.params, []);
276+
});
277+
provider.injectResult('0xffffdddd'); // gas price
278+
279+
provider.injectValidation(function (payload) {
280+
assert.equal(payload.method, 'eth_sendTransaction');
281+
assert.deepEqual(payload.params, [{
282+
from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae',
283+
to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae',
284+
data: '0xa123456',
285+
type: '0x0',
286+
gasPrice: '0xffffdddd',
287+
}]);
288+
289+
done();
290+
291+
});
292+
provider.injectResult('0x1234567453543456321456321'); // tx hash
293+
294+
send({
295+
from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
296+
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
297+
data: '0xa123456',
298+
type: '0x0'
299+
});
300+
301+
});
302+
230303
var succeedOnReceipt = function () {
231304
var provider = new FakeIpcProvider();
232305
var eth = new Eth(provider);

0 commit comments

Comments
 (0)