@sodax/wallet-sdk-react 2.0.0-rc.2 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/dist/{XConnector-B9YQTVJ4.d.ts → XConnector-12q0OVe5.d.ts} +1 -1
- package/dist/{chunk-NY7U7OJW.mjs → chunk-7V7O3Q7Y.mjs} +0 -2
- package/dist/{chunk-BXJLBR4G.mjs → chunk-C6M34IVL.mjs} +2 -4
- package/dist/{chunk-PLCA4ZDJ.mjs → chunk-HEY7NRFG.mjs} +254 -52
- package/dist/{chunk-X2MHIWXO.mjs → chunk-IFXZQW4C.mjs} +0 -2
- package/dist/{chunk-7ULB6DW4.mjs → chunk-JQ4H4GJ5.mjs} +3 -5
- package/dist/{chunk-E5IAZ7E6.mjs → chunk-LM7R5APS.mjs} +22 -11
- package/dist/{chunk-BKJB527E.mjs → chunk-MWWVB7TD.mjs} +2 -4
- package/dist/{chunk-MXZVF5HR.mjs → chunk-NAKCAL2M.mjs} +0 -2
- package/dist/{chunk-PJLEJVAU.mjs → chunk-OPX55MQO.mjs} +11 -6
- package/dist/chunk-QMXBY3UI.mjs +1 -0
- package/dist/{chunk-MAQ47Q52.mjs → chunk-TACW7Z4D.mjs} +0 -2
- package/dist/chunk-VPNYFVP6.mjs +53 -0
- package/dist/{chunk-2BOUGCJ7.mjs → chunk-WPZOLGVB.mjs} +4 -6
- package/dist/{chunk-66BAUK56.mjs → chunk-X7BHR7WS.mjs} +4 -6
- package/dist/{chunk-N5A2TMF6.mjs → chunk-XJA2MJMG.mjs} +2 -4
- package/dist/{config-OlnzyEUE.d.ts → config-DEsqgrG1.d.ts} +10 -5
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +20 -31
- package/dist/xchains/bitcoin/index.d.ts +20 -3
- package/dist/xchains/bitcoin/index.mjs +14 -16
- package/dist/xchains/evm/index.d.ts +3 -3
- package/dist/xchains/evm/index.mjs +3 -5
- package/dist/xchains/icon/index.d.ts +1 -1
- package/dist/xchains/icon/index.mjs +5 -7
- package/dist/xchains/injective/index.d.ts +2 -2
- package/dist/xchains/injective/index.mjs +3 -5
- package/dist/xchains/near/index.d.ts +1 -1
- package/dist/xchains/near/index.mjs +4 -6
- package/dist/xchains/solana/index.d.ts +1 -1
- package/dist/xchains/solana/index.mjs +5 -7
- package/dist/xchains/stacks/index.d.ts +10 -4
- package/dist/xchains/stacks/index.mjs +3 -5
- package/dist/xchains/stellar/index.d.ts +1 -1
- package/dist/xchains/stellar/index.mjs +4 -6
- package/dist/xchains/sui/index.d.ts +1 -1
- package/dist/xchains/sui/index.mjs +5 -7
- package/package.json +37 -29
- package/ai-exported/AGENTS.md +0 -122
- package/ai-exported/integration/README.md +0 -102
- package/ai-exported/integration/ai-rules.md +0 -136
- package/ai-exported/integration/architecture.md +0 -181
- package/ai-exported/integration/examples/01-minimal-evm.tsx +0 -75
- package/ai-exported/integration/examples/02-multi-chain-modal.tsx +0 -169
- package/ai-exported/integration/examples/03-nextjs-app-router.tsx +0 -99
- package/ai-exported/integration/examples/04-walletconnect-setup.tsx +0 -89
- package/ai-exported/integration/examples/README.md +0 -29
- package/ai-exported/integration/recipes/batch-operations.md +0 -223
- package/ai-exported/integration/recipes/bridge-to-sdk.md +0 -164
- package/ai-exported/integration/recipes/chain-detection.md +0 -254
- package/ai-exported/integration/recipes/connect-button.md +0 -156
- package/ai-exported/integration/recipes/multi-chain-modal.md +0 -199
- package/ai-exported/integration/recipes/setup.md +0 -158
- package/ai-exported/integration/recipes/sign-message.md +0 -137
- package/ai-exported/integration/recipes/sub-path-imports.md +0 -95
- package/ai-exported/integration/recipes/switch-chain.md +0 -141
- package/ai-exported/integration/recipes/walletconnect-setup.md +0 -139
- package/ai-exported/integration/reference/api-surface.md +0 -175
- package/ai-exported/integration/reference/chain-support.md +0 -78
- package/ai-exported/integration/reference/connectors.md +0 -74
- package/ai-exported/integration/reference/hooks.md +0 -204
- package/ai-exported/integration/reference/wallet-brands.md +0 -106
- package/ai-exported/migration/README.md +0 -49
- package/ai-exported/migration/ai-rules.md +0 -144
- package/ai-exported/migration/breaking-changes.md +0 -305
- package/ai-exported/migration/checklist.md +0 -159
- package/ai-exported/migration/recipes/connect-button.md +0 -166
- package/ai-exported/migration/recipes/multi-chain-modal.md +0 -244
- package/ai-exported/migration/recipes/ssr-setup.md +0 -162
- package/ai-exported/migration/recipes/walletconnect-migration.md +0 -168
- package/ai-exported/migration/reference/components.md +0 -73
- package/ai-exported/migration/reference/config.md +0 -307
- package/ai-exported/migration/reference/hooks.md +0 -278
- package/ai-exported/migration/reference/imports.md +0 -157
- package/dist/chunk-2BOUGCJ7.mjs.map +0 -1
- package/dist/chunk-66BAUK56.mjs.map +0 -1
- package/dist/chunk-7ULB6DW4.mjs.map +0 -1
- package/dist/chunk-BKJB527E.mjs.map +0 -1
- package/dist/chunk-BXJLBR4G.mjs.map +0 -1
- package/dist/chunk-E5IAZ7E6.mjs.map +0 -1
- package/dist/chunk-MAQ47Q52.mjs.map +0 -1
- package/dist/chunk-MXZVF5HR.mjs.map +0 -1
- package/dist/chunk-N5A2TMF6.mjs.map +0 -1
- package/dist/chunk-NY7U7OJW.mjs.map +0 -1
- package/dist/chunk-PJLEJVAU.mjs.map +0 -1
- package/dist/chunk-PLCA4ZDJ.mjs.map +0 -1
- package/dist/chunk-TZMKDXFA.mjs +0 -3
- package/dist/chunk-TZMKDXFA.mjs.map +0 -1
- package/dist/chunk-X2MHIWXO.mjs.map +0 -1
- package/dist/chunk-XZ7CHO2S.mjs +0 -41
- package/dist/chunk-XZ7CHO2S.mjs.map +0 -1
- package/dist/index.cjs +0 -3337
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/xchains/bitcoin/index.cjs +0 -1927
- package/dist/xchains/bitcoin/index.cjs.map +0 -1
- package/dist/xchains/bitcoin/index.mjs.map +0 -1
- package/dist/xchains/evm/index.cjs +0 -316
- package/dist/xchains/evm/index.cjs.map +0 -1
- package/dist/xchains/evm/index.mjs.map +0 -1
- package/dist/xchains/icon/index.cjs +0 -311
- package/dist/xchains/icon/index.cjs.map +0 -1
- package/dist/xchains/icon/index.mjs.map +0 -1
- package/dist/xchains/injective/index.cjs +0 -223
- package/dist/xchains/injective/index.cjs.map +0 -1
- package/dist/xchains/injective/index.mjs.map +0 -1
- package/dist/xchains/near/index.cjs +0 -190
- package/dist/xchains/near/index.cjs.map +0 -1
- package/dist/xchains/near/index.mjs.map +0 -1
- package/dist/xchains/solana/index.cjs +0 -186
- package/dist/xchains/solana/index.cjs.map +0 -1
- package/dist/xchains/solana/index.mjs.map +0 -1
- package/dist/xchains/stacks/index.cjs +0 -240
- package/dist/xchains/stacks/index.cjs.map +0 -1
- package/dist/xchains/stacks/index.mjs.map +0 -1
- package/dist/xchains/stellar/index.cjs +0 -322
- package/dist/xchains/stellar/index.cjs.map +0 -1
- package/dist/xchains/stellar/index.mjs.map +0 -1
- package/dist/xchains/sui/index.cjs +0 -248
- package/dist/xchains/sui/index.cjs.map +0 -1
- package/dist/xchains/sui/index.mjs.map +0 -1
- package/docs/ADDING_A_NEW_CHAIN.md +0 -440
- package/docs/ARCHITECTURE.md +0 -291
- package/docs/BATCH_OPERATIONS.md +0 -267
- package/docs/CHAIN_DETECTION.md +0 -216
- package/docs/CONFIGURE_PROVIDER.md +0 -360
- package/docs/CONNECTORS.md +0 -247
- package/docs/CONNECT_FLOW.md +0 -276
- package/docs/EVM_SWITCH_CHAIN.md +0 -161
- package/docs/SIGN_MESSAGE.md +0 -213
- package/docs/SUB_PATH_EXPORTS.md +0 -246
- package/docs/WALLETCONNECT.md +0 -154
- package/docs/WALLET_MODAL.md +0 -331
- package/docs/WALLET_PROVIDER_BRIDGE.md +0 -226
- package/skills/SKILLS.md +0 -84
- package/skills/bridge-to-sdk.md +0 -148
- package/skills/connect-button.md +0 -116
- package/skills/evm-only-walletconnect.md +0 -111
- package/skills/multi-chain-modal.md +0 -178
- package/skills/setup.md +0 -107
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# Recipe: Switch EVM Chain
|
|
2
|
-
|
|
3
|
-
A single wagmi connection covers **every configured EVM network** (Sonic, Ethereum, Arbitrum, Base, BSC, Optimism, Polygon, Avalanche, etc.). The user picks a wallet once; switching the **active network** is a separate concern handled by `useEvmSwitchChain`.
|
|
4
|
-
|
|
5
|
-
**Depends on:** [`setup.md`](./setup.md), [`connect-button.md`](./connect-button.md) or [`multi-chain-modal.md`](./multi-chain-modal.md)
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Why this exists
|
|
10
|
-
|
|
11
|
-
When you call `sodax.swaps.swap({ params: { srcChainKey: ChainKeys.BSC_MAINNET, ... }, walletProvider })`, the wallet provider must be **on BSC at signing time** — wagmi will reject the tx otherwise. But wagmi remembers the last network the user selected, so a user who connected via MetaMask on Ethereum and then opened your dApp's BSC swap form needs to switch first.
|
|
12
|
-
|
|
13
|
-
`useEvmSwitchChain` reads the connected EVM wallet's current chain id, compares against the chain id implied by `srcChainKey`, and exposes:
|
|
14
|
-
|
|
15
|
-
- `isWrongChain: boolean` — render a "Switch to BSC" CTA when `true`
|
|
16
|
-
- `handleSwitchChain()` — triggers wagmi's `switchChain()` (or `wallet_switchEthereumChain` for Injective MetaMask)
|
|
17
|
-
|
|
18
|
-
Without this hook you'd have to import wagmi directly and replicate the logic per-chain.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Hook API
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { useEvmSwitchChain } from '@sodax/wallet-sdk-react';
|
|
26
|
-
import { ChainKeys } from '@sodax/types';
|
|
27
|
-
|
|
28
|
-
const { isWrongChain, handleSwitchChain } = useEvmSwitchChain({
|
|
29
|
-
xChainId: ChainKeys.BSC_MAINNET,
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
| Field | Type | Behavior |
|
|
34
|
-
|-------|------|----------|
|
|
35
|
-
| `isWrongChain` | `boolean` | `true` when the wallet's active chain id doesn't match `xChainId`. Always `false` for non-EVM/Injective chain ids. |
|
|
36
|
-
| `handleSwitchChain` | `() => void` | Triggers the network switch. No-op for chain ids that aren't EVM or Injective. |
|
|
37
|
-
|
|
38
|
-
The hook never throws — `handleSwitchChain` returns synchronously and lets wagmi (or `wallet_switchEthereumChain`) own the user-rejection error path.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Standard EVM switch flow
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
'use client';
|
|
46
|
-
|
|
47
|
-
import { useEvmSwitchChain, useWalletProvider, useXAccount } from '@sodax/wallet-sdk-react';
|
|
48
|
-
import { ChainKeys } from '@sodax/types';
|
|
49
|
-
|
|
50
|
-
export function BscSwapButton() {
|
|
51
|
-
const account = useXAccount({ xChainType: 'EVM' });
|
|
52
|
-
const walletProvider = useWalletProvider({ xChainId: ChainKeys.BSC_MAINNET });
|
|
53
|
-
const { isWrongChain, handleSwitchChain } = useEvmSwitchChain({
|
|
54
|
-
xChainId: ChainKeys.BSC_MAINNET,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (!account.address || !walletProvider) {
|
|
58
|
-
return <ConnectCta />;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (isWrongChain) {
|
|
62
|
-
return <button onClick={handleSwitchChain}>Switch to BSC</button>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return <button onClick={() => doSwap(walletProvider)}>Swap on BSC</button>;
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
`useSwitchChain` opens the wallet's network-switch popup; wagmi handles the chain-config-not-added flow (most wallets prompt to add the chain if it's missing).
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Pattern: gate every cross-chain action
|
|
74
|
-
|
|
75
|
-
For dApps where the source chain depends on user input (e.g. a swap form with a "from chain" picker), wire `useEvmSwitchChain` against the **selected** chain id:
|
|
76
|
-
|
|
77
|
-
```tsx
|
|
78
|
-
function SwapForm() {
|
|
79
|
-
const [srcChainKey, setSrcChainKey] = useState<SpokeChainKey>(ChainKeys.SONIC_MAINNET);
|
|
80
|
-
const { isWrongChain, handleSwitchChain } = useEvmSwitchChain({ xChainId: srcChainKey });
|
|
81
|
-
const walletProvider = useWalletProvider({ xChainId: srcChainKey });
|
|
82
|
-
|
|
83
|
-
const buttonState =
|
|
84
|
-
!walletProvider ? 'connect' :
|
|
85
|
-
isWrongChain ? 'switch' :
|
|
86
|
-
'swap';
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<>
|
|
90
|
-
<ChainSelect value={srcChainKey} onChange={setSrcChainKey} />
|
|
91
|
-
{buttonState === 'connect' && <ConnectCta />}
|
|
92
|
-
{buttonState === 'switch' && <button onClick={handleSwitchChain}>Switch chain</button>}
|
|
93
|
-
{buttonState === 'swap' && <button onClick={() => doSwap(walletProvider)}>Swap</button>}
|
|
94
|
-
</>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Re-renders on `srcChainKey` change automatically — no manual reset needed.
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Injective MetaMask special case
|
|
104
|
-
|
|
105
|
-
Injective offers MetaMask as a wallet option (in addition to Keplr, Leap). When MetaMask is the active Injective wallet, **the underlying Ethereum chain id must be mainnet (`1`)** — Injective uses MetaMask's `personal_sign` infrastructure which is bound to whatever EVM network the wallet is currently on.
|
|
106
|
-
|
|
107
|
-
```tsx
|
|
108
|
-
const { isWrongChain, handleSwitchChain } = useEvmSwitchChain({
|
|
109
|
-
xChainId: ChainKeys.INJECTIVE_MAINNET,
|
|
110
|
-
});
|
|
111
|
-
// isWrongChain === true if user is on Injective via MetaMask AND active EVM chain is not mainnet (1)
|
|
112
|
-
// handleSwitchChain calls wallet_switchEthereumChain to chain id 0x1
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Keplr and Leap on Injective don't have this constraint — `isWrongChain` is `false` for those wallets regardless of network state.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Safe to call when EVM is disabled
|
|
120
|
-
|
|
121
|
-
`useEvmSwitchChain` checks `useEnabledChains()` and returns a no-op result `{ isWrongChain: false, handleSwitchChain: () => {} }` when the EVM slot isn't mounted in `SodaxWalletProvider` config. Calling wagmi's hooks outside a `WagmiProvider` would throw — the early-return lets components opt-in to a "switch chain" CTA without checking EVM-enabled themselves at every call site.
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Verification
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# 1. Type check
|
|
129
|
-
pnpm checkTs
|
|
130
|
-
|
|
131
|
-
# 2. Manual — connect MetaMask on Ethereum, open BSC swap form, confirm Switch button appears
|
|
132
|
-
# 3. Manual — click Switch, approve in MetaMask, confirm Swap button replaces it
|
|
133
|
-
# 4. Manual — switch to Polygon manually (in MetaMask), confirm Switch button reappears for BSC form
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Reference
|
|
139
|
-
|
|
140
|
-
- [wagmi `useSwitchChain`](https://wagmi.sh/react/api/hooks/useSwitchChain) — underlying hook
|
|
141
|
-
- [EIP-3326 — `wallet_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-3326) — RPC method spec
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
# Recipe: WalletConnect Setup (EVM only)
|
|
2
|
-
|
|
3
|
-
Enable WalletConnect protocol on the EVM slot for partners using enterprise custody (Fireblocks, Ledger Live, mobile-only wallets). Default EVM discovery (EIP-6963) only finds browser-extension wallets — WalletConnect lets users pair via QR / deep-link.
|
|
4
|
-
|
|
5
|
-
**Depends on:** [`setup.md`](./setup.md)
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## When to use
|
|
10
|
-
|
|
11
|
-
| Scenario | Need WalletConnect? |
|
|
12
|
-
|----------|---------------------|
|
|
13
|
-
| MetaMask / Hana / Rabby browser extension | ❌ — EIP-6963 covers them |
|
|
14
|
-
| Enterprise custody wallets (e.g. Fireblocks, Safe) | ✅ |
|
|
15
|
-
| Ledger Live | ✅ |
|
|
16
|
-
| MetaMask Mobile / Trust / Rainbow (paired via QR) | ✅ |
|
|
17
|
-
| Coinbase Smart Wallet | ✅ (fallback path) |
|
|
18
|
-
|
|
19
|
-
If your dApp only targets desktop browser-extension wallets, omit `walletConnect` entirely.
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 1. Get a WalletConnect Cloud project id
|
|
24
|
-
|
|
25
|
-
Sign up at [https://cloud.walletconnect.com](https://cloud.walletconnect.com) and copy your project id. Add it to `.env`:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
NEXT_PUBLIC_WC_PROJECT_ID=your-project-id
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## 2. Add `walletConnect` to the `EVM` slot
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { type SodaxWalletConfig } from '@sodax/wallet-sdk-react';
|
|
37
|
-
import { ChainKeys } from '@sodax/types';
|
|
38
|
-
|
|
39
|
-
const walletConfig: SodaxWalletConfig = {
|
|
40
|
-
EVM: {
|
|
41
|
-
ssr: true,
|
|
42
|
-
chains: {
|
|
43
|
-
[ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
|
|
44
|
-
[ChainKeys.ARBITRUM_MAINNET]: { rpcUrl: 'https://arb1.arbitrum.io/rpc' },
|
|
45
|
-
},
|
|
46
|
-
walletConnect: {
|
|
47
|
-
projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID!,
|
|
48
|
-
// showQrModal: true is the default — wagmi/WalletConnect own the QR display
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
A WalletConnect connector now surfaces alongside EIP-6963 wallets. `useXConnectors({ xChainType: 'EVM' })` returns it with `id === 'walletConnect'`. **No UI changes required** — your existing connect-button or modal already handles it.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## 3. Restrict the QR modal to a specific wallet (optional)
|
|
59
|
-
|
|
60
|
-
To show **only** one wallet in the WalletConnect modal (e.g. when integrating with a single enterprise custody provider), filter the WalletConnect Explorer list:
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
const walletConfig: SodaxWalletConfig = {
|
|
64
|
-
EVM: {
|
|
65
|
-
walletConnect: {
|
|
66
|
-
projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID!,
|
|
67
|
-
qrModalOptions: {
|
|
68
|
-
explorerRecommendedWalletIds: [
|
|
69
|
-
'<target-wallet-id>', // hex from WalletConnect Explorer
|
|
70
|
-
],
|
|
71
|
-
explorerExcludedWalletIds: 'ALL', // hide everything except recommended
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Find wallet IDs at the [WalletConnect Explorer](https://walletconnect.com/explorer) — they're the long hex strings in the URL, not the human names. Default (no `qrModalOptions`) shows the full WalletConnect wallet list.
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## 4. Hide the Sodax modal during WalletConnect QR
|
|
83
|
-
|
|
84
|
-
When the user picks the WalletConnect connector, wagmi opens its own QR modal — two dialogs would stack. Detect WC by connector id and render `null`:
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
import { useWalletModal } from '@sodax/wallet-sdk-react';
|
|
88
|
-
|
|
89
|
-
const modal = useWalletModal();
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
modal.state.kind === 'connecting' &&
|
|
93
|
-
modal.state.connector.id === 'walletConnect'
|
|
94
|
-
) {
|
|
95
|
-
return null; // wagmi's QR modal owns the screen
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
The `useWalletModal` state machine handles the `connecting → success | error` transition normally — only the rendering is conditionally blanked.
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Missing `projectId` — silent skip
|
|
104
|
-
|
|
105
|
-
Setting `walletConnect: {}` without a `projectId` (or with an empty string) **silently skips** the WalletConnect connector and logs a warning:
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
[wallet-sdk-react] walletConnect.projectId is required — WalletConnect connector skipped.
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
EIP-6963 wallets continue to work normally — the dApp degrades gracefully. This intentionally avoids forcing local-dev environments to plumb the env var.
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## EVM-only
|
|
116
|
-
|
|
117
|
-
The `walletConnect` field only exists on the `EVM` slot. Solana, Bitcoin, etc. use their own native wallet adapters and don't share the WalletConnect protocol layer. Don't attempt `SOLANA: { walletConnect: ... }` — TypeScript will reject it.
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## Verification
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
# 1. Type check
|
|
125
|
-
pnpm checkTs
|
|
126
|
-
|
|
127
|
-
# 2. Confirm walletConnect projectId is set
|
|
128
|
-
grep -rn "walletConnect" <user-src> | grep -i "projectId"
|
|
129
|
-
# expect at least one match
|
|
130
|
-
|
|
131
|
-
# 3. Manual — open connect modal, confirm WalletConnect option appears alongside extension wallets
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## Reference
|
|
137
|
-
|
|
138
|
-
- [wagmi `WalletConnectParameters`](https://wagmi.sh/core/api/connectors/walletConnect) — full options reference
|
|
139
|
-
- [WalletConnect Cloud](https://cloud.walletconnect.com) — get a `projectId`
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Reference: API Surface
|
|
2
|
-
|
|
3
|
-
The complete public export surface of `@sodax/wallet-sdk-react` v2. This is the **single source of truth** for "what can I import". If a symbol is not listed here, it is not part of the public API.
|
|
4
|
-
|
|
5
|
-
The check script `scripts/check-ai-exported.sh` validates that every symbol referenced in `ai-exported/**/*.md` appears either in this file or in `reference/connectors.md` / `reference/hooks.md`.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Barrel exports — `import { X } from '@sodax/wallet-sdk-react'`
|
|
10
|
-
|
|
11
|
-
### Components
|
|
12
|
-
|
|
13
|
-
| Symbol | Kind | Source |
|
|
14
|
-
|---|---|---|
|
|
15
|
-
| `SodaxWalletProvider` | React component | `SodaxWalletProvider.tsx` |
|
|
16
|
-
| `SodaxWalletProviderProps` | type | `SodaxWalletProvider.tsx` |
|
|
17
|
-
| `WalletConfigProvider` | React component (advanced — internal context) | `context/WalletConfigContext` |
|
|
18
|
-
|
|
19
|
-
### Hooks
|
|
20
|
-
|
|
21
|
-
See [`hooks.md`](./hooks.md) for full signatures. Names only:
|
|
22
|
-
|
|
23
|
-
- `useXAccount`, `useXAccounts`
|
|
24
|
-
- `useXConnect`, `useXDisconnect`
|
|
25
|
-
- `useXConnection`, `useXConnections`
|
|
26
|
-
- `useXConnectors`, `useXConnectorsByChain`
|
|
27
|
-
- `useIsWalletInstalled`
|
|
28
|
-
- `useChainGroups`, `useConnectedChains`
|
|
29
|
-
- `useConnectionFlow`
|
|
30
|
-
- `useBatchConnect`, `useBatchDisconnect`
|
|
31
|
-
- `useWalletModal`
|
|
32
|
-
- `useWalletProvider`
|
|
33
|
-
- `useXService`, `useXServices`
|
|
34
|
-
- `useEnabledChains`
|
|
35
|
-
- `useEvmSwitchChain`
|
|
36
|
-
- `useXSignMessage`
|
|
37
|
-
|
|
38
|
-
### Abstract classes (advanced — extend only when implementing a new chain)
|
|
39
|
-
|
|
40
|
-
| Symbol | Kind | Source |
|
|
41
|
-
|---|---|---|
|
|
42
|
-
| `XService` | abstract class | `core/XService` |
|
|
43
|
-
| `XConnector` | abstract class | `core/XConnector` |
|
|
44
|
-
|
|
45
|
-
### Imperative actions
|
|
46
|
-
|
|
47
|
-
| Symbol | Kind | Source |
|
|
48
|
-
|---|---|---|
|
|
49
|
-
| `getXChainType` | function | `actions/getXChainType` |
|
|
50
|
-
| `getXService` | function | `actions/getXService` |
|
|
51
|
-
|
|
52
|
-
### Utilities
|
|
53
|
-
|
|
54
|
-
| Symbol | Notes |
|
|
55
|
-
|---|---|
|
|
56
|
-
| `sortConnectors` | Stable-sort connectors by `preferred[]` then install state. See [`connectors.md`](./connectors.md). |
|
|
57
|
-
| `getEntryDefaults`, `getRpcUrl`, `resolveEvmDefaults` | Read defaults / RPC URL out of `SodaxWalletConfig` (advanced — for custom Hydrator-like code). |
|
|
58
|
-
| `isNativeToken`, `getWagmiChainId` | Small helpers — native-token check and `ChainKey` → wagmi numeric chain id. |
|
|
59
|
-
|
|
60
|
-
### Public interfaces
|
|
61
|
-
|
|
62
|
-
| Symbol | Kind | Source |
|
|
63
|
-
|---|---|---|
|
|
64
|
-
| `IXService` | interface | `types/interfaces` |
|
|
65
|
-
| `IXConnector` | interface | `types/interfaces` |
|
|
66
|
-
| `IWalletProvider` | re-export from `@sodax/types` | `types/index` |
|
|
67
|
-
|
|
68
|
-
### Account / connection types
|
|
69
|
-
|
|
70
|
-
| Symbol | Kind |
|
|
71
|
-
|---|---|
|
|
72
|
-
| `XAccount` | type |
|
|
73
|
-
| `XConnection` | type |
|
|
74
|
-
|
|
75
|
-
### Config types
|
|
76
|
-
|
|
77
|
-
Top-level:
|
|
78
|
-
|
|
79
|
-
| Symbol | Kind |
|
|
80
|
-
|---|---|
|
|
81
|
-
| `SodaxWalletConfig` | type |
|
|
82
|
-
| `ChainTypeConfig<T>` | generic type |
|
|
83
|
-
| `ChainEntry<K>` | generic type |
|
|
84
|
-
| `ChainMeta` | type |
|
|
85
|
-
| `ChainTypeOf<K>` | generic type |
|
|
86
|
-
| `WalletDefaultsByKey<K>` | generic type |
|
|
87
|
-
|
|
88
|
-
Per-chain aliases follow two naming patterns — one alias per chain family (9 each):
|
|
89
|
-
|
|
90
|
-
- `<Chain>TypeConfig` — per-slot config (e.g. `EvmTypeConfig`, `SolanaTypeConfig`)
|
|
91
|
-
- `<Chain>ChainEntry` — per-chain-key entry (e.g. `EvmChainEntry`, `BitcoinChainEntry`)
|
|
92
|
-
|
|
93
|
-
Replace `<Chain>` with `Evm | Solana | Sui | Bitcoin | Stellar | Injective | Icon | Near | Stacks`. Most consumers can derive these from `ChainTypeConfig<T>` / `ChainEntry<K>` instead of importing the per-chain alias directly.
|
|
94
|
-
|
|
95
|
-
Adapter-field types (only chains with React adapters):
|
|
96
|
-
|
|
97
|
-
| Symbol | Kind |
|
|
98
|
-
|---|---|
|
|
99
|
-
| `EvmAdapterFields` | type |
|
|
100
|
-
| `SolanaAdapterFields` | type |
|
|
101
|
-
| `SuiAdapterFields` | type |
|
|
102
|
-
|
|
103
|
-
### Hook option / result types
|
|
104
|
-
|
|
105
|
-
Every hook also exports its options / result types alongside it. Naming pattern is `Use<Name>Options`, `Use<Name>Result` (or `Use<Name>Return`), and any inline value types in `PascalCase` (e.g. `ChainGroup`, `ConnectedChain`, `WalletModalState`, `ConnectionStatus`). See [`hooks.md`](./hooks.md) for the signature each pair belongs to.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## Sub-path exports — `import { X } from '@sodax/wallet-sdk-react/xchains/<chain>'`
|
|
110
|
-
|
|
111
|
-
Concrete chain classes live behind sub-paths. Default to barrel imports; opt into these only when you need `instanceof`, want to extend a class, or are wiring a custom connector list via `ChainTypeConfig.connectors`.
|
|
112
|
-
|
|
113
|
-
### Default pattern (most chains)
|
|
114
|
-
|
|
115
|
-
`/xchains/{evm, icon, injective, near, solana, sui}` re-export the chain's `XService` + `XConnector` classes — `EvmXService`/`EvmXConnector`, `SolanaXService`/`SolanaXConnector`, etc. Icon also exports `IconHanaXConnector` (the connector for the Hana wallet).
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
import { EvmXService, EvmXConnector } from '@sodax/wallet-sdk-react/xchains/evm';
|
|
119
|
-
import { IconHanaXConnector } from '@sodax/wallet-sdk-react/xchains/icon';
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Chains with extra exports
|
|
123
|
-
|
|
124
|
-
| Sub-path | Beyond `XService`/`XConnector` |
|
|
125
|
-
|---|---|
|
|
126
|
-
| `/xchains/bitcoin` | `XverseXConnector`, `UnisatXConnector`, `OKXXConnector` (3 wallet connectors), hook `useBitcoinXConnectors`, type `BtcWalletAddressType` |
|
|
127
|
-
| `/xchains/evm` | `createWagmiConfig` (function — also exported as alias `createWagmi`) |
|
|
128
|
-
| `/xchains/icon` | `CHAIN_INFO` (value), `SupportedChainId` (enum) |
|
|
129
|
-
| `/xchains/stacks` | `STACKS_PROVIDERS` (value), hook `useStacksXConnectors`, type `StacksProviderConfig` |
|
|
130
|
-
|
|
131
|
-
### Special case
|
|
132
|
-
|
|
133
|
-
| Sub-path | Notes |
|
|
134
|
-
|---|---|
|
|
135
|
-
| `/xchains/stellar` | **No concrete classes re-exported.** Stellar uses `@creit.tech/stellar-wallets-kit` directly via an `XConnector` registered through the chain registry — no public class to `instanceof`-check. |
|
|
136
|
-
|
|
137
|
-
If unsure what a sub-path exports, check the published `dist/`:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
grep -E '^export' node_modules/@sodax/wallet-sdk-react/dist/xchains/<chain>/index.d.ts
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
## Peer dependencies (consumer must install)
|
|
146
|
-
|
|
147
|
-
| Package | Version |
|
|
148
|
-
|---|---|
|
|
149
|
-
| `react` | `>= 19` |
|
|
150
|
-
| `@tanstack/react-query` | `5.x` |
|
|
151
|
-
|
|
152
|
-
`@tanstack/react-query` is required at runtime — `<QueryClientProvider>` must wrap `<SodaxWalletProvider>`. v1 mounted one internally; v2 does not.
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## Not exported (deliberately internal)
|
|
157
|
-
|
|
158
|
-
These exist in the source but are **not** part of the public API. Do not import from `@sodax/wallet-sdk-react/dist/...` to reach them.
|
|
159
|
-
|
|
160
|
-
- `useEthereumChainId` — read EVM chain id via wagmi's `useAccount().chainId` instead.
|
|
161
|
-
- `useInitChainServices` — used by `<SodaxWalletProvider>` only.
|
|
162
|
-
- `useXWalletStore` — Zustand store hook. Public hooks are the supported surface; if you need store access, file an issue describing the use case.
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## What the v2 barrel does NOT re-export (vs v1)
|
|
167
|
-
|
|
168
|
-
For migration context only — these were on v1's barrel:
|
|
169
|
-
|
|
170
|
-
- All concrete `XService` / `XConnector` classes (now sub-path imports)
|
|
171
|
-
- `useXBalances` (moved to `@sodax/dapp-kit` with a new signature — see `migration/breaking-changes.md` § 10)
|
|
172
|
-
- `XWagmiProviders` (renamed to `SodaxWalletProvider`)
|
|
173
|
-
- `useXWagmiStore` (the store hook — v2 doesn't export the store hook under any name; use public hooks like `useXServices` / `useXConnections` instead)
|
|
174
|
-
|
|
175
|
-
See [`../../migration/reference/imports.md`](../../migration/reference/imports.md) for the full v1→v2 import map.
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Reference: Chain Support
|
|
2
|
-
|
|
3
|
-
Chains supported by `@sodax/wallet-sdk-react` v2 — their `ChainType` family and per-slot config shape. Use this when picking which slots to include in `walletConfig`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Chain families (`ChainType`)
|
|
8
|
-
|
|
9
|
-
9 chain families. Each is a top-level slot on `SodaxWalletConfig`:
|
|
10
|
-
|
|
11
|
-
| ChainType | Networks (examples) | React adapter mounted |
|
|
12
|
-
|---|---|---|
|
|
13
|
-
| `EVM` | Sonic, Ethereum, Arbitrum, Base, BSC, Optimism, Polygon, Avalanche, HyperEVM, Lightlink, Redbelly, Kaia | wagmi |
|
|
14
|
-
| `SOLANA` | Solana mainnet | `@solana/wallet-adapter-react` |
|
|
15
|
-
| `SUI` | Sui mainnet/testnet | `@mysten/dapp-kit` |
|
|
16
|
-
| `BITCOIN` | Bitcoin mainnet | (none — direct extension probes) |
|
|
17
|
-
| `STELLAR` | Stellar mainnet | (none) |
|
|
18
|
-
| `ICON` | ICON mainnet | (none) |
|
|
19
|
-
| `INJECTIVE` | Injective mainnet | (none) |
|
|
20
|
-
| `NEAR` | NEAR mainnet | (none) |
|
|
21
|
-
| `STACKS` | Stacks mainnet | (none) |
|
|
22
|
-
|
|
23
|
-
EVM is the only family with multiple networks under one connection — wagmi maintains a single connection that spans every configured EVM network. See [`../architecture.md`](../architecture.md) § "EVM is one connection".
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Per-slot config shape
|
|
28
|
-
|
|
29
|
-
| Slot | Config fields | Notes |
|
|
30
|
-
|---|---|---|
|
|
31
|
-
| `EVM` | `ssr?, walletConnect?, connectors?, chains` | `chains` keyed by `ChainKey` → `{ rpcUrl?, defaults? }` |
|
|
32
|
-
| `SOLANA` | `autoConnect?, connectors?, chains` | `chains` keyed by `ChainKey` → `{ rpcUrl?, defaults? }` |
|
|
33
|
-
| `SUI` | `network?, connectors?, chains?` | `network: 'mainnet' \| 'testnet'` |
|
|
34
|
-
| `BITCOIN` | extends `BitcoinRpcConfig` + `{ defaults?, connectors? }` | Pass `{}` for SDK defaults |
|
|
35
|
-
| `STELLAR` | extends `StellarRpcConfig` + `{ defaults?, connectors? }` | Pass `{}` for SDK defaults |
|
|
36
|
-
| `INJECTIVE` | extends `InjectiveRpcConfig` + `{ defaults?, connectors? }` | Pass `{}` for SDK defaults |
|
|
37
|
-
| `ICON` | `connectors?, chains` | `chains` keyed by `ChainKey` → `{ rpcUrl?, defaults? }` |
|
|
38
|
-
| `NEAR` | `connectors?, chains` | `chains` keyed by `ChainKey` → `{ rpcUrl?, defaults? }` |
|
|
39
|
-
| `STACKS` | preset name (string) **or** `StacksNetworkLike & { defaults?, connectors? }` | `'mainnet'` / `'testnet'` preset accepted |
|
|
40
|
-
|
|
41
|
-
The single source of truth for the per-chain shape is `ChainMeta` in `src/types/config.ts` — `SodaxWalletConfig`, `ChainEntry<K>`, `WalletDefaultsByKey<K>` derive from it.
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## ChainKey constants
|
|
46
|
-
|
|
47
|
-
`ChainKey` is the chain-id enum exported from `@sodax/types`. Use it in `walletConfig.<SLOT>.chains[<ChainKey>]` and in hooks that take `xChainId`.
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import { ChainKeys } from '@sodax/types';
|
|
51
|
-
|
|
52
|
-
ChainKeys.SONIC_MAINNET; // EVM
|
|
53
|
-
ChainKeys.ETHEREUM_MAINNET; // EVM
|
|
54
|
-
ChainKeys.SOLANA_MAINNET; // SOLANA
|
|
55
|
-
ChainKeys.BITCOIN_MAINNET; // BITCOIN
|
|
56
|
-
// …etc
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Naming pattern: `<NETWORK>_MAINNET`. EVM has 12 entries (Sonic, Ethereum, Arbitrum, Base, BSC, Optimism, Polygon, Avalanche, HyperEVM, Lightlink, Redbelly, Kaia); the other 8 families each have one. Inspect `@sodax/types` for the authoritative list.
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Slot opt-in behavior
|
|
64
|
-
|
|
65
|
-
- **Omit a slot** to skip mounting that adapter entirely. The chain won't appear in `useXConnectors`, `useChainGroups`, or `useEnabledChains`.
|
|
66
|
-
- **Pass `{}`** to mount with SDK defaults. Useful for chains where you don't need to override RPC or connectors.
|
|
67
|
-
- **Provide a partial config** (`{ chains: {...} }`) to override only what you need; everything else uses defaults.
|
|
68
|
-
|
|
69
|
-
```ts
|
|
70
|
-
const walletConfig: SodaxWalletConfig = {
|
|
71
|
-
EVM: { ssr: true, chains: { [ChainKeys.SONIC_MAINNET]: { rpcUrl: '...' } } }, // explicit
|
|
72
|
-
BITCOIN: {}, // defaults
|
|
73
|
-
SOLANA: { autoConnect: false, chains: { [ChainKeys.SOLANA_MAINNET]: {} } }, // partial
|
|
74
|
-
// STELLAR not included → not mounted
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
For per-hook fallback behavior when a slot is omitted, see [`hooks.md`](./hooks.md) § "Behavior when the chain slot is not in walletConfig".
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Reference: Connectors
|
|
2
|
-
|
|
3
|
-
A connector is the adapter between a specific wallet (Hana, MetaMask, Phantom, Xverse…) and the SODAX store. Every connector implements `IXConnector`, the public contract every hook in `wallet-sdk-react` consumes.
|
|
4
|
-
|
|
5
|
-
Concrete connector classes live behind sub-path imports — see [`api-surface.md`](./api-surface.md) § "Sub-path exports" for the per-chain map.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## `IXConnector` interface
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
export interface IXConnector {
|
|
13
|
-
readonly xChainType: ChainType;
|
|
14
|
-
readonly name: string; // 'Hana', 'MetaMask', 'Xverse', …
|
|
15
|
-
readonly id: string; // unique connector id (e.g. 'io.metamask')
|
|
16
|
-
readonly icon: string | undefined;
|
|
17
|
-
readonly isInstalled: boolean; // wallet extension presence (read at getter call time)
|
|
18
|
-
readonly installUrl: string | undefined;
|
|
19
|
-
connect(): Promise<XAccount | undefined>;
|
|
20
|
-
disconnect(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Consumer code should depend on **`IXConnector`** (the interface), not the concrete `XConnector` class — keeps your code chain-implementation-agnostic and allows custom connectors to slot in without inheriting from the abstract base.
|
|
25
|
-
|
|
26
|
-
`isInstalled` reads `window.*` at getter-call time — no extra subscription is installed. Components get fresh values through normal React render triggers.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Listing connectors at runtime
|
|
31
|
-
|
|
32
|
-
Don't import concrete classes to discover what's available — use the hook:
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
const connectors = useXConnectors({ xChainType: 'EVM' });
|
|
36
|
-
// IXConnector[] — already filtered to enabled chain
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
For the per-chain class names (only needed for `instanceof` or custom-connector-list use cases), see [`api-surface.md`](./api-surface.md) § "Sub-path exports" and the worked example in [`../recipes/sub-path-imports.md`](../recipes/sub-path-imports.md). Bitcoin's `BitcoinXConnector` is the only abstract base — its concrete subclasses (Unisat, Xverse, OKX) override per-wallet signing methods (see [`sign-message.md`](../recipes/sign-message.md)).
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## `sortConnectors` — display ordering
|
|
44
|
-
|
|
45
|
-
Pure utility for ranking connectors in lists. Stable sort by:
|
|
46
|
-
|
|
47
|
-
1. Position in `preferred[]` (earlier wins)
|
|
48
|
-
2. `isInstalled === true`
|
|
49
|
-
3. Original index
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { useXConnectors, sortConnectors } from '@sodax/wallet-sdk-react';
|
|
53
|
-
|
|
54
|
-
const PREFERRED = ['hana', 'metamask'];
|
|
55
|
-
|
|
56
|
-
function ConnectorList() {
|
|
57
|
-
const raw = useXConnectors({ xChainType: 'EVM' });
|
|
58
|
-
const sorted = sortConnectors(raw, { preferred: PREFERRED });
|
|
59
|
-
// Hana first if present, then MetaMask, then any other installed wallets, then uninstalled.
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
`preferred` matches by exact `connector.id`. For substring/case-insensitive matching across chains, use `useIsWalletInstalled` instead — see [`batch-operations.md`](../recipes/batch-operations.md).
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Custom connectors
|
|
68
|
-
|
|
69
|
-
Two ways to plug in a wallet the SDK doesn't ship:
|
|
70
|
-
|
|
71
|
-
1. **Extend `XConnector`** (abstract base, exported from the barrel) — implement `connect()` / `disconnect()` / `isInstalled` / `installUrl`. Pass via `SodaxWalletConfig.<CHAIN>.connectors` to replace the registry defaults for that chain.
|
|
72
|
-
2. **Implement `IXConnector` directly** — skip the abstract base. The SDK never does `instanceof XConnector` on user-supplied connectors; it only relies on the interface.
|
|
73
|
-
|
|
74
|
-
For a worked example with code, see [`../recipes/sub-path-imports.md`](../recipes/sub-path-imports.md) § "Custom connector list". For chains with extra signing methods (Bitcoin's `signBip322Message`, Injective specifics), implement the chain-specific extras — the SDK detects them via type guards at dispatch time.
|