From 7c207b8953b9d5aff369d0300498a42e46f11a2e Mon Sep 17 00:00:00 2001 From: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Sat, 5 Oct 2024 20:08:14 +0200 Subject: [PATCH] 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 --- .../guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md | 4 ++-- .../test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts | 2 +- packages/web3-types/CHANGELOG.md | 4 ++++ packages/web3-types/src/eth_types.ts | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/docs/guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md b/docs/docs/guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md index 10b57e1d261..4a7b36d62fb 100644 --- a/docs/docs/guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md +++ b/docs/docs/guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md @@ -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 @@ -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 ] // } ``` diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts index 54ea874c610..00ddece4e77 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts @@ -18,7 +18,7 @@ import { FeeHistoryResultAPI, BlockNumberOrTag, BlockTags, Numbers } from 'web3- export const mockRpcResponse: FeeHistoryResultAPI = { oldestBlock: '0xa30950', - baseFeePerGas: '0x9', + baseFeePerGas: ['0x9'], reward: [], gasUsedRatio: ['0'], }; diff --git a/packages/web3-types/CHANGELOG.md b/packages/web3-types/CHANGELOG.md index e38c479f914..aa6b36d4885 100644 --- a/packages/web3-types/CHANGELOG.md +++ b/packages/web3-types/CHANGELOG.md @@ -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) diff --git a/packages/web3-types/src/eth_types.ts b/packages/web3-types/src/eth_types.ts index 9c83e92d0d5..5458fe1d426 100644 --- a/packages/web3-types/src/eth_types.ts +++ b/packages/web3-types/src/eth_types.ts @@ -515,7 +515,7 @@ export type Block = BlockBase< export interface FeeHistoryBase { readonly oldestBlock: NumberType; - readonly baseFeePerGas: NumberType; + readonly baseFeePerGas: NumberType[]; readonly reward: NumberType[][]; readonly gasUsedRatio: NumberType[]; }