@sodax/wallet-sdk-react 1.5.6-beta → 2.0.0-rc.1
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 +103 -145
- package/ai-exported/AGENTS.md +122 -0
- package/ai-exported/integration/README.md +102 -0
- package/ai-exported/integration/ai-rules.md +136 -0
- package/ai-exported/integration/architecture.md +181 -0
- package/ai-exported/integration/examples/01-minimal-evm.tsx +75 -0
- package/ai-exported/integration/examples/02-multi-chain-modal.tsx +169 -0
- package/ai-exported/integration/examples/03-nextjs-app-router.tsx +99 -0
- package/ai-exported/integration/examples/04-walletconnect-setup.tsx +89 -0
- package/ai-exported/integration/examples/README.md +29 -0
- package/ai-exported/integration/recipes/batch-operations.md +223 -0
- package/ai-exported/integration/recipes/bridge-to-sdk.md +164 -0
- package/ai-exported/integration/recipes/chain-detection.md +254 -0
- package/ai-exported/integration/recipes/connect-button.md +156 -0
- package/ai-exported/integration/recipes/multi-chain-modal.md +199 -0
- package/ai-exported/integration/recipes/setup.md +158 -0
- package/ai-exported/integration/recipes/sign-message.md +137 -0
- package/ai-exported/integration/recipes/sub-path-imports.md +95 -0
- package/ai-exported/integration/recipes/switch-chain.md +141 -0
- package/ai-exported/integration/recipes/walletconnect-setup.md +139 -0
- package/ai-exported/integration/reference/api-surface.md +175 -0
- package/ai-exported/integration/reference/chain-support.md +78 -0
- package/ai-exported/integration/reference/connectors.md +74 -0
- package/ai-exported/integration/reference/hooks.md +204 -0
- package/ai-exported/integration/reference/wallet-brands.md +106 -0
- package/ai-exported/migration/README.md +49 -0
- package/ai-exported/migration/ai-rules.md +144 -0
- package/ai-exported/migration/breaking-changes.md +305 -0
- package/ai-exported/migration/checklist.md +159 -0
- package/ai-exported/migration/recipes/connect-button.md +166 -0
- package/ai-exported/migration/recipes/multi-chain-modal.md +244 -0
- package/ai-exported/migration/recipes/ssr-setup.md +162 -0
- package/ai-exported/migration/recipes/walletconnect-migration.md +168 -0
- package/ai-exported/migration/reference/components.md +73 -0
- package/ai-exported/migration/reference/config.md +307 -0
- package/ai-exported/migration/reference/hooks.md +278 -0
- package/ai-exported/migration/reference/imports.md +157 -0
- package/dist/XConnector-B9YQTVJ4.d.ts +146 -0
- package/dist/chunk-2BOUGCJ7.mjs +150 -0
- package/dist/chunk-2BOUGCJ7.mjs.map +1 -0
- package/dist/chunk-66BAUK56.mjs +202 -0
- package/dist/chunk-66BAUK56.mjs.map +1 -0
- package/dist/chunk-7ULB6DW4.mjs +102 -0
- package/dist/chunk-7ULB6DW4.mjs.map +1 -0
- package/dist/chunk-BKJB527E.mjs +125 -0
- package/dist/chunk-BKJB527E.mjs.map +1 -0
- package/dist/chunk-BXJLBR4G.mjs +88 -0
- package/dist/chunk-BXJLBR4G.mjs.map +1 -0
- package/dist/chunk-E5IAZ7E6.mjs +186 -0
- package/dist/chunk-E5IAZ7E6.mjs.map +1 -0
- package/dist/chunk-MAQ47Q52.mjs +33 -0
- package/dist/chunk-MAQ47Q52.mjs.map +1 -0
- package/dist/chunk-MXZVF5HR.mjs +34 -0
- package/dist/chunk-MXZVF5HR.mjs.map +1 -0
- package/dist/chunk-N5A2TMF6.mjs +33 -0
- package/dist/chunk-N5A2TMF6.mjs.map +1 -0
- package/dist/chunk-NY7U7OJW.mjs +64 -0
- package/dist/chunk-NY7U7OJW.mjs.map +1 -0
- package/dist/chunk-PJLEJVAU.mjs +140 -0
- package/dist/chunk-PJLEJVAU.mjs.map +1 -0
- package/dist/chunk-PLCA4ZDJ.mjs +1585 -0
- package/dist/chunk-PLCA4ZDJ.mjs.map +1 -0
- package/dist/chunk-TZMKDXFA.mjs +3 -0
- package/dist/chunk-TZMKDXFA.mjs.map +1 -0
- package/dist/chunk-X2MHIWXO.mjs +100 -0
- package/dist/chunk-X2MHIWXO.mjs.map +1 -0
- package/dist/chunk-XZ7CHO2S.mjs +41 -0
- package/dist/chunk-XZ7CHO2S.mjs.map +1 -0
- package/dist/config-OlnzyEUE.d.ts +146 -0
- package/dist/index.cjs +2784 -1594
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +768 -1498
- package/dist/index.mjs +463 -2004
- package/dist/index.mjs.map +1 -1
- package/dist/xchains/bitcoin/index.cjs +1927 -0
- package/dist/xchains/bitcoin/index.cjs.map +1 -0
- package/dist/xchains/bitcoin/index.d.ts +125 -0
- package/dist/xchains/bitcoin/index.mjs +16 -0
- package/dist/xchains/bitcoin/index.mjs.map +1 -0
- package/dist/xchains/evm/index.cjs +316 -0
- package/dist/xchains/evm/index.cjs.map +1 -0
- package/dist/xchains/evm/index.d.ts +39 -0
- package/dist/xchains/evm/index.mjs +5 -0
- package/dist/xchains/evm/index.mjs.map +1 -0
- package/dist/xchains/icon/index.cjs +311 -0
- package/dist/xchains/icon/index.cjs.map +1 -0
- package/dist/xchains/icon/index.d.ts +37 -0
- package/dist/xchains/icon/index.mjs +7 -0
- package/dist/xchains/icon/index.mjs.map +1 -0
- package/dist/xchains/injective/index.cjs +223 -0
- package/dist/xchains/injective/index.cjs.map +1 -0
- package/dist/xchains/injective/index.d.ts +35 -0
- package/dist/xchains/injective/index.mjs +5 -0
- package/dist/xchains/injective/index.mjs.map +1 -0
- package/dist/xchains/near/index.cjs +190 -0
- package/dist/xchains/near/index.cjs.map +1 -0
- package/dist/xchains/near/index.d.ts +34 -0
- package/dist/xchains/near/index.mjs +6 -0
- package/dist/xchains/near/index.mjs.map +1 -0
- package/dist/xchains/solana/index.cjs +186 -0
- package/dist/xchains/solana/index.cjs.map +1 -0
- package/dist/xchains/solana/index.d.ts +26 -0
- package/dist/xchains/solana/index.mjs +7 -0
- package/dist/xchains/solana/index.mjs.map +1 -0
- package/dist/xchains/stacks/index.cjs +240 -0
- package/dist/xchains/stacks/index.cjs.map +1 -0
- package/dist/xchains/stacks/index.d.ts +36 -0
- package/dist/xchains/stacks/index.mjs +5 -0
- package/dist/xchains/stacks/index.mjs.map +1 -0
- package/dist/xchains/stellar/index.cjs +322 -0
- package/dist/xchains/stellar/index.cjs.map +1 -0
- package/dist/xchains/stellar/index.d.ts +44 -0
- package/dist/xchains/stellar/index.mjs +6 -0
- package/dist/xchains/stellar/index.mjs.map +1 -0
- package/dist/xchains/sui/index.cjs +248 -0
- package/dist/xchains/sui/index.cjs.map +1 -0
- package/dist/xchains/sui/index.d.ts +37 -0
- package/dist/xchains/sui/index.mjs +7 -0
- package/dist/xchains/sui/index.mjs.map +1 -0
- package/docs/ADDING_A_NEW_CHAIN.md +440 -0
- package/docs/ARCHITECTURE.md +291 -0
- package/docs/BATCH_OPERATIONS.md +267 -0
- package/docs/CHAIN_DETECTION.md +216 -0
- package/docs/CONFIGURE_PROVIDER.md +360 -0
- package/docs/CONNECTORS.md +247 -0
- package/docs/CONNECT_FLOW.md +276 -0
- package/docs/EVM_SWITCH_CHAIN.md +161 -0
- package/docs/SIGN_MESSAGE.md +213 -0
- package/docs/SUB_PATH_EXPORTS.md +246 -0
- package/docs/WALLETCONNECT.md +154 -0
- package/docs/WALLET_MODAL.md +331 -0
- package/docs/WALLET_PROVIDER_BRIDGE.md +226 -0
- package/package.json +34 -9
- package/skills/SKILLS.md +84 -0
- package/skills/bridge-to-sdk.md +148 -0
- package/skills/connect-button.md +116 -0
- package/skills/evm-only-walletconnect.md +111 -0
- package/skills/multi-chain-modal.md +178 -0
- package/skills/setup.md +107 -0
- package/dist/index.d.cts +0 -1579
- package/src/Hydrate.ts +0 -65
- package/src/SodaxWalletProvider.tsx +0 -97
- package/src/actions/getXChainType.ts +0 -8
- package/src/actions/getXService.ts +0 -33
- package/src/actions/index.ts +0 -2
- package/src/assets/wallets/hana.svg +0 -6
- package/src/assets/wallets/havah.svg +0 -76
- package/src/assets/wallets/keplr.svg +0 -30
- package/src/assets/wallets/metamask.svg +0 -60
- package/src/assets/wallets/phantom.svg +0 -4
- package/src/assets/wallets/sui.svg +0 -20
- package/src/core/XConnector.ts +0 -54
- package/src/core/XService.ts +0 -85
- package/src/core/index.ts +0 -2
- package/src/hooks/index.ts +0 -11
- package/src/hooks/useEthereumChainId.ts +0 -44
- package/src/hooks/useEvmSwitchChain.ts +0 -91
- package/src/hooks/useWalletProvider.ts +0 -206
- package/src/hooks/useXAccount.ts +0 -51
- package/src/hooks/useXAccounts.ts +0 -56
- package/src/hooks/useXBalances.ts +0 -65
- package/src/hooks/useXConnect.ts +0 -118
- package/src/hooks/useXConnection.ts +0 -72
- package/src/hooks/useXConnectors.ts +0 -72
- package/src/hooks/useXDisconnect.ts +0 -73
- package/src/hooks/useXService.ts +0 -8
- package/src/hooks/useXSignMessage.ts +0 -82
- package/src/index.ts +0 -19
- package/src/types/index.ts +0 -22
- package/src/useXWagmiStore.ts +0 -116
- package/src/utils/index.ts +0 -21
- package/src/xchains/bitcoin/BitcoinXConnector.ts +0 -34
- package/src/xchains/bitcoin/BitcoinXService.ts +0 -40
- package/src/xchains/bitcoin/OKXXConnector.ts +0 -117
- package/src/xchains/bitcoin/UnisatXConnector.ts +0 -117
- package/src/xchains/bitcoin/XverseXConnector.ts +0 -232
- package/src/xchains/bitcoin/index.ts +0 -7
- package/src/xchains/bitcoin/useBitcoinXConnectors.ts +0 -14
- package/src/xchains/evm/EvmXConnector.ts +0 -27
- package/src/xchains/evm/EvmXService.ts +0 -211
- package/src/xchains/evm/index.ts +0 -3
- package/src/xchains/icon/IconHanaXConnector.ts +0 -39
- package/src/xchains/icon/IconXService.ts +0 -117
- package/src/xchains/icon/actions.ts +0 -28
- package/src/xchains/icon/iconex/index.tsx +0 -46
- package/src/xchains/icon/index.ts +0 -2
- package/src/xchains/injective/InjectiveXConnector.ts +0 -60
- package/src/xchains/injective/InjectiveXService.ts +0 -62
- package/src/xchains/injective/actions.ts +0 -32
- package/src/xchains/injective/index.ts +0 -2
- package/src/xchains/near/NearXConnector.ts +0 -42
- package/src/xchains/near/NearXService.ts +0 -46
- package/src/xchains/near/useNearXConnectors.ts +0 -23
- package/src/xchains/solana/SolanaXConnector.ts +0 -26
- package/src/xchains/solana/SolanaXService.ts +0 -46
- package/src/xchains/solana/index.ts +0 -2
- package/src/xchains/stacks/StacksXConnector.ts +0 -63
- package/src/xchains/stacks/StacksXService.ts +0 -59
- package/src/xchains/stacks/constants.ts +0 -42
- package/src/xchains/stacks/index.ts +0 -4
- package/src/xchains/stacks/useStacksXConnectors.ts +0 -7
- package/src/xchains/stellar/CustomSorobanServer.ts +0 -93
- package/src/xchains/stellar/StellarWalletsKitXConnector.ts +0 -53
- package/src/xchains/stellar/StellarXService.ts +0 -93
- package/src/xchains/stellar/actions.ts +0 -24
- package/src/xchains/stellar/index.tsx +0 -2
- package/src/xchains/stellar/useStellarXConnectors.ts +0 -21
- package/src/xchains/stellar/utils.ts +0 -49
- package/src/xchains/sui/SuiXConnector.ts +0 -28
- package/src/xchains/sui/SuiXService.ts +0 -66
- package/src/xchains/sui/index.ts +0 -2
|
@@ -0,0 +1,175 @@
|
|
|
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.
|
|
@@ -0,0 +1,78 @@
|
|
|
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".
|
|
@@ -0,0 +1,74 @@
|
|
|
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.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Reference: Hooks
|
|
2
|
+
|
|
3
|
+
Full hook surface of `@sodax/wallet-sdk-react` v2. All hooks accept an options object — never positional args. Pair this with [`connectors.md`](./connectors.md) for connector shape and [`chain-support.md`](./chain-support.md) for chain identifiers.
|
|
4
|
+
|
|
5
|
+
> **All hooks are client-only.** They depend on `<SodaxWalletProvider>` and `<QueryClientProvider>`, which only mount on the client. Next.js App Router consumers must mark every file calling these hooks with `'use client'`. Server Components cannot read connection state directly — pass it down from a client boundary.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Behavior when the chain slot is not in `walletConfig`
|
|
10
|
+
|
|
11
|
+
Hooks do **not** throw when their chain isn't enabled — each picks its own no-op fallback. UI code can call them unconditionally and branch on the return value.
|
|
12
|
+
|
|
13
|
+
| Hook | Behavior when chain absent |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `useXAccount`, `useXAccounts` | Returns shape with `address: undefined` |
|
|
16
|
+
| `useXConnection`, `useXConnections` | Returns `undefined` / empty record |
|
|
17
|
+
| `useXConnectors` | Returns `[]`. **One-time `console.warn`** per chain type to surface config mistakes. |
|
|
18
|
+
| `useXConnectorsByChain` | Returns empty record. No warning. |
|
|
19
|
+
| `useWalletProvider` | Returns `undefined` |
|
|
20
|
+
| `useXService`, `useXServices` | Returns `undefined` / empty record |
|
|
21
|
+
| `useEvmSwitchChain` | Returns `{ isWrongChain: false, handleSwitchChain: () => {} }` (no-op) |
|
|
22
|
+
| `useEnabledChains` | Returns the list of slots actually present (does not include the disabled one) |
|
|
23
|
+
| `useChainGroups`, `useConnectedChains` | Excludes the chain from output |
|
|
24
|
+
| `useXConnect`, `useXDisconnect`, `useXSignMessage` | Mutation rejects when invoked with an unsupported `xChainType` |
|
|
25
|
+
|
|
26
|
+
Rule of thumb: read-hooks degrade silently to "empty"; mutation-hooks reject. Both cases are safe to call unconditionally.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Connect / disconnect
|
|
31
|
+
|
|
32
|
+
| Hook | Signature | Returns |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `useXConnect` | `useXConnect(): UseMutationResult<XAccount \| undefined, Error, IXConnector>` | React Query mutation. **Resolves to `undefined` for provider-managed chains** (EVM/Solana/Sui) — read the connected account via `useXAccount` after the mutation lands. |
|
|
35
|
+
| `useXDisconnect` | `useXDisconnect(): (args: UseXDisconnectArgs) => Promise<void>` where `UseXDisconnectArgs = { xChainType: ChainType }` | Async function — never throws |
|
|
36
|
+
| `useConnectionFlow` | `useConnectionFlow(): { status, error, connect, retry, activeConnector }` | Status object |
|
|
37
|
+
| `useBatchConnect` | `useBatchConnect({ connectors, skipConnected?, onProgress? })` | `{ run, status, result, reset }` |
|
|
38
|
+
| `useBatchDisconnect` | `useBatchDisconnect({ connectors?, onProgress? })` | `{ run, status, result, reset }` |
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const { mutateAsync: connect } = useXConnect();
|
|
42
|
+
await connect(connector);
|
|
43
|
+
|
|
44
|
+
const disconnect = useXDisconnect();
|
|
45
|
+
await disconnect({ xChainType: 'EVM' });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Read account / connection state
|
|
51
|
+
|
|
52
|
+
| Hook | Signature | Returns |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `useXAccount` | `useXAccount({ xChainType }) \| useXAccount({ xChainId })` | `XAccount` (always populated; `address` undefined when disconnected) |
|
|
55
|
+
| `useXAccounts` | `useXAccounts()` | `Partial<Record<ChainType, XAccount>>` (only enabled chains; entries are populated, `address` undefined when disconnected) |
|
|
56
|
+
| `useXConnection` | `useXConnection({ xChainType })` | `XConnection \| undefined` |
|
|
57
|
+
| `useXConnections` | `useXConnections()` | `Partial<Record<ChainType, XConnection>>` |
|
|
58
|
+
| `useConnectedChains` | `useConnectedChains({ order? })` | `{ status: 'loading' \| 'ready', chains: ConnectedChain[], total: number }` |
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { ChainKeys } from '@sodax/types';
|
|
62
|
+
|
|
63
|
+
const { address } = useXAccount({ xChainType: 'EVM' });
|
|
64
|
+
const { address } = useXAccount({ xChainId: ChainKeys.BSC_MAINNET });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Connector discovery
|
|
70
|
+
|
|
71
|
+
| Hook | Signature | Returns |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `useXConnectors` | `useXConnectors({ xChainType })` | `IXConnector[]` (returns `[]` and logs a one-time warning if `xChainType` isn't enabled in `walletConfig`) |
|
|
74
|
+
| `useXConnectorsByChain` | `useXConnectorsByChain()` | `Partial<Record<ChainType, IXConnector[]>>` (no per-chain warnings) |
|
|
75
|
+
| `useIsWalletInstalled` | `useIsWalletInstalled({ connectors?, chainType? })` | `boolean` (at least one of `connectors`/`chainType` required) |
|
|
76
|
+
| `sortConnectors` | `sortConnectors(list, { preferred }): IXConnector[]` | Pure utility — installed first |
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const connectors = useXConnectors({ xChainType: 'EVM' });
|
|
80
|
+
const sorted = sortConnectors(connectors, { preferred: ['hana', 'metamask'] });
|
|
81
|
+
|
|
82
|
+
const isInstalled = useIsWalletInstalled({ connectors: ['hana'] });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Wallet provider bridge (for `@sodax/sdk` calls)
|
|
88
|
+
|
|
89
|
+
| Hook | Signature | Returns |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `useWalletProvider` | `useWalletProvider({ xChainId })` | Chain-narrowed `IXxxWalletProvider \| undefined` |
|
|
92
|
+
| `useWalletProvider` | `useWalletProvider({ xChainType })` | Family-level `IXxxWalletProvider \| undefined` |
|
|
93
|
+
| `useWalletProvider` | `useWalletProvider()` | `IWalletProvider \| undefined` |
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { ChainKeys } from '@sodax/types';
|
|
97
|
+
|
|
98
|
+
const evm = useWalletProvider({ xChainId: ChainKeys.BSC_MAINNET });
|
|
99
|
+
// evm: IEvmWalletProvider | undefined
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
See [`bridge-to-sdk.md`](../recipes/bridge-to-sdk.md) for usage with SDK calls.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Modal / multi-chain UI
|
|
107
|
+
|
|
108
|
+
| Hook | Signature | Returns |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `useWalletModal` | `useWalletModal({ onConnected? })` | `{ state, open, close, back, selectChain, selectWallet, retry }` |
|
|
111
|
+
| `useChainGroups` | `useChainGroups({ order? })` | `ChainGroup[]` (one per enabled chain family) |
|
|
112
|
+
|
|
113
|
+
State machine kinds: `closed`, `chainSelect`, `walletSelect`, `connecting`, `success`, `error`.
|
|
114
|
+
|
|
115
|
+
See [`multi-chain-modal.md`](../recipes/multi-chain-modal.md).
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Sign message
|
|
120
|
+
|
|
121
|
+
| Hook | Signature | Returns |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `useXSignMessage` | `useXSignMessage()` | React Query mutation — `{ xChainType, message }` → `` `0x${string}` \| Uint8Array \| string \| undefined `` |
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
const sign = useXSignMessage();
|
|
127
|
+
const sig = await sign.mutateAsync({ xChainType: 'EVM', message: 'hello' });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
See [`sign-message.md`](../recipes/sign-message.md) for per-chain matrix.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## EVM-specific
|
|
135
|
+
|
|
136
|
+
| Hook | Signature | Returns |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `useEvmSwitchChain` | `useEvmSwitchChain({ xChainId }: { xChainId: SpokeChainKey })` | `{ isWrongChain: boolean, handleSwitchChain: () => void }`. Compares the connected EVM chain to `xChainId` and exposes wrong-network state. Also handles Injective + MetaMask (auto-switches to Ethereum mainnet). Returns no-op values when `EVM` is not in `walletConfig`. |
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { ChainKeys } from '@sodax/types';
|
|
142
|
+
|
|
143
|
+
const { isWrongChain, handleSwitchChain } = useEvmSwitchChain({
|
|
144
|
+
xChainId: ChainKeys.BSC_MAINNET,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (isWrongChain) handleSwitchChain();
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
> **No top-level `useEthereumChainId` in v2.** The raw EVM chain ID is internal — read it via wagmi's `useAccount().chainId` instead. v2 folds the Injective+MetaMask "wrong network" UX into `useEvmSwitchChain` above.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Service-level (advanced)
|
|
155
|
+
|
|
156
|
+
| Hook | Signature | Returns |
|
|
157
|
+
|---|---|---|
|
|
158
|
+
| `useXService` | `useXService({ xChainType })` | `IXService \| undefined` |
|
|
159
|
+
| `useXServices` | `useXServices()` | `Partial<Record<ChainType, IXService>>` |
|
|
160
|
+
| `useEnabledChains` | `useEnabledChains()` | `ChainType[]` |
|
|
161
|
+
| `useInitChainServices` | (internal — handled by `SodaxWalletProvider`) | — |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Hook return-shape glossary
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
type XAccount = {
|
|
169
|
+
address: string | undefined;
|
|
170
|
+
xChainType: ChainType | undefined;
|
|
171
|
+
publicKey?: string;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
type XConnection = {
|
|
175
|
+
xAccount: XAccount;
|
|
176
|
+
xConnectorId: string;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
type IXConnector = {
|
|
180
|
+
readonly xChainType: ChainType;
|
|
181
|
+
readonly name: string;
|
|
182
|
+
readonly id: string;
|
|
183
|
+
readonly icon: string | undefined;
|
|
184
|
+
readonly isInstalled: boolean;
|
|
185
|
+
readonly installUrl: string | undefined;
|
|
186
|
+
connect(): Promise<XAccount | undefined>;
|
|
187
|
+
disconnect(): Promise<void>;
|
|
188
|
+
};
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## "Exactly one of" rule for chain identifiers
|
|
194
|
+
|
|
195
|
+
Hooks that accept both `xChainId` and `xChainType` enforce **exactly one** — passing both, neither, or `undefined` for both throws at runtime (and is a type error):
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
useXAccount({ xChainType: 'EVM' }); // ✅
|
|
199
|
+
useXAccount({ xChainId: ChainKeys.BSC_MAINNET }); // ✅
|
|
200
|
+
useXAccount({ xChainType: 'EVM', xChainId: ChainKeys.BSC_MAINNET }); // ❌ throws
|
|
201
|
+
useXAccount({}); // ❌ throws
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The chain-id form gives narrowest TypeScript inference (e.g. `xChainId: ChainKeys.BSC_MAINNET` → `IEvmWalletProvider`); the chain-type form is family-level.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Reference: Wallet Brand Identifiers
|
|
2
|
+
|
|
3
|
+
`useBatchConnect`, `useBatchDisconnect`, and `useIsWalletInstalled` accept a `connectors: readonly string[]` of **wallet brand identifiers** — short strings that match by **case-insensitive substring** against `connector.id` and `connector.name` (see [`../recipes/batch-operations.md`](../recipes/batch-operations.md)).
|
|
4
|
+
|
|
5
|
+
The identifiers are **open**: any string works. The table below lists every brand the package ships connectors for so you can pick an identifier short enough to match across chain families. To target a specific connector (not a brand), bypass this API and use `useXConnectors({ xChainType }).find(c => c.id === '…')` directly — see [`../recipes/sub-path-imports.md`](../recipes/sub-path-imports.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Known wallet brands
|
|
10
|
+
|
|
11
|
+
| Identifier | Chains it matches | Underlying connector id / name |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `'hana'` | EVM, ICON, Sui, Stellar | EVM via EIP-6963 RDNS (e.g. `io.havah.hana`); ICON id `hana`; Sui/Stellar — connector names containing "Hana" |
|
|
14
|
+
| `'phantom'` | EVM, Solana | EVM RDNS `app.phantom`; Solana adapter name `Phantom` |
|
|
15
|
+
| `'metamask'` | EVM, Injective | EVM RDNS `io.metamask`; Injective `Wallet.Metamask` strategy |
|
|
16
|
+
| `'xverse'` | Bitcoin, Stacks | Bitcoin id `xverse`; Stacks id `XverseProviders.BitcoinProvider` |
|
|
17
|
+
| `'unisat'` | Bitcoin | id `unisat` |
|
|
18
|
+
| `'okx'` | Bitcoin | id `okx-bitcoin` |
|
|
19
|
+
| `'leather'` | Stacks | id `LeatherProvider` |
|
|
20
|
+
| `'asigna'` | Stacks | id `AsignaProvider` |
|
|
21
|
+
| `'fordefi'` | Stacks | id `FordefiProviders.UtxoProvider` |
|
|
22
|
+
| `'solflare'`, `'backpack'`, `'coinbase'`, `'trust'`, `'ledger'`, … | Solana | Adapter names from `@solana/wallet-adapter-wallets` |
|
|
23
|
+
| `'freighter'`, `'albedo'`, `'lobstr'`, `'xbull'`, … | Stellar | Names from `@creit.tech/stellar-wallets-kit` |
|
|
24
|
+
|
|
25
|
+
EVM (via EIP-6963), Solana, Sui, Stellar, and Injective surface connectors **dynamically** — the actual ids depend on what's installed in the user's browser. The table reflects names the upstream libraries ship by default.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Picking a short identifier
|
|
30
|
+
|
|
31
|
+
Substring match is greedy. `'hana'` matches `Hana`, `io.havah.hana`, `hana-anything`. Trade-offs:
|
|
32
|
+
|
|
33
|
+
- **Shorter = broader.** `'hana'` matches everywhere Hana appears across chain families. Good for batch ops targeting a brand across many chains.
|
|
34
|
+
- **Longer = narrower.** `'io.metamask'` only matches the EIP-6963 RDNS — not Injective's MetaMask connector (which uses a different name string). Use when you specifically want one connector and nothing else.
|
|
35
|
+
- **`< 3 chars`** triggers a dev-mode warning — substring matching on 1–2 char identifiers (e.g. `'ok'`) hits unintended connectors. The package will keep working but logs once per identifier.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Runtime discovery — list what's actually installed
|
|
40
|
+
|
|
41
|
+
The table above is a guide, not authoritative. Browser extensions evolve and RDNS strings change. To inspect the real environment:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
'use client';
|
|
45
|
+
|
|
46
|
+
import { useXConnectors } from '@sodax/wallet-sdk-react';
|
|
47
|
+
import type { ChainType } from '@sodax/types';
|
|
48
|
+
|
|
49
|
+
const CHAINS: ChainType[] = ['EVM', 'SOLANA', 'SUI', 'BITCOIN', 'STELLAR', 'ICON', 'INJECTIVE', 'NEAR', 'STACKS'];
|
|
50
|
+
|
|
51
|
+
export function DevConnectorLister() {
|
|
52
|
+
return (
|
|
53
|
+
<table>
|
|
54
|
+
<thead>
|
|
55
|
+
<tr><th>Chain</th><th>id</th><th>name</th><th>installed</th></tr>
|
|
56
|
+
</thead>
|
|
57
|
+
<tbody>
|
|
58
|
+
{CHAINS.flatMap((chainType) => (
|
|
59
|
+
<ChainRow key={chainType} chainType={chainType} />
|
|
60
|
+
))}
|
|
61
|
+
</tbody>
|
|
62
|
+
</table>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function ChainRow({ chainType }: { chainType: ChainType }) {
|
|
67
|
+
const connectors = useXConnectors({ xChainType: chainType });
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
{connectors.map((c) => (
|
|
71
|
+
<tr key={`${chainType}-${c.id}`}>
|
|
72
|
+
<td>{chainType}</td>
|
|
73
|
+
<td><code>{c.id}</code></td>
|
|
74
|
+
<td>{c.name}</td>
|
|
75
|
+
<td>{c.isInstalled ? '✓' : '—'}</td>
|
|
76
|
+
</tr>
|
|
77
|
+
))}
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Drop this component into your app during integration to print the live connector roster. Pick a short identifier from the `id` or `name` columns and feed it into `useBatchConnect({ connectors: [...] })`.
|
|
84
|
+
|
|
85
|
+
For one-off inspection (no UI):
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const all = CHAINS.flatMap((chainType) =>
|
|
90
|
+
useXConnectors({ xChainType: chainType }).map((c) => ({ chainType, id: c.id, name: c.name, isInstalled: c.isInstalled })),
|
|
91
|
+
);
|
|
92
|
+
console.table(all);
|
|
93
|
+
}, []);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## When brand identifiers are the wrong tool
|
|
99
|
+
|
|
100
|
+
Reach for `useXConnectors({ xChainType }).find(c => c.id === '…')` + `useXConnect` directly when:
|
|
101
|
+
|
|
102
|
+
- **The brand list and chain list don't align.** e.g. "Connect Hana on EVM only, even though Hana also covers ICON" — the brand identifier API targets the wallet, not a chain/wallet pair.
|
|
103
|
+
- **You need to disambiguate two wallets with overlapping names.** `'wallet'` would match every wallet-named connector.
|
|
104
|
+
- **You're building a chain picker UI**, not a one-shot batch. Per-chain selection naturally uses `useXConnectors` per chain anyway.
|
|
105
|
+
|
|
106
|
+
See [`../recipes/sub-path-imports.md`](../recipes/sub-path-imports.md) for the worked code path.
|