Skip to content

Improve Reserve swap feedback and RPC resilience; upgrade to Node 24 - #645

Merged
L03TJ3 merged 9 commits into
masterfrom
reserve-and-rpc-fixes
Dec 3, 2026
Merged

L03TJ3 merged 9 commits into
masterfrom
reserve-and-rpc-fixes

Conversation

@L03TJ3

@L03TJ3 L03TJ3 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Aligned with upcoming sdk updates from this PR: GoodDollar/GoodWeb3-Mono#274

Reserve and mobile UI

  • Consume structured Reserve limit errors and the shared good-design error modal.
  • Show alternative-chain availability only when the network/Reserve feature is enabled and a fresh SDK check confirms availability; refresh checks every 15 seconds.
  • Handle both Exception and Fail transaction states for swaps and approvals, closing failed swap confirmations.
  • Remove mobile drag-to-dismiss from the shared modal while retaining its layout and opacity fade.

RPC handling

  • Use bounded fallback read-provider pools for SDK-v2 on Fuse/Celo, preserving SDK-v1’s scalar RPC configuration.
  • Apply RPC exclusions consistently across discovered, configured, cached and fallback endpoints.
  • Add regression coverage for HTTP 429 failover, exhausted providers, exclusions and provider compatibility.

Runtime

  • Upgrade CI/deployment workflows, .nvmrc, engine requirements and setup documentation to Node 24.

Dependencies and validation

  • Uses the published @gooddollar/web3sdk-v2@0.4.49 and @gooddollar/good-design@0.4.54 from the paired GoodWeb3-Mono Login SDK should update customization (whitelabel) settins #274 work; no local package linking is needed.
  • Signed follow-up ba944c92 resets pending swap state on Reserve-limit dismissal and expires alternative-chain suggestions 15 seconds after the check timestamp.
  • Local verification: 25 focused tests across five suites passed; lint and typecheck passed. The application changes passed a local production build before the final test-only lint adjustment. No new live wallet transaction was performed.

Summary by Sourcery

Improve Reserve swap failure guidance and RPC resilience while upgrading the project runtime and workflows to Node 24.

New Features:

  • Add a Reserve-limit explanation modal with chain-specific guidance and links to alternative Celo swap routes.
  • Add a development-only Reserve-limit QA simulation that is available only when the SDK capability is active and prevents real approvals and swaps while enabled.

Bug Fixes:

  • Recognize structured Reserve-limit errors and handle both failed and exceptional swap and approval states, closing failed swap confirmations.
  • Show an alternative-chain Reserve suggestion only when its network and Reserve features are enabled and a fresh availability check confirms it; refresh and expire checks every 15 seconds.
  • Apply configured RPC exclusions consistently to discovered and fallback endpoints, including duplicate and cached URL filtering.
  • Bound SDK-v2 read-provider failover on Fuse and Celo to avoid unbounded retries on HTTP 429 responses while retaining scalar URLs for SDK-v1.

Enhancements:

  • Remove mobile drag-to-dismiss from the shared modal while preserving its layout and opacity fade.

Build:

  • Upgrade the Node.js runtime requirement and repository setup to Node 24 with Yarn 3.6.1.

CI:

  • Update CI and Vercel workflows to use Node 24 and current checkout/setup actions, and run the focused RPC and Reserve regression suites.

Documentation:

  • Update setup instructions for Node 24 and add a guide for safely exercising the development-only Reserve-limit QA simulation.

Tests:

  • Add focused regression coverage for Reserve-limit classification and QA gating, alternative-chain result freshness, RPC exclusions, provider compatibility, and HTTP 429 failover.

Chores:

  • Replace local package archives with published @gooddollar/web3sdk-v2@0.4.49 and @gooddollar/good-design@0.4.54 dependencies and update the lockfile.

L03TJ3 added 2 commits October 5, 2026 18:32
- Integrate the shared Reserve limit modal and verified alternative-chain messaging.
- Handle failed swap/approval states and remove the broken mobile modal drag behavior.
- Add bounded Fuse/Celo read-RPC failover and consistent RPC exclusion filtering.
- Add provider and RPC regression tests.

L03TJ3 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot please add the ProtocolUI entry point for the minimal Reserve-limit QA override requested on GoodDollar/GoodWeb3-Mono#274. QA task: GoodDollar/GoodWeb3-Mono#275. Preserve this PR's existing RPC and Reserve changes.

Paired API contract requested from the SDK: optional qa?: { forceTradeLimits?: boolean } on Web3Provider / its context, default off.

  • Wire REACT_APP_QA_FORCE_TRADE_LIMITS=true through src/hooks/useWeb3.tsx to that SDK option. This app uses Vite with the existing REACT_APP_ convention. Gate on development build explicitly; never activate in a production build, and do not confuse build mode with the production/mainnet contract deployment env.
  • In src/pages/gd/Swap/SwapCore/mentoReserve.tsx, provide a visibly labelled QA simulation path through existing swap confirmation to the SDK send/error classifier and existing limit modal. An empty wallet must be able to use this without funding or approval. Only the labelled QA path may bypass balance/allowance gating; do not fake displayed balances or approval success. Keep the valid quote/account/network prerequisites explicit.
  • Disable/block real Reserve approval and submission while this simulation is active. Fail closed if the installed SDK lacks or does not activate the QA capability: an old/inactive SDK must never turn a UI gate bypass into a live send. Coordinate a small effective-mode/capability signal with Mono#274 if needed.
  • The SDK must inject the limit error before signer access. Do not open a hardcoded modal in place of exercising the existing error path. Verify confirmation closes, correct Celo/XDC message and links appear (Celo Uniswap/Ubeswap; XDC XSwap), and close/reopen works without stale errors.
  • Add focused tests for empty-wallet reachability, safe SDK wiring/no real approval or send, off/production behaviour, and classifier-to-modal behaviour. Verify the modal at a mobile viewport such as 375x812 for text/link/close-button overflow. This is layout verification, not mobile transaction QA. Report actual test/check commands and any checks not run.
  • Provide exact enable/disable/restart instructions and prerequisites for the QA tester. Use the existing yalc setup from Chore: QA release #275; package publication is not a QA prerequisite. No tester code patches or general mock harness.

Keep scope limited to forced Reserve-limit handling; do not claim this verifies real trade limits, mined receipts or delegated-wallet transaction execution.

Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Deploying goodprotocolui with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba944c9
Status: ✅  Deploy successful!
Preview URL: https://3b505dbe.goodprotocolui.pages.dev
Branch Preview URL: https://reserve-and-rpc-fixes.goodprotocolui.pages.dev

View logs

Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>

L03TJ3 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot focused review follow-up on eccc37b: the documented .env.local setup currently does not match the configuration reads.

src/hooks/useWeb3.tsx:249 and src/pages/gd/Swap/SwapCore/mentoReserve.tsx:72 read process.env.REACT_APP_QA_FORCE_TRADE_LIMITS. But vite.config.ts:41 calls loadEnv(mode, process.cwd()) with its default VITE_ prefix, while dotenv.config() loads .env, not .env.local. The existing envPrefix: 'REACT_APP_' exposes these variables through import.meta.env, not that manually defined process.env object.

Please use import.meta.env.REACT_APP_QA_FORCE_TRADE_LIMITS consistently (or explicitly load the proper prefix), keeping the development guard. Verify the exact documented .env.local + restart workflow actually activates the paired SDK context and labelled empty-wallet simulation, and that false/absent/production cannot activate it.

The added helper tests are useful, but do not yet render the confirmation or modal. Please add/perform the requested integration verification: empty wallet -> labelled confirmation -> actual SDK limit classification -> confirmation closes -> Celo/XDC modal and correct DEX links -> close/reopen. Ensure no signer/send/approval calls; check SDK capability absent/inactive fails closed. Also report the 375x812 layout check (or explicitly mark it not run). Keep the accepted yalc setup; no npm release gate. Report exact test commands/results and any environment blockers rather than claiming helper tests establish these UI outcomes.

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@copilot please add the ProtocolUI entry point for the minimal Reserve-limit QA override requested on GoodDollar/GoodWeb3-Mono#274. QA task: GoodDollar/GoodWeb3-Mono#275. Pre...

