@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,32 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
| Term | Definition |
|
|
4
|
+
|---|---|
|
|
5
|
+
| **Hub** | Sonic. The single chain through which every cross-chain operation routes. Hosts the asset manager, wallet abstraction, and vault contracts. |
|
|
6
|
+
| **Spoke** | Any of the 19 non-hub chains. Cross-chain operations enter and exit the system through spokes. |
|
|
7
|
+
| **Spoke service** | An internal SDK service (e.g. `EvmSpokeService`) that owns the chain-family-specific logic. Owned by `SpokeService` (singular, the router). Consumers never construct one. |
|
|
8
|
+
| **Chain key** | A string identifier for a chain (e.g. `'ethereum'`, `'0xa4b1.arbitrum'`). Type: `ChainKey` (full set) or `SpokeChainKey` (spoke chains only). Listed under `ChainKeys.*`. |
|
|
9
|
+
| **Chain family** | The class of chain (`'EVM'`, `'BITCOIN'`, `'SOLANA'`, …). Resolved via `getChainType(chainKey)`. |
|
|
10
|
+
| **Wallet provider** | A chain-specific signer/broadcaster (`IEvmWalletProvider`, etc.). Constructed by the consumer; passed into SDK calls. |
|
|
11
|
+
| **Intent** | A user-signed declaration of intended cross-chain action. The unit of solver-mediated swap. |
|
|
12
|
+
| **Solver** | An off-chain market maker that fulfills swap intents. The `SwapService` coordinates with the solver via `SolverApiService`. |
|
|
13
|
+
| **Relay** | The off-chain layer that propagates spoke→hub transactions. Public surface: `relayTxAndWaitPacket` and `submitTransaction` top-level functions (re-exported from `@sodax/sdk`). |
|
|
14
|
+
| **Relay chain id** | A bigint identifier used internally by the relay layer. **Different** from `ChainKey`. Convert via `sodax.config.getSpokeChainKeyFromIntentRelayChainId(BigInt(...))`. |
|
|
15
|
+
| **Vault** | Hub-side ERC4626 contract that holds wrapped/unified spoke tokens. Each `XToken` carries its `vault` address directly. |
|
|
16
|
+
| **Hub asset** | Hub-side token address representing a spoke asset on the hub chain. Each `XToken` carries its `hubAsset` address directly. |
|
|
17
|
+
| **Hub wallet abstraction** | A user-specific contract on the hub that holds funds during cross-chain ops. Resolved via `EvmHubProvider.getUserHubWalletAddress(...)`. |
|
|
18
|
+
| **`Result<T>`** | The `{ ok: true; value: T } \| { ok: false; error: E }` discriminated union returned by every async public method. |
|
|
19
|
+
| **`SodaxError<C>`** | The canonical error class. Discriminated by `(feature, code)`. |
|
|
20
|
+
| **Code (`SodaxErrorCode`)** | One of 13 reason-only error codes. See § 3. |
|
|
21
|
+
| **Feature (`SodaxFeature`)** | One of 8 producing features (`'swap'`, `'moneyMarket'`, …). |
|
|
22
|
+
| **Phase (`SodaxPhase`)** | The orchestration step at which an error occurred. See § 3. |
|
|
23
|
+
| **Action (`error.context.action`)** | The user-facing operation that triggered the error (`'supply'`, `'stake'`, `'migrateBaln'`, …). |
|
|
24
|
+
| **`raw: true / false`** | The discriminator on `WalletProviderSlot<K, Raw>`. `true` = build unsigned tx; `false` = sign and broadcast. |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Cross-references
|
|
30
|
+
|
|
31
|
+
- [`README.md`](README.md) — reference index.
|
|
32
|
+
- [`../architecture.md`](../architecture.md) — concepts behind these tables.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Public API surface
|
|
2
|
+
|
|
3
|
+
Import everything from `@sodax/sdk`. The barrel re-exports the entire `@sodax/types` surface — you don't need a separate `@sodax/types` dependency.
|
|
4
|
+
|
|
5
|
+
### Top-level exports
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
// Main entry
|
|
10
|
+
Sodax,
|
|
11
|
+
type SodaxConfig,
|
|
12
|
+
type DeepPartial,
|
|
13
|
+
|
|
14
|
+
// Chain keys + narrowing
|
|
15
|
+
ChainKeys,
|
|
16
|
+
type ChainKey,
|
|
17
|
+
type SpokeChainKey,
|
|
18
|
+
type HubChainKey,
|
|
19
|
+
type EvmChainKey,
|
|
20
|
+
getChainType,
|
|
21
|
+
isEvmChainKeyType,
|
|
22
|
+
isSolanaChainKeyType,
|
|
23
|
+
isStellarChainKeyType,
|
|
24
|
+
isSuiChainKeyType,
|
|
25
|
+
isIconChainKeyType,
|
|
26
|
+
isInjectiveChainKeyType,
|
|
27
|
+
isStacksChainKeyType,
|
|
28
|
+
isNearChainKeyType,
|
|
29
|
+
isBitcoinChainKeyType,
|
|
30
|
+
isHubChainKeyType,
|
|
31
|
+
type GetChainType,
|
|
32
|
+
type GetWalletProviderType,
|
|
33
|
+
type GetAddressType,
|
|
34
|
+
|
|
35
|
+
// Type system primitives
|
|
36
|
+
type Result,
|
|
37
|
+
type WalletProviderSlot,
|
|
38
|
+
type TxReturnType,
|
|
39
|
+
type EvmRawTransaction,
|
|
40
|
+
type SolanaRawTransaction,
|
|
41
|
+
// …per-chain raw-tx types
|
|
42
|
+
|
|
43
|
+
// Errors
|
|
44
|
+
SodaxError,
|
|
45
|
+
type SodaxErrorCode,
|
|
46
|
+
type SodaxFeature,
|
|
47
|
+
type SodaxPhase,
|
|
48
|
+
type SodaxErrorContext,
|
|
49
|
+
type RelayCode,
|
|
50
|
+
isSodaxError,
|
|
51
|
+
isFeatureError,
|
|
52
|
+
isCodeMember,
|
|
53
|
+
sodaxInvariant,
|
|
54
|
+
swapInvariant,
|
|
55
|
+
mmInvariant,
|
|
56
|
+
bridgeInvariant,
|
|
57
|
+
stakingInvariant,
|
|
58
|
+
migrationInvariant,
|
|
59
|
+
dexInvariant,
|
|
60
|
+
partnerInvariant,
|
|
61
|
+
recoveryInvariant,
|
|
62
|
+
mapRelayFailure,
|
|
63
|
+
|
|
64
|
+
// Tokens
|
|
65
|
+
type XToken,
|
|
66
|
+
type BtcAddressType,
|
|
67
|
+
|
|
68
|
+
// Service classes (constructed by Sodax — usually you don't import these directly)
|
|
69
|
+
// …
|
|
70
|
+
|
|
71
|
+
// Wallet provider interfaces
|
|
72
|
+
type IWalletProvider,
|
|
73
|
+
type IEvmWalletProvider,
|
|
74
|
+
type ISolanaWalletProvider,
|
|
75
|
+
type ISuiWalletProvider,
|
|
76
|
+
type IStellarWalletProvider,
|
|
77
|
+
type IIconWalletProvider,
|
|
78
|
+
type IInjectiveWalletProvider,
|
|
79
|
+
type IStacksWalletProvider,
|
|
80
|
+
type INearWalletProvider,
|
|
81
|
+
type IBitcoinWalletProvider,
|
|
82
|
+
|
|
83
|
+
// Param types (per feature)
|
|
84
|
+
type CreateIntentParams,
|
|
85
|
+
type CreateLimitOrderParams,
|
|
86
|
+
type MoneyMarketSupplyParams,
|
|
87
|
+
type MoneyMarketBorrowParams,
|
|
88
|
+
type MoneyMarketWithdrawParams,
|
|
89
|
+
type MoneyMarketRepayParams,
|
|
90
|
+
type StakeParams,
|
|
91
|
+
type UnstakeParams,
|
|
92
|
+
type InstantUnstakeParams,
|
|
93
|
+
type ClaimParams,
|
|
94
|
+
type CancelUnstakeParams,
|
|
95
|
+
type CreateAssetDepositParams,
|
|
96
|
+
type CreateAssetWithdrawParams,
|
|
97
|
+
type ClSupplyParams,
|
|
98
|
+
type ClIncreaseLiquidityParams,
|
|
99
|
+
type ClDecreaseLiquidityParams,
|
|
100
|
+
type ClClaimRewardsParams,
|
|
101
|
+
type MigrationParams,
|
|
102
|
+
type UnifiedBnUSDMigrateParams,
|
|
103
|
+
// …
|
|
104
|
+
|
|
105
|
+
// Backend / relay
|
|
106
|
+
type IConfigApi,
|
|
107
|
+
type SubmitSwapTxRequest,
|
|
108
|
+
type SubmitSwapTxResponse,
|
|
109
|
+
relayTxAndWaitPacket, // function — runs spoke→hub relay submit + wait
|
|
110
|
+
submitTransaction, // function — relay submit ack only
|
|
111
|
+
type RelayExtraData,
|
|
112
|
+
type IntentRelayChainId,
|
|
113
|
+
|
|
114
|
+
// Read shapes
|
|
115
|
+
type Intent,
|
|
116
|
+
type IntentResponse,
|
|
117
|
+
type SwapResponse,
|
|
118
|
+
type CreateIntentResult,
|
|
119
|
+
type TxHashPair,
|
|
120
|
+
} from '@sodax/sdk';
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This is a partial list — see `src/index.ts` of the published tarball for the authoritative barrel.
|
|
124
|
+
|
|
125
|
+
### Rules
|
|
126
|
+
|
|
127
|
+
- **Import only from `@sodax/sdk` root.** No deep imports from `dist/...`.
|
|
128
|
+
- **Do not depend on `@sodax/types` separately.** It's a transitive of `@sodax/sdk` (force-bundled via tsup `noExternal`); declaring it as a direct dependency invites version skew.
|
|
129
|
+
- **Stable contract:** every export above is part of the public API. Anything not exported from the root barrel is internal — don't reach for it via `dist` paths.
|
|
130
|
+
- **Tarball contents:** `dist/` (compiled JS + types). Nothing else ships. Consumer-facing AI docs (this tree) are shipped separately via [`@sodax/skills`](https://github.com/icon-project/sodax-sdks/tree/main/packages/skills).
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Cross-references
|
|
136
|
+
|
|
137
|
+
- [`README.md`](README.md) — reference index.
|
|
138
|
+
- [`../architecture.md`](../architecture.md) — concepts behind these tables.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Wallet provider interfaces
|
|
2
|
+
|
|
3
|
+
Every chain family has an `I*WalletProvider` interface. Each declares a `readonly chainType: '<NAME>'` literal field for runtime discrimination.
|
|
4
|
+
|
|
5
|
+
| Family | Interface | `chainType` literal | Implementation |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| EVM | `IEvmWalletProvider` | `'EVM'` | `EvmWalletProvider` (private-key or browser-extension) |
|
|
8
|
+
| Solana | `ISolanaWalletProvider` | `'SOLANA'` | `SolanaWalletProvider` |
|
|
9
|
+
| Sui | `ISuiWalletProvider` | `'SUI'` | `SuiWalletProvider` |
|
|
10
|
+
| Stellar | `IStellarWalletProvider` | `'STELLAR'` | `StellarWalletProvider` |
|
|
11
|
+
| ICON | `IIconWalletProvider` | `'ICON'` | `IconWalletProvider` (uses Hana-extension helper functions for browser; see `../chain-specifics.md` § 4) |
|
|
12
|
+
| Injective | `IInjectiveWalletProvider` | `'INJECTIVE'` | `InjectiveWalletProvider` |
|
|
13
|
+
| Stacks | `IStacksWalletProvider` | `'STACKS'` | `StacksWalletProvider` |
|
|
14
|
+
| NEAR | `INearWalletProvider` | `'NEAR'` | `NearWalletProvider` |
|
|
15
|
+
| Bitcoin | `IBitcoinWalletProvider` | `'BITCOIN'` | `BTCWalletProvider` (PSBT) |
|
|
16
|
+
|
|
17
|
+
### Common methods
|
|
18
|
+
|
|
19
|
+
Every `I*WalletProvider` has:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
getWalletAddress(): Promise<string>;
|
|
23
|
+
// Returns the chain-specific address (typed as `0x${string}` for EVM, base58 for Solana, etc.).
|
|
24
|
+
readonly chainType: '<FAMILY>';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Plus chain-specific signing/broadcasting methods. Each interface declares the methods consumers must implement to satisfy it; consumers usually don't call these methods directly — they pass the provider object to SDK methods. **Implementations are not part of `@sodax/sdk`** — write your own to satisfy the interface, or use `@sodax/wallet-sdk-core` (a separate SODAX package, install separately) which ships ready-made implementations for all 9 chain families with both private-key (Node) and browser-extension (dApp) modes.
|
|
28
|
+
|
|
29
|
+
### `GetWalletProviderType<K>`
|
|
30
|
+
|
|
31
|
+
Given a chain key literal `K`, resolves to the exact wallet provider interface for that chain:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
GetWalletProviderType<typeof ChainKeys.ETHEREUM_MAINNET> // IEvmWalletProvider
|
|
35
|
+
GetWalletProviderType<typeof ChainKeys.SOLANA_MAINNET> // ISolanaWalletProvider
|
|
36
|
+
GetWalletProviderType<typeof ChainKeys.BITCOIN_MAINNET> // IBitcoinWalletProvider
|
|
37
|
+
GetWalletProviderType<SpokeChainKey> // IWalletProvider (broad union)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### `IWalletProvider` (broad union)
|
|
41
|
+
|
|
42
|
+
The discriminated union of all 9 `I*WalletProvider` interfaces. Useful when a function accepts any chain's wallet provider:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import type { IWalletProvider } from '@sodax/sdk';
|
|
46
|
+
|
|
47
|
+
function logChain(wp: IWalletProvider) {
|
|
48
|
+
console.log(wp.chainType);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Implementing the interfaces
|
|
53
|
+
|
|
54
|
+
Each `I*WalletProvider` interface defines the methods consumers must implement; credentials, RPC clients, and browser-extension wiring are implementation concerns and intentionally outside the SDK. The SODAX-provided reference implementations in `@sodax/wallet-sdk-core` (separate package) accept either `{ privateKey, rpcUrl }` for Node / scripts or chain-specific browser-extension shapes (`{ walletClient }` for EVM via viem, `{ adapter }` for Solana, etc.) — refer to that package's documentation for specifics.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Cross-references
|
|
60
|
+
|
|
61
|
+
- [`README.md`](README.md) — reference index.
|
|
62
|
+
- [`../architecture.md`](../architecture.md) — concepts behind these tables.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sodax-sdk-migration
|
|
3
|
+
description: 'Granular skill for the @sodax/sdk v2 token-migration feature only — `MigrationService` (`sodax.migration`) covering ICX ↔ SODA, legacy bnUSD ↔ new bnUSD, and BALN → SODA with lockup multipliers. Use when the task is migrating legacy ICON-ecosystem tokens to SODAX (e.g. "migrate ICX to SODA", "revert SODA back to ICX", "swap legacy bnUSD on Sui/Stellar/ICON to new bnUSD", "migrate BALN with lock period for reward multiplier", "claim staked BALN"). IMPORTANT — this is NOT the same as v1 → v2 SDK migration (porting old SDK code). That is a separate cross-cutting concern handled by the broad sodax-sdk skill in migration mode and the migration-v1-to-v2/ knowledge subtree. Same word, different concept. Skill links into the parent sodax-sdk knowledge tree.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Token migration (Core SDK granular skill)
|
|
7
|
+
|
|
8
|
+
Granular skill for `MigrationService` — the SDK module that migrates legacy ICON-ecosystem tokens. Access via `sodax.migration` (with sub-services `sodax.migration.icxMigration`, `sodax.migration.bnUSDMigrationService`, `sodax.migration.balnSwapService`). Feature tag: `'migration'`.
|
|
9
|
+
|
|
10
|
+
> **Important disambiguation.** This skill is about the `MigrationService` SDK module. It is **NOT** about porting v1 SDK code to v2 — that lives under the broad `sodax-sdk` skill (migration mode) and the [`../migration-v1-to-v2/knowledge/`](../migration-v1-to-v2/knowledge/) subtree of this package. Same word, different concept.
|
|
11
|
+
|
|
12
|
+
## Step 0 — Confirm this IS a token-protocol migration
|
|
13
|
+
|
|
14
|
+
The word "migrate" is overloaded. This skill only handles **legacy ICON-ecosystem token swaps to SODAX assets** (ICX → SODA, legacy bnUSD → new bnUSD, BALN → SODA). If the user phrases the task as:
|
|
15
|
+
|
|
16
|
+
- *"move / send / transfer SODA from chain A to chain B"* → that's a **bridge** (vault-pair) or a **swap** (solver-routed). Load `sodax-sdk-bridge` or `sodax-sdk-swap` instead.
|
|
17
|
+
- *"migrate my v1 SDK code to v2"* → that's the SDK port. Load the broad `sodax-sdk` skill in migration mode and the `migration-v1-to-v2/` knowledge subtree.
|
|
18
|
+
|
|
19
|
+
Only continue here if the task involves one of the three legacy-token sources below.
|
|
20
|
+
|
|
21
|
+
## Step 1 — Clarify with user before coding
|
|
22
|
+
|
|
23
|
+
1. **Which token are you migrating?**
|
|
24
|
+
- **ICX / wICX** ↔ SODA → `sodax.migration.icxMigration`.
|
|
25
|
+
- **Legacy bnUSD** (ICON / Sui / Stellar) ↔ **new bnUSD** (EVM chains) → `sodax.migration.bnUSDMigrationService`.
|
|
26
|
+
- **BALN** → SODA with optional lockup (0–24 months, multiplier 0.5x–1.5x) → `sodax.migration.balnSwapService`.
|
|
27
|
+
2. **Forward** (legacy → new) **or revert** (new → legacy, ICX only)?
|
|
28
|
+
3. **For BALN: lock period?** No lock = baseline; longer lock = higher reward multiplier.
|
|
29
|
+
4. **Signed or unsigned-tx flow?**
|
|
30
|
+
5. **Need orchestrated full flow** (`migrateXxx`) **or just intent creation** (`createMigrateXxxIntent`)?
|
|
31
|
+
|
|
32
|
+
## Integration workflow
|
|
33
|
+
|
|
34
|
+
1. [`../integration/knowledge/ai-rules.md`](../integration/knowledge/ai-rules.md).
|
|
35
|
+
2. [`../integration/knowledge/features/migration.md`](../integration/knowledge/features/migration.md) — `MigrationService` API surface and the three sub-services.
|
|
36
|
+
3. Path-specific recipe:
|
|
37
|
+
- Signed → [`../integration/knowledge/recipes/signed-tx-flow.md`](../integration/knowledge/recipes/signed-tx-flow.md)
|
|
38
|
+
- Unsigned → [`../integration/knowledge/recipes/raw-tx-flow.md`](../integration/knowledge/recipes/raw-tx-flow.md)
|
|
39
|
+
4. Errors (`feature: 'migration'`) → [`../integration/knowledge/reference/error-codes.md`](../integration/knowledge/reference/error-codes.md).
|
|
40
|
+
|
|
41
|
+
### Token-migration-specific anti-patterns
|
|
42
|
+
|
|
43
|
+
- **Assuming `BalnSwapService.stake/unstake/claim/...` return `Result<T>`.** They still THROW — deliberate tech debt. Wrap them in `try/catch` until cleaned up.
|
|
44
|
+
- **Using `migration` (the SDK module) and `migration-v1-to-v2` (the SDK port) interchangeably.** Different concerns; reading one playbook for the other will produce broken code.
|
|
45
|
+
- **Skipping `getAvailableAmount` for partial ICX migrations.** Tells you how much SODA the user can claim from a partial migration.
|
|
46
|
+
|
|
47
|
+
## Migration workflow (v1 → v2 of the SDK itself)
|
|
48
|
+
|
|
49
|
+
If the user is porting v1 `MigrationService` code to v2:
|
|
50
|
+
|
|
51
|
+
1. [`../migration-v1-to-v2/knowledge/ai-rules.md`](../migration-v1-to-v2/knowledge/ai-rules.md).
|
|
52
|
+
2. [`../migration-v1-to-v2/knowledge/features/migration.md`](../migration-v1-to-v2/knowledge/features/migration.md) — v1 `MigrationError` → v2 `SodaxError<C>` with `feature: 'migration'`. Note the BALN lock-method carve-out (still throws).
|
|
53
|
+
|
|
54
|
+
## Verification
|
|
55
|
+
|
|
56
|
+
1. `pnpm tsc --noEmit` clean.
|
|
57
|
+
2. Every `await sodax.migration.<method>(...)` (orchestrators + intent creators) has `if (!result.ok)`.
|
|
58
|
+
3. BALN lock-method calls (`stake`, `unstake`, `claim`, `claimUnstaked`, `cancelUnstake`, `getDetailedUserLocks`) remain wrapped in `try/catch` — they do not return `Result<T>`.
|
|
59
|
+
|
|
60
|
+
## Related granular skills (same family)
|
|
61
|
+
|
|
62
|
+
- [`../staking/SKILL.md`](../staking/SKILL.md) — generic SODA staking (different from BALN lockup, which migrates BALN → SODA in one step).
|
|
63
|
+
- [`../recovery/SKILL.md`](../recovery/SKILL.md) — recovery for stuck migration assets on the hub.
|
|
64
|
+
|
|
65
|
+
For multi-feature tasks, load the broad [`sodax-sdk` skill](../SKILL.md).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Migration — `@sodax/sdk` v1 → v2
|
|
2
|
+
|
|
3
|
+
This tree is the v1 → v2 migration playbook for **existing consumers**. If you're starting fresh on v2 with no v1 code to port, skip to [`README.md`](../../integration/knowledge/README.md).
|
|
4
|
+
|
|
5
|
+
## What v2 changes (the 30-second version)
|
|
6
|
+
|
|
7
|
+
v2 was a deep architectural reshape, not a feature release. Five orthogonal changes account for ~95% of the breakage your typecheck will surface:
|
|
8
|
+
|
|
9
|
+
1. **Per-chain `*SpokeProvider` classes are gone.** Routing is by chain key (`srcChainKey: ChainKeys.ETHEREUM_MAINNET`). The SDK dispatches to the right per-chain spoke service internally; consumers pass `walletProvider` directly into payloads.
|
|
10
|
+
2. **`Result<T>` everywhere.** Every async public method on every service returns `Promise<Result<T, SodaxError<C>>>`. v1 throw-on-error patterns are gone.
|
|
11
|
+
3. **One canonical error class.** `SodaxError<C>` with a closed 13-code vocabulary plus `feature: 'swap' | 'moneyMarket' | …`. The per-module typed error unions (`MoneyMarketError<Code>`, `IntentError<Code>`, `StakingError<Code>`, `BridgeError<Code>`, `MigrationError<Code>`, `AssetServiceError<Code>`, `ConcentratedLiquidityError<Code>`, partner errors, …) are deleted.
|
|
12
|
+
4. **`WalletProviderSlot<K, Raw>` is the discriminated union.** Every signed-execution method takes `{ raw: false, walletProvider }` (chain-narrowed via `GetWalletProviderType<K>`); every raw-tx-building method takes `{ raw: true }` (no wallet provider). Compile-time enforced.
|
|
13
|
+
5. **`ConfigService` is the preferred lookup surface.** `hubAssets` and `*_MAINNET_CHAIN_ID` constants **are deleted** (won't compile). `moneyMarketSupportedTokens`, `SodaTokens`, `supportedSpokeChains` **are still exported** as packaged-default constants (so v1 imports keep compiling), but prefer `sodax.config.*` / `sodax.moneyMarket.getSupportedTokens*()` — those reflect backend-driven runtime updates after `await sodax.config.initialize()`. See [`breaking-changes/architecture.md`](breaking-changes/architecture.md) § 2 for the per-symbol table.
|
|
14
|
+
|
|
15
|
+
The remainder is per-feature (return shape diffs, field renames, new required params like `srcAddress`).
|
|
16
|
+
|
|
17
|
+
## Reading order
|
|
18
|
+
|
|
19
|
+
Read in this order. Each step builds on the last.
|
|
20
|
+
|
|
21
|
+
1. **[`ai-rules.md`](ai-rules.md)** — DO / DO NOT / workflow / stop-conditions. Read first, then dive in.
|
|
22
|
+
2. **This file.** Cross-cutting glossary below + reference list of breaking-changes / features / checklist.
|
|
23
|
+
3. **[`checklist.md`](checklist.md)** — the 17-step cross-cutting migration checklist. Walk top-down, mark items off as you go.
|
|
24
|
+
4. **[`breaking-changes/type-system.md`](breaking-changes/type-system.md)** — fix every import + type-level error first. Once your imports compile, the rest is tractable.
|
|
25
|
+
5. **[`breaking-changes/architecture.md`](breaking-changes/architecture.md)** — `*SpokeProvider` deletion, `ConfigService` replacing static lookups, relay-flow reshape, `sodaxInvariant` + per-feature aliases.
|
|
26
|
+
6. **[`breaking-changes/result-and-errors.md`](breaking-changes/result-and-errors.md)** — convert call-site error handling, then run the v1↔v2 error-code crosswalk.
|
|
27
|
+
7. **[`features/<x>.md`](features/)** — port the call sites for each feature you use. Pair with [`features/`](../../integration/knowledge/features/) (same filename) when you need the v2 design context.
|
|
28
|
+
8. **[`recipes.md`](recipes.md)** — codemods and adapters when full conversion in one pass isn't realistic.
|
|
29
|
+
|
|
30
|
+
## v1 ↔ v2 glossary (terms that changed meaning)
|
|
31
|
+
|
|
32
|
+
Same word, different concept across versions. Skim before reading the breaking-changes files — this dictionary prevents the most common porting confusions.
|
|
33
|
+
|
|
34
|
+
| Term | v1 meaning | v2 meaning |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| **spoke provider** | A per-chain class instance (`EvmSpokeProvider`, `SolanaSpokeProvider`, …) consumers constructed and passed into every SDK call. | A per-chain-family service inside the SDK, owned by `SpokeService` and routed to via `getSpokeService(chainKey)`. Consumers never construct one. |
|
|
37
|
+
| **chain id** | Numeric or string identifier varying by chain family. v1 had `*_MAINNET_CHAIN_ID` constants, often unifying as `SpokeChainId`. | A string literal from `ChainKeys.*` (the value union is `SpokeChainKey`). `ChainKeys.ICON_MAINNET` is `'0x1.icon'` (a string), not a number. |
|
|
38
|
+
| **error / `*Error<Code>`** | One typed-error union per module: `MoneyMarketError<MoneyMarketErrorCode>`, `IntentError<IntentErrorCode>`, etc. Discriminated by `error.code`. | One canonical class `SodaxError<C>` for all features. 13-code reason vocabulary. Discriminated by `(error.feature, error.code)`; the producing feature is a first-class field. |
|
|
39
|
+
| **chain narrowing** | A combination of `instanceof EvmSpokeProvider` and string equality on `chainConfig.chain.type`. | Pure type-level narrowing via `GetChainType<K>` and `GetWalletProviderType<K>` flowing from a literal `srcChainKey` generic. Runtime variant: `walletProvider.chainType === 'EVM'` (every `I*WalletProvider` declares a `readonly chainType` literal). |
|
|
40
|
+
| **raw tx** | An ad-hoc method on each spoke provider, sometimes named `executeXxx`, returning a chain-specific payload. | The discriminator `{ raw: true }` on the standard SDK call shape. Return type narrows via `TxReturnType<K, true>` (`EvmRawTransaction`, `SolanaRawTransaction`, …). |
|
|
41
|
+
| **config** | A `SodaxConfig` object passed at construction with hard-coded chain/token tables. Solver endpoints lived under `SodaxConfig.swaps`. | A `Sodax` instance owns a `ConfigService` that loads from the backend API, with packaged defaults as fallback. `sodax.config.*` is the lookup surface. **Solver endpoints moved to `SodaxConfig.solver`** (not `swaps`); `swaps` is `SwapsConfig` (supported tokens). |
|
|
42
|
+
| **`xChainId` field on tokens** | Field name on the `Token` type. | Renamed: `XToken.chainKey`. Type also renamed: `Token` → `XToken`. |
|
|
43
|
+
| **`hubAssets` / `moneyMarketSupportedTokens`** | Static `Record` global maps imported and walked. | `hubAssets` **deleted** — won't compile. `moneyMarketSupportedTokens` **still exported** as a packaged default, but prefer `sodax.config.*` and `sodax.moneyMarket.getSupportedTokens*()` so backend updates take effect. Each `XToken` now carries `vault` and `hubAsset` directly. |
|
|
44
|
+
| **`SubmitSwapTxRequest.srcChainId`** | Numeric chain id field on the backend submit-swap request. | Renamed: `srcChainKey: SpokeChainKey`. |
|
|
45
|
+
| **`Intent.srcChain` / `Intent.dstChain`** | Read shape: `IntentRelayChainId` (bigint). | **Unchanged.** This is the relay chain id, not a spoke chain key. A blanket grep-replace `srcChain`→`srcChainKey` will break this. |
|
|
46
|
+
| **`AddressType`** | Bitcoin-specific address-type union. | Renamed: `BtcAddressType`. (Generic name freed up.) |
|
|
47
|
+
|
|
48
|
+
## Cross-references to integration
|
|
49
|
+
|
|
50
|
+
Every breaking-change file in this tree has a v2-design counterpart in [`sodax-sdk` (integration mode)](../../integration/knowledge/). Follow the link when "what does v2 expect instead?" comes up:
|
|
51
|
+
|
|
52
|
+
- [`breaking-changes/type-system.md`](breaking-changes/type-system.md) ↔ [`architecture.md`](../../integration/knowledge/architecture.md) (§ ChainKeys, WalletProviderSlot, Result, SodaxError) and [`reference/`](../../integration/knowledge/reference/) (chain-key + error-code tables).
|
|
53
|
+
- [`breaking-changes/architecture.md`](breaking-changes/architecture.md) ↔ [`architecture.md`](../../integration/knowledge/architecture.md) (§ SpokeService, Sodax facade, ConfigService, relay layer).
|
|
54
|
+
- [`breaking-changes/result-and-errors.md`](breaking-changes/result-and-errors.md) ↔ [`recipes/`](../../integration/knowledge/recipes/) (§ Result handling, error discrimination).
|
|
55
|
+
- [`features/<x>.md`](features/) ↔ [`features/`](../../integration/knowledge/features/) (same filename).
|
|
56
|
+
- [`recipes.md`](recipes.md) ↔ no integration counterpart (migration-only patterns).
|
|
57
|
+
|
|
58
|
+
The pair-completeness rule: every file in `migration/features/` has a sibling in `integration/features/` with the same filename. Use this when you're stuck in one and want the other view.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# AI rules — `@sodax/sdk` v1 → v2 migration
|
|
2
|
+
|
|
3
|
+
DO / DO NOT / workflow / stop conditions for AI agents porting v1 `@sodax/sdk` consumer code to v2. Read this **before** the per-feature migration files — these rules prevent the most common porting mistakes.
|
|
4
|
+
|
|
5
|
+
## Workflow (do these in order)
|
|
6
|
+
|
|
7
|
+
1. **Survey the consumer.** Grep for v1 fingerprints to scope the migration:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm tsc --noEmit > /tmp/v1-errors.log 2>&1 # baseline error population
|
|
11
|
+
grep -rE '_MAINNET_CHAIN_ID\b|\bSpokeProvider\b|\bxChainId\b|\bSpokeChainId\b|hubAssets|moneyMarketSupportedTokens' src/
|
|
12
|
+
grep -rE 'instanceof (MoneyMarketError|IntentError|StakingError|BridgeError|MigrationError|AssetServiceError|ConcentratedLiquidityError|RelayError)' src/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. **Read the cross-cutting docs first.** [`README.md`](README.md) → [`breaking-changes/type-system.md`](breaking-changes/type-system.md) → [`breaking-changes/architecture.md`](breaking-changes/architecture.md) → [`breaking-changes/result-and-errors.md`](breaking-changes/result-and-errors.md). Then [`features/<x>.md`](features/) for each feature you use.
|
|
16
|
+
3. **Apply changes in order: type-level first, runtime second.** Type-level renames don't affect behavior; runtime patterns (Result branching, error model) require thinking. Doing them in the wrong order means the typecheck stays noisy and you can't see the real problems.
|
|
17
|
+
4. **Re-run `pnpm tsc --noEmit` after every step.** Each step should reduce the error count. If errors grow, you've introduced something — back out and try again.
|
|
18
|
+
|
|
19
|
+
> **v2 cross-cutting rules apply too.** Everything in [`integration/ai-rules.md`](../../integration/knowledge/ai-rules.md) (Result branching, `isSodaxError`, `TxHashPair`, `BalnSwapService` throws, package-root imports, no `@sodax/types` peer dep, …) holds when writing migrated code. The DO / DO NOT below are **migration-specific** rules on top.
|
|
20
|
+
|
|
21
|
+
## DO (migration-specific)
|
|
22
|
+
|
|
23
|
+
- **DO** start with mechanical type renames:
|
|
24
|
+
- `*_MAINNET_CHAIN_ID` → `ChainKeys.*` (regex: `(\w+)_MAINNET_CHAIN_ID` → `ChainKeys.$1_MAINNET`).
|
|
25
|
+
- `xChainId` → `chainKey` (on `XToken` and tokens-likes).
|
|
26
|
+
- `SpokeChainId` / `ChainId` → `SpokeChainKey`.
|
|
27
|
+
- `Token` → `XToken`.
|
|
28
|
+
- `AddressType` → `BtcAddressType` (only at `@sodax/types` import sites).
|
|
29
|
+
- **DO** add `srcChainKey` + `srcAddress` to every action params object (every `MoneyMarketSupplyParams`, `StakeParams`, `CreateAssetDepositParams`, etc. now requires both).
|
|
30
|
+
- **DO** add the `raw: false` (or `raw: true`) discriminator to every signed call shape that previously took `{ intentParams, spokeProvider }`. Also rename `intentParams` → `params` and drop `spokeProvider` in favor of `walletProvider`.
|
|
31
|
+
- **DO** convert v1 `try/catch` to `result.ok` branching last — touching every call site is the biggest commit, easiest to do once the type-level changes settled.
|
|
32
|
+
- **DO** treat the `Result<T>` ↔ `try/catch` migration as the *highest-leverage* change. If you stop early, ensure result branching is at least in place even if the surrounding error UX is rough.
|
|
33
|
+
|
|
34
|
+
## DO NOT (migration-specific)
|
|
35
|
+
|
|
36
|
+
- **DO NOT** grep-replace `srcChain` → `srcChainKey` blindly. The `Intent` *read* shape (returned from `createIntent` / `getIntentByHash` / etc.) keeps `srcChain` and `dstChain` as `IntentRelayChainId` (bigint) — those did **not** rename. Only **request** types changed (`CreateIntentParams`, `CreateLimitOrderParams`, `SubmitSwapTxRequest`).
|
|
37
|
+
- **DO NOT** treat `instanceof MoneyMarketError` (or any other module-error class) as still working. Those classes are deleted. Replace with `isSodaxError(e) && e.feature === 'moneyMarket'`.
|
|
38
|
+
- **DO NOT** pass v1 spoke-side state into `getStakingInfo(hubAddress)`. The method is still public in v2 but expects a *hub* address. v1 call sites that used `spokeProvider`-derived data should switch to `getStakingInfoFromSpoke(srcAddress, srcChainKey)` which derives the hub wallet internally.
|
|
39
|
+
- **DO NOT** keep `try { await sodax.swaps.createIntent(...) } catch` and expect to inspect `e.code === 'CREATE_INTENT_FAILED'`. The v2 code is `INTENT_CREATION_FAILED` and lives on `result.error.code` (Result branch), not on a thrown error. See [`reference/error-code-crosswalk.md`](reference/error-code-crosswalk.md) for the full v1 → v2 code crosswalk.
|
|
40
|
+
|
|
41
|
+
## Stop conditions (defer to user)
|
|
42
|
+
|
|
43
|
+
| Signal | Why stop |
|
|
44
|
+
|---|---|
|
|
45
|
+
| v1 code uses framework-layer wrapper hooks (any `use*` identifier that wraps SDK calls rather than calling `@sodax/sdk` directly) | This migration tree covers Core SDK call sites only. Framework-layer migrations live in their own skills under `@sodax/skills` (e.g. `sodax-dapp-kit` (migration mode), `sodax-wallet-sdk-react` (migration mode)). Tell the user to load those. |
|
|
46
|
+
| v1 code uses `@sodax/wallet-sdk-core` classes | Those classes still exist in v2 of that separate package. Their constructor shapes may have changed — refer to that package's docs, not this tree. |
|
|
47
|
+
| Consumer wants to skip the `Result<T>` migration | Explain that v2 SDK calls don't throw for SDK-level failures; without `result.ok` branching the consumer silently swallows errors. Don't silently skip. |
|
|
48
|
+
| Consumer maintains a `*SpokeProvider` wrapper / shim | Don't try to recreate a v1-shaped wrapper in v2 — pass `walletProvider` directly into call payloads. The wrapper isn't doing useful work in v2's design. |
|
|
49
|
+
|
|
50
|
+
## Verification protocol
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# 1. Typecheck must reach zero errors.
|
|
54
|
+
pnpm tsc --noEmit
|
|
55
|
+
|
|
56
|
+
# 2. No leftover v1 fingerprints.
|
|
57
|
+
grep -rE '_MAINNET_CHAIN_ID\b|\bxChainId\b|\bSpokeChainId\b|\bSpokeProvider\b|hubAssets|moneyMarketSupportedTokens' src/ # should be empty
|
|
58
|
+
|
|
59
|
+
# 3. No leftover v1 error type imports.
|
|
60
|
+
grep -rE 'MoneyMarketError|IntentError|StakingError|BridgeError|MigrationError|AssetServiceError|ConcentratedLiquidityError|RelayError' src/ # should be empty
|
|
61
|
+
|
|
62
|
+
# 4. No leftover try/catch around SDK calls expecting to catch SDK-level failures.
|
|
63
|
+
# (Manual review — heuristic, not mechanical.)
|
|
64
|
+
grep -rB1 -A3 'try {' src/ | grep -A2 'await sodax\.' # eyeball each match
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Done criteria
|
|
68
|
+
|
|
69
|
+
- [ ] `pnpm tsc --noEmit` returns 0 errors.
|
|
70
|
+
- [ ] No `*_MAINNET_CHAIN_ID` references remain.
|
|
71
|
+
- [ ] No `xChainId` field accesses remain.
|
|
72
|
+
- [ ] No `SpokeProvider` / `*SpokeProvider` references remain.
|
|
73
|
+
- [ ] No imports of `MoneyMarketError`, `IntentError`, `StakingError`, etc.
|
|
74
|
+
- [ ] Every `await sodax.<feature>.<method>(...)` call site has `if (!result.ok)` branching.
|
|
75
|
+
- [ ] `instanceof SodaxError` is replaced with `isSodaxError(e)` in cross-bundle code.
|
|
76
|
+
- [ ] `BalnSwapService` lock methods are wrapped in `try/catch` (still-throws carve-out).
|