@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,341 @@
|
|
|
1
|
+
# Type-system breaking changes — v1 → v2
|
|
2
|
+
|
|
3
|
+
Every type-level rename and shape change introduced by v2. Fix these first — once your imports compile, every other migration step is tractable. The errors you'll see during this phase live in three buckets: **import resolution** (a symbol moved or was deleted), **field access** (a field renamed), and **shape mismatch** (a generic added a required parameter, a return type changed).
|
|
4
|
+
|
|
5
|
+
> v1 source the comparisons below cite: `github.com/icon-project/sodax-frontend` (branch `sdk-v1-main`), `packages/sdk` and `packages/types`. v2 source: this package's `src/`.
|
|
6
|
+
|
|
7
|
+
## Section index
|
|
8
|
+
|
|
9
|
+
1. [Chain identifiers](#1-chain-identifiers) — `*_MAINNET_CHAIN_ID` → `ChainKeys.*`. The single biggest mechanical migration.
|
|
10
|
+
2. [`@sodax/types` package surface](#2-sodaxtypes-package-surface) — what to import, what got renamed, what got deleted.
|
|
11
|
+
3. [Wallet-provider typing](#3-wallet-provider-typing) — `GetWalletProviderType<K>` and `WalletProviderSlot<K, Raw>` replace ad-hoc spoke-provider classes.
|
|
12
|
+
4. [`Token` / `XToken` field renames](#4-token--xtoken-field-renames) — `xChainId` → `chainKey`; `Token` → `XToken`.
|
|
13
|
+
5. [`RpcConfig` reshape](#5-rpcconfig-reshape) — now keyed by `ChainKey` values; chain-family-specific shapes for Bitcoin and Stellar.
|
|
14
|
+
6. [`IConfigApi` Result-wrapping](#6-iconfigapi-result-wrapping) — every method returns `Promise<Result<T>>`.
|
|
15
|
+
7. [Address-type rename](#7-address-type-rename) — `AddressType` → `BtcAddressType`.
|
|
16
|
+
8. [Wallet-provider `chainType` discriminant](#8-wallet-provider-chaintype-discriminant) — every `I*WalletProvider` declares a literal field.
|
|
17
|
+
9. [`ChainId` / `SpokeChainId` → `SpokeChainKey`](#9-chainid--spokechainid--spokechainkey) — type alias rename.
|
|
18
|
+
10. [Deleted module-error types](#10-deleted-module-error-types) — covered structurally here, semantics in [`result-and-errors.md`](result-and-errors.md).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 1. Chain identifiers
|
|
23
|
+
|
|
24
|
+
v1 exported one constant per chain (`SONIC_MAINNET_CHAIN_ID`, `ARBITRUM_MAINNET_CHAIN_ID`, …). v2 collapses them into a single `ChainKeys` object whose values are the same string union exposed as the `ChainKey` type. The constants and their old union (`SpokeChainId` / `ChainId`) are deleted.
|
|
25
|
+
|
|
26
|
+
### Import migration
|
|
27
|
+
|
|
28
|
+
```diff
|
|
29
|
+
- import {
|
|
30
|
+
- SONIC_MAINNET_CHAIN_ID,
|
|
31
|
+
- ARBITRUM_MAINNET_CHAIN_ID,
|
|
32
|
+
- AVALANCHE_MAINNET_CHAIN_ID,
|
|
33
|
+
- // ...
|
|
34
|
+
- } from '@sodax/types';
|
|
35
|
+
+ import { ChainKeys } from '@sodax/sdk'; // re-exported from @sodax/types
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> Prefer importing `ChainKeys` from `@sodax/sdk` — see [§2](#2-sodaxtypes-package-surface). Importing from `@sodax/types` still works but adds an unnecessary peer dependency.
|
|
39
|
+
|
|
40
|
+
### Full mapping table
|
|
41
|
+
|
|
42
|
+
| v1 constant | v2 `ChainKeys.*` | String value |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `SONIC_MAINNET_CHAIN_ID` | `ChainKeys.SONIC_MAINNET` | `'sonic'` |
|
|
45
|
+
| `ARBITRUM_MAINNET_CHAIN_ID` | `ChainKeys.ARBITRUM_MAINNET` | `'0xa4b1.arbitrum'` |
|
|
46
|
+
| `AVALANCHE_MAINNET_CHAIN_ID` | `ChainKeys.AVALANCHE_MAINNET` | `'0xa86a.avax'` |
|
|
47
|
+
| `BASE_MAINNET_CHAIN_ID` | `ChainKeys.BASE_MAINNET` | `'0x2105.base'` |
|
|
48
|
+
| `BSC_MAINNET_CHAIN_ID` | `ChainKeys.BSC_MAINNET` | `'0x38.bsc'` |
|
|
49
|
+
| `ETHEREUM_MAINNET_CHAIN_ID` | `ChainKeys.ETHEREUM_MAINNET` | `'ethereum'` |
|
|
50
|
+
| `HYPEREVM_MAINNET_CHAIN_ID` | `ChainKeys.HYPEREVM_MAINNET` | `'hyper'` |
|
|
51
|
+
| `ICON_MAINNET_CHAIN_ID` | `ChainKeys.ICON_MAINNET` | `'0x1.icon'` |
|
|
52
|
+
| `INJECTIVE_MAINNET_CHAIN_ID` | `ChainKeys.INJECTIVE_MAINNET` | `'injective-1'` |
|
|
53
|
+
| `KAIA_MAINNET_CHAIN_ID` | `ChainKeys.KAIA_MAINNET` | `'0x2019.kaia'` |
|
|
54
|
+
| `LIGHTLINK_MAINNET_CHAIN_ID` | `ChainKeys.LIGHTLINK_MAINNET` | `'lightlink'` |
|
|
55
|
+
| `NEAR_MAINNET_CHAIN_ID` | `ChainKeys.NEAR_MAINNET` | `'near'` |
|
|
56
|
+
| `OPTIMISM_MAINNET_CHAIN_ID` | `ChainKeys.OPTIMISM_MAINNET` | `'0xa.optimism'` |
|
|
57
|
+
| `POLYGON_MAINNET_CHAIN_ID` | `ChainKeys.POLYGON_MAINNET` | `'0x89.polygon'` |
|
|
58
|
+
| `REDBELLY_MAINNET_CHAIN_ID` | `ChainKeys.REDBELLY_MAINNET` | `'redbelly'` |
|
|
59
|
+
| `SOLANA_MAINNET_CHAIN_ID` | `ChainKeys.SOLANA_MAINNET` | `'solana'` |
|
|
60
|
+
| `STACKS_MAINNET_CHAIN_ID` | `ChainKeys.STACKS_MAINNET` | `'stacks'` |
|
|
61
|
+
| `STELLAR_MAINNET_CHAIN_ID` | `ChainKeys.STELLAR_MAINNET` | `'stellar'` |
|
|
62
|
+
| `SUI_MAINNET_CHAIN_ID` | `ChainKeys.SUI_MAINNET` | `'sui'` |
|
|
63
|
+
| `BITCOIN_MAINNET_CHAIN_ID` | `ChainKeys.BITCOIN_MAINNET` | `'bitcoin'` |
|
|
64
|
+
|
|
65
|
+
### Bulk codemod
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Find — preserves capture group
|
|
69
|
+
grep -rE '(\w+)_MAINNET_CHAIN_ID' src/
|
|
70
|
+
|
|
71
|
+
# Sed (one-shot)
|
|
72
|
+
find src -type f -name '*.ts' -o -name '*.tsx' | xargs sed -i '' -E 's/([A-Z_]+)_MAINNET_CHAIN_ID/ChainKeys.\1_MAINNET/g'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
After replacement, fix import statements: remove the individual constants, add `ChainKeys`. See [`../recipes.md`](../recipes.md) § "Codemod patterns" for a more robust `ts-morph` variant.
|
|
76
|
+
|
|
77
|
+
### Pitfalls
|
|
78
|
+
|
|
79
|
+
1. **`ChainKeys.ICON_MAINNET` is a string `'0x1.icon'`, not the legacy numeric ID.** Anywhere v1 did `Number(chainId)` for ICON, the v2 result is `NaN`. Use string equality (`chainKey === ChainKeys.ICON_MAINNET`) and audit numeric coercions.
|
|
80
|
+
2. **`SONIC_MAINNET` is `'sonic'`, not `'0x92.sonic'`** — it's the simple string `'sonic'` because Sonic is the hub chain and treated specially by routing.
|
|
81
|
+
3. **Don't confuse `ChainKey` with relay chain IDs.** Read shapes like `Intent.srcChain` and `Intent.dstChain` are still `IntentRelayChainId` (bigint) — those did **not** rename. A blanket `srcChain` → `srcChainKey` grep-replace will break Intent reads. Use `sodax.config.getSpokeChainKeyFromIntentRelayChainId(...)` to convert.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 2. `@sodax/types` package surface
|
|
86
|
+
|
|
87
|
+
### Export reorganization
|
|
88
|
+
|
|
89
|
+
v1 had a single `packages/types/src/constants/index.ts` barrel exporting all chain IDs and ad-hoc tables. That file is **deleted**. Symbols now live in domain-organized modules: `chains/`, `swap/`, `wallet/`, `bitcoin/`, etc.
|
|
90
|
+
|
|
91
|
+
| v1 import path | v2 home |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `@sodax/types/btc/...` | `@sodax/types/bitcoin` (path renamed) |
|
|
94
|
+
| `*_MAINNET_CHAIN_ID` from `@sodax/types` constants index | `ChainKeys.*` (single barrel) |
|
|
95
|
+
| `Token` | `XToken` (renamed; see [§4](#4-token--xtoken-field-renames)) |
|
|
96
|
+
| `SpokeChainId` / `ChainId` | `SpokeChainKey` (see [§9](#9-chainid--spokechainid--spokechainkey)) |
|
|
97
|
+
|
|
98
|
+
### Re-export from `@sodax/sdk`
|
|
99
|
+
|
|
100
|
+
`@sodax/sdk` v2 barrel re-exports the entire `@sodax/types` surface (`export * from '@sodax/types'` from `src/index.ts`). For consumers, this means:
|
|
101
|
+
|
|
102
|
+
- **Recommended:** import everything from `@sodax/sdk`. You don't need a separate `@sodax/types` dependency.
|
|
103
|
+
- **Tolerated:** keep importing from `@sodax/types` directly. v2 guarantees type identity (since SDK bundles `@sodax/types` via `noExternal`), but you'll pin two versions instead of one.
|
|
104
|
+
|
|
105
|
+
### Pitfall
|
|
106
|
+
|
|
107
|
+
If your `package.json` lists `@sodax/types` as a direct dependency in v2, **remove it**. Letting it float independent of `@sodax/sdk` invites silent version skew on the next minor bump.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 3. Wallet-provider typing
|
|
112
|
+
|
|
113
|
+
v1 modeled "the wallet to use for chain X" as a class instance: `EvmSpokeProvider`, `SolanaSpokeProvider`, etc. Consumers constructed one and passed it positionally to every SDK call. v2 deletes these classes (see [`architecture.md`](architecture.md) § "Spoke-provider deletion") and replaces the typing with two parameterised aliases:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
GetChainType<K extends ChainKey> // 'EVM' | 'BITCOIN' | 'SOLANA' | …
|
|
117
|
+
GetWalletProviderType<K extends ChainKey> // IEvmWalletProvider | IBitcoinWalletProvider | …
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
When the caller passes a literal chain key (e.g. `ChainKeys.ETHEREUM_MAINNET`), TypeScript preserves the literal in the generic `K`. From that one literal:
|
|
121
|
+
|
|
122
|
+
- `GetChainType<K>` resolves to `'EVM'`.
|
|
123
|
+
- `GetWalletProviderType<K>` resolves to `IEvmWalletProvider` (the exact interface, not a broad union).
|
|
124
|
+
|
|
125
|
+
This is what allows v2 to demand the chain-correct wallet provider at compile time without a runtime check.
|
|
126
|
+
|
|
127
|
+
### `WalletProviderSlot<K, Raw>` — the discriminator
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// Conceptual; lives in @sodax/types/common
|
|
131
|
+
export type WalletProviderSlot<K extends ChainKey, Raw extends boolean> =
|
|
132
|
+
Raw extends true
|
|
133
|
+
? { raw: true; walletProvider?: never }
|
|
134
|
+
: { raw: false; walletProvider: GetWalletProviderType<K> };
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Three rules enforced at compile time:
|
|
138
|
+
|
|
139
|
+
1. **`raw: true`** — `walletProvider` is **forbidden** (`?: never` rejects any value). The method returns a raw, unsigned tx payload. Use for sign-elsewhere flows.
|
|
140
|
+
2. **`raw: false`** — `walletProvider` is **required** and chain-narrowed. The method signs and broadcasts; returns a tx hash.
|
|
141
|
+
3. **No overlap** — TypeScript can't pick a branch unless the discriminator field is present. Forgetting `raw: false` is the #1 v2 typecheck error after migration.
|
|
142
|
+
|
|
143
|
+
### Migration mechanics
|
|
144
|
+
|
|
145
|
+
```diff
|
|
146
|
+
await sodax.swaps.createIntent({
|
|
147
|
+
- intentParams,
|
|
148
|
+
- spokeProvider: sourceProvider,
|
|
149
|
+
+ params: intentParams,
|
|
150
|
+
+ raw: false,
|
|
151
|
+
+ walletProvider: sourceWalletProvider,
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
For raw-tx building:
|
|
156
|
+
|
|
157
|
+
```diff
|
|
158
|
+
- // v1 had a separate executeXxx method per chain
|
|
159
|
+
- const tx = await sourceProvider.executeCreateIntent(intentParams);
|
|
160
|
+
+ const result = await sodax.swaps.createIntent({ params: intentParams, raw: true });
|
|
161
|
+
+ // result.value: { tx: EvmRawTransaction | SolanaRawTransaction | ..., intent, relayData }
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Pitfall
|
|
165
|
+
|
|
166
|
+
If your wallet provider variable is typed as the broad `IWalletProvider | undefined` union (the typical case when the variable is keyed by a runtime chain-key value rather than a literal), v2 still accepts it — `K` defaults to the broad `SpokeChainKey` union, so `GetWalletProviderType<K>` resolves to the `IWalletProvider` union. For tighter narrowing on a literal chain branch, see [`../recipes.md`](../recipes.md) § "Cast-at-boundary".
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 4. `Token` / `XToken` field renames
|
|
171
|
+
|
|
172
|
+
| v1 | v2 |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `Token` (type name) | `XToken` |
|
|
175
|
+
| `Token.xChainId` | `XToken.chainKey` |
|
|
176
|
+
| `Token.symbol`, `decimals`, `address`, `name` | unchanged |
|
|
177
|
+
| (n/a) | `XToken.vault` — added; the hub-side ERC4626 vault for this token |
|
|
178
|
+
| (n/a) | `XToken.hubAsset` — added; the hub-side wrapped/unified asset address |
|
|
179
|
+
|
|
180
|
+
Migration:
|
|
181
|
+
|
|
182
|
+
```diff
|
|
183
|
+
- import type { Token } from '@sodax/types';
|
|
184
|
+
+ import type { XToken } from '@sodax/sdk';
|
|
185
|
+
- token.xChainId
|
|
186
|
+
+ token.chainKey
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Why `vault` / `hubAsset` matter
|
|
190
|
+
|
|
191
|
+
v1 consumers reached into a global `hubAssets[chainId][address]` map to get the vault address for a token. **v2 deletes that global** and bakes the data directly into every supported `XToken`. Anywhere v1 walked `hubAssets`, v2 reads `token.vault` or `token.hubAsset` directly. See [`architecture.md`](architecture.md) § "ConfigService replaces static lookups" for the full lookup migration.
|
|
192
|
+
|
|
193
|
+
### Pitfall
|
|
194
|
+
|
|
195
|
+
Read shapes like `Intent` and `IntentResponse` from the backend keep `srcChain` / `dstChain` as the **relay** chain id (numeric, `IntentRelayChainId`). They are **not** chain keys and were **not** renamed to `srcChainKey`/`dstChainKey`. Only **request** types (`CreateIntentParams`, `CreateLimitOrderParams`, `SubmitSwapTxRequest`) gained the `*ChainKey` field names.
|
|
196
|
+
|
|
197
|
+
### Exception — partner module read shapes DID rename
|
|
198
|
+
|
|
199
|
+
The above "read shapes keep `srcChain`/`dstChain`" rule has one exception: **partner module** read shapes also renamed `dstChain` → `dstChainKey`. Specifically:
|
|
200
|
+
|
|
201
|
+
- `AutoSwapPreferences` (returned by `sodax.partners.getAutoSwapPreferences(queryAddress)`) — field `dstChain` → **`dstChainKey: SpokeChainKey | 'not configured'`**.
|
|
202
|
+
- `SetSwapPreferenceParams` (request type for `setSwapPreference`) — `dstChain` → `dstChainKey: SpokeChainKey`.
|
|
203
|
+
|
|
204
|
+
```diff
|
|
205
|
+
- // v1
|
|
206
|
+
- const prefs = await partnerFeeClaimService.getAutoSwapPreferences(addr);
|
|
207
|
+
- const destChain: SpokeChainId = prefs.dstChain;
|
|
208
|
+
|
|
209
|
+
+ // v2
|
|
210
|
+
+ const result = await sodax.partners.getAutoSwapPreferences(addr);
|
|
211
|
+
+ if (!result.ok) return;
|
|
212
|
+
+ const destChain: SpokeChainKey | 'not configured' = result.value.dstChainKey;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
A blanket grep `dstChain` → `dstChainKey` is safe in the partner module **but** still unsafe in `Intent` / `IntentResponse` reads. Scope grep replacements per file or per import. The general rule for `srcChain` (Intent read field) is unchanged: it remains the relay chain id.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 5. `RpcConfig` reshape
|
|
220
|
+
|
|
221
|
+
v1 modeled `RpcConfig` as a flat object with one optional URL field per chain. v2 makes it a mapped type keyed by `ChainKey` values, with chain-family-specific shapes:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
type RpcConfig = {
|
|
225
|
+
[K in ChainKey]:
|
|
226
|
+
K extends typeof ChainKeys.BITCOIN_MAINNET ? BitcoinRpcConfig :
|
|
227
|
+
K extends typeof ChainKeys.STELLAR_MAINNET ? StellarRpcConfig :
|
|
228
|
+
string // RPC URL for every other chain
|
|
229
|
+
};
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Migration:
|
|
233
|
+
|
|
234
|
+
```diff
|
|
235
|
+
- rpcConfig.sonic
|
|
236
|
+
+ rpcConfig[ChainKeys.SONIC_MAINNET]
|
|
237
|
+
- rpcConfig.btc
|
|
238
|
+
+ rpcConfig[ChainKeys.BITCOIN_MAINNET] // BitcoinRpcConfig (shape, not string)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Pitfall
|
|
242
|
+
|
|
243
|
+
Bitcoin and Stellar have richer RPC needs than other chains (multiple endpoints, network params). Their entries in `RpcConfig` are objects, not strings. If your config builder did `rpcConfig.btc = 'https://…'` in v1, that's a type error in v2 — you need the full `BitcoinRpcConfig` shape.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 6. `IConfigApi` Result-wrapping
|
|
248
|
+
|
|
249
|
+
Every method on the `IConfigApi` contract changed signature in v2. v1 returned plain `Promise<T>` and threw on failure; v2 returns `Promise<Result<T>>` and never throws.
|
|
250
|
+
|
|
251
|
+
| Method | v1 return | v2 return |
|
|
252
|
+
|---|---|---|
|
|
253
|
+
| `getChains` | `Promise<ChainConfig[]>` | `Promise<Result<GetChainsApiResponse>>` |
|
|
254
|
+
| `getSwapTokens` | `Promise<SwapTokenConfig>` | `Promise<Result<GetSwapTokensApiResponse>>` |
|
|
255
|
+
| `getSwapTokensByChainId` | `Promise<XToken[]>` | `Promise<Result<XToken[]>>` |
|
|
256
|
+
| `getMoneyMarketTokens` | `Promise<MMTokenConfig>` | `Promise<Result<GetMoneyMarketTokensApiResponse>>` |
|
|
257
|
+
| `getMoneyMarketTokensByChainId` | `Promise<XToken[]>` | `Promise<Result<XToken[]>>` |
|
|
258
|
+
| `getRelayChainIdMap` | (n/a in v1) | `Promise<Result<GetRelayChainIdMapApiResponse>>` (v2-new) |
|
|
259
|
+
|
|
260
|
+
If you implemented a custom `IConfigApi` (e.g. for a sandbox or test fixture), update every method signature. If you only consumed the default implementation through `Sodax.config`, the SDK already uses `Result` internally — your consumer-side code doesn't see the wrapping.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 7. Address-type rename
|
|
265
|
+
|
|
266
|
+
The Bitcoin-specific address-type union changed name to free up the generic `AddressType` identifier:
|
|
267
|
+
|
|
268
|
+
```diff
|
|
269
|
+
- import type { AddressType } from '@sodax/types';
|
|
270
|
+
+ import type { BtcAddressType } from '@sodax/sdk';
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Value union is unchanged: `'P2PKH' | 'P2SH' | 'P2WPKH' | 'P2TR'`. Custom Bitcoin wallet provider implementations must update the import.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 8. Wallet-provider `chainType` discriminant
|
|
278
|
+
|
|
279
|
+
Every `I*WalletProvider` interface in v2 declares a `readonly chainType: '<CHAIN>'` literal field. Custom implementations must add the field; consumers can use it for runtime narrowing without `instanceof`:
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
if (walletProvider.chainType === 'EVM') {
|
|
283
|
+
// walletProvider: IEvmWalletProvider
|
|
284
|
+
}
|
|
285
|
+
if (walletProvider.chainType === 'SOLANA') {
|
|
286
|
+
// walletProvider: ISolanaWalletProvider
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Supported values: `'EVM'`, `'BITCOIN'`, `'SOLANA'`, `'STELLAR'`, `'SUI'`, `'ICON'`, `'INJECTIVE'`, `'STACKS'`, `'NEAR'`.
|
|
291
|
+
|
|
292
|
+
This replaces v1's `provider instanceof EvmSpokeProvider` discrimination. Cross-bundle `instanceof` is fragile (different `@sodax/sdk` copies in dual ESM/CJS bundles can return false); the literal `chainType` field works regardless.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 9. `ChainId` / `SpokeChainId` → `SpokeChainKey`
|
|
297
|
+
|
|
298
|
+
Type alias rename. Same value union (the chain-key strings).
|
|
299
|
+
|
|
300
|
+
```diff
|
|
301
|
+
- import type { ChainId, SpokeChainId } from '@sodax/types';
|
|
302
|
+
+ import type { SpokeChainKey } from '@sodax/sdk';
|
|
303
|
+
- function pickChain(id: ChainId): boolean { ... }
|
|
304
|
+
+ function pickChain(key: SpokeChainKey): boolean { ... }
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Function bodies that compared `chainId === SONIC_MAINNET_CHAIN_ID` need [§1](#1-chain-identifiers)'s constant rename in addition to the type rename.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 10. Deleted module-error types
|
|
312
|
+
|
|
313
|
+
These types were exported from v1 but are deleted in v2. Replace with `SodaxError<C>` (see [`result-and-errors.md`](result-and-errors.md) for full semantics):
|
|
314
|
+
|
|
315
|
+
- `MoneyMarketError<MoneyMarketErrorCode>`
|
|
316
|
+
- `IntentError<IntentErrorCode>`
|
|
317
|
+
- `StakingError<StakingErrorCode>`
|
|
318
|
+
- `BridgeError<BridgeErrorCode>`
|
|
319
|
+
- `MigrationError<MigrationErrorCode>`
|
|
320
|
+
- `AssetServiceError<AssetServiceErrorCode>`
|
|
321
|
+
- `ConcentratedLiquidityError<ConcentratedLiquidityErrorCode>`
|
|
322
|
+
- `RelayError<RelayErrorCode>`
|
|
323
|
+
- 5 partner error types (`PartnerFeeClaimError<...>`, etc.) and their `is<Module>Error()` type-guard helpers.
|
|
324
|
+
|
|
325
|
+
The replacement contract:
|
|
326
|
+
|
|
327
|
+
```diff
|
|
328
|
+
- if (error instanceof MoneyMarketError && error.code === 'CREATE_SUPPLY_INTENT_FAILED') { … }
|
|
329
|
+
+ if (isSodaxError(error) && error.feature === 'moneyMarket' && error.code === 'INTENT_CREATION_FAILED') { … }
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The full v1 → v2 code crosswalk lives in [`result-and-errors.md`](result-and-errors.md) § "v1 ↔ v2 code crosswalk".
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Cross-references
|
|
337
|
+
|
|
338
|
+
- Architectural changes (spoke-provider deletion, ConfigService, relay flow): [`architecture.md`](architecture.md).
|
|
339
|
+
- Result/error model details (propagation patterns, code crosswalk, return shapes): [`result-and-errors.md`](result-and-errors.md).
|
|
340
|
+
- v2 design context (what to use instead of each deleted symbol): [`architecture.md`](../../../integration/knowledge/architecture.md).
|
|
341
|
+
- Lookup tables (full chain-key list, `I*WalletProvider` interfaces, public API surface): [`reference/`](../../../integration/knowledge/reference/).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# v1 → v2 cross-cutting migration checklist
|
|
2
|
+
|
|
3
|
+
Work this top-down. Each step is independent enough to land as its own commit; the order minimizes typecheck noise.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
[ ] 1. Replace every *_MAINNET_CHAIN_ID constant with ChainKeys.* (mechanical).
|
|
7
|
+
See breaking-changes/type-system.md § "Chain IDs".
|
|
8
|
+
[ ] 2. Replace every SpokeChainId / ChainId type alias with SpokeChainKey.
|
|
9
|
+
Mechanical rename. Same value union.
|
|
10
|
+
[ ] 3. Rename XToken.xChainId → XToken.chainKey. Same for any consumer types
|
|
11
|
+
that mirrored that field.
|
|
12
|
+
[ ] 4. Remove any direct dependency on @sodax/types from package.json.
|
|
13
|
+
v2 @sodax/sdk barrel re-exports the entire types surface.
|
|
14
|
+
[ ] 5. Delete every *SpokeProvider class instantiation. Replace with passing
|
|
15
|
+
walletProvider (an I*WalletProvider instance) directly into SDK call
|
|
16
|
+
payloads.
|
|
17
|
+
[ ] 6. Replace every isXxxSpokeProvider(provider) guard with a chain-key
|
|
18
|
+
compare: chainKey === ChainKeys.<X>_MAINNET, or use
|
|
19
|
+
is<Family>ChainKeyType(chainKey) from @sodax/sdk.
|
|
20
|
+
[ ] 7. Add { raw: false } discriminator to every signed call shape that
|
|
21
|
+
previously took a positional spoke provider:
|
|
22
|
+
{ intentParams, spokeProvider } → { params, raw: false, walletProvider }
|
|
23
|
+
[ ] 7b. Cross-cutting rename: every payload field named `spokeProvider:` (incl.
|
|
24
|
+
approve/allowance/utility methods that aren't signed-execution shapes)
|
|
25
|
+
→ `walletProvider:`. Mechanical for the OBJECT-LITERAL field key; don't
|
|
26
|
+
blindly rename variable names of the same spelling. See
|
|
27
|
+
[`recipes.md`](recipes.md) § 1 "What's not safe to grep-replace".
|
|
28
|
+
[ ] 8. Add srcChainKey + srcAddress to every action params object that didn't
|
|
29
|
+
carry them in v1 (most MM, staking, dex, bridge, migration param shapes).
|
|
30
|
+
[ ] 9. Convert every await sodax.<service>.<method>(...) call site that previously
|
|
31
|
+
threw to branch on result.ok / result.error. Use isSodaxError(e) for type
|
|
32
|
+
narrowing.
|
|
33
|
+
[ ] 10. Delete imports of MoneyMarketError, IntentError, StakingError, BridgeError,
|
|
34
|
+
MigrationError, AssetServiceError, ConcentratedLiquidityError, RelayError,
|
|
35
|
+
plus the five Partner error types and their type-guard helpers.
|
|
36
|
+
[ ] 11. Replace any walked global lookup (hubAssets, moneyMarketSupportedTokens,
|
|
37
|
+
SodaTokens, supportedSpokeChains) with the equivalent sodax.config.* /
|
|
38
|
+
sodax.moneyMarket.getSupportedTokens*() call. Per-symbol deleted-vs-
|
|
39
|
+
still-exported status: see breaking-changes/architecture.md § 2.
|
|
40
|
+
[ ] 12. Initialize ConfigService at app startup: await sodax.config.initialize().
|
|
41
|
+
Falls back to packaged defaults if the backend is unreachable.
|
|
42
|
+
[ ] 13. Add { raw: true } to any read-only allowance check that previously took
|
|
43
|
+
a spoke provider but didn't actually consult it (the underlying SDK
|
|
44
|
+
method now requires WalletProviderSlot).
|
|
45
|
+
[ ] 14. For every CreateIntentResult consumer: stop destructuring as a tuple;
|
|
46
|
+
the v2 shape is { tx, intent, relayData }. Stop destructuring tx-pair
|
|
47
|
+
results as arrays — every cross-chain mutation returns
|
|
48
|
+
TxHashPair = { srcChainTxHash, dstChainTxHash }.
|
|
49
|
+
[ ] 15. For every backend-API call site: every method on IConfigApi now returns
|
|
50
|
+
Promise<Result<T>>. Wrap or unwrap accordingly.
|
|
51
|
+
[ ] 16. (Optional) Adopt isSodaxError(e) over instanceof SodaxError in cross-bundle
|
|
52
|
+
/ cross-realm contexts.
|
|
53
|
+
[ ] 17. Run pnpm tsc --noEmit and start crossing items off the typecheck output.
|
|
54
|
+
Use each remaining error category to navigate to the relevant per-feature
|
|
55
|
+
migration file in features/.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
After items 1–17 land, the typecheck should be clean. The remaining work is per-feature behavior (cross-chain borrow / repay deltas, staking action discriminators, etc.) covered in [`features/`](features/).
|
|
59
|
+
|
|
60
|
+
## Reading order while working the checklist
|
|
61
|
+
|
|
62
|
+
- Items 1–4: [`breaking-changes/type-system.md`](breaking-changes/type-system.md).
|
|
63
|
+
- Items 5–6, 11–12: [`breaking-changes/architecture.md`](breaking-changes/architecture.md).
|
|
64
|
+
- Items 7–8, 13: [`breaking-changes/architecture.md`](breaking-changes/architecture.md) § "WalletProviderSlot" + per-feature files.
|
|
65
|
+
- Items 9–10, 14, 16: [`breaking-changes/result-and-errors.md`](breaking-changes/result-and-errors.md).
|
|
66
|
+
- Item 15: [`features/backend-api.md`](features/backend-api.md).
|
|
67
|
+
- Item 17 + the long tail: [`features/`](features/), one per feature you use.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Per-feature migration playbooks — v1 → v2
|
|
2
|
+
|
|
3
|
+
One file per feature, paired with the v2 design counterpart in [`features/`](../../../integration/knowledge/features/) (same filename).
|
|
4
|
+
|
|
5
|
+
| Feature | Migration file |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Swap | [`swap.md`](swap.md) |
|
|
8
|
+
| Money Market | [`money-market.md`](money-market.md) |
|
|
9
|
+
| Staking | [`staking.md`](staking.md) |
|
|
10
|
+
| Bridge | [`bridge.md`](bridge.md) |
|
|
11
|
+
| DEX | [`dex.md`](dex.md) |
|
|
12
|
+
| ICX/bnUSD/BALN | [`migration.md`](migration.md) |
|
|
13
|
+
| Partner | [`partner.md`](partner.md) — standard pattern; 5 v1 typed errors collapse into `SodaxError<C>` with `feature: 'partner'`. |
|
|
14
|
+
| Recovery | [`recovery.md`](recovery.md) — new in v2; no v1 equivalent. |
|
|
15
|
+
| Backend API | [`backend-api.md`](backend-api.md) — load-bearing change: every method now returns `Promise<Result<T>>`. |
|
|
16
|
+
|
|
17
|
+
## Reading order within a feature
|
|
18
|
+
|
|
19
|
+
Each per-feature file follows the same shape:
|
|
20
|
+
|
|
21
|
+
1. **TL;DR** — the load-bearing changes in 5–10 bullets.
|
|
22
|
+
2. **Type / symbol cheat sheet** — exact renames and shape diffs.
|
|
23
|
+
3. **Per-method delta** — call shape v1 vs v2, return type v1 vs v2, error model v1 vs v2.
|
|
24
|
+
4. **Worked example** — a representative migration of one call site, before / after.
|
|
25
|
+
5. **Pitfalls** — the things that look right but compile or run wrong.
|
|
26
|
+
6. **Verification** — what to run to confirm the port is complete.
|
|
27
|
+
|
|
28
|
+
## Cross-cutting prerequisites
|
|
29
|
+
|
|
30
|
+
Before reading any feature file, finish the cross-cutting work in:
|
|
31
|
+
|
|
32
|
+
- [`../README.md`](../README.md) — top-level checklist (chain-id rename, type renames, `walletProvider` extraction).
|
|
33
|
+
- [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) — type imports must compile first.
|
|
34
|
+
- [`../breaking-changes/architecture.md`](../breaking-changes/architecture.md) — `*SpokeProvider` deletion, `ConfigService`.
|
|
35
|
+
- [`../breaking-changes/result-and-errors.md`](../breaking-changes/result-and-errors.md) — `Result<T>` and `SodaxError<C>`.
|
|
36
|
+
|
|
37
|
+
Per-feature work assumes those are done.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Backend API migration — v1 → v2
|
|
2
|
+
|
|
3
|
+
Pure-SDK migration playbook for `BackendApiService`. The load-bearing v1 → v2 change here is **`Result`-wrapping every method**.
|
|
4
|
+
|
|
5
|
+
Pair: [`features/backend-api.md`](../../../integration/knowledge/features/backend-api.md).
|
|
6
|
+
|
|
7
|
+
## TL;DR
|
|
8
|
+
|
|
9
|
+
1. **Every method now returns `Promise<Result<T>>`** (v1 returned plain `Promise<T>` and threw on failure). `IConfigApi` implementations must update method signatures.
|
|
10
|
+
2. **`SubmitSwapTxRequest.srcChainId` → `srcChainKey`.** And `relayData` field is `string` (`relayData.payload`), not the `RelayExtraData` object. (Cross-cutting detail; covered in detail in [`swap.md`](swap.md).)
|
|
11
|
+
|
|
12
|
+
## Type / symbol cheat sheet
|
|
13
|
+
|
|
14
|
+
| Method | v1 return | v2 return |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `submitSwapTx` | `Promise<SubmitSwapTxResponse>` | `Promise<Result<SubmitSwapTxResponse>>` |
|
|
17
|
+
| `getIntentByHash` | `Promise<IntentResponse>` | `Promise<Result<IntentResponse>>` |
|
|
18
|
+
| `getIntentByTxHash` | (n/a in v1) | `Promise<Result<IntentResponse>>` (v2-new) |
|
|
19
|
+
| `getOrderbook` (was `getSolverOrderbook`) | `Promise<OrderbookEntry[]>` | `Promise<Result<OrderbookEntry[]>>` |
|
|
20
|
+
| `getUserIntents` (was `getUserSwapHistory`) | `Promise<IntentResponse[]>` | `Promise<Result<IntentResponse[]>>` |
|
|
21
|
+
| `getChains` | `Promise<ChainConfig[]>` | `Promise<Result<GetChainsApiResponse>>` |
|
|
22
|
+
| `getSwapTokens` | `Promise<SwapTokenConfig>` | `Promise<Result<GetSwapTokensApiResponse>>` |
|
|
23
|
+
| `getSwapTokensByChainId` | `Promise<XToken[]>` | `Promise<Result<XToken[]>>` |
|
|
24
|
+
| `getMoneyMarketTokens` | `Promise<MMTokenConfig>` | `Promise<Result<GetMoneyMarketTokensApiResponse>>` |
|
|
25
|
+
| `getMoneyMarketTokensByChainId` | `Promise<XToken[]>` | `Promise<Result<XToken[]>>` |
|
|
26
|
+
| `SubmitSwapTxRequest.srcChainId` | numeric chain id | renamed → `srcChainKey: SpokeChainKey` |
|
|
27
|
+
| `SubmitSwapTxRequest.relayData` | `RelayExtraData` object | now `string` (use `relayData.payload`) |
|
|
28
|
+
|
|
29
|
+
## Per-method delta
|
|
30
|
+
|
|
31
|
+
```diff
|
|
32
|
+
- const response: SubmitSwapTxResponse = await sodax.backendApi.submitSwapTx(request);
|
|
33
|
+
- // throws on failure
|
|
34
|
+
+ const result = await sodax.backendApi.submitSwapTx({
|
|
35
|
+
+ txHash: spokeTxHash as string,
|
|
36
|
+
+ srcChainKey: src.chain, // was: srcChainId
|
|
37
|
+
+ walletAddress: '0x…',
|
|
38
|
+
+ intent: swapIntentData,
|
|
39
|
+
+ relayData: relayData.payload, // was: relayData (object)
|
|
40
|
+
+ });
|
|
41
|
+
+ if (!result.ok) {
|
|
42
|
+
+ // result.error: SodaxError with feature: 'swap', context.api: 'backend'
|
|
43
|
+
+ return;
|
|
44
|
+
+ }
|
|
45
|
+
+ const response = result.value;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Custom `IConfigApi` (sandbox / test fixtures)
|
|
49
|
+
|
|
50
|
+
If you implemented `IConfigApi` for a sandbox or test fixture, two things changed in v2:
|
|
51
|
+
|
|
52
|
+
**1. Method signatures.** Every method now returns `Promise<Result<T>>` instead of throwing on failure:
|
|
53
|
+
|
|
54
|
+
```diff
|
|
55
|
+
const sandboxApi: IConfigApi = {
|
|
56
|
+
- async getChains(): Promise<ChainConfig[]> {
|
|
57
|
+
- return [/* fixture */];
|
|
58
|
+
- },
|
|
59
|
+
- async getSwapTokens(): Promise<SwapTokenConfig> { /* … */ },
|
|
60
|
+
+ async getChains(): Promise<Result<ChainConfig[], unknown>> {
|
|
61
|
+
+ return { ok: true, value: [/* fixture */] };
|
|
62
|
+
+ },
|
|
63
|
+
+ async getSwapTokens(): Promise<Result<SwapTokenConfig, unknown>> { /* … */ },
|
|
64
|
+
// …5 methods total
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**2. Injection mechanism.** `SodaxConfig` does NOT expose a typed slot to inject a custom `IConfigApi` at construction. v1 patterns that passed a custom api into `new Sodax(...)` no longer typecheck. Point at a local mock via `SodaxConfig.api.baseURL`, or inject your own `BackendApiService`-compatible mock at the app layer. See [`../../../integration/knowledge/architecture.md`](../../../integration/knowledge/architecture.md) § 4 "Custom backend" for the v2 pattern.
|
|
69
|
+
|
|
70
|
+
## Pitfalls
|
|
71
|
+
|
|
72
|
+
1. **`SubmitSwapTxRequest.relayData` is `string`, not the `RelayExtraData` object.** v1 took the object; v2 takes the `payload` field as a string.
|
|
73
|
+
2. **Backend errors carry `error.context.api === 'backend'`** but the `feature` reflects the call site (`'swap'` for `submitSwapTx`, `'moneyMarket'` for MM-related backend calls, etc.). Use both for logger tag pairs.
|
|
74
|
+
3. **Custom `IConfigApi` implementations must return `Result<T>`** — old throw-on-error implementations will compile-error against the v2 interface.
|
|
75
|
+
|
|
76
|
+
## Verification
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pnpm -C <your-app-dir> checkTs
|
|
80
|
+
|
|
81
|
+
# Targeted scans:
|
|
82
|
+
grep -rE "srcChainId:\s*\w+|\.relayData(?!\s*\.payload)" src/ # legacy field name + non-string relayData
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Cross-references
|
|
86
|
+
|
|
87
|
+
- v2 backend API usage: [`features/backend-api.md`](../../../integration/knowledge/features/backend-api.md).
|
|
88
|
+
- `submitSwapTx` flow with `createIntent` upstream: [`./swap.md`](swap.md) (the swap migration covers the request-shape changes in detail).
|
|
89
|
+
- Partner migration (separate service): [`./partner.md`](partner.md).
|
|
90
|
+
- Recovery migration (separate service, new in v2): [`./recovery.md`](recovery.md).
|
|
91
|
+
- Result/error model: [`../breaking-changes/result-and-errors.md`](../breaking-changes/result-and-errors.md).
|
|
92
|
+
- `IConfigApi` Result-wrapping cross-cutting note: [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 6.
|