-
Notifications
You must be signed in to change notification settings - Fork 5.1k
allowing to specify percentage-based factors (like 1.125 for 112.5%) #7332
allowing to specify percentage-based factors (like 1.125 for 112.5%) #7332
Conversation
…cimals
logic handled according to number or bigint added unit test
@@ -308,7 +308,7 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip | |||
* ``` | |||
*/ | |||
public async calculateFeeData( | |||
baseFeePerGasFactor = BigInt(2), | |||
baseFeePerGasFactor: bigint | number = BigInt(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @TemirlanBasitov I'll suggest to also add few examples and short description in above documentation comments so with this PR merge it will update docs website. https://docs.web3js.org/libdocs/Web3Eth#calculatefeedata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdevcs where i can add comment and short description here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adjusted description of method with examples in the web3_eth.ts
Here also short explanation:
calculateFeeData method now supports both bigint and number types for the baseFeePerGasFactor parameter. If a number is provided, it will be converted to a bigint with three decimal precision. This allows for more flexible calculations when dealing with decimal values.
Ex:
await calculateFeeData(BigInt(2));
// baseFeePerGasFactor remains as 2n
await calculateFeeData(1.5);
// baseFeePerGasFactor is converted to BigInt(1.500) for precise calculations
These changes make the method more versatile while ensuring backward compatibility with previous bigint usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TemirlanBasitov PR looks good, you just need to fix Conflicting file CHANGELOG.md, thanks,
…cimals
…cimals
…cimals
@krzysu @Muhammad-Altabba @luu-alex plz review |
public async calculateFeeData( | ||
baseFeePerGasFactor = BigInt(2), | ||
baseFeePerGasFactor: bigint | number = BigInt(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luu-alex web3-eth package's changelog is not update for this PR but root. so In release for this PR, web3-eth will be patch bump if there are no other changes in eth.
Description
Please include a summary of the changes and be sure to follow our Contribution Guidelines.
Type of change
Checklist:
npm run lint
with success and extended the tests and types if necessary.npm run test:unit
with success.npm run test:coverage
and my test cases cover all the lines and branches of the added code.npm run build
and testeddist/web3.min.js
in a browser.CHANGELOG.md
file in the root folder.