Implemented in 9c2e54a (helper move in eccc37b): dev-only SDK wiring, effective-capability/modal fail-closed gating, a labelled confirmation simulation, real-action guards, focused tests, and yalc setup instructions. QA stays unavailable until Mono #274 implements the qa.forceTradeLimits effective signal and injects the classified error before signer access. Standalone helper typecheck/assertions and secret scanning passed. Jest, lint, build, and the 375×812 layout check were not run: this checkout has no install state/yalc packages and runs Node 22 instead of the required Node 24.

Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@copilot focused review follow-up on eccc37b: the documented .env.local setup currently does not match the configuration reads.

src/hooks/useWeb3.tsx:249 and `src/pages/gd/Swap/SwapCore/mentoRese...

Fixed in 6d539fe: both flag reads now use import.meta.env.REACT_APP_QA_FORCE_TRADE_LIMITS; the development-only guard remains, and false/absent cases are covered. The exact flag/capability gates passed standalone typecheck/assertions and the documented .env.local key aligns with Vite’s REACT_APP_ env prefix. Rendered confirmation-to-modal/SDK integration and 375×812 checks remain unverified: this checkout lacks Node 24, install state, yalc packages, and the QA-capable SDK. Focused Jest could not start because Yarn reports no install state.

L03TJ3 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot a concrete build blocker from paired local validation, confirmed in current head 6d539fe: src/hooks/useWeb3.tsx opens <QaAwareWeb3Provider> at line 264 but closes </Web3Provider> at line 276. Please correct the closing tag to match the opening component.

The paired local typecheck and Vite build both catch this JSX error. The 18 focused UI tests pass but do not compile this provider, so they did not catch it. Add a focused compile/typecheck safeguard covering the actual provider wiring, or otherwise ensure that file is included in the validation you run; report the exact check and result. Keep this correction small and preserve the accepted yalc workflow and existing changes.

For clarity, the separate clean-install/lockfile and yalc-package setup issues are not functional QA results. They do not explain away this source-level JSX error. The QA issue remains pending paired validation; do not claim the app is ready based only on helper tests.

Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@copilot a concrete build blocker from paired local validation, confirmed in current head 6d539fe: src/hooks/useWeb3.tsx opens <QaAwareWeb3Provider> at line 264 but closes </Web3Provider> at l...

Fixed in af93662: the provider now closes with </QaAwareWeb3Provider>. Added src/hooks/useWeb3.test.ts, which transpiles the actual provider source and checks tag pairing and QA prop wiring. The focused test command (yarn test --runInBand src/hooks/useWeb3.test.ts) could not start because there is no Yarn install state. Parsing the provider with tsc --ignoreConfig --noEmit --jsx react-jsx --target ESNext --module ESNext --moduleResolution bundler --skipLibCheck --pretty false src/hooks/useWeb3.tsx produced no JSX/syntax diagnostics; remaining errors are unresolved project dependencies/types. I could not inspect Actions logs because the GitHub Actions tools are unavailable in this session.

L03TJ3 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot one small simplification following the maintainer's clarified lifecycle: QA uses the updated Mono SDK through yalc; after validation the SDKs will be published and ProtocolUI upgraded before merge. Compatibility with older SDK types is not required for this change.

Current af93662 fixes the JSX mismatch but retains QaAwareWeb3Provider, a type-cast alias of the existing provider. Please remove that alias and use the existing Web3Provider directly with its new SDK-typed qa={{ forceTradeLimits: ... }} prop, with matching JSX tags. Update the new provider test accordingly. Keep the development/default-off and no-signing safeguards, and the straightforward boolean pass-through; no additional provider abstraction or old-SDK compatibility workaround is needed.

Validate against the paired updated SDK via the documented yalc workflow. An unreleased registry SDK or CI checkout lacking yalc packages is expected at this stage and is not itself a QA blocker; report actual source errors separately. No broader refactor.

Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@copilot one small simplification following the maintainer's clarified lifecycle: QA uses the updated Mono SDK through yalc; after validation the SDKs will be published and ProtocolUI upgraded before ...

Implemented in ac50050: removed the type-cast alias and now pass qa={{ forceTradeLimits: forceTradeLimitsQa }} directly to the SDK-typed <Web3Provider>, with matching closing tag. Updated the provider source test to assert direct tag and prop wiring. tsc parsing found no JSX/syntax diagnostics; the Jest test and paired SDK typecheck could not run because this checkout has no node_modules/yalc package and only Node 22. git diff --check and secret scanning passed.

@L03TJ3
L03TJ3 marked this pull request as ready for review December 2, 2026 15:32
@L03TJ3
L03TJ3 requested review from a team and blueogin December 2, 2026 15:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T15:36:57.571972Z ba944c9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit ba944c9

#635 Bug: Error displayed before Approve/Swap on Celo Reserve, but transaction completes · 0 of 1 met

# Requirement Status Notes
1 Do not show an error before Approve or Swap when the flow will complete successfully. ❌ Not addressed The swap effect still sets an error for Exception or Fail states, including a Reserve-limit modal for classified failures; it does not prevent a misleading error from appearing when the operation later succeeds.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/pages/gd/Swap/reserveLimitQa.test.ts" line_range="74-77" />
<code_context>
+    })
+
+    it('blocks real approval and swap actions while the SDK QA mode is active', () => {
+        expect(canUseRealReserveActions(true)).toBe(false)
+        expect(canUseRealReserveActions(false)).toBe(true)
+        expect(canConfirmReserveLimitQa(true, false)).toBe(false)
+        expect(canConfirmReserveLimitQa(true, true)).toBe(true)
+        expect(canConfirmReserveLimitQa(false, false)).toBe(true)
+    })
</code_context>
<issue_to_address>
**Real-action gates can be bypassed**

When A regression removes or bypasses the `MentoSwap` guards while leaving the helper implementations unchanged, the helper assertions still pass if `MentoSwap` stops using `canUseRealReserveActions` to guard approval and swap actions, so the test does not catch real transactions becoming available in QA mode.

Exercise the component actions in QA mode and assert that approval and real swap callbacks cannot run.
</issue_to_address>

### Comment 2
<location path="src/functions/rpcProviders.ts" line_range="12" />
<code_context>
+): Config['readOnlyUrls'] {
+    const readOnlyUrls: NonNullable<Config['readOnlyUrls']> = { ...rpcs }
+    for (const chainId of [122, 42220]) {
+        const urls = filterExcludedRpcs([rpcs[chainId] || '', ...(candidates[chainId] || [])])
+        if (!urls.length) {
+            readOnlyUrls[chainId] = ''
</code_context>
<issue_to_address>
**Excluded RPCs remain in wallet config**

When an endpoint listed in `REACT_APP_EXCLUDED_RPCS` is also configured for a wallet chain, `createSdkReadOnlyUrls` filters the SDK read-provider pool, but the wallet chain configuration still receives the raw configured URL from `connectOptions.chains[].rpcUrl`. AppKit can therefore continue using an endpoint that the exclusion setting is intended to block.

Apply the exclusion filter when constructing the wallet chain RPC configuration, and ensure an excluded endpoint is not selected as its fallback.
</issue_to_address>

### Comment 3
<location path="src/pages/gd/Swap/SwapCore/mentoReserve.tsx" line_range="158-170" />
<code_context>
-                message: i18n._(t`Swap transaction failed, please try again.`),
-                reason: decodeTransactionErrorReason(swap.state.errorMessage),
-            })
+        if (swap?.state?.status === 'Exception' || swap?.state?.status === 'Fail') {
+            const classifiedLimitChainId = getReserveLimitFailureChainId(swap.state, chainId)
+            if (classifiedLimitChainId !== undefined && ReserveLimitModal) {
+                setError(undefined)
+                setLimitErrorChainId(classifiedLimitChainId)
+            } else {
+                setLimitErrorChainId(undefined)
+                setError({
+                    message: i18n._(t`Swap transaction failed, please try again.`),
+                    reason: decodeTransactionErrorReason(swap.state.errorMessage),
+                })
+            }
         }
-        if (approve?.state?.status === 'Exception') {
</code_context>
<issue_to_address>
**Suppress misleading swap errors**

The issue asks that users not see an error when the swap flow will succeed. This effect still sets an error for every Exception or Fail state unless it is classified as a Reserve-limit failure, and the Reserve-limit path still displays a modal; no success-aware handling prevents a false warning.
</issue_to_address>

### Comment 4
<location path="src/pages/gd/Swap/useReserveAlternative.ts" line_range="24" />
<code_context>
+        const refresh = async () => {
+            setVerified(undefined)
+            try {
+                const result = await check()
+                const age = result ? Date.now() - result.checkedAt : Infinity
+                if (!cancelled && result?.chainId === otherChainId && age >= 0 && age < refreshInterval) {
</code_context>
<issue_to_address>
**Alternative checks can stall**

When the SDK alternative-reserve check never settles because its RPC or service is unresponsive, `useReserveAlternative` awaits `check()` without a timeout, and schedules its next check only in `finally` after that promise settles. A hung SDK/RPC request therefore permanently stops refreshes for this mounted suggestion, leaving alternative-chain availability unavailable after any existing result expires.

Bound the check with a timeout and ensure the next refresh is scheduled even when the check stalls.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 4 findings to address first, and the new fallback RPC pools feed data to the swap SDK, so a bad or stale endpoint response could inform a swap the user confirms; an on-chain transaction already submitted cannot be undone. Reverting restores the previous RPC wiring, but does not reverse transactions already made.

Blocking findings: src/pages/gd/Swap/reserveLimitQa.test.ts:77, src/functions/rpcProviders.ts:12, src/pages/gd/Swap/SwapCore/mentoReserve.tsx:170, src/pages/gd/Swap/useReserveAlternative.ts:24


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/functions/rpcProviders.ts Resolved
Comment on lines +158 to 170
if (swap?.state?.status === 'Exception' || swap?.state?.status === 'Fail') {
const classifiedLimitChainId = getReserveLimitFailureChainId(swap.state, chainId)
if (classifiedLimitChainId !== undefined && ReserveLimitModal) {
setError(undefined)
setLimitErrorChainId(classifiedLimitChainId)
} else {
setLimitErrorChainId(undefined)
setError({
message: i18n._(t`Swap transaction failed, please try again.`),
reason: decodeTransactionErrorReason(swap.state.errorMessage),
})
}
}

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.

🟠 High · Suppress misleading swap errors

The issue asks that users not see an error when the swap flow will succeed. This effect still sets an error for every Exception or Fail state unless it is classified as a Reserve-limit failure, and the Reserve-limit path still displays a modal; no success-aware handling prevents a false warning.

Prompt for AI agents
In `src/pages/gd/Swap/SwapCore/mentoReserve.tsx` at lines 158-170:

**Suppress misleading swap errors**

The issue asks that users not see an error when the swap flow will succeed. This effect still sets an error for every Exception or Fail state unless it is classified as a Reserve-limit failure, and the Reserve-limit path still displays a modal; no success-aware handling prevents a false warning.

From #635:

Do not show an error before Approve or Swap when the flow will complete successfully.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The published @gooddollar/web3sdk-v2@0.4.49 bundle pinned by this PR uses the connected signer directly for both Reserve approve and swap. This bypasses the usedapp Safe-detection path implicated in #647. The UI still reports genuine terminal failures as intended. Leaving this open until the affected MetaMask approve → swap path is verified end to end without a premature error; the SDK inspection alone does not establish that.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba944c92b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (expiryTimer) clearTimeout(expiryTimer)
}
}, [sourceChainId, enabled, check])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Stabilize the alternative-check dependency

When a valid alternative is found, setVerified rerenders MentoSwap; the installed SDK's useSwap returns a newly allocated checkAlternativeReserve function on that render, so including check here immediately cleans up and restarts the effect. Each successful check therefore triggers another check instead of waiting 15 seconds, continuously issuing RPC requests while the recommendation repeatedly resets. Memoize the SDK callback or retain it in a ref so this effect restarts only when the source chain or request inputs change.

Useful? React with 👍 / 👎.

@L03TJ3
L03TJ3 merged commit aab8b6f into master Dec 3, 2026
8 checks passed
@L03TJ3
L03TJ3 deleted the reserve-and-rpc-fixes branch December 3, 2026 05:30

This branch was successfully deployed

2 active deployments
preview — ba944c92 Deployed Dec 2, 2026 by L03TJ3 via preview #1089
internal — ba944c92 Deployed Dec 2, 2026 by L03TJ3 via authorize #1089
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.

Bug: Error displayed before Approve/Swap on Celo Reserve, but transaction completes

2 participants