@sodax/wallet-sdk-react 2.0.0-rc.3 → 2.0.0-rc.5

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.
Files changed (129) hide show
  1. package/README.md +12 -5
  2. package/dist/{XConnector-B9YQTVJ4.d.ts → XConnector-12q0OVe5.d.ts} +1 -1
  3. package/dist/{chunk-NY7U7OJW.mjs → chunk-7V7O3Q7Y.mjs} +0 -2
  4. package/dist/{chunk-BXJLBR4G.mjs → chunk-C6M34IVL.mjs} +2 -4
  5. package/dist/{chunk-XZ7CHO2S.mjs → chunk-FSOGMSJH.mjs} +2 -4
  6. package/dist/{chunk-X2MHIWXO.mjs → chunk-IFXZQW4C.mjs} +0 -2
  7. package/dist/{chunk-7ULB6DW4.mjs → chunk-JQ4H4GJ5.mjs} +3 -5
  8. package/dist/{chunk-N5A2TMF6.mjs → chunk-LKSSME2J.mjs} +2 -4
  9. package/dist/{chunk-BKJB527E.mjs → chunk-MWWVB7TD.mjs} +2 -4
  10. package/dist/{chunk-MXZVF5HR.mjs → chunk-NAKCAL2M.mjs} +0 -2
  11. package/dist/{chunk-PJLEJVAU.mjs → chunk-OPYSVPRW.mjs} +10 -6
  12. package/dist/chunk-QMXBY3UI.mjs +1 -0
  13. package/dist/{chunk-MAQ47Q52.mjs → chunk-TACW7Z4D.mjs} +0 -2
  14. package/dist/{chunk-PLCA4ZDJ.mjs → chunk-VCESC6QT.mjs} +54 -30
  15. package/dist/{chunk-2BOUGCJ7.mjs → chunk-WPZOLGVB.mjs} +4 -6
  16. package/dist/{chunk-66BAUK56.mjs → chunk-X7BHR7WS.mjs} +4 -6
  17. package/dist/{chunk-E5IAZ7E6.mjs → chunk-Z5GXDHGL.mjs} +11 -7
  18. package/dist/{config-OlnzyEUE.d.ts → config-DEsqgrG1.d.ts} +10 -5
  19. package/dist/index.d.ts +6 -6
  20. package/dist/index.mjs +20 -31
  21. package/dist/xchains/bitcoin/index.d.ts +1 -1
  22. package/dist/xchains/bitcoin/index.mjs +14 -16
  23. package/dist/xchains/evm/index.d.ts +3 -3
  24. package/dist/xchains/evm/index.mjs +3 -5
  25. package/dist/xchains/icon/index.d.ts +1 -1
  26. package/dist/xchains/icon/index.mjs +5 -7
  27. package/dist/xchains/injective/index.d.ts +2 -2
  28. package/dist/xchains/injective/index.mjs +3 -5
  29. package/dist/xchains/near/index.d.ts +1 -1
  30. package/dist/xchains/near/index.mjs +4 -6
  31. package/dist/xchains/solana/index.d.ts +1 -1
  32. package/dist/xchains/solana/index.mjs +5 -7
  33. package/dist/xchains/stacks/index.d.ts +10 -4
  34. package/dist/xchains/stacks/index.mjs +3 -5
  35. package/dist/xchains/stellar/index.d.ts +1 -1
  36. package/dist/xchains/stellar/index.mjs +4 -6
  37. package/dist/xchains/sui/index.d.ts +1 -1
  38. package/dist/xchains/sui/index.mjs +5 -7
  39. package/docs/ADDING_A_NEW_CHAIN.md +1 -1
  40. package/docs/SUB_PATH_EXPORTS.md +14 -42
  41. package/package.json +35 -28
  42. package/ai-exported/AGENTS.md +0 -122
  43. package/ai-exported/integration/README.md +0 -102
  44. package/ai-exported/integration/ai-rules.md +0 -136
  45. package/ai-exported/integration/architecture.md +0 -181
  46. package/ai-exported/integration/examples/01-minimal-evm.tsx +0 -75
  47. package/ai-exported/integration/examples/02-multi-chain-modal.tsx +0 -169
  48. package/ai-exported/integration/examples/03-nextjs-app-router.tsx +0 -99
  49. package/ai-exported/integration/examples/04-walletconnect-setup.tsx +0 -89
  50. package/ai-exported/integration/examples/README.md +0 -29
  51. package/ai-exported/integration/recipes/batch-operations.md +0 -223
  52. package/ai-exported/integration/recipes/bridge-to-sdk.md +0 -164
  53. package/ai-exported/integration/recipes/chain-detection.md +0 -254
  54. package/ai-exported/integration/recipes/connect-button.md +0 -156
  55. package/ai-exported/integration/recipes/multi-chain-modal.md +0 -199
  56. package/ai-exported/integration/recipes/setup.md +0 -160
  57. package/ai-exported/integration/recipes/sign-message.md +0 -137
  58. package/ai-exported/integration/recipes/sub-path-imports.md +0 -95
  59. package/ai-exported/integration/recipes/switch-chain.md +0 -141
  60. package/ai-exported/integration/recipes/walletconnect-setup.md +0 -139
  61. package/ai-exported/integration/reference/api-surface.md +0 -175
  62. package/ai-exported/integration/reference/chain-support.md +0 -78
  63. package/ai-exported/integration/reference/connectors.md +0 -74
  64. package/ai-exported/integration/reference/hooks.md +0 -204
  65. package/ai-exported/integration/reference/wallet-brands.md +0 -106
  66. package/ai-exported/migration/README.md +0 -49
  67. package/ai-exported/migration/ai-rules.md +0 -144
  68. package/ai-exported/migration/breaking-changes.md +0 -305
  69. package/ai-exported/migration/checklist.md +0 -159
  70. package/ai-exported/migration/recipes/connect-button.md +0 -166
  71. package/ai-exported/migration/recipes/multi-chain-modal.md +0 -244
  72. package/ai-exported/migration/recipes/ssr-setup.md +0 -164
  73. package/ai-exported/migration/recipes/walletconnect-migration.md +0 -168
  74. package/ai-exported/migration/reference/components.md +0 -73
  75. package/ai-exported/migration/reference/config.md +0 -325
  76. package/ai-exported/migration/reference/hooks.md +0 -323
  77. package/ai-exported/migration/reference/imports.md +0 -157
  78. package/dist/chunk-2BOUGCJ7.mjs.map +0 -1
  79. package/dist/chunk-66BAUK56.mjs.map +0 -1
  80. package/dist/chunk-7ULB6DW4.mjs.map +0 -1
  81. package/dist/chunk-BKJB527E.mjs.map +0 -1
  82. package/dist/chunk-BXJLBR4G.mjs.map +0 -1
  83. package/dist/chunk-E5IAZ7E6.mjs.map +0 -1
  84. package/dist/chunk-MAQ47Q52.mjs.map +0 -1
  85. package/dist/chunk-MXZVF5HR.mjs.map +0 -1
  86. package/dist/chunk-N5A2TMF6.mjs.map +0 -1
  87. package/dist/chunk-NY7U7OJW.mjs.map +0 -1
  88. package/dist/chunk-PJLEJVAU.mjs.map +0 -1
  89. package/dist/chunk-PLCA4ZDJ.mjs.map +0 -1
  90. package/dist/chunk-TZMKDXFA.mjs +0 -3
  91. package/dist/chunk-TZMKDXFA.mjs.map +0 -1
  92. package/dist/chunk-X2MHIWXO.mjs.map +0 -1
  93. package/dist/chunk-XZ7CHO2S.mjs.map +0 -1
  94. package/dist/index.cjs +0 -3337
  95. package/dist/index.cjs.map +0 -1
  96. package/dist/index.mjs.map +0 -1
  97. package/dist/xchains/bitcoin/index.cjs +0 -1927
  98. package/dist/xchains/bitcoin/index.cjs.map +0 -1
  99. package/dist/xchains/bitcoin/index.mjs.map +0 -1
  100. package/dist/xchains/evm/index.cjs +0 -316
  101. package/dist/xchains/evm/index.cjs.map +0 -1
  102. package/dist/xchains/evm/index.mjs.map +0 -1
  103. package/dist/xchains/icon/index.cjs +0 -311
  104. package/dist/xchains/icon/index.cjs.map +0 -1
  105. package/dist/xchains/icon/index.mjs.map +0 -1
  106. package/dist/xchains/injective/index.cjs +0 -223
  107. package/dist/xchains/injective/index.cjs.map +0 -1
  108. package/dist/xchains/injective/index.mjs.map +0 -1
  109. package/dist/xchains/near/index.cjs +0 -190
  110. package/dist/xchains/near/index.cjs.map +0 -1
  111. package/dist/xchains/near/index.mjs.map +0 -1
  112. package/dist/xchains/solana/index.cjs +0 -186
  113. package/dist/xchains/solana/index.cjs.map +0 -1
  114. package/dist/xchains/solana/index.mjs.map +0 -1
  115. package/dist/xchains/stacks/index.cjs +0 -240
  116. package/dist/xchains/stacks/index.cjs.map +0 -1
  117. package/dist/xchains/stacks/index.mjs.map +0 -1
  118. package/dist/xchains/stellar/index.cjs +0 -322
  119. package/dist/xchains/stellar/index.cjs.map +0 -1
  120. package/dist/xchains/stellar/index.mjs.map +0 -1
  121. package/dist/xchains/sui/index.cjs +0 -248
  122. package/dist/xchains/sui/index.cjs.map +0 -1
  123. package/dist/xchains/sui/index.mjs.map +0 -1
  124. package/skills/SKILLS.md +0 -84
  125. package/skills/bridge-to-sdk.md +0 -148
  126. package/skills/connect-button.md +0 -116
  127. package/skills/evm-only-walletconnect.md +0 -111
  128. package/skills/multi-chain-modal.md +0 -178
  129. package/skills/setup.md +0 -107
