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

Commit 7c207b8

Browse files
fix: correct type and documentation for baseFeePerGas at web3.eth.getFeeHistory (#7291)
* update type and documentation for `baseFeePerGas` at `web3.eth.getFeeHistory` * fix a type at a unit test
1 parent 76c468a commit 7c207b8

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

docs/docs/guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ web3.eth.getHashRate // -> correct usage
147147

148148
#### web3.eth.getFeeHistory
149149

150-
4.x returns a `BigInt` for `oldestBlock` instead of the hex string that's returned in 1.x.
150+
4.x returns a `BigInt` for `oldestBlock` instead of the hex string that's returned in 1.x. And 4.x returns `number[]`, instead of `strings[]` for `baseFeePerGas`.
151151

152152
```typescript
153153
// in 1.x
@@ -162,7 +162,7 @@ await web3.eth.getFeeHistory('0x1', 'latest', []);
162162
await web3.eth.getFeeHistory('0x1', 'latest', []);
163163
// {
164164
// oldestBlock: 0n,
165-
// baseFeePerGas: [ '0x3b9aca00', '0x342770c0' ],
165+
// baseFeePerGas: [ 1000000000, 875000000 ],
166166
// gasUsedRatio: [ 0 ]
167167
// }
168168
```

packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { FeeHistoryResultAPI, BlockNumberOrTag, BlockTags, Numbers } from 'web3-
1818

1919
export const mockRpcResponse: FeeHistoryResultAPI = {
2020
oldestBlock: '0xa30950',
21-
baseFeePerGas: '0x9',
21+
baseFeePerGas: ['0x9'],
2222
reward: [],
2323
gasUsedRatio: ['0'],
2424
};

packages/web3-types/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,7 @@ Documentation:
209209
- Add COMMITTED to BlockTags (#7124)
210210

211211
## [Unreleased]
212+
213+
### Changed
214+
215+
- update the type for `baseFeePerGas` at `web3.eth.getFeeHistory` to be a number. (#7291)

packages/web3-types/src/eth_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ export type Block = BlockBase<
515515

516516
export interface FeeHistoryBase<NumberType> {
517517
readonly oldestBlock: NumberType;
518-
readonly baseFeePerGas: NumberType;
518+
readonly baseFeePerGas: NumberType[];
519519
readonly reward: NumberType[][];
520520
readonly gasUsedRatio: NumberType[];
521521
}

0 commit comments

Comments
 (0)