Skip to content

Commit

Permalink
Fixup base fee type (#6456)
Browse files Browse the repository at this point in the history
* Fixup base fee type

* Removes any

* v4.2.0-bigint

* Adds changelog

* Update packages/web3-core/CHANGELOG.md

Co-authored-by: Alex  <luu.alex98@gmail.com>

* Remove version name

---------

Co-authored-by: 3commascapital <8562488-3commascapital@users.noreply.gitlab.com>
Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com>
Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
Co-authored-by: Alex <luu.alex98@gmail.com>
  • Loading branch information
5 people committed Sep 29, 2023
1 parent 3060994 commit 4b445ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/web3-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,5 @@ Documentation:

### Changed

- defaultTransactionType is now type 0x2 instead of 0x0 (#6282)
- defaultTransactionType is now type 0x2 instead of 0x0 (#6282)
- Allows formatter to parse large base fee (#6456)
2 changes: 1 addition & 1 deletion packages/web3-core/src/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export const outputBlockFormatter = (block: BlockInput): BlockOutput => {
}

if (block.baseFeePerGas) {
modifiedBlock.baseFeePerGas = hexToNumber(block.baseFeePerGas);
modifiedBlock.baseFeePerGas = outputBigIntegerFormatter(block.baseFeePerGas);
}

return modifiedBlock;
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-core/test/unit/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,13 @@ describe('formatters', () => {
});

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

expect(utils.hexToNumber).toHaveBeenCalledWith('baseFeePerGas');
expect(outputBigIntegerFormatter).toHaveBeenCalledWith('baseFeePerGas');
expect(result).toEqual(expect.objectContaining({ baseFeePerGas: hexToNumberResult }));
});
});
Expand Down

0 comments on commit 4b445ae

Please sign in to comment.