@sodax/wallet-sdk-react 2.0.0-rc.2 → 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 -23
  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 -158
  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 -162
  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 -307
  67. package/ai-exported/migration/reference/hooks.md +0 -278
  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
@@ -109,35 +109,26 @@ If a cross-cutting type genuinely needs to be available from the barrel (typing
109
109
  [`tsup.config.ts`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/tsup.config.ts) declares one entry per public boundary:
110
110
 
111
111
  ```typescript
112
- const sharedConfig = {
112
+ export default defineConfig({
113
113
  entry: [
114
114
  'src/index.ts',
115
115
  'src/xchains/*/index.ts', // glob — picks up new chain folders automatically
116
116
  'src/xchains/*/index.tsx',
117
117
  ],
118
+ format: ['esm'],
118
119
  outDir: 'dist',
119
120
  external: ['react', 'react-dom', '@tanstack/react-query'],
120
121
  // ...
121
- };
122
-
123
- export default defineConfig([
124
- { ...sharedConfig, format: ['esm'], splitting: true, outExtension: () => ({ js: '.mjs' }) },
125
- { ...sharedConfig, format: ['cjs'], splitting: false, outExtension: () => ({ js: '.cjs' }) },
126
- ]);
122
+ });
127
123
  ```
128
124
 
129
- Two production builds:
130
-
131
- | Build | `splitting` | Output |
132
- |-------|-------------|--------|
133
- | ESM | `true` | `.mjs` files share class instances across entry points |
134
- | CJS | `false` | One `.cjs` per entry, no chunk-sharing |
125
+ The build is ESM-only with `splitting: true` so chunks are shared across entry points and `instanceof XverseXConnector` works regardless of which entry the connector was imported from. React-only consumers (Vite, Next.js, esbuild, Webpack) all resolve ESM by default — no CJS output is shipped.
135
126
 
136
- **Why ESM splitting matters** without it, the same class would be defined twice (once in `dist/index.mjs`, once in `dist/xchains/bitcoin/index.mjs`), and `instanceof XverseXConnector` would return `false` if the connector was constructed in one entry and tested in another. With splitting on, both entries import the class from a shared chunk, preserving identity.
127
+ DTS is generated by tsup's internal `rollup-plugin-dts` integration (`dts: true`), which emits `.d.ts` declarations. The build script wraps tsup in `NODE_OPTIONS=--max-old-space-size=8192` because rollup-plugin-dts inlines transitive dep types and otherwise OOMs the default V8 heap on this package's type graph.
137
128
 
138
129
  ### Adding a new chain
139
130
 
140
- The glob `src/xchains/*/index.ts` is **auto-discovering** — creating `src/xchains/aptos/index.ts` automatically produces `dist/xchains/aptos/index.{mjs,cjs,d.ts}` on next build. No `tsup.config.ts` edit required. See [`ADDING_A_NEW_CHAIN.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ADDING_A_NEW_CHAIN.md#step-4--xchainschainindexts-barrel-for-sub-path-export).
131
+ The glob `src/xchains/*/index.ts` is **auto-discovering** — creating `src/xchains/aptos/index.ts` automatically produces `dist/xchains/aptos/index.{mjs,d.ts}` on next build. No `tsup.config.ts` edit required. See [`ADDING_A_NEW_CHAIN.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ADDING_A_NEW_CHAIN.md#step-4--xchainschainindexts-barrel-for-sub-path-export).
141
132
 
142
133
  ---
143
134
 
@@ -150,13 +141,11 @@ Two fields work together to support modern bundlers and legacy `moduleResolution
150
141
  "exports": {
151
142
  ".": {
152
143
  "types": "./dist/index.d.ts",
153
- "import": "./dist/index.mjs",
154
- "require": "./dist/index.cjs"
144
+ "import": "./dist/index.mjs"
155
145
  },
156
146
  "./xchains/*": {
157
147
  "types": "./dist/xchains/*/index.d.ts",
158
- "import": "./dist/xchains/*/index.mjs",
159
- "require": "./dist/xchains/*/index.cjs"
148
+ "import": "./dist/xchains/*/index.mjs"
160
149
  }
161
150
  },
162
151
  "typesVersions": {
@@ -169,8 +158,8 @@ Two fields work together to support modern bundlers and legacy `moduleResolution
169
158
 
170
159
  | Field | Read by | Purpose |
171
160
  |-------|---------|---------|
172
- | `exports['.']` | All bundlers (Vite, Webpack, esbuild, Next.js), modern Node | Resolves `@sodax/wallet-sdk-react` to the right artifact per condition (ESM/CJS/types) |
173
- | `exports['./xchains/*']` | Same | Wildcard maps `@sodax/wallet-sdk-react/xchains/<chain>` to the matching `dist/xchains/<chain>/index.<ext>` |
161
+ | `exports['.']` | All bundlers (Vite, Webpack, esbuild, Next.js), modern Node | Resolves `@sodax/wallet-sdk-react` to the ESM artifact + types |
162
+ | `exports['./xchains/*']` | Same | Wildcard maps `@sodax/wallet-sdk-react/xchains/<chain>` to the matching `dist/xchains/<chain>/index.mjs` |
174
163
  | `typesVersions['xchains/*']` | TypeScript with `moduleResolution: "node"` (legacy) | Fallback for TS configs that don't honor the `exports` field's `types` condition |
175
164
 
176
165
  Modern projects with `"moduleResolution": "bundler"` or `"node16"` only need `exports`. `typesVersions` ensures sub-path types resolve for older configs that still see `@sodax/wallet-sdk-react/xchains/bitcoin` as a path traversal.
@@ -181,32 +170,15 @@ If a consumer reports "Cannot find module" for sub-paths in TypeScript, check th
181
170
 
182
171
  ## `instanceof` semantics across entry points
183
172
 
184
- Class identity is preserved across barrel and sub-path entries **only in ESM**:
173
+ Class identity is preserved across barrel and sub-path entries by tsup's `splitting: true`, which emits shared chunks:
185
174
 
186
175
  ```typescript
187
- // ESM — works
188
176
  import { XverseXConnector } from '@sodax/wallet-sdk-react/xchains/bitcoin';
189
177
  const connectors = useXConnectors({ xChainType: 'BITCOIN' });
190
178
  const xverse = connectors.find(c => c instanceof XverseXConnector); // ✅ may be true
191
-
192
- // CJS — broken (in theory)
193
- // require('@sodax/wallet-sdk-react') and require('@sodax/wallet-sdk-react/xchains/bitcoin')
194
- // load XverseXConnector from separate compiled files; instanceof returns false.
195
179
  ```
196
180
 
197
- In practice this **doesn't break browser consumers** Vite, Next.js, esbuild, Webpack all resolve ESM by default. CJS-only Node.js scripts that mix barrel and sub-path imports would hit the issue, but those scripts typically don't need `instanceof XverseXConnector` (they wouldn't run in a browser-extension context).
198
-
199
- If you're a Node.js consumer running CJS and need cross-entry `instanceof`, either:
200
- - Switch your project to ESM (`"type": "module"` in your `package.json`), or
201
- - Stick to **one** entry point — only the sub-path or only the barrel, never both for the same class.
202
-
203
- The `tsup.config.ts` comment documents this trade-off:
204
-
205
- ```typescript
206
- // CJS does not support code splitting — instanceof across barrel and sub-path
207
- // entries will fail. In practice this is not an issue because browser apps (Vite,
208
- // Next.js) resolve ESM, and Node.js scripts don't use sub-path instanceof checks.
209
- ```
181
+ The package is ESM-only browser apps (Vite, Next.js) and Node consumers both resolve through the same `.mjs` chunks, so `instanceof` holds regardless of whether the connector was imported via the barrel or via a sub-path.
210
182
 
211
183
  ---
212
184
 
@@ -229,7 +201,7 @@ The error message can also appear if you tried `import type { XverseXConnector }
229
201
 
230
202
  ### `instanceof XverseXConnector` returns `false` for a connector that should match
231
203
 
232
- Likely a CJS / dual-import issue. Verify that the connector instance came from the same entry point you're testing against. Switching to ESM resolution fixes this for all bundlers.
204
+ Likely caused by the package being loaded twice (e.g. duplicate copies under different `node_modules` paths, or a bundler config that splits the dependency across chunks without dedup). Verify there is exactly one `@sodax/wallet-sdk-react` in your dependency tree (`pnpm why @sodax/wallet-sdk-react`).
233
205
 
234
206
  ### `Module not found: '@sodax/wallet-sdk-react/xchains/aptos'` after adding a new chain
235
207
 
@@ -242,5 +214,5 @@ Run `pnpm build:packages` — `dist/xchains/aptos/` only exists after a build. T
242
214
  - [Connectors](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECTORS.md) — full sub-path map per chain
243
215
  - [Adding a New Chain](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ADDING_A_NEW_CHAIN.md) — Step 4 covers the barrel that powers a new sub-path
244
216
  - [Architecture](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ARCHITECTURE.md) — store-first hooks consume only barrel exports
245
- - [tsup splitting docs](https://tsup.egoist.dev/#code-splitting) — official docs on the ESM splitting behavior
217
+ - [tsup reference](https://tsup.egoist.dev/) — bundler config reference
246
218
  - [Node.js subpath exports](https://nodejs.org/api/packages.html#subpath-exports) — the spec behind `package.json` `exports`
package/package.json CHANGED
@@ -1,32 +1,46 @@
1
1
  {
2
2
  "name": "@sodax/wallet-sdk-react",
3
+ "private": false,
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
3
7
  "license": "MIT",
4
- "version": "2.0.0-rc.2",
8
+ "version": "2.0.0-rc.4",
5
9
  "description": "Wallet SDK of Sodax",
10
+ "keywords": [
11
+ "sodax",
12
+ "wallet",
13
+ "sdk",
14
+ "react",
15
+ "multichain",
16
+ "web3"
17
+ ],
18
+ "homepage": "https://github.com/icon-project/sodax-sdks/tree/main/packages/wallet-sdk-react",
19
+ "bugs": {
20
+ "url": "https://github.com/icon-project/sodax-sdks/issues"
21
+ },
6
22
  "type": "module",
7
- "main": "./dist/index.cjs",
23
+ "main": "./dist/index.mjs",
8
24
  "module": "./dist/index.mjs",
9
25
  "types": "./dist/index.d.ts",
10
26
  "engines": {
11
- "node": ">=20.0.0"
27
+ "node": ">=20.12.0"
12
28
  },
13
29
  "files": [
14
30
  "dist",
31
+ "!dist/**/*.map",
15
32
  "README.md",
16
- "docs",
17
- "skills",
18
- "ai-exported"
33
+ "docs"
19
34
  ],
35
+ "sideEffects": false,
20
36
  "exports": {
21
37
  ".": {
22
38
  "types": "./dist/index.d.ts",
23
- "import": "./dist/index.mjs",
24
- "require": "./dist/index.cjs"
39
+ "import": "./dist/index.mjs"
25
40
  },
26
41
  "./xchains/*": {
27
42
  "types": "./dist/xchains/*/index.d.ts",
28
- "import": "./dist/xchains/*/index.mjs",
29
- "require": "./dist/xchains/*/index.cjs"
43
+ "import": "./dist/xchains/*/index.mjs"
30
44
  }
31
45
  },
32
46
  "typesVersions": {
@@ -52,37 +66,35 @@
52
66
  "@injectivelabs/wallet-base": "1.18.14",
53
67
  "@injectivelabs/wallet-core": "1.18.14",
54
68
  "@injectivelabs/wallet-cosmos": "1.18.14",
55
- "@injectivelabs/wallet-evm": "1.18.14",
56
69
  "@injectivelabs/wallet-strategy": "1.18.14",
57
70
  "@mysten/dapp-kit": "0.14.18",
58
71
  "@mysten/sui": "1.21.2",
59
72
  "near-api-js": "7.2.0",
60
73
  "@solana/spl-token": "0.4.9",
61
74
  "@solana/wallet-adapter-react": "0.15.35",
62
- "@solana/wallet-adapter-wallets": "0.19.30",
63
75
  "@solana/web3.js": "1.98.0",
64
76
  "@stellar/stellar-sdk": "15.1.0",
65
- "@walletconnect/ethereum-provider": "^2.23.9",
66
77
  "icon-sdk-js": "1.5.3",
67
78
  "immer": "10.1.1",
68
79
  "sats-connect": "^4.2.1",
69
80
  "viem": "2.29.2",
70
81
  "wagmi": "2.16.9",
71
82
  "zustand": "4.5.2",
72
- "bs58": "6.0.0",
73
- "@sodax/wallet-sdk-core": "2.0.0-rc.2",
74
- "@sodax/types": "2.0.0-rc.2"
83
+ "@sodax/wallet-sdk-core": "2.0.0-rc.4",
84
+ "@sodax/types": "2.0.0-rc.4"
75
85
  },
76
86
  "devDependencies": {
87
+ "@arethetypeswrong/cli": "0.17.4",
77
88
  "@testing-library/react": "^16.1.0",
78
89
  "@types/react": "^19.0.8",
79
90
  "@types/react-dom": "^19.0.3",
80
91
  "happy-dom": "^20.8.9",
81
92
  "knip": "5.30.5",
82
93
  "react-dom": "19.1.4",
94
+ "tslib": "2.8.1",
83
95
  "tsup": "8.5.0",
84
96
  "typescript": "5.5.4",
85
- "vitest": "2.1.9"
97
+ "vitest": "3.2.4"
86
98
  },
87
99
  "peerDependencies": {
88
100
  "@tanstack/react-query": "5.x",
@@ -94,12 +106,9 @@
94
106
  "clean": "rm -rf dist && rm -rf node_modules && rm -rf .turbo",
95
107
  "pretty": "biome format . --write",
96
108
  "checkTs": "tsc --noEmit",
97
- "checkTs:examples": "tsc --noEmit -p tsconfig.examples.json",
109
+ "check-exports": "attw --pack --profile esm-only",
98
110
  "test": "vitest run",
99
- "knip": "knip",
100
- "lint": "biome lint . --write",
101
- "check:ai-exported": "bash ./scripts/check-ai-exported.sh",
102
- "check:ai-links": "bash ./scripts/check-ai-links.sh",
103
- "check:ai-imports": "bash ./scripts/check-ai-imports.sh"
111
+ "check:knip": "knip",
112
+ "lint": "biome lint . --write"
104
113
  }
105
114
  }
@@ -1,122 +0,0 @@
1
- # AGENTS.md — `@sodax/wallet-sdk-react` AI Export
2
-
3
- You are a coding agent helping a developer **integrate** or **migrate** the `@sodax/wallet-sdk-react` package. This document is your entry point. Read this first, then route to the right sub-folder.
4
-
5
- The files in this `ai-exported/` directory are designed for AI consumption: short, table-heavy, self-contained recipes, and machine-checkable checklists. Human-readable narrative lives in each folder's `README.md`.
6
-
7
- ---
8
-
9
- ## Step 1 — Identify the task
10
-
11
- | User says... | Path | Start at |
12
- |---|---|---|
13
- | "upgrade to v2", "migrate from v1", "old hooks no longer work", "useXWagmiStore is gone" | **migration** | `migration/ai-rules.md` |
14
- | "add wallet connect", "set up SodaxWalletProvider", "first time using this lib" | **integration** | `integration/ai-rules.md` |
15
- | Looking up a v1 → v2 symbol mapping | direct | `migration/reference/*.md` |
16
- | Looking up a hook signature or available connector | direct | `integration/reference/*.md` |
17
-
18
- The package name **did not change** between v1 and v2 — both versions publish as `@sodax/wallet-sdk-react`. Migration is detected by import surface (`useXWagmiStore`, positional hook args, `rpcConfig` / `options` / `initialState` props on `SodaxWalletProvider`), not by package name.
19
-
20
- If both signals appear (project has v1 patterns AND wants new features), **migration first, then integration**.
21
-
22
- ---
23
-
24
- ## Step 2 — Load the right context
25
-
26
- **For migration tasks:**
27
-
28
- 1. `migration/ai-rules.md` — DO/DON'T + workflow + stop conditions
29
- 2. `migration/breaking-changes.md` — narrative WHY behind each change
30
- 3. `migration/reference/*.md` — lookup tables (imports, hooks, config, components)
31
- 4. `migration/recipes/<task>.md` — paired before/after for the specific use case
32
- 5. `migration/checklist.md` — verification loop
33
-
34
- **For integration tasks:**
35
-
36
- 1. `integration/ai-rules.md` — DO/DON'T + workflow
37
- 2. `integration/recipes/setup.md` — always read this first (everything else depends on it)
38
- 3. `integration/recipes/<task>.md` — task-specific guide
39
- 4. `integration/reference/*.md` — API surface lookup
40
-
41
- ---
42
-
43
- ## Step 3 — Honor flow-specific stop conditions
44
-
45
- Each flow has its own list of conditions that **HARD STOP** code generation and require asking the user:
46
-
47
- - Migration stops → [`migration/ai-rules.md`](./migration/ai-rules.md) § "Stop conditions"
48
- - Integration stops → [`integration/ai-rules.md`](./integration/ai-rules.md) § "Stop conditions"
49
-
50
- Read the relevant list **before** applying any change. When stopping, quote the offending file/line and present the user with concrete options. Do **not** guess.
51
-
52
- Cross-flow signals (true regardless of flow):
53
-
54
- - User explicitly requests a behavior that v2 does not support (custom chain not in [`integration/reference/chain-support.md`](./integration/reference/chain-support.md), custom `XService` / `XConnector` subclass with non-trivial logic).
55
- - User mixes both v1 and v2 patterns in new code being written — do migration first, then integration.
56
-
57
- ---
58
-
59
- ## Step 4 — Verification protocol
60
-
61
- After **every** code change you make:
62
-
63
- 1. Run `pnpm checkTs` from the user's app root (or the package the change touched).
64
- 2. If errors mention `@sodax/wallet-sdk-react`, look up the symbol in `migration/reference/` or `integration/reference/`.
65
- 3. If a symbol isn't in any reference file, **stop and ask**. Do not invent migrations.
66
- 4. After all errors resolve, mark the relevant items in `migration/checklist.md` (for migrations) or move to the next recipe.
67
-
68
- You are **done** when:
69
- - `pnpm checkTs` exits clean for the user's project.
70
- - All items in `migration/checklist.md` are checked (migration only).
71
- - The user has confirmed the changed flow works in their dev environment.
72
-
73
- ---
74
-
75
- ## Conventions in this directory
76
-
77
- - **Recipes are self-contained.** A recipe file in `recipes/` contains everything needed to apply the change — before/after code, steps, verification. Do not jump between files.
78
- - **Reference files are tables.** `reference/*.md` contains markdown tables and paired code blocks marked `// v1 ❌` and `// v2 ✅`. Treat them as lookup, not narrative.
79
- - **Token budget**: Each file is sized to fit comfortably in your context. If you find yourself loading more than 3 files for a single task, you are probably doing it wrong — re-route via the table above.
80
- - **Single source of truth**: Behavioral / breaking-change *explanations* live only in `migration/breaking-changes.md`. Other files reference it but do not duplicate the prose.
81
-
82
- ---
83
-
84
- ## Quick symbol lookup
85
-
86
- If the user mentions a symbol you don't recognize, grep these files in order:
87
-
88
- ```
89
- migration/reference/imports.md — import path changes
90
- migration/reference/hooks.md — hook renames + signature changes
91
- migration/reference/config.md — SodaxWalletProvider config changes
92
- migration/reference/components.md — component / provider renames
93
- integration/reference/hooks.md — full v2 hook surface
94
- integration/reference/connectors.md — available wallet connectors per chain
95
- integration/reference/chain-support.md — supported chains + slots
96
- ```
97
-
98
- If still not found: the symbol may be **internal** (not exported from v2) or **removed**. Ask the user to share the v1 file/line so you can decide.
99
-
100
- ---
101
-
102
- ## Package context
103
-
104
- - **Name**: `@sodax/wallet-sdk-react` (same package name in v1 and v2)
105
- - **Version target**: v2.x (current).
106
- - **Peer deps**: `react >= 19`, `@tanstack/react-query 5.x`
107
- - **Install**: `pnpm add @sodax/wallet-sdk-react @tanstack/react-query`
108
- - **Audience**: dApp builders integrating multi-chain wallet connectivity (9 chain types: EVM, Solana, Sui, Bitcoin, Stellar, ICON, Injective, NEAR, Stacks).
109
-
110
- For internal architecture (only relevant if you're modifying the package itself, not consuming it), see `../CLAUDE.md` in the parent directory.
111
-
112
- ---
113
-
114
- ## Pointers
115
-
116
- - [`integration/README.md`](./integration/README.md) — start here for new integrations: file index, recommended reading order, install snippet, provider-stack ordering.
117
- - [`migration/README.md`](./migration/README.md) — start here for v1 → v2 ports: file index, reading order, cross-cutting checklist pointer.
118
- - [`integration/recipes/setup.md`](./integration/recipes/setup.md) — install, mount `SodaxWalletProvider`, pick chain slots.
119
- - [`integration/architecture.md`](./integration/architecture.md) — mental model: provider mount tree, frozen config, EVM single-connection, `xChainType` vs `xChainId`.
120
- - [`integration/reference/`](./integration/reference/) — hooks, connectors, chain-support, wallet-brand identifiers lookup tables.
121
- - [`integration/reference/wallet-brands.md`](./integration/reference/wallet-brands.md) — known wallet brand identifiers (`'hana'`, `'phantom'`, `'xverse'`, …) for batch hooks, plus a runtime discovery snippet.
122
- - [`migration/breaking-changes.md`](./migration/breaking-changes.md) — full narrative of every v1 → v2 change.
@@ -1,102 +0,0 @@
1
- # Integration: First-time setup (Human-readable overview)
2
-
3
- This folder helps you integrate `@sodax/wallet-sdk-react` into a fresh React app. It is the **human-facing** entry point for new integrations. If you are a coding agent, read [`ai-rules.md`](./ai-rules.md) first.
4
-
5
- If you are migrating from v1 instead, see `../migration/`.
6
-
7
- ---
8
-
9
- ## What this package does
10
-
11
- `@sodax/wallet-sdk-react` is the React layer over `@sodax/wallet-sdk-core`. It gives you:
12
-
13
- - **Multi-chain wallet connect** across 9 chain types (EVM, Solana, Sui, Bitcoin, Stellar, ICON, Injective, NEAR, Stacks).
14
- - **Hooks** (`useXConnect`, `useXAccount`, `useXDisconnect`, `useXSignMessage`, etc.) backed by a Zustand store — composable and SSR-safe.
15
- - **Headless modal primitives** (`useWalletModal`, `useChainGroups`, `useBatchConnect`) — bring your own UI.
16
- - **Typed wallet providers** for hand-off to `@sodax/sdk` calls (`useWalletProvider`).
17
-
18
- ---
19
-
20
- ## Recommended path (in order)
21
-
22
- If this is your first time using the package:
23
-
24
- 1. [`recipes/setup.md`](./recipes/setup.md) — install, wire `SodaxWalletProvider`, pick chain slots. **Always do this first**.
25
- 2. Pick a connect UX (one, not both):
26
- - [`recipes/connect-button.md`](./recipes/connect-button.md) — single chain, simplest UX.
27
- - [`recipes/multi-chain-modal.md`](./recipes/multi-chain-modal.md) — chain picker + connector picker, headless.
28
- 3. [`recipes/sign-message.md`](./recipes/sign-message.md) — sign messages cross-chain (auth flows).
29
- 4. [`recipes/bridge-to-sdk.md`](./recipes/bridge-to-sdk.md) — pass `walletProvider` to `@sodax/sdk` calls (swaps, lending, staking, etc.).
30
- 5. [`recipes/switch-chain.md`](./recipes/switch-chain.md) — switch the active EVM network when source chain doesn't match.
31
- 6. [`recipes/chain-detection.md`](./recipes/chain-detection.md) — list enabled chains, render connected list with hydration gate, install detection.
32
- 7. Add advanced features as needed:
33
- - [`recipes/walletconnect-setup.md`](./recipes/walletconnect-setup.md) — enable WalletConnect for enterprise-custody / mobile-only wallets.
34
- - [`recipes/batch-operations.md`](./recipes/batch-operations.md) — batch connect / disconnect across multiple chains.
35
- - [`recipes/sub-path-imports.md`](./recipes/sub-path-imports.md) — deep imports from `xchains/<chain>` for `instanceof` checks or custom connector lists.
36
- 8. Reference docs (lookup as needed):
37
- - [`reference/hooks.md`](./reference/hooks.md) — full hook surface with signatures.
38
- - [`reference/connectors.md`](./reference/connectors.md) — available wallet connectors per chain.
39
- - [`reference/chain-support.md`](./reference/chain-support.md) — supported chains, slots, and adapter notes.
40
- 9. Copy-paste examples (runnable code, minimal narrative):
41
- - [`examples/`](./examples/) — 4 self-contained `.tsx` files: minimal EVM setup, multi-chain modal, Next.js App Router, WalletConnect setup.
42
-
43
- ---
44
-
45
- ## Install
46
-
47
- ```bash
48
- pnpm add @sodax/wallet-sdk-react @tanstack/react-query
49
- ```
50
-
51
- Peer dependencies:
52
-
53
- ```json
54
- {
55
- "react": ">=19",
56
- "@tanstack/react-query": "5.x"
57
- }
58
- ```
59
-
60
- ---
61
-
62
- ## Pair with `@sodax/sdk` and `@sodax/dapp-kit`
63
-
64
- Most apps integrate this package together with the SDK and dapp-kit:
65
-
66
- ```
67
- @sodax/sdk ← business logic (swaps, lending, staking, etc.)
68
- @sodax/dapp-kit ← high-level React hooks combining SDK + wallet-sdk
69
- @sodax/wallet-sdk-react ← wallet connectivity (this package)
70
- ```
71
-
72
- If you are using all three, mount providers in this order at the app root:
73
-
74
- ```tsx
75
- <SodaxProvider config={sodaxConfig}> {/* @sodax/dapp-kit */}
76
- <QueryClientProvider client={queryClient}>
77
- <SodaxWalletProvider config={walletConfig}> {/* this package */}
78
- {children}
79
- </SodaxWalletProvider>
80
- </QueryClientProvider>
81
- </SodaxProvider>
82
- ```
83
-
84
- `SodaxProvider` (from dapp-kit) wraps the lot. `QueryClientProvider` must wrap `SodaxWalletProvider` because hooks inside use React Query.
85
-
86
- ---
87
-
88
- ## Conventions worth knowing
89
-
90
- - **Hooks use a single options object.** `useXConnectors({ xChainType: 'EVM' })`, not positional args.
91
- - **`xChainId` (chain key) and `xChainType` (family) are both accepted** by `useXAccount` and `useWalletProvider`. Pass one, not both.
92
- - **`useXConnect` is a React Query mutation.** Pass an `IXConnector` to `mutateAsync`.
93
- - **Persisted connections.** Connections survive reload via `localStorage` key `xwagmi-store`. Gate UI on `useConnectedChains().status === 'ready'` to avoid hydration flicker.
94
- - **EVM is one connection across all networks.** wagmi treats every configured EVM chain as part of one connector — there is no per-network connect/disconnect.
95
-
96
- ---
97
-
98
- ## Getting help
99
-
100
- - API surface lookup: [`reference/`](./reference/).
101
- - Bug or missing feature: [open an issue](https://github.com/icon-project/sodax-sdks/issues).
102
- - Internal architecture (only relevant for SODAX maintainers): `../CLAUDE.md` in the package root.
@@ -1,136 +0,0 @@
1
- # AI Rules — Fresh Integration
2
-
3
- You are integrating `@sodax/wallet-sdk-react` into a user's React app for the first time. Follow this protocol exactly.
4
-
5
- ---
6
-
7
- ## Workflow (do these in order)
8
-
9
- ### 1. Survey the project
10
-
11
- Before changing anything, gather context:
12
-
13
- ```bash
14
- # Framework — Next.js (App Router or Pages)? Vite? CRA?
15
- cat <user>/package.json | grep -E '"next|"vite|"react-scripts'
16
-
17
- # React version — must be >= 19
18
- cat <user>/package.json | grep '"react"'
19
-
20
- # React Query already installed?
21
- cat <user>/package.json | grep '"@tanstack/react-query'
22
-
23
- # Existing wallet libraries that may conflict
24
- grep -l "wagmi\|@solana/wallet-adapter\|@mysten/dapp-kit" <user>/package.json
25
- ```
26
-
27
- **If React < 19**, stop and tell the user — this package requires React 19.
28
-
29
- **If wagmi / @solana/wallet-adapter / @mysten/dapp-kit are already direct dependencies**, stop and ask the user — this package mounts those internally; running both will cause duplicate provider context errors.
30
-
31
- ### 2. Always start with `setup.md`
32
-
33
- Read [`recipes/setup.md`](./recipes/setup.md) and apply it. **Do not skip ahead** — every subsequent recipe assumes `SodaxWalletProvider` is already mounted.
34
-
35
- ### 3. Pick exactly one connect UX
36
-
37
- Connect UX is **either / or**, not additive:
38
-
39
- - [`recipes/connect-button.md`](./recipes/connect-button.md) — pick this when the app needs to connect one chain at a time, and the UX is a single button per chain.
40
- - [`recipes/multi-chain-modal.md`](./recipes/multi-chain-modal.md) — pick this when the app needs a chain-picker → connector-picker modal, or when one wallet should connect multiple chains in sequence.
41
-
42
- Ask the user which UX they want before applying. If unsure, default to `connect-button.md` (simpler).
43
-
44
- ### 4. Add advanced features as separate steps
45
-
46
- Only after the connect UX works should you add:
47
-
48
- - Sign-message flows ([`recipes/sign-message.md`](./recipes/sign-message.md))
49
- - Bridge to `@sodax/sdk` calls ([`recipes/bridge-to-sdk.md`](./recipes/bridge-to-sdk.md))
50
- - Switch active EVM network ([`recipes/switch-chain.md`](./recipes/switch-chain.md))
51
- - Chain & wallet detection patterns ([`recipes/chain-detection.md`](./recipes/chain-detection.md))
52
- - WalletConnect ([`recipes/walletconnect-setup.md`](./recipes/walletconnect-setup.md))
53
- - Batch connect / disconnect ([`recipes/batch-operations.md`](./recipes/batch-operations.md))
54
-
55
- Each is independent — apply only what the user asked for.
56
-
57
- ### Copy-paste templates
58
-
59
- If the user wants a full working starter file rather than narrative steps, point them at [`examples/`](./examples/):
60
-
61
- - `01-minimal-evm.tsx` — provider + 1 connect button
62
- - `02-multi-chain-modal.tsx` — full headless modal
63
- - `03-nextjs-app-router.tsx` — Next.js 15 SSR setup
64
- - `04-walletconnect-setup.tsx` — WalletConnect setup (optional single-wallet filter)
65
-
66
- Always combine with the narrative recipe — examples are skeletons, recipes explain why each piece exists.
67
-
68
- ---
69
-
70
- ## DO
71
-
72
- - **DO** put `SodaxWalletProvider` at the app root, inside `QueryClientProvider`. Order matters.
73
- - **DO** include only the chain slots the user actually needs in `walletConfig`. Each slot mounts a real React provider — unused slots waste bundle size.
74
- - **DO** use the chain-typed hooks: `useXAccount({ xChainType: 'EVM' })`, not `useXAccount({ xChainId: someId })` unless the user specifically needs per-chain-id resolution.
75
- - **DO** gate UI on `useConnectedChains().status === 'ready'` whenever you render based on connection state — prevents hydration flicker on Next.js.
76
- - **DO** use the headless primitives (`useWalletModal`, `useChainGroups`) and let the user style the UI. Do not hand-roll a hidden chain registry.
77
- - **DO** if Next.js, set `EVM.ssr: true` in `walletConfig`.
78
-
79
- ---
80
-
81
- ## DO NOT
82
-
83
- - **DO NOT** import from `@sodax/wallet-sdk-react/xchains/<chain>` unless you specifically need a concrete class (e.g. `instanceof XverseXConnector`). Default to barrel imports.
84
- - **DO NOT** instantiate `XService` or `XConnector` subclasses manually — `SodaxWalletProvider` does this via the chain registry.
85
- - **DO NOT** call `useXConnect` outside a React component / custom hook.
86
- - **DO NOT** read from `useXWalletStore` directly. Use the public hooks. The store shape is internal.
87
- - **DO NOT** stack multiple `SodaxWalletProvider` instances. One per app.
88
- - **DO NOT** pass changing config references on every render — `SodaxWalletProvider` freezes config on first render. To swap config at runtime, remount with a new `key`.
89
- - **DO NOT** mock `useXConnect` / `useXAccount` in tests by stubbing the store. Use the real provider with a test config.
90
-
91
- ---
92
-
93
- ## Stop conditions (defer to user)
94
-
95
- | Signal | Why stop |
96
- |---|---|
97
- | User asks for a chain not in the [chain support list](./reference/chain-support.md) | Adding a new chain requires package-level changes (see `../../CLAUDE.md`), not user-app integration. |
98
- | User wants to use `@sodax/sdk` for swaps / lending / etc. | This package only handles wallet connectivity. Direct user to also install `@sodax/dapp-kit`. |
99
- | User wants Server Components to use `useXAccount` directly | Hooks are client-only. Must wrap consumer in `'use client'`. |
100
- | User mentions Next.js Pages Router | Setup differs slightly — confirm before applying App Router defaults. |
101
- | User asks "how do I connect wallet X" but the connector isn't built in | Check [`reference/connectors.md`](./reference/connectors.md). If absent, the connector doesn't exist yet — flag as out of scope. |
102
- | User wants custom chains (e.g. EVM testnet not in the default list) | `EVM.chains` accepts custom chain configs, but ChainKey enum is fixed. Confirm before extending. |
103
-
104
- ---
105
-
106
- ## Verification protocol (after every recipe)
107
-
108
- ```bash
109
- # 1. Type check passes
110
- pnpm checkTs
111
-
112
- # 2. Provider is mounted exactly once
113
- grep -rn "SodaxWalletProvider" <user-src> # expect one match
114
-
115
- # 3. QueryClientProvider wraps SodaxWalletProvider
116
- # (manual — open the provider file, confirm nesting order)
117
-
118
- # 4. Connect/disconnect works in dev
119
- # (manual — start dev server, click connect, verify localStorage has `xwagmi-store` key after success)
120
- ```
121
-
122
- If steps 1–3 pass and the user confirms step 4, the recipe is done.
123
-
124
- ---
125
-
126
- ## Done criteria
127
-
128
- The integration is complete when:
129
-
130
- - [ ] `pnpm checkTs` exits clean.
131
- - [ ] `SodaxWalletProvider` is mounted at the app root with the user's chosen `walletConfig`.
132
- - [ ] `QueryClientProvider` wraps `SodaxWalletProvider`.
133
- - [ ] At least one connect UX (button or modal) is wired and works in the user's dev environment.
134
- - [ ] If using `@sodax/sdk` features: `useWalletProvider` is used to bridge to SDK calls (see `recipes/setup.md` § "Pair with `@sodax/sdk`").
135
-
136
- Do not declare integration done before all of the above are true.