Skip to content

fix(examples): keep wallet connect retryable after rejection - #7

Closed
omerbek wants to merge 2 commits into
circlefin:masterfrom
omerbek:fix/wallet-connect-retry
Closed

omerbek wants to merge 2 commits into
circlefin:masterfrom
omerbek:fix/wallet-connect-retry

Conversation

@omerbek

@omerbek omerbek commented Sep 3, 2026

Copy link
Copy Markdown

Summary

  • keep EVM and Solana provider candidates local until wallet permission and account discovery succeed
  • restore disconnected provider and action-button state when a connection attempt fails, allowing users to retry without reloading
  • add focused connection helpers and regression tests across the send, swap, EVM bridge, and Solana bridge examples

Fixes #6.

Testing

  • cd app-kit-send && npm test && npm run build
  • cd app-kit-swap && npm test && npm run build
  • cd app-kit-bridge-evm && npm test && npm run build
  • cd app-kit-bridge-solana && npm test && npm run build

All 10 tests pass and all four Vite production builds complete successfully on Node.js v24.20.0.

@kutluhaneth46

Copy link
Copy Markdown

Thanks for the retryability fix — the catch path restoring provider = null / disabling the action button is the right shape.

One gap across the shared connectEvmProvider helpers (send / swap / bridge-evm / bridge-solana):

const accounts = (await provider.request({ method: "eth_accounts", ... })) as string[];
return { provider, account: accounts[0] };

If eth_accounts returns [] (or accounts[0] is otherwise missing), the helper still resolves successfully. Callers then do:

walletInfo.textContent = connection.account ?? "Connected";
sendButton.disabled = false; // or bridgeButton.disabled = false on EVM-only examples

So the UI can show a fake "Connected" state and re-enable the action with no usable account. Pre-PR code had the same accounts[0] hole, but the new helper + disabled = false makes the success path more assertive.

Suggested harden (same for Solana when address is missing):

  1. Prefer the accounts array returned by eth_requestAccounts (avoid a second eth_accounts round-trip that can race empty).
  2. if (!account) throw new Error("No account returned after wallet permission"); so the existing catch path keeps the button disabled.

Happy to re-review once that lands.

@omerbek

omerbek commented Sep 5, 2026

Copy link
Copy Markdown
Author

Good point. I pushed cc3debd to cover that path as part of this PR.

The EVM helpers now use the account list returned by eth_requestAccounts and throw if it is empty, so the existing catch path keeps the UI disabled instead of reporting a usable connection. I also added the same missing-address guard for the Solana helper.

Verified locally with Node 22.12.0:

  • app-kit-send: vitest run, tsc, vite build
  • app-kit-swap: vitest run, tsc, vite build
  • app-kit-bridge-evm: vitest run, tsc, vite build
  • app-kit-bridge-solana: vitest run, tsc, vite build

@hjchen-circle

Copy link
Copy Markdown
Contributor

We acknowledge the issue raised in #6, but the scope of the proposed fix goes far beyond the original issue. Closing the PR. The issue is resolved in #9

hjchen-circle added a commit to hjchen-circle/docs-examples that referenced this pull request Sep 16, 2026
This PR:
- addresses the issue raised in circlefin#6 and supersedes circlefin#7 and circlefin#8 
- also clears the output panel on successful wallet connect
- surfaces the actual `Error` throw message instead of generic `Unknown
error`
- adds potential troubleshooting guidance for Swap kit in case of bad
RPC
- switches out Base Sepolia for Avalanche Fuji for the unified balance
kit demo and explains the situation of both EVM and Solana wallet
prompts required during the spend operation
- drops the estimate pre-step for `send()` and `swap()`
- bumps dependencies to latest versions

Closes circlefin#6
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.

Rejected wallet connection leaves App Kit examples unable to retry

3 participants