Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block tag support for eth_feeHistory #4224

Merged
merged 5 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,5 @@ 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)
- Support for EIP-1559 to `web3.eth.sendTransaction` (#4220)
2 changes: 1 addition & 1 deletion packages/web3-eth/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, null]
}),
new Method({
name: 'getAccounts',
Expand Down
113 changes: 112 additions & 1 deletion test/eth.feeHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var methodCall = 'eth_feeHistory';
var tests = [
{
args: [4, "0xA30953", []],
formattedArgs: [4, "0xA30953", []],
formattedArgs: [4, "0xa30953", []],
result: {
"baseFeePerGas": [
"0xa",
Expand Down Expand Up @@ -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
}
];

Expand Down