Repository navigation
Improve Reserve swap feedback and RPC resilience; upgrade to Node 24 - #645
Conversation
- 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.
|
@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
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>
Deploying goodprotocolui with
|
| Latest commit: |
ba944c9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3b505dbe.goodprotocolui.pages.dev |
| Branch Preview URL: | https://reserve-and-rpc-fixes.goodprotocolui.pages.dev |
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
|
@copilot focused review follow-up on eccc37b: the documented
Please use 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. |
Implemented in |
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
Fixed in |
|
@copilot a concrete build blocker from paired local validation, confirmed in current head 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>
Fixed in |
|
@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 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>
Implemented in |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Linked issuesChecked at commit ba944c9 #635 Bug: Error displayed before Approve/Swap on Celo Reserve, but transaction completes · 0 of 1 met
|
There was a problem hiding this comment.
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
| 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), | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
🟠 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.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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]) | ||
|
|
There was a problem hiding this comment.
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 👍 / 👎.
Description
Aligned with upcoming sdk updates from this PR: GoodDollar/GoodWeb3-Mono#274
Reserve and mobile UI
RPC handling
Runtime
Dependencies and validation
@gooddollar/web3sdk-v2@0.4.49and@gooddollar/good-design@0.4.54from the paired GoodWeb3-Mono Login SDK should update customization (whitelabel) settins #274 work; no local package linking is needed.ba944c92resets pending swap state on Reserve-limit dismissal and expires alternative-chain suggestions 15 seconds after the check timestamp.Summary by Sourcery
Improve Reserve swap failure guidance and RPC resilience while upgrading the project runtime and workflows to Node 24.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests:
Chores: