add: new gas defaults#263
Merged
Merged
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
useGasFees, thelibrary.getFeeData()call is not guarded against errors or rejection; consider adding a.catchor try/catch with a safe fallback to avoid leaving the hook stuck with stale defaults if the RPC call fails. - The comment in
useContractFunctionWithDefaultGasFeessays to 'use gasPrice value instead of maxFeePerGas' but the implementation setsmaxFeePerGasfromgasFees.gasPrice; it would be clearer either to update the comment or explicitly set bothgasPriceandmaxFeePerGasto reflect the intended behavior. - The initial
feesstate inuseGasFeesis cast asFeeData, which can hide mismatches ifFeeData’s shape changes; consider constructing a fully typedFeeDataobject without the type assertion to let the compiler catch potential discrepancies.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `useGasFees`, the `library.getFeeData()` call is not guarded against errors or rejection; consider adding a `.catch` or try/catch with a safe fallback to avoid leaving the hook stuck with stale defaults if the RPC call fails.
- The comment in `useContractFunctionWithDefaultGasFees` says to 'use gasPrice value instead of maxFeePerGas' but the implementation sets `maxFeePerGas` from `gasFees.gasPrice`; it would be clearer either to update the comment or explicitly set both `gasPrice` and `maxFeePerGas` to reflect the intended behavior.
- The initial `fees` state in `useGasFees` is cast as `FeeData`, which can hide mismatches if `FeeData`’s shape changes; consider constructing a fully typed `FeeData` object without the type assertion to let the compiler catch potential discrepancies.
## Individual Comments
### Comment 1
<location path="packages/sdk-v2/src/sdk/claim/react.ts" line_range="78-79" />
<code_context>
- const { gasPrice = BigNumber.from(25.001e9) } = useGasFees();
- const minBalance = BigNumber.from(chainId === 42220 ? "250000" : "150000").mul(gasPrice);
+ const fees = useGasFees();
+ const minBalance = BigNumber.from(chainId === 42220 ? "250000" : "150000").mul(fees?.gasPrice ?? 0);
const signer = (library as ethers.providers.JsonRpcProvider)?.getSigner();
</code_context>
<issue_to_address>
**question (bug_risk):** Align minBalance fallback with the default values used in useGasFees to avoid silent behavior changes.
This hook used to default `gasPrice` to `25.001e9` on Celo; now it effectively falls back to `0` via `fees?.gasPrice ?? 0`, while `useGasFees` itself seeds `gasPrice` to `30e9`. To avoid a zero `minBalance` and keep behavior consistent with other call sites, consider either relying on the `fees` default (dropping `?? 0`) or using the same numeric fallback as `useGasFees` here.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+78
to
+79
| const fees = useGasFees(); | ||
| const minBalance = BigNumber.from(chainId === 42220 ? "250000" : "150000").mul(fees?.gasPrice ?? 0); |
There was a problem hiding this comment.
question (bug_risk): Align minBalance fallback with the default values used in useGasFees to avoid silent behavior changes.
This hook used to default gasPrice to 25.001e9 on Celo; now it effectively falls back to 0 via fees?.gasPrice ?? 0, while useGasFees itself seeds gasPrice to 30e9. To avoid a zero minBalance and keep behavior consistent with other call sites, consider either relying on the fees default (dropping ?? 0) or using the same numeric fallback as useGasFees here.
L03TJ3
reviewed
Apr 6, 2026
L03TJ3
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Update gas fee handling to use provider fee data with sensible defaults and adjust consumers accordingly.
New Features:
Enhancements: