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

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