Skip to content

Share wallet connection state across React hooks - #1063

Open
deslawson wants to merge 3 commits into
BCPathway:mainfrom
deslawson:feature/953-wallet-state-machine
Open

deslawson wants to merge 3 commits into
BCPathway:mainfrom
deslawson:feature/953-wallet-state-machine

Conversation

@deslawson

@deslawson deslawson commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Add a shared wallet state machine for connection, network mismatch, and errors. Block write hooks unless a wallet is connected, pass the configured network to wallet signers, and cover transitions with fake-adapter tests.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • CI
  • Chore

Checklist

  • I ran pre-commit run --all-files locally and it passed
  • All CI jobs pass on this branch
  • I added or updated tests for new behaviour
  • I updated relevant docs / comments
  • No secrets or credentials are included
  • No breaking changes to public APIs (or I've documented them)

Breaking changes?

No. The wallet status and network signing parameters are additive; existing adapter implementations remain compatible.

Related issues

Closes #953

Add a shared wallet state machine for connection, network mismatch, and errors. Block write hooks unless a wallet is connected, pass the configured network to wallet signers, and cover transitions with fake-adapter tests.

Closes BCPathway#953
@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@deslawson Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

p3ris0n
p3ris0n previously approved these changes Sep 28, 2026

@p3ris0n p3ris0n 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.

Review

This covers #953.

  • The wallet reducer exposes disconnected, connecting, connected, wrong-network, and error, and useWallet shares that state.
  • useMint, useTransfer, useApprove, and useBurn throw before submit unless status is connected.
  • A rejected connect lands in error, and a passphrase mismatch lands in wrong-network without registering the adapter. Fake-adapter tests cover those transitions.
  • Freighter and Albedo report a network passphrase and receive the configured network when signing.

One non-blocking note: Cargo.lock only adds bc-forge-flash-loan-guard. It is unrelated to the wallet machine. It is harmless if that crate is already a workspace member, but it should not have ridden along.

CI is green and the branch merges cleanly. Approving.

@p3ris0n

p3ris0n commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Approved above, and CI on this head is still green. I did not merge it.

After #1019 and #1061 landed, this branch is now CONFLICTING with main (hooks.ts, context.tsx, and sdk/src/client.ts). Rebase onto current main, keep the wallet state machine, and make sure useVaultDeposit and useProposalVote from #1061 also refuse to submit unless the shared status is connected. I will merge once that rebase is conflict-free and CI is green again.

1 similar comment
@p3ris0n

p3ris0n commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Approved above, and CI on this head is still green. I did not merge it.

After #1019 and #1061 landed, this branch is now CONFLICTING with main (hooks.ts, context.tsx, and sdk/src/client.ts). Rebase onto current main, keep the wallet state machine, and make sure useVaultDeposit and useProposalVote from #1061 also refuse to submit unless the shared status is connected. I will merge once that rebase is conflict-free and CI is green again.

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.

Share a connected-wallet state machine across hooks

2 participants