@@ -1,168 +0,0 @@
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.
@@ -1,73 +0,0 @@
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.
@@ -1,325 +0,0 @@
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
- ## ⚠️ First, fix the provider stack (silent runtime crash otherwise)
8
-
9
- **v1 created `QueryClient` internally; v2 expects the consumer to provide one.** If you only swap the prop shape without adding `QueryClientProvider`, the app crashes at runtime — React Query hooks throw "No QueryClient set". This is **not** a typecheck error; it surfaces only when a wallet hook mounts.
10
-
11
- ```tsx
12
- // v1 ❌ — QueryClientProvider was internal
13
- <SodaxWalletProvider rpcConfig={...} options={...}>{children}</SodaxWalletProvider>
14
-
15
- // v2 ✅ — caller wraps with QueryClientProvider
16
- <QueryClientProvider client={queryClient}>
17
- <SodaxWalletProvider config={walletConfig}>{children}</SodaxWalletProvider>
18
- </QueryClientProvider>
19
- ```
20
-
21
- 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.
22
-
23
- When dapp-kit is also in use, the full provider stack is:
24
-
25
- ```tsx
26
- <SodaxProvider config={sodaxConfig}>
27
- <QueryClientProvider client={queryClient}> {/* required wrapper */}
28
- <SodaxWalletProvider config={walletConfig}>
29
- <YourApp />
30
- </SodaxWalletProvider>
31
- </QueryClientProvider>
32
- </SodaxProvider>
33
- ```
34
-
35
- ---
36
-
37
- ## Top-level shape
38
-
39
- ```tsx
40
- // v1 ❌
41
- <SodaxWalletProvider
42
- rpcConfig={rpcConfig}
43
- options={{ wagmi, solana, sui }}
44
- initialState={wagmiState}
45
- >
46
- {children}
47
- </SodaxWalletProvider>
48
-
49
- // v2 ✅
50
- <SodaxWalletProvider config={walletConfig}>{children}</SodaxWalletProvider>
51
- ```
52
-
53
- 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.
54
-
55
- ---
56
-
57
- ## v1 `rpcConfig` → v2 per-chain `rpcUrl`
58
-
59
- v1 took a flat dictionary keyed by some chain string:
60
-
61
- ```ts
62
- // v1 ❌
63
- const rpcConfig: RpcConfig = {
64
- 'sonic': 'https://rpc.soniclabs.com',
65
- '0x1.eth': 'https://ethereum-rpc.publicnode.com',
66
- 'solana': 'https://api.mainnet-beta.solana.com',
67
- // ...
68
- };
69
- ```
70
-
71
- v2 nests RPC URLs under `<ChainTypeSlot>.chains[ChainKey].rpcUrl`:
72
-
73
- ```ts
74
- // v2 ✅
75
- import { ChainKeys } from '@sodax/types';
76
- import type { SodaxWalletConfig } from '@sodax/wallet-sdk-react';
77
-
78
- const walletConfig: SodaxWalletConfig = {
79
- EVM: {
80
- chains: {
81
- [ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
82
- [ChainKeys.ETHEREUM_MAINNET]: { rpcUrl: 'https://ethereum-rpc.publicnode.com' },
83
- },
84
- },
85
- SOLANA: {
86
- chains: {
87
- [ChainKeys.SOLANA_MAINNET]: { rpcUrl: 'https://api.mainnet-beta.solana.com' },
88
- },
89
- },
90
- };
91
- ```
92
-
93
- **Per-chain entry shape varies** by chain type:
94
-
95
- | Slot | Per-chain entry |
96
- |---|---|
97
- | `EVM`, `SOLANA`, `SUI`, `ICON`, `NEAR` | `{ rpcUrl?, defaults? }` |
98
- | `BITCOIN`, `STELLAR`, `INJECTIVE` | extends their `*RpcConfig` type with `{ defaults? }` |
99
- | `STACKS` | preset name (string) **or** `StacksNetworkLike & { defaults? }` |
100
-
101
- 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.
102
-
103
- ---
104
-
105
- ## v1 `options.wagmi` → v2 `EVM.*`
106
-
107
- ```ts
108
- // v1 ❌
109
- options: {
110
- wagmi: {
111
- reconnectOnMount: false,
112
- ssr: true,
113
- },
114
- }
115
- ```
116
-
117
- ```ts
118
- // v2 ✅
119
- EVM: {
120
- ssr: true,
121
- reconnectOnMount: true,
122
- chains: { ... },
123
- }
124
- ```
125
-
126
- | v1 | v2 | Notes |
127
- |---|---|---|
128
- | `options.wagmi.ssr` | `EVM.ssr` | Defaults: v1 `true`, v2 not set (caller decides). For Next.js, set `true`. |
129
- | `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. |
130
-
131
- ---
132
-
133
- ## v1 `options.solana` → v2 `SOLANA.*`
134
-
135
- ```ts
136
- // v1 ❌
137
- options: {
138
- solana: { autoConnect: true },
139
- }
140
- ```
141
-
142
- ```ts
143
- // v2 ✅
144
- SOLANA: {
145
- autoConnect: true,
146
- chains: {
147
- [ChainKeys.SOLANA_MAINNET]: { rpcUrl: '...' },
148
- },
149
- }
150
- ```
151
-
152
- | v1 | v2 |
153
- |---|---|
154
- | `options.solana.autoConnect` | `SOLANA.autoConnect` |
155
-
156
- ---
157
-
158
- ## v1 `options.sui` → v2 `SUI.*`
159
-
160
- ```ts
161
- // v1 ❌
162
- options: {
163
- sui: { autoConnect: true },
164
- }
165
- ```
166
-
167
- ```ts
168
- // v2 ✅
169
- SUI: {
170
- autoConnect: true,
171
- network: 'mainnet',
172
- }
173
- ```
174
-
175
- `SUI` slot fields (per `SuiAdapterFields` in `src/types/config.ts`):
176
-
177
- | Field | Type | Default |
178
- |---|---|---|
179
- | `autoConnect` | `boolean?` | `true` |
180
- | `network` | `'mainnet' \| 'testnet' \| 'devnet'?` | `'mainnet'` |
181
-
182
- | v1 | v2 |
183
- |---|---|
184
- | `options.sui.autoConnect` | `SUI.autoConnect` |
185
-
186
- ---
187
-
188
- ## v1 `initialState` → v2 `EVM.initialState`
189
-
190
- 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.
191
-
192
- ```ts
193
- // v1 ❌
194
- <SodaxWalletProvider rpcConfig={...} options={...} initialState={wagmiState}>
195
-
196
- // v2 ✅
197
- <SodaxWalletProvider config={{
198
- EVM: {
199
- ssr: true,
200
- initialState: wagmiState,
201
- chains: {...},
202
- },
203
- /* ... */
204
- }}>
205
- ```
206
-
207
- 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.
208
-
209
- ---
210
-
211
- ## New in v2: per-chain `defaults`
212
-
213
- Each chain entry can hold call-level defaults that flow to the bridged `IXxxWalletProvider`:
214
-
215
- ```ts
216
- // v2 ✅
217
- EVM: {
218
- chains: {
219
- [ChainKeys.ARBITRUM_MAINNET]: {
220
- rpcUrl: 'https://arb1.arbitrum.io/rpc',
221
- defaults: {
222
- waitForTransactionReceipt: { confirmations: 1 },
223
- },
224
- },
225
- },
226
- }
227
- ```
228
-
229
- The `defaults` shape is per-chain — the type system narrows what's valid per chain key. Inspect `WalletDefaultsByKey<K>` in `src/types/config.ts`.
230
-
231
- ---
232
-
233
- ## New in v2: `EVM.walletConnect`
234
-
235
- WalletConnect support for EVM — extends wagmi's `WalletConnectParameters`:
236
-
237
- ```ts
238
- // v2 ✅
239
- EVM: {
240
- walletConnect: {
241
- projectId: 'wc-cloud-project-id', // required from cloud.walletconnect.com
242
- // qrModalOptions, isNewChainsStale, etc. — full WalletConnectParameters
243
- },
244
- }
245
- ```
246
-
247
- 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).
248
-
249
- See [`../recipes/walletconnect-migration.md`](../recipes/walletconnect-migration.md).
250
-
251
- ---
252
-
253
- ## New in v2: `<chainSlot>.connectors?` override
254
-
255
- 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.
256
-
257
- ---
258
-
259
- ## Frozen on first render
260
-
261
- `SodaxWalletProvider` captures `config` once on mount and ignores prop-reference changes. To swap config at runtime, remount with a new `key`:
262
-
263
- ```tsx
264
- // v2 ✅
265
- <SodaxWalletProvider key={configVersion} config={walletConfig}>
266
- {children}
267
- </SodaxWalletProvider>
268
- ```
269
-
270
- 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.
271
-
272
- ---
273
-
274
- ## Provider-stack order changed
275
-
276
- Moved to the top of this file — see the ⚠️ block at the start. The summary: wrap `SodaxWalletProvider` in `QueryClientProvider`, otherwise React Query throws "No QueryClient set" at runtime.
277
-
278
- ---
279
-
280
- ## Minimal valid v2 config — every shape, side by side
281
-
282
- ```ts
283
- // v2 ✅
284
- import { ChainKeys } from '@sodax/types';
285
- import type { SodaxWalletConfig } from '@sodax/wallet-sdk-react';
286
-
287
- const walletConfig: SodaxWalletConfig = {
288
- // EVM — needs chains
289
- EVM: {
290
- ssr: true,
291
- chains: {
292
- [ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
293
- },
294
- // optional:
295
- // walletConnect: { projectId: '...' },
296
- },
297
-
298
- // SOLANA — chain entry + autoConnect
299
- SOLANA: {
300
- autoConnect: false,
301
- chains: {
302
- [ChainKeys.SOLANA_MAINNET]: { rpcUrl: 'https://api.mainnet-beta.solana.com' },
303
- },
304
- },
305
-
306
- // SUI — network preset
307
- SUI: { network: 'mainnet' },
308
-
309
- // ICON — chain entry
310
- ICON: {
311
- chains: {
312
- [ChainKeys.ICON_MAINNET]: { rpcUrl: 'https://ctz.solidwallet.io/api/v3' },
313
- },
314
- },
315
-
316
- // BITCOIN, STELLAR, INJECTIVE, NEAR, STACKS — pass {} to mount with SDK defaults
317
- BITCOIN: {},
318
- STELLAR: {},
319
- INJECTIVE: {},
320
- NEAR: {},
321
- STACKS: {},
322
- };
323
- ```
324
-
325
- Omit any slot to skip that chain entirely.