@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,168 @@
|
|
|
1
|
+
# Recipe: Adopt WalletConnect (v2 only)
|
|
2
|
+
|
|
3
|
+
WalletConnect support is **new in v2** — there is no v1 equivalent to migrate from. This recipe is here for users who tried to bolt WalletConnect onto v1 by hand-rolling a wagmi config and now want to use the v2 first-class option.
|
|
4
|
+
|
|
5
|
+
If you didn't have WalletConnect in v1, **this recipe is opt-in, not required**. Skip if not relevant.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When to use this recipe
|
|
10
|
+
|
|
11
|
+
Apply when the user's v1 code:
|
|
12
|
+
|
|
13
|
+
- Built a custom wagmi config that injected `walletConnect()` connector
|
|
14
|
+
- Mounted a separate `WagmiProvider` outside `SodaxWalletProvider`
|
|
15
|
+
- Patched the v1 internal `createWagmiConfig` helper to include WalletConnect
|
|
16
|
+
|
|
17
|
+
Or when the user simply wants to **add WalletConnect for the first time** while migrating to v2.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Why apps add WalletConnect
|
|
22
|
+
|
|
23
|
+
EIP-6963 (the default v2 EVM discovery mechanism) only finds **browser-extension wallets**. Partners using enterprise custody — Fireblocks, Ledger Live, mobile-only wallets — cannot install browser extensions. WalletConnect is the protocol that lets these wallets connect via QR / deep link.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Before (v1, hand-rolled — typical workaround)
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
// v1 ❌ — bypassed the package's wagmi config
|
|
31
|
+
import { createConfig, WagmiProvider } from 'wagmi';
|
|
32
|
+
import { walletConnect } from 'wagmi/connectors';
|
|
33
|
+
import { mainnet, sonic } from 'wagmi/chains';
|
|
34
|
+
|
|
35
|
+
const wagmiConfig = createConfig({
|
|
36
|
+
chains: [mainnet, sonic],
|
|
37
|
+
connectors: [
|
|
38
|
+
walletConnect({ projectId: 'wc-cloud-project-id' }),
|
|
39
|
+
// ...
|
|
40
|
+
],
|
|
41
|
+
// ...
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export function Providers({ children }) {
|
|
45
|
+
return (
|
|
46
|
+
<WagmiProvider config={wagmiConfig}>
|
|
47
|
+
{/* SodaxWalletProvider mounted alongside, with conflicting wagmi state */}
|
|
48
|
+
<SodaxWalletProvider rpcConfig={...} options={...}>
|
|
49
|
+
{children}
|
|
50
|
+
</SodaxWalletProvider>
|
|
51
|
+
</WagmiProvider>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
(This pattern caused two parallel wagmi states and was never officially supported.)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## After (v2 — first-class)
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// v2 ✅
|
|
64
|
+
import { ChainKeys } from '@sodax/types';
|
|
65
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
66
|
+
import { SodaxWalletProvider, type SodaxWalletConfig } from '@sodax/wallet-sdk-react';
|
|
67
|
+
|
|
68
|
+
const walletConfig: SodaxWalletConfig = {
|
|
69
|
+
EVM: {
|
|
70
|
+
ssr: true,
|
|
71
|
+
walletConnect: {
|
|
72
|
+
projectId: 'wc-cloud-project-id', // from cloud.walletconnect.com
|
|
73
|
+
},
|
|
74
|
+
chains: {
|
|
75
|
+
[ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
|
|
76
|
+
[ChainKeys.ETHEREUM_MAINNET]: { rpcUrl: 'https://ethereum-rpc.publicnode.com' },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const queryClient = new QueryClient();
|
|
82
|
+
|
|
83
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
84
|
+
return (
|
|
85
|
+
<QueryClientProvider client={queryClient}>
|
|
86
|
+
<SodaxWalletProvider config={walletConfig}>{children}</SodaxWalletProvider>
|
|
87
|
+
</QueryClientProvider>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The WalletConnect connector is added to wagmi automatically. `useXConnectors({ xChainType: 'EVM' })` will surface it alongside any EIP-6963 wallets.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## What changed
|
|
97
|
+
|
|
98
|
+
| Concern | v1 (hand-rolled) | v2 (first-class) |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| WagmiProvider mount | manual, outside SodaxWalletProvider | internal to SodaxWalletProvider |
|
|
101
|
+
| wagmi config | hand-built via `createConfig` | derived from `walletConfig` |
|
|
102
|
+
| WalletConnect projectId | passed to `walletConnect()` connector | passed to `EVM.walletConnect.projectId` |
|
|
103
|
+
| Two parallel wagmi states | yes — common bug | no — single source of truth |
|
|
104
|
+
| Connector list in modal | mixed (some via custom connectors, some via SodaxWalletProvider) | unified via `useXConnectors({ xChainType: 'EVM' })` |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Restricting the modal to specific wallets
|
|
109
|
+
|
|
110
|
+
`EVM.walletConnect` extends wagmi's `WalletConnectParameters` — full options available. To show only one specific wallet (e.g. when integrating with a single enterprise custody provider) and hide the rest:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
EVM: {
|
|
114
|
+
walletConnect: {
|
|
115
|
+
projectId: 'wc-cloud-project-id',
|
|
116
|
+
qrModalOptions: {
|
|
117
|
+
explorerRecommendedWalletIds: ['<target-wallet-id>'],
|
|
118
|
+
explorerExcludedWalletIds: 'ALL',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Wallet IDs come from the [WalletConnect Explorer](https://cloud.walletconnect.com/sign-in). Filter options:
|
|
125
|
+
|
|
126
|
+
| Option | Effect |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `explorerRecommendedWalletIds` | Prioritized at the top of the QR modal. |
|
|
129
|
+
| `explorerExcludedWalletIds: 'ALL'` | Hides every wallet not in `explorerRecommendedWalletIds`. |
|
|
130
|
+
| `explorerExcludedWalletIds: ['id1', 'id2']` | Hides specific wallets only. |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Migration steps
|
|
135
|
+
|
|
136
|
+
1. **Remove the hand-rolled `WagmiProvider` and `createConfig`.** v2 builds wagmi config internally.
|
|
137
|
+
2. **Move `projectId`** into `walletConfig.EVM.walletConnect.projectId`.
|
|
138
|
+
3. **Move any `qrModalOptions`** (e.g. wallet filters) into `walletConfig.EVM.walletConnect.qrModalOptions`.
|
|
139
|
+
4. **Verify** that `useXConnectors({ xChainType: 'EVM' })` returns both EIP-6963 connectors and the WalletConnect entry.
|
|
140
|
+
5. **Drop** any custom hooks / state that bridged between the two wagmi configs in v1.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Verification
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# 1. Type check
|
|
148
|
+
pnpm checkTs
|
|
149
|
+
|
|
150
|
+
# 2. Confirm no manual WagmiProvider remains
|
|
151
|
+
grep -rn "WagmiProvider" <user-src>
|
|
152
|
+
# expect empty (or only inside the wallet-sdk-react package itself if the user has a deep import — flag and remove)
|
|
153
|
+
|
|
154
|
+
# 3. Confirm walletConnect config is in walletConfig
|
|
155
|
+
grep -rn "walletConnect" <user-src> | grep -i "projectId"
|
|
156
|
+
# expect at least one match in the provider file
|
|
157
|
+
|
|
158
|
+
# 4. Manual — load app, open connect modal, confirm WalletConnect option appears
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Common pitfalls
|
|
164
|
+
|
|
165
|
+
- **Missing projectId.** Without `projectId`, the WalletConnect connector won't initialize. Get one free at [cloud.walletconnect.com](https://cloud.walletconnect.com).
|
|
166
|
+
- **Bundling EIP-6963 + WalletConnect.** The two are additive — `useXConnectors` returns both. UI should let users pick.
|
|
167
|
+
- **`qrModalOptions.explorerExcludedWalletIds` typo.** It's `'ALL'` (string), not `true` or `'all'`.
|
|
168
|
+
- **Multiple SodaxWalletProvider mounts.** Don't mount one with WalletConnect and another without — define `walletConfig` once at the app root.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Reference: Component / Provider Map
|
|
2
|
+
|
|
3
|
+
Components and exported providers between v1 and v2. See [`../breaking-changes.md`](../breaking-changes.md) for the WHY.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## `SodaxWalletProvider`
|
|
8
|
+
|
|
9
|
+
Same name in v1 and v2. **Props changed** — see [`config.md`](./config.md) for the full shape map.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// v1 ❌
|
|
13
|
+
<SodaxWalletProvider
|
|
14
|
+
rpcConfig={rpcConfig}
|
|
15
|
+
options={{ wagmi, solana, sui }}
|
|
16
|
+
initialState={wagmiState}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</SodaxWalletProvider>
|
|
20
|
+
|
|
21
|
+
// v2 ✅
|
|
22
|
+
<SodaxWalletProvider config={walletConfig}>
|
|
23
|
+
{children}
|
|
24
|
+
</SodaxWalletProvider>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Provider-stack order
|
|
28
|
+
|
|
29
|
+
| Position | v1 | v2 |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| Outermost (app entry) | `SodaxWalletProvider` (creates internal QueryClient) | `QueryClientProvider` (caller-provided QueryClient) |
|
|
32
|
+
| Middle | (none) | `SodaxWalletProvider` |
|
|
33
|
+
| Children | app | app |
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
// v1 ❌ — SodaxWalletProvider internal QueryClient
|
|
37
|
+
<SodaxWalletProvider rpcConfig={...} options={...}>
|
|
38
|
+
{children}
|
|
39
|
+
</SodaxWalletProvider>
|
|
40
|
+
|
|
41
|
+
// v2 ✅ — caller wraps with QueryClientProvider
|
|
42
|
+
<QueryClientProvider client={queryClient}>
|
|
43
|
+
<SodaxWalletProvider config={walletConfig}>
|
|
44
|
+
{children}
|
|
45
|
+
</SodaxWalletProvider>
|
|
46
|
+
</QueryClientProvider>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Internal-only components (do not import directly)
|
|
52
|
+
|
|
53
|
+
These are mounted **inside** `SodaxWalletProvider` and are not part of the public API in either v1 or v2. Listed for awareness — if you imported them in v1 you should not have, and v2 may not expose them.
|
|
54
|
+
|
|
55
|
+
| Component | v1 | v2 | Note |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `Hydrate` | exported (file `Hydrate.ts`) | replaced by per-chain `EvmHydrator`, `SolanaHydrator`, `SuiHydrator` (internal) | If you imported `Hydrate` from v1, **remove the import** — v2 does not export an equivalent. State hydration is automatic. |
|
|
58
|
+
| `WagmiProvider`, `SuiClientProvider`, `SolanaWalletProvider` (re-exports) | not re-exported | not re-exported | Use the original packages (`wagmi`, `@mysten/dapp-kit`, `@solana/wallet-adapter-react`) only if you need direct access — most apps should not. |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## `XService` and `XConnector` abstract classes
|
|
63
|
+
|
|
64
|
+
| | v1 | v2 |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| Import path | `@sodax/wallet-sdk-react` (barrel) | `@sodax/wallet-sdk-react` (barrel — types only) |
|
|
67
|
+
| Runtime class export | yes | yes |
|
|
68
|
+
| Abstract method signature | `abstract connect(): Promise<XAccount \| undefined>` | unchanged |
|
|
69
|
+
| Properties | `id`, `name`, `icon`, `xChainType` | unchanged |
|
|
70
|
+
|
|
71
|
+
The abstract contract is **stable across v1 → v2**. If you have a custom subclass, it should compile against v2 with no changes — but verify, and check `getBalance` / `getBalances` defaults if you override them.
|
|
72
|
+
|
|
73
|
+
> **Stop condition:** if the user has a custom `XConnector` or `XService` subclass, the migration agent must stop and ask. The abstract surface is stable but downstream usage (e.g. how the subclass is instantiated, registered) has changed.
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Reference: `SodaxWalletProvider` Config Map
|
|
2
|
+
|
|
3
|
+
The biggest single change in v2. v1 spread chain configuration across three props (`rpcConfig`, `options`, `initialState`); v2 collapses them into one `config` prop. See [`../breaking-changes.md`](../breaking-changes.md) §1 for the WHY.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Top-level shape
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
// v1 ❌
|
|
11
|
+
<SodaxWalletProvider
|
|
12
|
+
rpcConfig={rpcConfig}
|
|
13
|
+
options={{ wagmi, solana, sui }}
|
|
14
|
+
initialState={wagmiState}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</SodaxWalletProvider>
|
|
18
|
+
|
|
19
|
+
// v2 ✅
|
|
20
|
+
<SodaxWalletProvider config={walletConfig}>{children}</SodaxWalletProvider>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The v2 `config` is `SodaxWalletConfig`. Top-level keys are **chain-type slots** (`EVM`, `SOLANA`, `SUI`, `BITCOIN`, `STELLAR`, `ICON`, `INJECTIVE`, `NEAR`, `STACKS`). **Omit a slot to skip mounting that adapter**; pass `{}` to mount with SDK defaults.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## v1 `rpcConfig` → v2 per-chain `rpcUrl`
|
|
28
|
+
|
|
29
|
+
v1 took a flat dictionary keyed by some chain string:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// v1 ❌
|
|
33
|
+
const rpcConfig: RpcConfig = {
|
|
34
|
+
'sonic': 'https://rpc.soniclabs.com',
|
|
35
|
+
'0x1.eth': 'https://ethereum-rpc.publicnode.com',
|
|
36
|
+
'solana': 'https://api.mainnet-beta.solana.com',
|
|
37
|
+
// ...
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
v2 nests RPC URLs under `<ChainTypeSlot>.chains[ChainKey].rpcUrl`:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// v2 ✅
|
|
45
|
+
import { ChainKeys } from '@sodax/types';
|
|
46
|
+
import type { SodaxWalletConfig } from '@sodax/wallet-sdk-react';
|
|
47
|
+
|
|
48
|
+
const walletConfig: SodaxWalletConfig = {
|
|
49
|
+
EVM: {
|
|
50
|
+
chains: {
|
|
51
|
+
[ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
|
|
52
|
+
[ChainKeys.ETHEREUM_MAINNET]: { rpcUrl: 'https://ethereum-rpc.publicnode.com' },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
SOLANA: {
|
|
56
|
+
chains: {
|
|
57
|
+
[ChainKeys.SOLANA_MAINNET]: { rpcUrl: 'https://api.mainnet-beta.solana.com' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Per-chain entry shape varies** by chain type:
|
|
64
|
+
|
|
65
|
+
| Slot | Per-chain entry |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `EVM`, `SOLANA`, `SUI`, `ICON`, `NEAR` | `{ rpcUrl?, defaults? }` |
|
|
68
|
+
| `BITCOIN`, `STELLAR`, `INJECTIVE` | extends their `*RpcConfig` type with `{ defaults? }` |
|
|
69
|
+
| `STACKS` | preset name (string) **or** `StacksNetworkLike & { defaults? }` |
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## v1 `options.wagmi` → v2 `EVM.*`
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// v1 ❌
|
|
79
|
+
options: {
|
|
80
|
+
wagmi: {
|
|
81
|
+
reconnectOnMount: false,
|
|
82
|
+
ssr: true,
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// v2 ✅
|
|
89
|
+
EVM: {
|
|
90
|
+
ssr: true,
|
|
91
|
+
reconnectOnMount: true,
|
|
92
|
+
chains: { ... },
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| v1 | v2 | Notes |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `options.wagmi.ssr` | `EVM.ssr` | Defaults: v1 `true`, v2 not set (caller decides). For Next.js, set `true`. |
|
|
99
|
+
| `options.wagmi.reconnectOnMount` | `EVM.reconnectOnMount` | Still supported, default `false`. Moved into the `EVM` slot. See [`migration/recipes/ssr-setup.md`](../recipes/ssr-setup.md) for the SSR-aware flow. |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## v1 `options.solana` → v2 `SOLANA.*`
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
// v1 ❌
|
|
107
|
+
options: {
|
|
108
|
+
solana: { autoConnect: true },
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
// v2 ✅
|
|
114
|
+
SOLANA: {
|
|
115
|
+
autoConnect: true,
|
|
116
|
+
chains: {
|
|
117
|
+
[ChainKeys.SOLANA_MAINNET]: { rpcUrl: '...' },
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| v1 | v2 |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `options.solana.autoConnect` | `SOLANA.autoConnect` |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## v1 `options.sui` → v2 `SUI.*`
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// v1 ❌
|
|
132
|
+
options: {
|
|
133
|
+
sui: { autoConnect: true },
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
// v2 ✅
|
|
139
|
+
SUI: {
|
|
140
|
+
autoConnect: true,
|
|
141
|
+
network: 'mainnet',
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`SUI` slot fields (per `SuiAdapterFields` in `src/types/config.ts`):
|
|
146
|
+
|
|
147
|
+
| Field | Type | Default |
|
|
148
|
+
|---|---|---|
|
|
149
|
+
| `autoConnect` | `boolean?` | `true` |
|
|
150
|
+
| `network` | `'mainnet' \| 'testnet' \| 'devnet'?` | `'mainnet'` |
|
|
151
|
+
|
|
152
|
+
| v1 | v2 |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `options.sui.autoConnect` | `SUI.autoConnect` |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## v1 `initialState` → v2 `EVM.initialState`
|
|
159
|
+
|
|
160
|
+
v1 accepted a top-level `initialState` prop (`WagmiState`) for SSR hydration. v2 still accepts the same value — it just lives **inside the `EVM` slot** of the `config` prop.
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
// v1 ❌
|
|
164
|
+
<SodaxWalletProvider rpcConfig={...} options={...} initialState={wagmiState}>
|
|
165
|
+
|
|
166
|
+
// v2 ✅
|
|
167
|
+
<SodaxWalletProvider config={{
|
|
168
|
+
EVM: {
|
|
169
|
+
ssr: true,
|
|
170
|
+
initialState: wagmiState,
|
|
171
|
+
chains: {...},
|
|
172
|
+
},
|
|
173
|
+
/* ... */
|
|
174
|
+
}}>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
If you previously derived `initialState` via `cookieToInitialState(...)` in a server component, keep that logic — just pass the result into `EVM.initialState` instead of the top-level prop. See [`../recipes/ssr-setup.md`](../recipes/ssr-setup.md) for a full Next.js example.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## New in v2: per-chain `defaults`
|
|
182
|
+
|
|
183
|
+
Each chain entry can hold call-level defaults that flow to the bridged `IXxxWalletProvider`:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
// v2 ✅
|
|
187
|
+
EVM: {
|
|
188
|
+
chains: {
|
|
189
|
+
[ChainKeys.ARBITRUM_MAINNET]: {
|
|
190
|
+
rpcUrl: 'https://arb1.arbitrum.io/rpc',
|
|
191
|
+
defaults: {
|
|
192
|
+
waitForTransactionReceipt: { confirmations: 1 },
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The `defaults` shape is per-chain — the type system narrows what's valid per chain key. Inspect `WalletDefaultsByKey<K>` in `src/types/config.ts`.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## New in v2: `EVM.walletConnect`
|
|
204
|
+
|
|
205
|
+
WalletConnect support for EVM — extends wagmi's `WalletConnectParameters`:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
// v2 ✅
|
|
209
|
+
EVM: {
|
|
210
|
+
walletConnect: {
|
|
211
|
+
projectId: 'wc-cloud-project-id', // required from cloud.walletconnect.com
|
|
212
|
+
// qrModalOptions, isNewChainsStale, etc. — full WalletConnectParameters
|
|
213
|
+
},
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
When `walletConnect` is present, a WalletConnect connector is added to the wagmi config; `useXConnectors({ xChainType: 'EVM' })` will surface it. Omitting the field preserves v1 behavior (EIP-6963 only).
|
|
218
|
+
|
|
219
|
+
See [`../recipes/walletconnect-migration.md`](../recipes/walletconnect-migration.md).
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## New in v2: `<chainSlot>.connectors?` override
|
|
224
|
+
|
|
225
|
+
Each chain slot accepts an optional `connectors` field to override the default connector list. Most consumers don't need this — defaults work for all common wallet vendors.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Frozen on first render
|
|
230
|
+
|
|
231
|
+
`SodaxWalletProvider` captures `config` once on mount and ignores prop-reference changes. To swap config at runtime, remount with a new `key`:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
// v2 ✅
|
|
235
|
+
<SodaxWalletProvider key={configVersion} config={walletConfig}>
|
|
236
|
+
{children}
|
|
237
|
+
</SodaxWalletProvider>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Bumping `configVersion` (e.g. when the user picks a new RPC endpoint) forces a clean re-init. See [`../breaking-changes.md`](../breaking-changes.md) §12.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Provider-stack order changed
|
|
245
|
+
|
|
246
|
+
v1 created `QueryClient` internally; v2 expects the consumer to provide one:
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
// v1 ❌ — QueryClientProvider was internal
|
|
250
|
+
<SodaxWalletProvider rpcConfig={...} options={...}>{children}</SodaxWalletProvider>
|
|
251
|
+
|
|
252
|
+
// v2 ✅ — caller wraps with QueryClientProvider
|
|
253
|
+
<QueryClientProvider client={queryClient}>
|
|
254
|
+
<SodaxWalletProvider config={walletConfig}>{children}</SodaxWalletProvider>
|
|
255
|
+
</QueryClientProvider>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Add `@tanstack/react-query 5.x` as a direct dependency if your app didn't already have it. See [`../breaking-changes.md`](../breaking-changes.md) §2.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Minimal valid v2 config — every shape, side by side
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
// v2 ✅
|
|
266
|
+
import { ChainKeys } from '@sodax/types';
|
|
267
|
+
import type { SodaxWalletConfig } from '@sodax/wallet-sdk-react';
|
|
268
|
+
|
|
269
|
+
const walletConfig: SodaxWalletConfig = {
|
|
270
|
+
// EVM — needs chains
|
|
271
|
+
EVM: {
|
|
272
|
+
ssr: true,
|
|
273
|
+
chains: {
|
|
274
|
+
[ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
|
|
275
|
+
},
|
|
276
|
+
// optional:
|
|
277
|
+
// walletConnect: { projectId: '...' },
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
// SOLANA — chain entry + autoConnect
|
|
281
|
+
SOLANA: {
|
|
282
|
+
autoConnect: false,
|
|
283
|
+
chains: {
|
|
284
|
+
[ChainKeys.SOLANA_MAINNET]: { rpcUrl: 'https://api.mainnet-beta.solana.com' },
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
// SUI — network preset
|
|
289
|
+
SUI: { network: 'mainnet' },
|
|
290
|
+
|
|
291
|
+
// ICON — chain entry
|
|
292
|
+
ICON: {
|
|
293
|
+
chains: {
|
|
294
|
+
[ChainKeys.ICON_MAINNET]: { rpcUrl: 'https://ctz.solidwallet.io/api/v3' },
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
// BITCOIN, STELLAR, INJECTIVE, NEAR, STACKS — pass {} to mount with SDK defaults
|
|
299
|
+
BITCOIN: {},
|
|
300
|
+
STELLAR: {},
|
|
301
|
+
INJECTIVE: {},
|
|
302
|
+
NEAR: {},
|
|
303
|
+
STACKS: {},
|
|
304
|
+
};
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Omit any slot to skip that chain entirely.
|