fix(goodreserve-widget): staging review - balances, double approve, confirm amount, retry button - #174
Merged
Merged
Conversation
…to swap flow - Introduced refreshBalances action in ReserveSwapWidgetAdapterActions to ensure balance updates. - Updated SwapSuccessView to refresh balances before setting swap direction. - Implemented useEffect in MainSwapView to automatically refresh balances on component mount.
…rawer - Updated the font size calculation in ConfirmDrawer to use a constant for better readability. - Set a specific line height for the text to improve layout consistency.
… related approval logic - Eliminated the ensureSwapAllowance function to streamline the swap process. - Removed the pre-flight ERC20 approval logic from the useReserveSwap hook. - Updated the swap flow to enhance clarity and reduce complexity in the codebase.
- Added height and border radius properties to the Retry button for improved visual consistency and user experience.
blueogin
requested review from
a team and
sirpy
and
a lite review from Copilot
August 17, 2026 17:03
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies GoodReserve widget fixes identified during a staging review, focusing on improving post-swap balance freshness, preventing duplicate approval transactions, and tightening UI layout/styling consistency.
Changes:
- Adds an explicit
refreshBalances()action to the adapter contract and wires it into the UI (success screen + main swap view). - Removes the widget-level ERC20 pre-approval flow so approval is handled only inside the SDK
buy()/sell()calls. - Updates confirm “Minimum Received” typography and aligns the Retry button dimensions with the primary CTA.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/goodreserve-widget/src/widgetRuntimeContract.ts | Extends the public adapter actions contract with refreshBalances() for explicit balance refresh triggers. |
| packages/goodreserve-widget/src/useReserveSwap.ts | Removes the local approval helper and relies on SDK buy()/sell() for allowance handling. |
| packages/goodreserve-widget/src/useGoodReserveAdapter.ts | Exposes refreshBalances() on the adapter actions object and includes it in memo deps. |
| packages/goodreserve-widget/src/ReserveSwapView.tsx | Calls refreshBalances() on main view mount and before resetting after success; tweaks confirm typography and Retry button styling. |
Suppressed comments (1)
packages/goodreserve-widget/src/ReserveSwapView.tsx:582
actions.refreshBalances()can reject (it performs on-chain reads) and calling it as a fire-and-forget promise from an effect can produce unhandled promise rejections in the browser. Catch/log (or surface) errors here to keep the widget stable if the read fails.
useEffect(() => {
void actions.refreshBalances()
}, [actions.refreshBalances])
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+343
to
+346
| onPress={async () => { | ||
| await actions.refreshBalances() | ||
| actions.setDirection('buy') | ||
| }} |
Comment on lines
66
to
68
| executeSwap: () => Promise<void> | ||
| refreshBalances: () => Promise<void> | ||
| refresh: () => Promise<void> |
Comment on lines
19
to
21
| export function useReserveSwap( | ||
| refs: ReserveRefs, | ||
| state: ReserveSwapWidgetAdapterState, |
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.
Description
Fixes from the GoodReserve staging review (GoodWallet).
balanceOfread, then opens the form.MainSwapViewalso reads balances when it is shown.ensureSwapAllowance. Approve now happens only insidesdk.buy()/sdk.sell(), so the wallet sees at most one approve + one swap.height={54}/borderRadius="$3"as Review Swap.About # (link your issue here)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: