-
Notifications
You must be signed in to change notification settings - Fork 0
Add estimation hooks #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Pull request overview
Adds new fee-estimation utilities and hooks and wires up Vitest so consumers can estimate total EIP-1559 fees and ERC-20 approve costs with test coverage.
Changes:
- Added
estimateTotalFeeutility with a comprehensive Vitest suite. - Added
useEstimateFeesanduseEstimateApproveErc20Feeshooks for fee estimation flows. - Introduced Vitest config/scripts and bumped package version.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Adds Vitest configuration (clear mocks) to support the new test suite. |
| src/utils/fees.ts | Introduces estimateTotalFee utility used by the new hooks to compute total EIP-1559 fees. |
| src/utils/fees.test.ts | Adds unit tests validating fee estimation behavior and edge cases. |
| src/useEstimateFees.ts | Adds a hook that composes wagmi fee data with estimateTotalFee. |
| src/useEstimateApproveTokenFees.ts | Adds a hook to estimate ERC-20 approve gas and total fees. |
| package.json | Adds Vitest scripts/deps and bumps version for release. |
| README.md | Documents the two new hooks in the public API table. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ArturDolzan
left a comment
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.
LGTM.
Description
This PR adds 2 extra hooks
useEstimateFees, which is based on the implementation from the portal. There are a few minor differences though: That hook used to default to0nwhen values were still loading or on error. Now, unless there's an exact estimation,undefinedis returned. I think that's the best behaviour, and loading and error states should be handled. The defaultoverEstimationis now1.5(instead of 1) as all usages in the portal were passing1.5. And now thefallbackPriorityFeeis a parameter for the consumer, instead of being hardcoded per chain (we only used it forhemiSepoliain the portal). Tests were added!Screenshots
Checklist