From 9dde5a720ba8819ce88aef534c580538a0ae1727 Mon Sep 17 00:00:00 2001 From: brg8 Date: Wed, 4 Aug 2021 22:53:21 -0400 Subject: [PATCH 1/4] Accept predefined block numbers for eth_feeHistory (#4213) * Accept predefined block numbers for eth_feeHistory * Update feeHistory tests to reflect new input formatter Co-authored-by: Wyatt Barnes --- packages/web3-eth/src/index.js | 2 +- test/eth.feeHistory.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web3-eth/src/index.js b/packages/web3-eth/src/index.js index f78e1f5b915..cc3452c675c 100644 --- a/packages/web3-eth/src/index.js +++ b/packages/web3-eth/src/index.js @@ -389,7 +389,7 @@ var Eth = function Eth() { name: 'getFeeHistory', call: 'eth_feeHistory', params: 3, - inputFormatter: [utils.toNumber, utils.toHex, function(value) {return value}] + inputFormatter: [utils.toNumber, formatter.inputBlockNumberFormatter, function(value) {return value}] }), new Method({ name: 'getAccounts', diff --git a/test/eth.feeHistory.js b/test/eth.feeHistory.js index f773075c166..c515f3e2b94 100644 --- a/test/eth.feeHistory.js +++ b/test/eth.feeHistory.js @@ -8,7 +8,7 @@ var methodCall = 'eth_feeHistory'; var tests = [ { args: [4, "0xA30953", []], - formattedArgs: [4, "0xA30953", []], + formattedArgs: [4, "0xa30953", []], result: { "baseFeePerGas": [ "0xa", From b1b977c9107ba175affec6489d9e14c5a156075e Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 4 Aug 2021 17:00:45 -1000 Subject: [PATCH 2/4] Add block tag tests --- test/eth.feeHistory.js | 111 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/test/eth.feeHistory.js b/test/eth.feeHistory.js index c515f3e2b94..9ae1e16d66c 100644 --- a/test/eth.feeHistory.js +++ b/test/eth.feeHistory.js @@ -116,6 +116,117 @@ var tests = [ "oldestBlock": 10684752 }, call: methodCall + }, + { + args: [4, 'latest', []], + formattedArgs: [4, 'latest', []], + result: { + "baseFeePerGas": [ + "0xa", + "0x9", + "0x8", + "0x9", + "0x9" + ], + "gasUsedRatio": [ + 0.003920375, + 0.002625, + 0.904999125, + 0.348347625 + ], + "oldestBlock": 10684752 + }, + formattedResult: { + "baseFeePerGas": [ + "0xa", + "0x9", + "0x8", + "0x9", + "0x9" + ], + "gasUsedRatio": [ + 0.003920375, + 0.002625, + 0.904999125, + 0.348347625 + ], + "oldestBlock": 10684752 + }, + call: methodCall + }, + { + args: [4, 'earliest', []], + formattedArgs: [4, 'earliest', []], + result: { + "baseFeePerGas": [ + "0xa", + "0x9", + "0x8", + "0x9", + "0x9" + ], + "gasUsedRatio": [ + 0.003920375, + 0.002625, + 0.904999125, + 0.348347625 + ], + "oldestBlock": 10684752 + }, + formattedResult: { + "baseFeePerGas": [ + "0xa", + "0x9", + "0x8", + "0x9", + "0x9" + ], + "gasUsedRatio": [ + 0.003920375, + 0.002625, + 0.904999125, + 0.348347625 + ], + "oldestBlock": 10684752 + }, + call: methodCall + }, + { + args: [4, 'pending', []], + formattedArgs: [4, 'pending', []], + result: { + "baseFeePerGas": [ + "0xa", + "0x9", + "0x8", + "0x9", + "0x9" + ], + "gasUsedRatio": [ + 0.003920375, + 0.002625, + 0.904999125, + 0.348347625 + ], + "oldestBlock": 10684752 + }, + formattedResult: { + "baseFeePerGas": [ + "0xa", + "0x9", + "0x8", + "0x9", + "0x9" + ], + "gasUsedRatio": [ + 0.003920375, + 0.002625, + 0.904999125, + 0.348347625 + ], + "oldestBlock": 10684752 + }, + call: methodCall } ]; From 80ae404e3c31adda1a9ebb0ba59407ffce793b5c Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 4 Aug 2021 17:01:53 -1000 Subject: [PATCH 3/4] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb86263fc6..ae1ef10eb0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -424,3 +424,4 @@ Released with 1.0.0-beta.37 code base. - `maxPriorityFeePerGas` and `maxFeePerGas` now included in `_txInputFormatter` (#4217) - If `maxPriorityFeePerGas` of `maxFeePerGas` present `_txInputFormatter` deletes `tx.gasPrice` (fixes #4211) (#4217) +- Add block tag support (e.g. `latest`, `pending`, `earliest`) to `getFeeHistory` (#4224) From 4f39c176bf2c6abbf342da9493fe728446875fee Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 4 Aug 2021 17:37:54 -1000 Subject: [PATCH 4/4] Replace inputFormatter with null to match existing code --- packages/web3-eth/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-eth/src/index.js b/packages/web3-eth/src/index.js index cc3452c675c..b503e10c3e3 100644 --- a/packages/web3-eth/src/index.js +++ b/packages/web3-eth/src/index.js @@ -389,7 +389,7 @@ var Eth = function Eth() { name: 'getFeeHistory', call: 'eth_feeHistory', params: 3, - inputFormatter: [utils.toNumber, formatter.inputBlockNumberFormatter, function(value) {return value}] + inputFormatter: [utils.toNumber, formatter.inputBlockNumberFormatter, null] }), new Method({ name: 'getAccounts',