From 293450a4b6cceaf3777e0558d0edc96c0e7fd81e Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:28:10 +0200 Subject: [PATCH 1/5] update type and documentation for `baseFeePerGas` at `web3.eth.getFeeHistory` --- .../web3_upgrade_guide/1.x/web3_eth_migration_guide.md | 6 ++++-- packages/web3-types/src/eth_types.ts | 2 +- 2 files changed, 5 insertions(+), 3 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..41a1818f6d0 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,9 @@ 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`. + +bigint | number ```typescript // in 1.x @@ -162,7 +164,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-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[]; } From 9216355bcffe3abae2f6d601dc78ca8e0daa7e0a Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:31:13 +0200 Subject: [PATCH 2/5] update CHANGELOG.md --- .../guides/web3_upgrade_guide/1.x/web3_eth_migration_guide.md | 2 -- packages/web3-types/CHANGELOG.md | 4 ++++ 2 files changed, 4 insertions(+), 2 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 41a1818f6d0..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 @@ -149,8 +149,6 @@ web3.eth.getHashRate // -> correct usage 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`. -bigint | number - ```typescript // in 1.x await web3.eth.getFeeHistory('0x1', 'latest', []); diff --git a/packages/web3-types/CHANGELOG.md b/packages/web3-types/CHANGELOG.md index e38c479f914..ee3a97c324a 100644 --- a/packages/web3-types/CHANGELOG.md +++ b/packages/web3-types/CHANGELOG.md @@ -209,3 +209,7 @@ Documentation: - Add COMMITTED to BlockTags (#7124) ## [Unreleased] + +### Fixed + +- update the type for `baseFeePerGas` at `web3.eth.getFeeHistory` to be a number. From 6472d423b6649cd18fe55b9ea9c177fc3f2f169c Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:33:17 +0200 Subject: [PATCH 3/5] update CHANGELOG.md --- packages/web3-types/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-types/CHANGELOG.md b/packages/web3-types/CHANGELOG.md index ee3a97c324a..f497fbd0d35 100644 --- a/packages/web3-types/CHANGELOG.md +++ b/packages/web3-types/CHANGELOG.md @@ -212,4 +212,4 @@ Documentation: ### Fixed -- update the type for `baseFeePerGas` at `web3.eth.getFeeHistory` to be a number. +- update the type for `baseFeePerGas` at `web3.eth.getFeeHistory` to be a number. (#7291) From 72dc66d9dd33fa3d901ce130b28c2b984dce4bdc Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:50:45 +0200 Subject: [PATCH 4/5] fix a type at a unit test --- .../test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..36f0148ab39 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: [9], reward: [], gasUsedRatio: ['0'], }; From 960d30e785b51c0634767f5434edb08dc7b28e33 Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:02:44 +0200 Subject: [PATCH 5/5] fix a type at a unit test --- .../test/unit/rpc_method_wrappers/fixtures/get_fee_history.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 36f0148ab39..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: [9], + baseFeePerGas: ['0x9'], reward: [], gasUsedRatio: ['0'], };