Skip to content

Commit

Permalink
fix: correct type and documentation for baseFeePerGas at `web3.eth.…
Browse files Browse the repository at this point in the history
…getFeeHistory` (#7291)

* update type and documentation for `baseFeePerGas` at `web3.eth.getFeeHistory`

* fix a type at a unit test
  • Loading branch information
Muhammad-Altabba authored Oct 5, 2024
1 parent 76c468a commit 7c207b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ web3.eth.getHashRate // -> correct usage

#### web3.eth.getFeeHistory

4.x returns a `BigInt` for `oldestBlock` instead of the hex string that's returned in 1.x.
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`.

```typescript
// in 1.x
Expand All @@ -162,7 +162,7 @@ await web3.eth.getFeeHistory('0x1', 'latest', []);
await web3.eth.getFeeHistory('0x1', 'latest', []);
// {
// oldestBlock: 0n,
// baseFeePerGas: [ '0x3b9aca00', '0x342770c0' ],
// baseFeePerGas: [ 1000000000, 875000000 ],
// gasUsedRatio: [ 0 ]
// }
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { FeeHistoryResultAPI, BlockNumberOrTag, BlockTags, Numbers } from 'web3-

export const mockRpcResponse: FeeHistoryResultAPI = {
oldestBlock: '0xa30950',
baseFeePerGas: '0x9',
baseFeePerGas: ['0x9'],
reward: [],
gasUsedRatio: ['0'],
};
Expand Down
4 changes: 4 additions & 0 deletions packages/web3-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,7 @@ Documentation:
- Add COMMITTED to BlockTags (#7124)

## [Unreleased]

### Changed

- update the type for `baseFeePerGas` at `web3.eth.getFeeHistory` to be a number. (#7291)
2 changes: 1 addition & 1 deletion packages/web3-types/src/eth_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export type Block = BlockBase<

export interface FeeHistoryBase<NumberType> {
readonly oldestBlock: NumberType;
readonly baseFeePerGas: NumberType;
readonly baseFeePerGas: NumberType[];
readonly reward: NumberType[][];
readonly gasUsedRatio: NumberType[];
}
Expand Down

1 comment on commit 7c207b8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 7c207b8 Previous: 76c468a Ratio
processingTx 20590 ops/sec (±8.07%) 21644 ops/sec (±7.51%) 1.05
processingContractDeploy 39585 ops/sec (±5.47%) 39881 ops/sec (±6.40%) 1.01
processingContractMethodSend 14808 ops/sec (±10.80%) 15939 ops/sec (±6.63%) 1.08
processingContractMethodCall 27609 ops/sec (±6.88%) 27981 ops/sec (±6.91%) 1.01
abiEncode 42563 ops/sec (±7.37%) 43956 ops/sec (±6.74%) 1.03
abiDecode 28955 ops/sec (±7.81%) 29215 ops/sec (±9.42%) 1.01
sign 1499 ops/sec (±3.09%) 1506 ops/sec (±3.35%) 1.00
verify 362 ops/sec (±0.59%) 366 ops/sec (±0.56%) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.