@sodax/skills 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +18 -0
- package/AGENTS.md +83 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/package.json +58 -0
- package/skills/sodax-dapp-kit/SKILL.md +129 -0
- package/skills/sodax-dapp-kit/integration/knowledge/README.md +49 -0
- package/skills/sodax-dapp-kit/integration/knowledge/ai-rules.md +80 -0
- package/skills/sodax-dapp-kit/integration/knowledge/architecture.md +276 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/README.md +29 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/auxiliary-services.md +169 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/bitcoin.md +87 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/bridge.md +91 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/dex.md +152 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/migration.md +118 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/money-market.md +144 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/staking.md +123 -0
- package/skills/sodax-dapp-kit/integration/knowledge/features/swap.md +101 -0
- package/skills/sodax-dapp-kit/integration/knowledge/quickstart.md +188 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/README.md +136 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/backend-queries.md +157 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/bitcoin.md +193 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/bridge.md +174 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/dex.md +204 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/invalidations.md +115 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/migration.md +212 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/money-market.md +207 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/mutation-error-handling.md +118 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/observability.md +93 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/setup.md +168 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/staking.md +202 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/swap.md +272 -0
- package/skills/sodax-dapp-kit/integration/knowledge/recipes/wallet-connectivity.md +128 -0
- package/skills/sodax-dapp-kit/integration/knowledge/reference/README.md +12 -0
- package/skills/sodax-dapp-kit/integration/knowledge/reference/glossary.md +190 -0
- package/skills/sodax-dapp-kit/integration/knowledge/reference/hooks-index.md +190 -0
- package/skills/sodax-dapp-kit/integration/knowledge/reference/public-api.md +110 -0
- package/skills/sodax-dapp-kit/integration/knowledge/reference/querykey-conventions.md +179 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/README.md +60 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/ai-rules.md +81 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/hook-signatures.md +233 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/querykey-conventions.md +108 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/result-handling.md +211 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/breaking-changes/sdk-leakage.md +167 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/checklist.md +89 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/README.md +34 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/auxiliary-services.md +114 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/bitcoin.md +88 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/bridge.md +160 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/dex.md +101 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/migration.md +120 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/money-market.md +139 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/staking.md +109 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/features/swap.md +133 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/recipes.md +185 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/README.md +15 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/deleted-hooks.md +110 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/error-shape-crosswalk.md +144 -0
- package/skills/sodax-dapp-kit/migration-v1-to-v2/knowledge/reference/renamed-hooks.md +68 -0
- package/skills/sodax-sdk/SKILL.md +140 -0
- package/skills/sodax-sdk/backend-api/SKILL.md +52 -0
- package/skills/sodax-sdk/bridge/SKILL.md +49 -0
- package/skills/sodax-sdk/dex/SKILL.md +50 -0
- package/skills/sodax-sdk/integration/knowledge/README.md +43 -0
- package/skills/sodax-sdk/integration/knowledge/ai-rules.md +75 -0
- package/skills/sodax-sdk/integration/knowledge/architecture.md +517 -0
- package/skills/sodax-sdk/integration/knowledge/chain-specifics.md +189 -0
- package/skills/sodax-sdk/integration/knowledge/features/README.md +21 -0
- package/skills/sodax-sdk/integration/knowledge/features/backend-api.md +81 -0
- package/skills/sodax-sdk/integration/knowledge/features/bridge.md +172 -0
- package/skills/sodax-sdk/integration/knowledge/features/dex.md +182 -0
- package/skills/sodax-sdk/integration/knowledge/features/migration.md +181 -0
- package/skills/sodax-sdk/integration/knowledge/features/money-market.md +198 -0
- package/skills/sodax-sdk/integration/knowledge/features/partner.md +63 -0
- package/skills/sodax-sdk/integration/knowledge/features/recovery.md +50 -0
- package/skills/sodax-sdk/integration/knowledge/features/staking.md +171 -0
- package/skills/sodax-sdk/integration/knowledge/features/swap.md +273 -0
- package/skills/sodax-sdk/integration/knowledge/quickstart.md +213 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/README.md +21 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/backend-server-init.md +69 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/chain-key-narrowing.md +65 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/gas-estimation.md +33 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/initialize-sodax.md +78 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/raw-tx-flow.md +71 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/result-and-errors.md +104 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/signed-tx-flow.md +46 -0
- package/skills/sodax-sdk/integration/knowledge/recipes/testing.md +101 -0
- package/skills/sodax-sdk/integration/knowledge/reference/README.md +18 -0
- package/skills/sodax-sdk/integration/knowledge/reference/chain-keys.md +67 -0
- package/skills/sodax-sdk/integration/knowledge/reference/error-codes.md +165 -0
- package/skills/sodax-sdk/integration/knowledge/reference/glossary.md +32 -0
- package/skills/sodax-sdk/integration/knowledge/reference/public-api.md +138 -0
- package/skills/sodax-sdk/integration/knowledge/reference/wallet-providers.md +62 -0
- package/skills/sodax-sdk/migration/SKILL.md +65 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/README.md +58 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/ai-rules.md +76 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/breaking-changes/architecture.md +344 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/breaking-changes/result-and-errors.md +363 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/breaking-changes/type-system.md +341 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/checklist.md +67 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/README.md +37 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/backend-api.md +92 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/bridge.md +128 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/dex.md +143 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/migration.md +151 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/money-market.md +214 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/partner.md +59 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/recovery.md +35 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/staking.md +143 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/features/swap.md +198 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/recipes.md +350 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/README.md +18 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/deleted-exports.md +127 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/error-code-crosswalk.md +104 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/return-shapes.md +49 -0
- package/skills/sodax-sdk/migration-v1-to-v2/knowledge/reference/sodax-config.md +145 -0
- package/skills/sodax-sdk/money-market/SKILL.md +52 -0
- package/skills/sodax-sdk/partner/SKILL.md +51 -0
- package/skills/sodax-sdk/recovery/SKILL.md +49 -0
- package/skills/sodax-sdk/staking/SKILL.md +49 -0
- package/skills/sodax-sdk/swap/SKILL.md +67 -0
- package/skills/sodax-wallet-sdk-core/SKILL.md +114 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/README.md +108 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/ai-rules.md +141 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/architecture.md +212 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/README.md +22 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/bitcoin.md +103 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/evm.md +102 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/icon.md +88 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/injective.md +92 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/near.md +92 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/solana.md +104 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/stacks.md +91 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/stellar.md +95 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/features/sui.md +96 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/quickstart.md +259 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/README.md +15 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/bridge-to-sdk.md +145 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/defaults-and-overrides.md +159 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/library-exports.md +129 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/setup-browser-extension.md +137 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/setup-private-key.md +115 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/sign-and-broadcast.md +201 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/recipes/testing.md +163 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/README.md +13 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/chain-support.md +65 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/glossary.md +28 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/interfaces.md +131 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/provider-classes.md +54 -0
- package/skills/sodax-wallet-sdk-core/integration/knowledge/reference/public-api.md +128 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/README.md +84 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/ai-rules.md +139 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/README.md +14 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/base-wallet-provider.md +52 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/defaults-config.md +57 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/folder-layout.md +99 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/breaking-changes/library-exports.md +58 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/checklist.md +62 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/README.md +12 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/adopt-defaults.md +84 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/adopt-library-exports.md +99 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/README.md +12 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/added-fields.md +71 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/deleted-exports.md +35 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/renamed-symbols.md +31 -0
- package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/return-shapes.md +23 -0
- package/skills/sodax-wallet-sdk-react/SKILL.md +154 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/README.md +103 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/ai-rules.md +136 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/architecture.md +185 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/01-minimal-evm.tsx +75 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/02-multi-chain-modal.tsx +169 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/03-nextjs-app-router.tsx +99 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/04-walletconnect-setup.tsx +89 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/examples/README.md +29 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/batch-operations.md +224 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/bridge-to-sdk.md +165 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/chain-detection.md +259 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/connect-button.md +159 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/multi-chain-modal.md +203 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/setup.md +163 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/sign-message.md +138 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/sub-path-imports.md +97 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/switch-chain.md +144 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/recipes/walletconnect-setup.md +139 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/api-surface.md +176 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/chain-support.md +79 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/connectors.md +75 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/hooks.md +212 -0
- package/skills/sodax-wallet-sdk-react/integration/knowledge/reference/wallet-brands.md +107 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/README.md +49 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/ai-rules.md +144 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/breaking-changes.md +310 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/checklist.md +159 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/connect-button.md +170 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/multi-chain-modal.md +245 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/ssr-setup.md +165 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/recipes/walletconnect-migration.md +170 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/components.md +75 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/config.md +339 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/hooks.md +336 -0
- package/skills/sodax-wallet-sdk-react/migration-v1-to-v2/knowledge/reference/imports.md +158 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Recipe: Adopt `defaults` (optional cleanup)
|
|
2
|
+
|
|
3
|
+
Replace hand-rolled wrappers with provider-level `defaults`. Optional — older per-call style still works.
|
|
4
|
+
|
|
5
|
+
**Apply when:** the user has a helper like `makeProvider(pk)` or `withDefaults(provider)` that injects fixed options on every call.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Before — hand-rolled wrapper
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
|
|
13
|
+
import type { EvmRawTransaction } from '@sodax/types';
|
|
14
|
+
import { ChainKeys } from '@sodax/types';
|
|
15
|
+
|
|
16
|
+
function makeEvmProvider(pk: `0x${string}`) {
|
|
17
|
+
const provider = new EvmWalletProvider({ privateKey: pk, chainId: ChainKeys.SONIC_MAINNET });
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
...provider,
|
|
21
|
+
sendTransaction(tx: EvmRawTransaction) {
|
|
22
|
+
// hard-coded gas on every call
|
|
23
|
+
return provider.sendTransaction(tx, { gas: 3_000_000n });
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## After — provider-level `defaults`
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
|
|
33
|
+
import { ChainKeys } from '@sodax/types';
|
|
34
|
+
|
|
35
|
+
const provider = new EvmWalletProvider({
|
|
36
|
+
privateKey: process.env.EVM_PK as `0x${string}`,
|
|
37
|
+
chainId: ChainKeys.SONIC_MAINNET,
|
|
38
|
+
defaults: {
|
|
39
|
+
sendTransaction: { gas: 3_000_000n },
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Use directly — defaults apply automatically; per-call override still works.
|
|
44
|
+
await provider.sendTransaction(tx);
|
|
45
|
+
await provider.sendTransaction(tx2, { gas: 5_000_000n });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Steps
|
|
51
|
+
|
|
52
|
+
1. **Identify the wrapper.** Look for functions that wrap a provider and inject options on every method call.
|
|
53
|
+
2. **Move the injected options into `defaults`.** Pick the right slice — `defaults.sendTransaction` for EVM, `defaults.signAndExecuteTxn` for Sui, flat `defaults` for Bitcoin / Stellar / ICON / Injective / NEAR / Stacks.
|
|
54
|
+
3. **Delete the wrapper.** Replace call sites with direct provider method calls.
|
|
55
|
+
4. **Keep behavior for callers that already pass options.** Per-call options shallow-merge over defaults, so existing call sites that pass `{ gas: 5_000_000n }` still get exactly that gas value.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## When NOT to adopt
|
|
60
|
+
|
|
61
|
+
| Scenario | Why skip |
|
|
62
|
+
|---|---|
|
|
63
|
+
| The wrapper does more than inject defaults (e.g. logging, telemetry, retries) | `defaults` is just a config slice; it can't do behavior wrapping. Keep the wrapper. |
|
|
64
|
+
| The "default" actually changes per call (e.g. dynamic gas estimation) | That's not a default — it's per-call logic. Keep it inline. |
|
|
65
|
+
| The user's code base would gain churn for trivial savings | Migration cost > value. Leave it. |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Verification
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# 1. Type check
|
|
73
|
+
pnpm checkTs
|
|
74
|
+
|
|
75
|
+
# 2. Search for remaining hand-rolled wrappers (heuristic)
|
|
76
|
+
grep -rnE "function\s+(make|build|with)(Wallet|Evm|Solana|Sui|Bitcoin|Stellar|Icon|Injective|Near|Stacks)Provider" <user-src>
|
|
77
|
+
# review each — confirm each is justified per the table above
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Why
|
|
83
|
+
|
|
84
|
+
See [`../breaking-changes/defaults-config.md`](../breaking-changes/defaults-config.md) for the model.
|
package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/recipes/adopt-library-exports.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Recipe: Adopt `library-exports` (optional cleanup)
|
|
2
|
+
|
|
3
|
+
Re-import types from `@sodax/wallet-sdk-core` instead of upstream chain SDKs. Optionally drop direct chain-SDK deps from `package.json`.
|
|
4
|
+
|
|
5
|
+
**Apply when:** the user imports type names like `WalletClient`, `PublicClient`, `Networks`, `PostConditionMode`, `NearConnector`, etc. directly from their upstream packages.
|
|
6
|
+
|
|
7
|
+
For the full list of re-exported types, see [`recipes/library-exports.md`](../../../integration/knowledge/recipes/library-exports.md).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Before
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import type { WalletClient, PublicClient, TransactionReceipt } from 'viem';
|
|
15
|
+
import { Networks } from '@stellar/stellar-sdk';
|
|
16
|
+
import { PostConditionMode } from '@stacks/transactions';
|
|
17
|
+
import type { WalletAccount, WalletWithFeatures, SuiWalletFeatures } from '@mysten/wallet-standard';
|
|
18
|
+
import type { Commitment, ConnectionConfig, SendOptions } from '@solana/web3.js';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## After
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import type {
|
|
25
|
+
WalletClient,
|
|
26
|
+
PublicClient,
|
|
27
|
+
TransactionReceipt,
|
|
28
|
+
WalletAccount,
|
|
29
|
+
WalletWithFeatures,
|
|
30
|
+
SuiWalletFeatures,
|
|
31
|
+
Commitment,
|
|
32
|
+
ConnectionConfig,
|
|
33
|
+
SendOptions,
|
|
34
|
+
} from '@sodax/wallet-sdk-core';
|
|
35
|
+
|
|
36
|
+
import { Networks, PostConditionMode } from '@sodax/wallet-sdk-core';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Steps
|
|
42
|
+
|
|
43
|
+
1. **Identify candidate imports.** Run the grep below to find type imports from upstream chain SDKs:
|
|
44
|
+
```bash
|
|
45
|
+
grep -rn "from 'viem'" <user-src> | grep -E "WalletClient|PublicClient|TransactionReceipt|SendTransactionParameters|WaitForTransactionReceiptParameters"
|
|
46
|
+
grep -rn "from '@stellar/stellar-sdk'" <user-src> | grep "Networks"
|
|
47
|
+
grep -rn "from '@stacks/transactions'" <user-src> | grep -E "PostConditionMode|ClarityValue|PostConditionModeName"
|
|
48
|
+
# …see ../../integration/recipes/library-exports.md for the full grep list
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. **Replace one import statement at a time.** Switch the `from` clause to `@sodax/wallet-sdk-core`. Re-run `pnpm checkTs` after each file.
|
|
52
|
+
|
|
53
|
+
3. **Check whether the upstream package is still needed for runtime.** If the consumer's only remaining import from `viem` (etc.) is one of the re-exported types, you can drop the dep from `package.json`. If they also import `createPublicClient`, `Connection`, `Transaction`, etc. — keep the dep.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
grep -rn "from 'viem'" <user-src> # confirm nothing remains
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Trade-offs
|
|
62
|
+
|
|
63
|
+
| Switch | Trade-off |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Type imports | Lossless. Same symbol, different module. |
|
|
66
|
+
| Dep removal (after switching all imports) | Smaller `node_modules`, faster installs. But you re-add the dep if you later need a runtime helper. |
|
|
67
|
+
| Version pinning | After dep removal, you no longer control the chain-SDK version directly — it's locked to whatever SODAX uses. Acceptable for most apps. |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## When NOT to adopt
|
|
72
|
+
|
|
73
|
+
| Scenario | Why skip |
|
|
74
|
+
|---|---|
|
|
75
|
+
| The user is pinned to a specific chain-SDK version different from SODAX's | Adopting library-exports forces SODAX's version. Keep direct imports. |
|
|
76
|
+
| The user imports many runtime symbols (`createPublicClient`, etc.) not in library-exports | Migration churn for limited benefit — they still need the dep. |
|
|
77
|
+
| The user is mid-migration to another chain SDK and library-exports doesn't cover the new one | Wait until library-exports catches up, or just keep the direct dep. |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Verification
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# 1. Type check
|
|
85
|
+
pnpm checkTs
|
|
86
|
+
|
|
87
|
+
# 2. No remaining direct upstream-SDK type imports
|
|
88
|
+
grep -rn "from 'viem'" <user-src> | grep -E "WalletClient|PublicClient|TransactionReceipt"
|
|
89
|
+
# expect empty (or kept on purpose with justification)
|
|
90
|
+
|
|
91
|
+
# 3. Optional: confirm the upstream dep was actually removed
|
|
92
|
+
cat <user>/package.json | jq -r '.dependencies | keys[]'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Why
|
|
98
|
+
|
|
99
|
+
See [`../breaking-changes/library-exports.md`](../breaking-changes/library-exports.md) for the motivation.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Migration reference
|
|
2
|
+
|
|
3
|
+
Lookup tables. Use these to answer "what was renamed / added / removed" without reading the breaking-change narratives.
|
|
4
|
+
|
|
5
|
+
| File | Use for |
|
|
6
|
+
|---|---|
|
|
7
|
+
| [`renamed-symbols.md`](./renamed-symbols.md) | Old name → new name. |
|
|
8
|
+
| [`deleted-exports.md`](./deleted-exports.md) | Symbols removed; what to use instead. |
|
|
9
|
+
| [`added-fields.md`](./added-fields.md) | New optional fields you can adopt. |
|
|
10
|
+
| [`return-shapes.md`](./return-shapes.md) | Method return shapes that changed (none currently — placeholder for future). |
|
|
11
|
+
|
|
12
|
+
For narrative WHY behind each change, see [`../breaking-changes/`](../breaking-changes/).
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Added fields and types
|
|
2
|
+
|
|
3
|
+
Additive changes that older code does not use. All optional — no migration required.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## New types
|
|
8
|
+
|
|
9
|
+
| Type | Chain(s) | Purpose |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `EvmWalletDefaults` | EVM | `defaults` slice shape |
|
|
12
|
+
| `EvmSendTransactionPolicy` | EVM | Per-call options shape for `sendTransaction` |
|
|
13
|
+
| `EvmWaitForTransactionReceiptPolicy` | EVM | Per-call options shape for `waitForTransactionReceipt` |
|
|
14
|
+
| `SolanaWalletDefaults` | Solana | `defaults` slice shape |
|
|
15
|
+
| `SuiWalletDefaults` | Sui | `defaults` slice shape |
|
|
16
|
+
| `SuiSignAndExecutePolicy` | Sui | Per-call options for `signAndExecuteTxn` |
|
|
17
|
+
| `SuiGetCoinsPolicy` | Sui | Per-call options for `getCoins` |
|
|
18
|
+
| `BitcoinWalletDefaults` | Bitcoin | `defaults` slice shape |
|
|
19
|
+
| `StellarWalletDefaults` | Stellar | `defaults` slice shape |
|
|
20
|
+
| `IconWalletDefaults` | ICON | `defaults` slice shape |
|
|
21
|
+
| `InjectiveWalletDefaults` | Injective | `defaults` slice shape |
|
|
22
|
+
| `NearWalletDefaults` | NEAR | `defaults` slice shape |
|
|
23
|
+
| `NearTxExecutionStatus` | NEAR | Status union for `waitUntil` default |
|
|
24
|
+
| `StacksWalletDefaults` | Stacks | `defaults` slice shape |
|
|
25
|
+
| `BaseWalletProvider<TDefaults>` | all | Abstract base class (consumers do not subclass) |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## New optional fields on existing configs
|
|
30
|
+
|
|
31
|
+
| Config | Field | Default if omitted |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `PrivateKeyEvmWalletConfig` | `defaults?: EvmWalletDefaults` | `{}` |
|
|
34
|
+
| `BrowserExtensionEvmWalletConfig` | `defaults?: EvmWalletDefaults` | `{}` (note: transport/clients in defaults are no-ops here) |
|
|
35
|
+
| `PrivateKeySolanaWalletConfig` | `defaults?: SolanaWalletDefaults` | `{}` |
|
|
36
|
+
| `BrowserExtensionSolanaWalletConfig` | `defaults?: SolanaWalletDefaults` | `{}` |
|
|
37
|
+
| `PrivateKeySuiWalletConfig` | `defaults?: SuiWalletDefaults` | `{}` |
|
|
38
|
+
| `BrowserExtensionSuiWalletConfig` | `defaults?: SuiWalletDefaults` | `{}` |
|
|
39
|
+
| `PrivateKeyBitcoinWalletConfig` | `defaults?: BitcoinWalletDefaults` | `{}` |
|
|
40
|
+
| `BrowserExtensionBitcoinWalletConfig` | `defaults?: BitcoinWalletDefaults` | `{}` |
|
|
41
|
+
| `PrivateKeyStellarWalletConfig` | `defaults?: StellarWalletDefaults` | `{}` |
|
|
42
|
+
| `BrowserExtensionStellarWalletConfig` | `defaults?: StellarWalletDefaults` | `{}` |
|
|
43
|
+
| `PrivateKeyIconWalletConfig` | `defaults?: IconWalletDefaults` | `{}` |
|
|
44
|
+
| `BrowserExtensionIconWalletConfig` | `defaults?: IconWalletDefaults` | `{}` |
|
|
45
|
+
| `SecretInjectiveWalletConfig` | `defaults?: InjectiveWalletDefaults` | `{}` |
|
|
46
|
+
| `BrowserExtensionInjectiveWalletConfig` | `defaults?: InjectiveWalletDefaults` | `{}` |
|
|
47
|
+
| `PrivateKeyNearWalletConfig` | `defaults?: NearWalletDefaults` | `{}` |
|
|
48
|
+
| `BrowserExtensionNearWalletConfig` | `defaults?: NearWalletDefaults` | `{}` |
|
|
49
|
+
| `PrivateKeyStacksWalletConfig` | `defaults?: StacksWalletDefaults` | `{}` |
|
|
50
|
+
| `BrowserExtensionStacksWalletConfig` | `defaults?: StacksWalletDefaults` | `{}` |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## New library-exports re-exports
|
|
55
|
+
|
|
56
|
+
See [`recipes/library-exports.md`](../../../integration/knowledge/recipes/library-exports.md) for the full table. Re-exporting these means consumers can drop direct deps on upstream chain SDKs for type-only usage.
|
|
57
|
+
|
|
58
|
+
Summary:
|
|
59
|
+
|
|
60
|
+
- **viem** — `Account`, `Address`, `Chain`, `Transport`, `PublicClient`, `WalletClient`, `HttpTransportConfig`, `PublicClientConfig`, `WalletClientConfig`, `SendTransactionParameters`, `WaitForTransactionReceiptParameters`, `TransactionReceipt`
|
|
61
|
+
- **@mysten/sui** — `SuiTransactionBlockResponseOptions`, `Transaction`, `TransactionArgument`
|
|
62
|
+
- **@mysten/wallet-standard** — `SuiWalletFeatures`, `WalletAccount`, `WalletWithFeatures`
|
|
63
|
+
- **@solana/web3.js** — `Commitment`, `ConnectionConfig`, `SendOptions`
|
|
64
|
+
- **@injectivelabs/*** — `Network`, `ChainId`, `EvmChainId`, `MsgBroadcaster`
|
|
65
|
+
- **@stellar/stellar-sdk** — `Networks` (runtime value)
|
|
66
|
+
- **@stacks/transactions** — `PostConditionMode` (runtime enum), `ClarityValue`, `PostConditionModeName`
|
|
67
|
+
- **@stacks/network** — `StacksNetwork`
|
|
68
|
+
- **@stacks/connect** — `StacksProvider`
|
|
69
|
+
- **near-api-js** — `KeyPairString`
|
|
70
|
+
- **@hot-labs/near-connect** — `NearConnector`
|
|
71
|
+
- **bitcoinjs-lib** — `Network as BitcoinJsNetwork`
|
package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/deleted-exports.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Deleted exports
|
|
2
|
+
|
|
3
|
+
**No symbols were deleted from the public surface between v1 and v2.** Every v1 named export is still available on v2's barrel.
|
|
4
|
+
|
|
5
|
+
If a v1 import does not compile against v2, the cause is most likely:
|
|
6
|
+
|
|
7
|
+
| Symptom | Likely cause |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `Cannot find module '@sodax/wallet-sdk-core/wallet-providers/EvmWalletProvider'` | Deep import from v1's flat layout. Replace with barrel: `from '@sodax/wallet-sdk-core'`. See [`../breaking-changes/folder-layout.md`](../breaking-changes/folder-layout.md). |
|
|
10
|
+
| `'X' has no exported member 'Y'` against `@sodax/sdk` or `@sodax/types` | Not this package. See the corresponding package's migration docs. |
|
|
11
|
+
| Symbol `shallowMerge` not found | Internal in both v1 and v2 (v1 didn't even have it). Use `defaults` config + per-call options. |
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Internal symbols (never publicly exported, in any version)
|
|
16
|
+
|
|
17
|
+
| Symbol | Where it lives | Replacement |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `shallowMerge` | `src/utils/merge.ts` (v2 only — did not exist in v1) | Use the `defaults` config + per-call options. Merge is automatic. |
|
|
20
|
+
| `serializeReceipt` | private static on `EvmWalletProvider` | `waitForTransactionReceipt` already returns the serialised shape. |
|
|
21
|
+
| Anything under `src/utils/` | — | Internal. |
|
|
22
|
+
|
|
23
|
+
If user code deep-imports one of these, it must be replaced with a public API call.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## How to verify
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
grep -rn "shallowMerge" <user-src>
|
|
31
|
+
# expect empty
|
|
32
|
+
|
|
33
|
+
grep -rn "@sodax/wallet-sdk-core/" <user-src> | grep -v "from '@sodax/wallet-sdk-core'"
|
|
34
|
+
# expect empty
|
|
35
|
+
```
|
package/skills/sodax-wallet-sdk-core/migration-v1-to-v2/knowledge/reference/renamed-symbols.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Renamed symbols
|
|
2
|
+
|
|
3
|
+
**None.** No symbol exported from `@sodax/wallet-sdk-core` was renamed between v1 and v2.
|
|
4
|
+
|
|
5
|
+
This file exists so AI agents and humans can look up "what was renamed" and get a definitive **nothing**. If you suspect a rename, you are almost certainly looking at the wrong package:
|
|
6
|
+
|
|
7
|
+
- `@sodax/sdk` — has real v1→v2 renames (e.g. `EvmSpokeProvider` → `EvmSpokeService`).
|
|
8
|
+
- `@sodax/types` — has real v1→v2 renames (e.g. `SONIC_MAINNET_CHAIN_ID` removed in favor of `ChainKeys.SONIC_MAINNET`).
|
|
9
|
+
- `@sodax/wallet-sdk-react` — has real v1→v2 renames (e.g. `useXWagmiStore` removed; `rpcConfig` prop → `config`).
|
|
10
|
+
|
|
11
|
+
For wallet-sdk-core itself, v1 and v2 share **identical** public type names:
|
|
12
|
+
|
|
13
|
+
- `EvmWalletConfig`, `PrivateKeyEvmWalletConfig`, `BrowserExtensionEvmWalletConfig`
|
|
14
|
+
- `SolanaWalletConfig`, `PrivateKeySolanaWalletConfig`, `BrowserExtensionSolanaWalletConfig`
|
|
15
|
+
- `SuiWalletConfig`, `PrivateKeySuiWalletConfig`, `BrowserExtensionSuiWalletConfig`
|
|
16
|
+
- `BitcoinWalletConfig`, `PrivateKeyBitcoinWalletConfig`, `BrowserExtensionBitcoinWalletConfig`
|
|
17
|
+
- `StellarWalletConfig`, `PrivateKeyStellarWalletConfig`, `BrowserExtensionStellarWalletConfig`
|
|
18
|
+
- `IconWalletConfig`, `PrivateKeyIconWalletConfig`, `BrowserExtensionIconWalletConfig`
|
|
19
|
+
- `InjectiveWalletConfig`, **`SecretInjectiveWalletConfig`** (note: not `PrivateKey*` — same in v1), `BrowserExtensionInjectiveWalletConfig`
|
|
20
|
+
- `NearWalletConfig`, `PrivateKeyNearWalletConfig`, `BrowserExtensionNearWalletConfig`
|
|
21
|
+
- `StacksWalletConfig`, `PrivateKeyStacksWalletConfig`, `BrowserExtensionStacksWalletConfig`
|
|
22
|
+
|
|
23
|
+
…and the corresponding provider class names (`EvmWalletProvider`, …).
|
|
24
|
+
|
|
25
|
+
If a v1 codebase compiles against v2 with no symbol-not-found errors, that is the expected outcome.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## What WAS added
|
|
30
|
+
|
|
31
|
+
See [`added-fields.md`](./added-fields.md) for new types (`*WalletDefaults`, `*Policy` types, `BaseWalletProvider`) and new optional fields (`defaults?`, Stellar's `rpcUrl?`).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Return shapes
|
|
2
|
+
|
|
3
|
+
Method return shapes that changed between RC versions.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Currently: no breaking return-shape changes
|
|
8
|
+
|
|
9
|
+
All provider method return types are stable across the RC series. This file is a placeholder — future return-shape changes will be documented here in the same format used by `@sodax/sdk`'s migration docs (paired before/after shapes per method).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What to check anyway
|
|
14
|
+
|
|
15
|
+
If you suspect a return shape issue:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm checkTs
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Any TypeScript error mentioning a `@sodax/wallet-sdk-core` method's return type is most likely (a) propagated from `@sodax/sdk` / `@sodax/types` (which **did** change between v1 and v2), or (b) the consumer is reading a method that **never had** the shape they expect.
|
|
22
|
+
|
|
23
|
+
For (a), open an issue with the version delta — we'll add it to this file. For (b), see [`reference/interfaces.md`](../../../integration/knowledge/reference/interfaces.md) for the authoritative current shape.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sodax-wallet-sdk-react
|
|
3
|
+
description: 'INTEGRATION (write NEW code) — @sodax/wallet-sdk-react is the React wallet connectivity layer for multi-chain dapps. Covers `SodaxWalletProvider` setup, hook-based connect/disconnect/account/signing UX across 9 chain types (EVM, Solana, Sui, Bitcoin, Stellar, ICON, Injective, NEAR, Stacks), headless wallet-modal primitives, WalletConnect for non-injected wallets (Fireblocks/Ledger/mobile), and `useWalletProvider` for bridging the connected wallet into `@sodax/sdk` calls. Use whenever a React dapp needs SODAX wallet connectivity. Triggers on "add wallet connect", "set up SodaxWalletProvider", "useXConnect", "useXAccount", "useWalletProvider", "useWalletModal", "wallet modal", "connect button", "multi-chain wallet UI", "WalletConnect for Fireblocks". Peer deps: `react >= 19`, `@tanstack/react-query 5.x`. MIGRATION (port v1 → v2) — the v2 reshape removed `useXWagmiStore` from the public API (each selector must be replaced with a public hook like `useXServices` / `useXService({ xChainType })` / `useXConnections` / `useXConnection({ xChainType })`; do NOT rename to `useXWalletStore` — the v2 barrel does not export it), unified hook signatures to single-object params, reshaped `SodaxWalletProvider` props (removed `rpcConfig` / `options` / `initialState` in favor of `config: SodaxWalletConfig`), and flattened the chain-slot wrapper (`chains: { EVM, SOLANA, ... }` → top-level slots on `SodaxWalletConfig`). Triggers on "useXWagmiStore is gone", "SodaxWalletProvider props broke", "old wallet-sdk-react hooks", "upgrade @sodax/wallet-sdk-react". Load this skill if EITHER applies; the body gates by mode.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# When to use this skill
|
|
7
|
+
|
|
8
|
+
AGENTS.md routes you here when you're working with `@sodax/wallet-sdk-react` v2 — either writing new code or porting from v1.
|
|
9
|
+
|
|
10
|
+
**Pick your mode:**
|
|
11
|
+
|
|
12
|
+
- Writing NEW v2 code (greenfield, no v1 imports)? → § **Integration mode** below.
|
|
13
|
+
- Porting EXISTING v1 code to v2 (grep finds `useXWagmiStore`, `rpcConfig`, `initialState`, or positional-args hooks)? → § **Migration mode** below.
|
|
14
|
+
- Both? → migration first, then integration.
|
|
15
|
+
|
|
16
|
+
For backend / non-React → use `sodax-wallet-sdk-core` instead.
|
|
17
|
+
For React dapps with hooks wrapping the SDK → also load `sodax-dapp-kit`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Integration mode (writing new v2 code)
|
|
22
|
+
|
|
23
|
+
Pick this mode when the consumer is a React dapp that needs SODAX wallet connectivity. Common signals:
|
|
24
|
+
|
|
25
|
+
- "I need a wallet connect button" — `useXConnect`, `useXAccount`.
|
|
26
|
+
- "Multi-chain modal UI" — `useWalletModal`, `useChainGroups`, `useConnectedChains`.
|
|
27
|
+
- "Pass the connected wallet to a `@sodax/sdk` swap" — `useWalletProvider({ xChainId })`.
|
|
28
|
+
- "Add WalletConnect for enterprise custody (Fireblocks, mobile)" — `walletConnect` field on `SodaxWalletConfig.EVM`.
|
|
29
|
+
- "SSR with Next.js" — `ssr: true` flag on the EVM slot.
|
|
30
|
+
|
|
31
|
+
### Workflow
|
|
32
|
+
|
|
33
|
+
1. Read [`integration/knowledge/ai-rules.md`](./integration/knowledge/ai-rules.md) — DO / DON'T + workflow.
|
|
34
|
+
2. **Always start with setup** → [`integration/knowledge/recipes/setup.md`](./integration/knowledge/recipes/setup.md). Mount `SodaxWalletProvider`, declare chain-type slots, wire `@tanstack/react-query`.
|
|
35
|
+
3. Read [`integration/knowledge/architecture.md`](./integration/knowledge/architecture.md) — provider mount tree, frozen config, EVM single-connection model, `xChainType` vs `xChainId`.
|
|
36
|
+
4. Task-specific recipes → [`integration/knowledge/recipes/`](./integration/knowledge/recipes/) — `connect-button.md`, `multi-chain-modal.md`, `walletconnect-setup.md`, `bridge-to-sdk.md`, `sign-message.md`, `switch-chain.md`, `batch-operations.md`, `chain-detection.md`, `sub-path-imports.md`.
|
|
37
|
+
5. Working examples → [`integration/knowledge/examples/`](./integration/knowledge/examples/) — 4 working `.tsx` app shells (`01-minimal-evm`, `02-multi-chain-modal`, `03-nextjs-app-router`, `04-walletconnect-setup`).
|
|
38
|
+
6. Lookups → [`integration/knowledge/reference/`](./integration/knowledge/reference/) — hooks, connectors, chain-support, wallet-brands, api-surface.
|
|
39
|
+
|
|
40
|
+
### Conventions to follow (integration)
|
|
41
|
+
|
|
42
|
+
- **Single object parameter on every hook.** `useXConnectors({ xChainType: 'EVM' })`, `useXAccount({ xChainId: ChainKeys.BSC_MAINNET })`, `useWalletProvider({ xChainType: 'EVM' })`. `useXAccount` and `useWalletProvider` take **either** `xChainId` (chain key) **or** `xChainType` (family) — never both.
|
|
43
|
+
- **`useXConnect` is a React Query mutation.** Pass an `IXConnector` to `mutate` / `mutateAsync`. For provider-managed chains (EVM/Solana/Sui), the resolved value is `undefined` — read the connected account via `useXAccount` after the mutation lands.
|
|
44
|
+
- **Persisted connections.** Connections survive page reloads via `localStorage` (key `xwagmi-store`). Gate UI on hydration with `useConnectedChains().status === 'ready'` to avoid flicker.
|
|
45
|
+
- **EVM is one connection across all networks.** wagmi covers every configured EVM network under one connector — `useChainGroups` / `useConnectedChains` report a single `EVM` row.
|
|
46
|
+
- **Configurable chain opt-in.** `SodaxWalletProvider config` accepts a `SodaxWalletConfig` where top-level keys are `ChainType` slots (`EVM`, `SOLANA`, `SUI`, `BITCOIN`, `STELLAR`, `INJECTIVE`, `ICON`, `NEAR`, `STACKS`). Omit a slot to skip mounting that adapter; pass `{}` to mount with SDK defaults.
|
|
47
|
+
- **Don't import concrete chain classes from the barrel.** `EvmXService`, `XverseXConnector`, etc. are **deep-import only** (`@sodax/wallet-sdk-react/xchains/<chain>`). The barrel only exports hooks, types, interfaces, and `SodaxWalletProvider`.
|
|
48
|
+
|
|
49
|
+
### Wallet modal primitives
|
|
50
|
+
|
|
51
|
+
Headless building blocks (render-agnostic, wallet-agnostic):
|
|
52
|
+
|
|
53
|
+
| Hook | Purpose |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `useWalletModal({ onConnected })` | State machine: `closed → chainSelect → walletSelect → connecting → success \| error`. |
|
|
56
|
+
| `useConnectionFlow()` | `connect + status + retry` without a modal. |
|
|
57
|
+
| `useBatchConnect({ connectors, skipConnected })` | Sequential connect across every chain a wallet identifier covers. |
|
|
58
|
+
| `useBatchDisconnect({ connectors? })` | Mirror of `useBatchConnect`; omit `connectors` to disconnect all. |
|
|
59
|
+
| `useChainGroups({ order? })` | One entry per enabled chain; EVM collapses to one group. |
|
|
60
|
+
| `useConnectedChains({ order? })` | Aggregate connected view; `status: 'loading' \| 'ready'`. |
|
|
61
|
+
| `useIsWalletInstalled({ connectors?, chainType? })` | Cross-chain install check; filters AND. |
|
|
62
|
+
| `sortConnectors(xs, { preferred })` | Preferred first, then installed, then original. |
|
|
63
|
+
|
|
64
|
+
Reference app: `apps/wallet-modal-example` in the SODAX monorepo.
|
|
65
|
+
|
|
66
|
+
### Top traps to avoid (integration)
|
|
67
|
+
|
|
68
|
+
1. **Passing both `xChainId` and `xChainType`** to `useXAccount` / `useWalletProvider`. They're mutually exclusive.
|
|
69
|
+
2. **Casting the return value of `useWalletProvider`.** Use the chain-key narrowing pattern (passing a specific `xChainId`) to get the typed `IXxxWalletProvider` without `as`.
|
|
70
|
+
3. **Importing concrete classes from the barrel.** `EvmXService`, `XverseXConnector`, etc. live behind `@sodax/wallet-sdk-react/xchains/<chain>` deep imports.
|
|
71
|
+
4. **Ignoring the persist-hydration gate.** Render UI before `useConnectedChains().status === 'ready'` and you get a flicker / stale-state.
|
|
72
|
+
5. **Forgetting WalletConnect setup for enterprise custody.** Default EVM discovery is EIP-6963 (browser extensions only). Fireblocks / Ledger / mobile-only wallets need the `walletConnect` field on the `EVM` slot.
|
|
73
|
+
|
|
74
|
+
### Verification (integration)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pnpm tsc --noEmit # must exit clean
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Manually verify in browser:
|
|
81
|
+
- Connect / disconnect flows work for at least one wallet per enabled chain.
|
|
82
|
+
- Page reload preserves the connection (until `useXDisconnect`).
|
|
83
|
+
- `useWalletProvider({ xChainId: ChainKeys.X })` returns the chain-narrowed `IXxxWalletProvider`, ready to pass into `@sodax/sdk` calls (with `raw: false`).
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Migration mode (v1 → v2 porting)
|
|
88
|
+
|
|
89
|
+
Pick this mode if the consumer has v1 wallet-sdk-react patterns. Grep signals:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
grep -rE 'useXWagmiStore|rpcConfig|initialState' src/
|
|
93
|
+
grep -rE 'SodaxWalletProvider.*(options|rpcConfig|initialState)' src/
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The package name **did not change** between v1 and v2 — both versions publish as `@sodax/wallet-sdk-react`. Migration is detected by import surface, not by package name.
|
|
97
|
+
|
|
98
|
+
If a project has both v1 patterns AND a request for new features: **migration first, then integration**.
|
|
99
|
+
|
|
100
|
+
### Workflow
|
|
101
|
+
|
|
102
|
+
1. Read [`migration-v1-to-v2/knowledge/ai-rules.md`](./migration-v1-to-v2/knowledge/ai-rules.md) — DO / DON'T + workflow + stop conditions.
|
|
103
|
+
2. Read [`migration-v1-to-v2/knowledge/breaking-changes.md`](./migration-v1-to-v2/knowledge/breaking-changes.md) — full narrative of every v1 → v2 change.
|
|
104
|
+
3. Apply per-task recipes from [`migration-v1-to-v2/knowledge/recipes/`](./migration-v1-to-v2/knowledge/recipes/) — `connect-button.md`, `multi-chain-modal.md`, `ssr-setup.md`, `walletconnect-migration.md`.
|
|
105
|
+
4. Use [`reference/`](./migration-v1-to-v2/knowledge/reference/) lookups when symbols don't match — `imports.md`, `hooks.md`, `config.md`, `components.md`.
|
|
106
|
+
5. Verify with [`checklist.md`](./migration-v1-to-v2/knowledge/checklist.md).
|
|
107
|
+
|
|
108
|
+
### Top mechanical changes
|
|
109
|
+
|
|
110
|
+
1. **`useXWagmiStore` removed from the public API.** v2 does **not** export the store hook at all — neither `useXWagmiStore` nor `useXWalletStore` is available from the package barrel. Replace each `useXWagmiStore(state => state.X)` selector with the matching public hook (`useXServices`, `useXService({ xChainType })`, `useXConnections`, `useXConnection({ xChainType })`, etc.). See [`migration-v1-to-v2/knowledge/reference/imports.md`](./migration-v1-to-v2/knowledge/reference/imports.md) § "Store hook removed from the public API" for the full field-to-hook map and a STOP decision tree for selectors hitting v2-internal fields. The localStorage persistence key `'xwagmi-store'` is unchanged, so user connections survive the upgrade.
|
|
111
|
+
2. **Hook args unified to a single object.** v1 hooks took positional args; v2 hooks take `{ xChainType }` or `{ xChainId }` (mutually exclusive on `useXAccount` / `useWalletProvider`).
|
|
112
|
+
3. **`SodaxWalletProvider` props.** v1's `rpcConfig`, `options`, `initialState` props are removed. v2 takes one `config: SodaxWalletConfig` prop where top-level keys are `ChainType` slots (`EVM`, `SOLANA`, `SUI`, …). The old `chains: { EVM, SOLANA, ... }` wrapper is also gone — chain-type slots are now top-level.
|
|
113
|
+
4. **Per-chain entry shape varies.** EVM/SOLANA/SUI/ICON/NEAR use `{ rpcUrl?, defaults? }`; BITCOIN/STELLAR/INJECTIVE extend their `*RpcConfig` with `{ defaults? }`; STACKS accepts a preset name or `StacksNetworkLike & { defaults? }`.
|
|
114
|
+
|
|
115
|
+
### Stop conditions (defer to user)
|
|
116
|
+
|
|
117
|
+
| Signal | Why stop |
|
|
118
|
+
|---|---|
|
|
119
|
+
| User wants a chain family not in `integration/knowledge/reference/chain-support.md` | Adding a new chain is a maintainer task. |
|
|
120
|
+
| User has a custom `XService` / `XConnector` subclass with non-trivial logic | Custom subclasses are a maintainer-only path. Confirm scope first. |
|
|
121
|
+
| User mixes v1 and v2 patterns in new code being written | Do migration first, then integration. |
|
|
122
|
+
|
|
123
|
+
### DO (migration)
|
|
124
|
+
|
|
125
|
+
- Replace every `useXWagmiStore(state => state.X)` selector with the matching v2 public hook (`useXServices`, `useXService({ xChainType })`, `useXConnections`, `useXConnection({ xChainType })`, …) — drop the `useXWagmiStore` import entirely. See `migration-v1-to-v2/knowledge/reference/imports.md` § "Store hook removed" for the field-to-hook map.
|
|
126
|
+
- Reshape `SodaxWalletProvider` props to the single `config` object.
|
|
127
|
+
- Move RPC config from old `rpcConfig` prop to per-chain `{ rpcUrl }` under the relevant slot.
|
|
128
|
+
- For EVM-only WalletConnect setup (Fireblocks etc.), add `walletConnect: { projectId: '…' }` to the EVM slot — see `recipes/walletconnect-migration.md`.
|
|
129
|
+
|
|
130
|
+
### DO NOT (migration)
|
|
131
|
+
|
|
132
|
+
- **Rename `useXWagmiStore` to `useXWalletStore`.** The v2 barrel does not export either name. The store implementation file is named `useXWalletStore.ts` internally, but the hook is private — every consumer call site must move to a public hook.
|
|
133
|
+
- Keep destructuring positional args from hooks — every v2 hook takes one object.
|
|
134
|
+
- Use `rpcConfig` / `options` / `initialState` props on `SodaxWalletProvider` — they're gone.
|
|
135
|
+
- Pass both `xChainId` and `xChainType` to `useXAccount` / `useWalletProvider` — mutually exclusive.
|
|
136
|
+
- Forget about persist hydration. `useConnectedChains().status === 'ready'` gates UI; render too early and you get flicker.
|
|
137
|
+
|
|
138
|
+
### Verification (migration)
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
pnpm tsc --noEmit # must exit clean
|
|
142
|
+
grep -rE 'useXWagmiStore|useXWalletStore' src/ # empty — v2 exports neither
|
|
143
|
+
grep -rE 'SodaxWalletProvider.*(rpcConfig|initialState)' src/ # empty
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Manual: connections still survive page reload (localStorage key `xwagmi-store` was preserved for backward compat).
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
# Related skills
|
|
151
|
+
|
|
152
|
+
- `sodax-dapp-kit` — React hooks wrapping `@sodax/sdk`. Use `useWalletProvider` to bridge.
|
|
153
|
+
- `sodax-sdk` — for any direct SDK call from the React app (or for the SDK-level v1 → v2 work that often runs alongside this one).
|
|
154
|
+
- `sodax-wallet-sdk-core` — the underlying provider classes that `useWalletProvider` returns.
|
|
@@ -0,0 +1,103 @@
|
|
|
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 [`sodax-wallet-sdk-react` (migration mode)](../../migration-v1-to-v2/knowledge/).
|
|
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
|
+
// @ai-snippets-skip
|
|
76
|
+
<SodaxProvider config={sodaxConfig}> {/* @sodax/dapp-kit */}
|
|
77
|
+
<QueryClientProvider client={queryClient}>
|
|
78
|
+
<SodaxWalletProvider config={walletConfig}> {/* this package */}
|
|
79
|
+
{children}
|
|
80
|
+
</SodaxWalletProvider>
|
|
81
|
+
</QueryClientProvider>
|
|
82
|
+
</SodaxProvider>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`SodaxProvider` (from dapp-kit) wraps the lot. `QueryClientProvider` must wrap `SodaxWalletProvider` because hooks inside use React Query.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Conventions worth knowing
|
|
90
|
+
|
|
91
|
+
- **Hooks use a single options object.** `useXConnectors({ xChainType: 'EVM' })`, not positional args.
|
|
92
|
+
- **`xChainId` (chain key) and `xChainType` (family) are both accepted** by `useXAccount` and `useWalletProvider`. Pass one, not both.
|
|
93
|
+
- **`useXConnect` is a React Query mutation.** Pass an `IXConnector` to `mutateAsync`.
|
|
94
|
+
- **Persisted connections.** Connections survive reload via `localStorage` key `xwagmi-store`. Gate UI on `useConnectedChains().status === 'ready'` to avoid hydration flicker.
|
|
95
|
+
- **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.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Getting help
|
|
100
|
+
|
|
101
|
+
- API surface lookup: [`reference/`](./reference/).
|
|
102
|
+
- Bug or missing feature: [open an issue](https://github.com/icon-project/sodax-sdks/issues).
|
|
103
|
+
- Internal architecture (only relevant for SODAX maintainers): `../CLAUDE.md` in the package root.
|