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

Commit 4b445ae

Browse files
3commascapital3commascapitalMuhammad-AltabbaAlexluu-alex
authored
Fixup base fee type (#6456)
* Fixup base fee type * Removes any * v4.2.0-bigint * Adds changelog * Update packages/web3-core/CHANGELOG.md Co-authored-by: Alex <[email protected]> * Remove version name --------- Co-authored-by: 3commascapital <[email protected]> Co-authored-by: Muhammad Altabba <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
1 parent 3060994 commit 4b445ae

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

packages/web3-core/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,5 @@ Documentation:
183183

184184
### Changed
185185

186-
- defaultTransactionType is now type 0x2 instead of 0x0 (#6282)
186+
- defaultTransactionType is now type 0x2 instead of 0x0 (#6282)
187+
- Allows formatter to parse large base fee (#6456)

packages/web3-core/src/formatters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export const outputBlockFormatter = (block: BlockInput): BlockOutput => {
450450
}
451451

452452
if (block.baseFeePerGas) {
453-
modifiedBlock.baseFeePerGas = hexToNumber(block.baseFeePerGas);
453+
modifiedBlock.baseFeePerGas = outputBigIntegerFormatter(block.baseFeePerGas);
454454
}
455455

456456
return modifiedBlock;

packages/web3-core/test/unit/formatters.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,13 @@ describe('formatters', () => {
537537
});
538538

539539
it('should convert "baseFeePerGas" from hex to number', () => {
540+
jest.spyOn(formatters, 'outputBigIntegerFormatter').mockReturnValue(123);
540541
const result = outputBlockFormatter({
541542
...validBlock,
542543
baseFeePerGas: 'baseFeePerGas',
543544
} as any);
544545

545-
expect(utils.hexToNumber).toHaveBeenCalledWith('baseFeePerGas');
546+
expect(outputBigIntegerFormatter).toHaveBeenCalledWith('baseFeePerGas');
546547
expect(result).toEqual(expect.objectContaining({ baseFeePerGas: hexToNumberResult }));
547548
});
548549
});

0 commit comments

Comments
 (0)