Skip to content

fix(goodreserve-widget): staging review - balances, double approve, confirm amount, retry button - #174

Merged
blueogin merged 4 commits into
mainfrom
fix/goodreserve-widget-staging-review
Aug 17, 2026
Merged

fix(goodreserve-widget): staging review - balances, double approve, confirm amount, retry button#174
blueogin merged 4 commits into
mainfrom
fix/goodreserve-widget-staging-review

Conversation

@blueogin

Copy link
Copy Markdown
Contributor

Description

Fixes from the GoodReserve staging review (GoodWallet).

  • Balances after swap: the success screen does not show Balance rows. Do another swap waits for a chain balanceOf read, then opens the form. MainSwapView also reads balances when it is shown.
  • Two approve txs (USDM → G$): removed the widget’s extra ensureSwapAllowance. Approve now happens only inside sdk.buy() / sdk.sell(), so the wallet sees at most one approve + one swap.
  • Confirm amount clipped: Minimum Received uses the same 32px size and 36px line height as the swap inputs.
  • Retry vs Review Swap: Retry keeps its own button and uses the same 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:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

…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
blueogin requested review from a team and sirpy and a lite review from Copilot August 17, 2026 17:03
@blueogin
blueogin merged commit e9abf4c into main Aug 17, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants