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

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