-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(bitcoin): add Signet support and network-aware OKX/Unisat connectors #5347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(bitcoin): add Signet support and network-aware OKX/Unisat connectors #5347
Conversation
…96-babylon-bug-signet-network-not-working-correctly-in-bitcoin
🦋 Changeset detectedLatest commit: 07e3d7a The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
10 Skipped Deployments
|
Visual Regression Test Results ❌ FailedChromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=494 👉 Please review the visual changes in Chromatic and accept or reject them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Signet support to Bitcoin flows and makes connectors network-aware. It fixes issues where Signet network was not working correctly with OKX, by standardizing how caipNetworkId is passed through the connection flow.
Key changes:
- Extended type interfaces to accept optional
caipNetworkIdfor network-scoped operations - Refactored OKX connector to resolve wallet handles per network at call time rather than storing a single instance
- Updated adapters to pass
caipNetworkIdthrough connect and account retrieval flows
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/controllers/src/utils/TypeUtil.ts | Extended Provider.connect interface to accept optional caipNetworkId |
| packages/controllers/src/controllers/AdapterController/ChainAdapterBlueprint.ts | Added caipNetworkId to GetAccountsParams for network-scoped account retrieval |
| packages/appkit-utils/src/bitcoin/BitcoinTypesUtil.ts | Extended getAccountAddresses to accept optional caipNetworkId parameter |
| packages/adapters/bitcoin/src/connectors/UnisatConnector/index.ts | Added chainChanged event emission after network switch |
| packages/adapters/bitcoin/src/connectors/OKXConnector.ts | Major refactor: added Signet support, made connector network-aware with dynamic wallet resolution |
| packages/adapters/bitcoin/src/adapter.ts | Updated to pass caipNetworkId through connect/getAccounts calls and improved onChainChanged flow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Bundle Size Check✅ All bundles are within size limits 📊 View detailed bundle sizes> @reown/[email protected] size /home/runner/work/appkit/appkit > size-limit |
…ot-working-correctly-in-bitcoin
…ot-working-correctly-in-bitcoin
Description
Context
Addresses APKT-4196: Signet network was not working correctly in Bitcoin flows, particularly with OKX. This PR standardizes network awareness across connectors and adapters, adds Signet support, and fixes event emission and account fetching across networks.
What’s Changed
controllers
AdapterController/ChainAdapterBlueprint.tsGetAccountsParamswith optionalcaipNetworkIdto allow network-scoped account retrieval.utils/TypeUtil.tsProvider.connectto accept optional{ caipNetworkId, onUri }for network-aware connections.appkit-utils
bitcoin/BitcoinTypesUtil.tsBitcoinConnector.getAccountAddressesaccepts optional{ caipNetworkId }to fetch accounts for a specific network.adapters/bitcoin
adapter.tscaipNetworkIdwhen callingconnector.connectandgetAccountsto ensure correct network context.onChainChanged: resolve the chain, reconnect to obtainaddress, fetch accounts for that specificcaipNetworkId, update connection, then emitswitchNetworkwith the resolvedchain.id.connectors/UnisatConnectorswitchChain, find the chain and emitchainChangedwithchain.idfor consistent event semantics.connectors/OKXConnectorbitcoinSignet.caipNetworkIdtowindow.okxwallet.bitcoinSignet._connect(caipNetworkId)andconnect({ caipNetworkId? }).getWallet({ requestedCaipNetworkId })at call time.getAccountAddresses({ caipNetworkId? }): for Signet, returnselectedAccount; otherwise usegetAccounts+getPublicKey.sendTransferandsignPSBTnow resolve the wallet for the active/requested network before acting.switchNetwork: unbind current listeners and emitchainChangedwith the resolvedchain.id(OKX lacks a true switch RPC), relying on reconnect flow for actual wallet context.bitcoinSignetimport and mapping; extendwindow.okxwallettyping for Signet.getWalletto an instance method returning the wallet handle (not a new connector).Why
caipNetworkIdacross connect/account flows so adapters and connectors operate on the intended network.chainChangedandswitchNetworkare emitted with the correctchain.idand timing after state updates.Behavior Notes
caipNetworkIdinconnectandgetAccountAddresses. If ignored, they continue to work as before; implementing the hint enables correct multi-network behavior.selectedAccount.BitcoinAdapter.switchNetworknow awaits provider switching and relies on subsequent events to complete the flow; functional behavior unchanged for consumers.Breaking/Surface Changes
Provider.connect(params?: { caipNetworkId?: CaipNetworkId; onUri?: fn })BitcoinConnector.getAccountAddresses(params?: { caipNetworkId?: CaipNetworkId })caipNetworkIdto be multi-network correct.Type of change
Associated Issues
Closes APKT-4196
Checklist
Note
Adds Signet support and makes Bitcoin adapter + OKX/Unisat connectors network-aware via caipNetworkId, with updated types and corrected event/account handling.
caipNetworkIdtoconnector.connectandgetAccountsinsrc/adapter.ts.onChainChanged: resolve chain, reconnect, fetch network-scoped accounts, update connection, emitswitchNetworkwith resolvedchain.id.syncConnectors: instantiateOKXConnector; add when client-side.bitcoinSignet) and window typings.getWallet().connect/getAccountAddresses/sendTransfer/signPSBTnow network-aware; on Signet useselectedAccount.switchNetworkunbinds listeners and emitschainChangedwith resolvedchain.id.switchChain, emitchainChangedwith resolvedchain.id.Provider.connectaccepts{ caipNetworkId, onUri }.AdapterBlueprint.GetAccountsParamsadds optionalcaipNetworkId.BitcoinConnector.getAccountAddressesaccepts optional{ caipNetworkId }.connect: reuse existing connection only whenparams.addressprovided.Written by Cursor Bugbot for commit 07e3d7a. This will update automatically on new commits. Configure here.