@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,350 @@
|
|
|
1
|
+
# Migration recipes — v1 → v2
|
|
2
|
+
|
|
3
|
+
Practical patterns for porting consumer code without rewriting everything in one pass.
|
|
4
|
+
|
|
5
|
+
1. [Codemod patterns](#1-codemod-patterns) — regex find/replace + a small `ts-morph` script for the renames that grep can't safely handle.
|
|
6
|
+
2. [Free-function lookups at module scope](#2-free-function-lookups-at-module-scope) — `getHubChainConfig()` / `getMoneyMarketConfig()` migration for constants/util files where no `Sodax` instance exists yet.
|
|
7
|
+
3. [Error-shape adapter](#3-error-shape-adapter) — adapt v2 `SodaxError` onto v1 `{ code, data }` branches so existing error-formatting helpers keep working.
|
|
8
|
+
4. [Result adapter](#4-result-adapter) — wrap v2 `Result<T>` in a v1-style throw shim for incremental conversion of call sites.
|
|
9
|
+
|
|
10
|
+
These are migration-only — once the port is complete, delete them. They're not patterns for new code.
|
|
11
|
+
|
|
12
|
+
The patterns below describe **what** the rewrite needs to do; pick whichever codemod tool fits your project (regex, `ts-morph`, `jscodeshift`, IDE refactor). The example scripts use `ts-morph` for AST-level rewrites where regex is unsafe.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Codemod patterns
|
|
17
|
+
|
|
18
|
+
### What's safe to grep-replace
|
|
19
|
+
|
|
20
|
+
| Change | Find | Replace | Notes |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| Chain-id constants | `(\w+)_MAINNET_CHAIN_ID` | `ChainKeys.$1_MAINNET` | Mechanical. **Two-pass — see below.** First-pass rewrites usages; second-pass fixes the broken `import { ... }` statements. |
|
|
23
|
+
| `xChainId` field on `XToken` | `\.xChainId\b` | `.chainKey` | Token field rename. Audit first — some non-token types may use `xChainId` differently. |
|
|
24
|
+
| `Token` type rename | `\bimport(.*)\bToken\b(.*)\bfrom 'sodax/types'` | `import$1XToken$2from '@sodax/sdk'` | Best done with `ts-morph` to avoid touching unrelated `Token` identifiers. |
|
|
25
|
+
| `SpokeChainId` → `SpokeChainKey` | `\b(SpokeChainId\|ChainId)\b` (in type positions) | `SpokeChainKey` | Audit — `ChainId` is also used by 3rd-party libs (viem, etc.). Limit to `@sodax/types` imports. |
|
|
26
|
+
| `AddressType` → `BtcAddressType` | `\bAddressType\b` (in `@sodax/types` import positions) | `BtcAddressType` | |
|
|
27
|
+
|
|
28
|
+
### Two-pass codemod for chain-id constants
|
|
29
|
+
|
|
30
|
+
A one-pass `_MAINNET_CHAIN_ID` → `ChainKeys.*_MAINNET` rewrite produces invalid syntax inside `import { ... }` blocks — `ChainKeys.SONIC_MAINNET` is a member-access expression, not a bare identifier, and cannot live inside a named-import list (TS1109).
|
|
31
|
+
|
|
32
|
+
Split the rewrite into two passes:
|
|
33
|
+
|
|
34
|
+
1. **Pass 1 — rewrite usages.** Every `<X>_MAINNET_CHAIN_ID` → `ChainKeys.<X>_MAINNET`. Touches expression positions and (incorrectly) named-import positions; the broken imports get fixed in pass 2.
|
|
35
|
+
2. **Pass 2 — sweep imports.** For each `import { … } from '@sodax/{types,sdk}'`, drop the now-broken `ChainKeys.<X>_MAINNET` entries from the named-imports list and ensure `ChainKeys` itself is imported once.
|
|
36
|
+
|
|
37
|
+
Use the `ts-morph` script from the chain-id section above as a starting point for an AST-aware version, or build the two passes with whatever tooling fits your repo. After pass 2, every chain-id reference compiles.
|
|
38
|
+
|
|
39
|
+
### Pitfall — duplicate `ChainKeys` imports
|
|
40
|
+
|
|
41
|
+
If a file imports `<X>_MAINNET_CHAIN_ID` from BOTH `@sodax/types` and `@sodax/sdk` (some legacy code split imports across the two), pass 2 may add `ChainKeys` to both import statements → `TS2300 Duplicate identifier 'ChainKeys'`. Either keep `ChainKeys` only in the first import block, or consolidate to one import — `@sodax/sdk` re-exports the entire `@sodax/types` surface, so a single `import … from '@sodax/sdk'` is sufficient.
|
|
42
|
+
|
|
43
|
+
### What's not safe to grep-replace
|
|
44
|
+
|
|
45
|
+
- `srcChain` → `srcChainKey` on **request** types only. Read shapes (`Intent.srcChain`, `IntentResponse.srcChain`) keep `srcChain` as the relay chain id. Use a `ts-morph` script keyed by parameter type.
|
|
46
|
+
- `spokeProvider` → `walletProvider`. The replacement isn't 1-to-1 (`spokeProvider` was a class instance; `walletProvider` is a separate field). You're better off doing this manually per call site.
|
|
47
|
+
- `instanceof EvmSpokeProvider` → chain-key check. Chain-specific replacement varies (some need `chainKey === ChainKeys.X`, some `getChainType(chainKey) === 'EVM'`).
|
|
48
|
+
|
|
49
|
+
### `ts-morph` script for chain-id imports
|
|
50
|
+
|
|
51
|
+
When you have many files, a one-shot script for the chain-id rename. Run from the root of your consumer repo with `tsx codemod-chain-ids.ts`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// codemod-chain-ids.ts
|
|
55
|
+
import { Project, SyntaxKind } from 'ts-morph';
|
|
56
|
+
|
|
57
|
+
const project = new Project({ tsConfigFilePath: 'tsconfig.json' });
|
|
58
|
+
const sodaxImports = ['@sodax/types', '@sodax/sdk'];
|
|
59
|
+
const renamed = new Set<string>();
|
|
60
|
+
|
|
61
|
+
for (const file of project.getSourceFiles('src/**/*.{ts,tsx}')) {
|
|
62
|
+
let edited = false;
|
|
63
|
+
|
|
64
|
+
for (const decl of file.getImportDeclarations()) {
|
|
65
|
+
if (!sodaxImports.includes(decl.getModuleSpecifierValue())) continue;
|
|
66
|
+
|
|
67
|
+
const named = decl.getNamedImports();
|
|
68
|
+
const toRemove: typeof named = [];
|
|
69
|
+
let needsChainKeysImport = false;
|
|
70
|
+
|
|
71
|
+
for (const imp of named) {
|
|
72
|
+
const name = imp.getName();
|
|
73
|
+
const m = name.match(/^(.+)_MAINNET_CHAIN_ID$/);
|
|
74
|
+
if (!m) continue;
|
|
75
|
+
const newName = `ChainKeys.${m[1]}_MAINNET`;
|
|
76
|
+
// Replace usages inside the file
|
|
77
|
+
file.forEachDescendant(node => {
|
|
78
|
+
if (node.isKind(SyntaxKind.Identifier) && node.getText() === name) {
|
|
79
|
+
node.replaceWithText(newName);
|
|
80
|
+
edited = true;
|
|
81
|
+
renamed.add(name);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
toRemove.push(imp);
|
|
85
|
+
needsChainKeysImport = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (const imp of toRemove) imp.remove();
|
|
89
|
+
if (needsChainKeysImport) {
|
|
90
|
+
const existing = decl.getNamedImports().find(i => i.getName() === 'ChainKeys');
|
|
91
|
+
if (!existing) decl.addNamedImport('ChainKeys');
|
|
92
|
+
}
|
|
93
|
+
if (decl.getNamedImports().length === 0 && !decl.getNamespaceImport() && !decl.getDefaultImport()) {
|
|
94
|
+
decl.remove();
|
|
95
|
+
edited = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (edited) await file.save();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log('Renamed constants:', [...renamed].join(', '));
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Exit codes and post-run checks:
|
|
106
|
+
|
|
107
|
+
- **Run `tsc --noEmit` after** — confirm imports resolve. The script doesn't touch `ChainKey` type imports (which you may also need to add manually in some files).
|
|
108
|
+
- **Re-run with `--dry-run`** semantics by commenting out `file.save()` to preview the diff.
|
|
109
|
+
|
|
110
|
+
### Pitfall
|
|
111
|
+
|
|
112
|
+
The `ts-morph` script above edits in-place. Commit your tree before running.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 2. Free-function lookups at module scope
|
|
117
|
+
|
|
118
|
+
v1 exported free functions like `getHubChainConfig()` and `getMoneyMarketConfig(chainId)` that consumers called at **module-load time** inside constants/util files — *before* any `Sodax` instance exists. The v2 replacement on `Sodax.config.*` is unusable in that context (chicken-and-egg).
|
|
119
|
+
|
|
120
|
+
The real v2 answer: read directly from the packaged-default const `sodaxConfig`, re-exported from `@sodax/sdk` (and from `@sodax/types`):
|
|
121
|
+
|
|
122
|
+
| v1 free function | v2 module-scope equivalent |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `getHubChainConfig()` | `sodaxConfig.hub` |
|
|
125
|
+
| `getMoneyMarketConfig(hubChainId)` | `sodaxConfig.moneyMarket` |
|
|
126
|
+
| `getMoneyMarketConfig(hubChainId).supportedTokens` | `sodaxConfig.moneyMarket.supportedTokens` |
|
|
127
|
+
| `getSolverConfig(SONIC_MAINNET_CHAIN_ID)` (read solver endpoints) | `sodaxConfig.solver` |
|
|
128
|
+
| (none — v1 had no module-scope-safe accessor for full hub object) | `sodaxConfig.hub.addresses.hubWallet`, `.assetManager`, etc. |
|
|
129
|
+
|
|
130
|
+
```diff
|
|
131
|
+
- // v1 — module-scope constants file (no Sodax instance available yet)
|
|
132
|
+
- import { getHubChainConfig, getMoneyMarketConfig } from '@sodax/sdk';
|
|
133
|
+
- import { SONIC_MAINNET_CHAIN_ID } from '@sodax/types';
|
|
134
|
+
-
|
|
135
|
+
- const hubConfig = { hubRpcUrl, chainConfig: getHubChainConfig() };
|
|
136
|
+
- const moneyMarketConfig = getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID);
|
|
137
|
+
|
|
138
|
+
+ // v2 — read from packaged defaults; no Sodax instance needed
|
|
139
|
+
+ import { sodaxConfig } from '@sodax/sdk';
|
|
140
|
+
+
|
|
141
|
+
+ const hubAddresses = sodaxConfig.hub.addresses;
|
|
142
|
+
+ const moneyMarketTokens = sodaxConfig.moneyMarket.supportedTokens;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> **Once you have a `Sodax` instance**, prefer `sodax.config.*` (`sodax.config.getHubChainConfig()`, `sodax.config.getMoneyMarketReserveAssets()`, etc.). The service-API path reflects backend-driven runtime updates after `await sodax.config.initialize()`; `sodaxConfig` is a packaged-default snapshot frozen at SDK release time.
|
|
146
|
+
|
|
147
|
+
For hub-only module-scope reads, `hubConfig` is also exported directly:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { hubConfig } from '@sodax/sdk';
|
|
151
|
+
|
|
152
|
+
const HUB_WALLET = hubConfig.addresses.hubWallet;
|
|
153
|
+
const STAKING_ROUTER = hubConfig.addresses.stakingRouter;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
See [`reference/sodax-config.md`](reference/sodax-config.md) § "Pitfall — module-scope reads" for the same guidance in the SodaxConfig reshape doc.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 3. Error-shape adapter
|
|
161
|
+
|
|
162
|
+
If your consumer code has `getMmErrorText`, `getSwapErrorText`, or similar helpers that branch on a v1 error object's `.code` and `.data.error`, the minimal-change migration is to wrap incoming v2 `SodaxError` instances at the entry point of each helper:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
// shared/error-shape-adapter.ts
|
|
166
|
+
import { isSodaxError } from '@sodax/sdk';
|
|
167
|
+
|
|
168
|
+
export type V1ErrorShape = {
|
|
169
|
+
code?: string;
|
|
170
|
+
message?: string;
|
|
171
|
+
data?: { error?: unknown };
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Adapt v2 SodaxError onto the v1 `{ code, message, data: { error } }` shape so
|
|
176
|
+
* existing v1-style error helpers keep working without rewriting every branch.
|
|
177
|
+
*
|
|
178
|
+
* Migration only — replace with `(error.feature, error.code)` branching once the
|
|
179
|
+
* helper is rewritten.
|
|
180
|
+
*/
|
|
181
|
+
export function adaptToV1ErrorShape(error: unknown): V1ErrorShape | null {
|
|
182
|
+
if (error == null) return null;
|
|
183
|
+
|
|
184
|
+
// v2 SodaxError → v1-shaped object with code on top level.
|
|
185
|
+
if (isSodaxError(error)) {
|
|
186
|
+
return {
|
|
187
|
+
code: error.code,
|
|
188
|
+
message: error.message,
|
|
189
|
+
data: { error: error.cause },
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Plain Error (no code) — fall back to message.
|
|
194
|
+
if (error instanceof Error) {
|
|
195
|
+
return { code: error.message, message: error.message };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Already v1 shape — pass through.
|
|
199
|
+
if (typeof error === 'object') {
|
|
200
|
+
return error as V1ErrorShape;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Usage
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
// Before:
|
|
211
|
+
function getMmErrorText(error: unknown): string {
|
|
212
|
+
if (error instanceof MoneyMarketError) {
|
|
213
|
+
if (error.code === 'CREATE_SUPPLY_INTENT_FAILED') return 'Could not build supply';
|
|
214
|
+
if (error.code === 'SUPPLY_FAILED') return 'Supply failed';
|
|
215
|
+
}
|
|
216
|
+
return 'Unknown error';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// After (adapter at the top, branches keep working):
|
|
220
|
+
function getMmErrorText(error: unknown): string {
|
|
221
|
+
const sdkError = adaptToV1ErrorShape(error);
|
|
222
|
+
if (sdkError?.code === 'INTENT_CREATION_FAILED') return 'Could not build supply'; // v2 code
|
|
223
|
+
if (sdkError?.code === 'EXECUTION_FAILED') return 'Supply failed'; // v2 code
|
|
224
|
+
return 'Unknown error';
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Final-form (recommended)
|
|
229
|
+
|
|
230
|
+
After the adapter is in place, gradually rewrite each helper to use `(feature, code)` directly. The adapter is a stepping stone, not the destination:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import { isSodaxError } from '@sodax/sdk';
|
|
234
|
+
|
|
235
|
+
function getMmErrorText(error: unknown): string {
|
|
236
|
+
if (!isSodaxError(error) || error.feature !== 'moneyMarket') return 'Unknown error';
|
|
237
|
+
switch (error.code) {
|
|
238
|
+
case 'INTENT_CREATION_FAILED':
|
|
239
|
+
return error.context?.action === 'supply' ? 'Could not build supply' : 'Could not build operation';
|
|
240
|
+
case 'EXECUTION_FAILED':
|
|
241
|
+
return `${error.context?.action ?? 'operation'} failed`;
|
|
242
|
+
case 'RELAY_TIMEOUT':
|
|
243
|
+
return 'Cross-chain relay timed out';
|
|
244
|
+
case 'TX_VERIFICATION_FAILED':
|
|
245
|
+
return 'Transaction could not be verified on the source chain';
|
|
246
|
+
default:
|
|
247
|
+
return 'Unexpected error';
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
See [`reference/error-code-crosswalk.md`](reference/error-code-crosswalk.md) for the full v1 → v2 code crosswalk and [`breaking-changes/result-and-errors.md`](breaking-changes/result-and-errors.md) § 6 for the discrimination patterns this snippet uses.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 4. Result adapter
|
|
257
|
+
|
|
258
|
+
If converting every call site to branch on `result.ok` in one pass isn't realistic, use a `throwIfError` shim during migration. Then convert call sites at your own pace.
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
// shared/result-adapter.ts
|
|
262
|
+
import { isSodaxError } from '@sodax/sdk';
|
|
263
|
+
import type { Result } from '@sodax/sdk';
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Throw on { ok: false }. v1-shape callers can `await throwIfError(result)` and
|
|
267
|
+
* keep their existing try/catch blocks during migration.
|
|
268
|
+
*
|
|
269
|
+
* The thrown value is the original error from the Result — typically a SodaxError.
|
|
270
|
+
* Existing instanceof / .code branches will still work via adaptToV1ErrorShape.
|
|
271
|
+
*
|
|
272
|
+
* Migration only — once the call site is converted to branch on result.ok directly,
|
|
273
|
+
* remove the throwIfError wrap.
|
|
274
|
+
*/
|
|
275
|
+
export function throwIfError<T>(result: Result<T, unknown>): T {
|
|
276
|
+
if (!result.ok) {
|
|
277
|
+
if (isSodaxError(result.error)) throw result.error;
|
|
278
|
+
if (result.error instanceof Error) throw result.error;
|
|
279
|
+
throw new Error(`unwrap failed: ${String(result.error)}`);
|
|
280
|
+
}
|
|
281
|
+
return result.value;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Same as throwIfError, but coerces non-Error errors to a thrown Error
|
|
286
|
+
* (useful when downstream code only catches Error).
|
|
287
|
+
*/
|
|
288
|
+
export function throwAsError<T>(result: Result<T, unknown>, fallbackMessage = 'operation failed'): T {
|
|
289
|
+
if (!result.ok) {
|
|
290
|
+
const e = result.error;
|
|
291
|
+
if (e instanceof Error) throw e;
|
|
292
|
+
throw new Error(typeof e === 'string' ? e : fallbackMessage);
|
|
293
|
+
}
|
|
294
|
+
return result.value;
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Usage during migration
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
// Before (v1):
|
|
302
|
+
try {
|
|
303
|
+
const txHash = await sodax.moneyMarket.supply({ params, spokeProvider });
|
|
304
|
+
/* … */
|
|
305
|
+
} catch (e) {
|
|
306
|
+
if (e instanceof MoneyMarketError && e.code === 'SUPPLY_FAILED') /* … */
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// During migration (with shim):
|
|
310
|
+
try {
|
|
311
|
+
const { srcChainTxHash } = await throwIfError(
|
|
312
|
+
await sodax.moneyMarket.supply({ params, raw: false, walletProvider }),
|
|
313
|
+
);
|
|
314
|
+
/* … */
|
|
315
|
+
} catch (e) {
|
|
316
|
+
// existing v1-shape branches keep working via adaptToV1ErrorShape;
|
|
317
|
+
// SodaxError instances satisfy the same checks once you migrate them
|
|
318
|
+
if (e instanceof Error && /* … */) /* … */
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Final-form (recommended)
|
|
323
|
+
|
|
324
|
+
Once the call site is converted, drop `throwIfError`:
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
const result = await sodax.moneyMarket.supply({ params, raw: false, walletProvider });
|
|
328
|
+
if (!result.ok) {
|
|
329
|
+
setError(getMmErrorText(result.error));
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const { srcChainTxHash } = result.value;
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Pitfall — the v1-style `try { await sodax.<method>(...) } catch` does not work
|
|
336
|
+
|
|
337
|
+
A common mistake during migration: keeping the `try/catch` block but updating the inner call to v2 shape, expecting it to still throw. **It won't.** v2 `Result<T>` resolves on failure — the `catch` only fires for synchronous wrapper exceptions (e.g. missing `walletProvider`). Either:
|
|
338
|
+
|
|
339
|
+
- Wrap the call in `throwIfError` (this recipe), so failures throw.
|
|
340
|
+
- Branch on `result.ok` (preferred end state).
|
|
341
|
+
|
|
342
|
+
Don't leave the `try/catch` in place expecting it to catch SDK-level failures — it can't.
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Cross-references
|
|
347
|
+
|
|
348
|
+
- The breaking changes that motivate these recipes: [`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).
|
|
349
|
+
- Per-feature playbooks (which assume these recipes are in your toolkit): [`features/`](features/).
|
|
350
|
+
- v2 design context (the patterns you're migrating *to*): [`recipes/`](../../integration/knowledge/recipes/).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Migration reference — `@sodax/sdk` v1 → v2
|
|
2
|
+
|
|
3
|
+
Tables. Each file is a focused lookup; the prose explanations live in `../breaking-changes/` and `../features/`.
|
|
4
|
+
|
|
5
|
+
| File | Contents |
|
|
6
|
+
|---|---|
|
|
7
|
+
| [`deleted-exports.md`](deleted-exports.md) | Comprehensive table of every removed v1 export with its v2 replacement: spoke-provider classes & guards, static lookup tables, type aliases, constants, error types, per-feature param-shape changes. |
|
|
8
|
+
| [`sodax-config.md`](sodax-config.md) | `SodaxConfig` constructor reshape: `swaps` vs `solver` field split, `rpcConfig` keying change, `hubProviderConfig` → `hubConfig` rename, `configService` injection point gone. |
|
|
9
|
+
| [`error-code-crosswalk.md`](error-code-crosswalk.md) | Per-feature v1 module-error code → v2 `(feature, code, context)` tuple. Money market, swap, staking, bridge, migration, DEX, relay, partner, recovery. |
|
|
10
|
+
| [`return-shapes.md`](return-shapes.md) | Per-method return-shape diffs. `CreateIntentResult` tuple→object, every cross-chain mutation now returns `TxHashPair`, `getBridgeableAmount` returns `BridgeLimit`, `getStakeRatio` returns a tuple, etc. |
|
|
11
|
+
|
|
12
|
+
## Cross-references
|
|
13
|
+
|
|
14
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
15
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|
|
16
|
+
- [`../ai-rules.md`](../ai-rules.md) — DO / DO NOT / workflow.
|
|
17
|
+
- [`../breaking-changes/`](../breaking-changes/) — the prose that explains what these tables tabulate.
|
|
18
|
+
- v2 design context: [`architecture.md`](../../../integration/knowledge/architecture.md) and [`reference/`](../../../integration/knowledge/reference/).
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Deleted / replaced exports inventory
|
|
2
|
+
|
|
3
|
+
Every v1 export that's gone or repurposed in v2 — and its v2 successor. If you see `error TS2305: Module '"@sodax/sdk"' has no exported member '<X>'`, find `<X>` in the left column.
|
|
4
|
+
|
|
5
|
+
Two categories worth distinguishing:
|
|
6
|
+
- **Truly deleted** — the v1 symbol is gone; an import will fail compile (`TS2305`).
|
|
7
|
+
- **Name preserved, shape replaced** — a v1 `import` still compiles, but the runtime shape changed. Silent breakage if you read v1-only fields.
|
|
8
|
+
|
|
9
|
+
> Scope note: This doc only lists symbols that **don't import anymore** or **silently changed shape**. For v1 static constants that are still exported in v2 but should yield to the dynamic service API, see [`../breaking-changes/architecture.md`](../breaking-changes/architecture.md) § 2.
|
|
10
|
+
|
|
11
|
+
### Spoke-provider classes + guards
|
|
12
|
+
|
|
13
|
+
| v1 export | v2 replacement |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `EvmSpokeProvider` (class) | None — pass `walletProvider` + `srcChainKey` to SDK calls. See [`../breaking-changes/architecture.md`](../breaking-changes/architecture.md) § 1. |
|
|
16
|
+
| `SonicSpokeProvider` (class) | Same. |
|
|
17
|
+
| `SolanaSpokeProvider` (class) | Same. |
|
|
18
|
+
| `SuiSpokeProvider` (class) | Same. |
|
|
19
|
+
| `IconSpokeProvider` (class) | Same. |
|
|
20
|
+
| `InjectiveSpokeProvider` (class) | Same. |
|
|
21
|
+
| `StellarSpokeProvider` / `StellarBaseSpokeProvider` (classes) | Same. |
|
|
22
|
+
| `StacksSpokeProvider` (class) | Same. |
|
|
23
|
+
| `BitcoinSpokeProvider` (class) | Same. |
|
|
24
|
+
| `NearSpokeProvider` (class) | Same. |
|
|
25
|
+
| `SpokeProvider` (union type) | None — broad-union typing replaced by `srcChainKey: SpokeChainKey` + `walletProvider: GetWalletProviderType<K>`. |
|
|
26
|
+
| `isEvmSpokeProvider`, `isSolanaSpokeProvider`, `isBitcoinSpokeProvider`, `isStellarSpokeProvider`, `isIconSpokeProvider`, `isSuiSpokeProvider`, `isInjectiveSpokeProvider`, `isStacksSpokeProvider`, `isNearSpokeProvider`, `isSonicSpokeProvider` | `getChainType(chainKey) === '<FAMILY>'`, or family-level `is<Family>ChainKeyType(chainKey)` from `@sodax/sdk`. See [`../breaking-changes/architecture.md`](../breaking-changes/architecture.md) § 1. |
|
|
27
|
+
|
|
28
|
+
### Static lookup tables and helpers
|
|
29
|
+
|
|
30
|
+
| v1 export | v2 replacement |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `hubAssets` | `XToken.vault` / `XToken.hubAsset` baked in; or `sodax.config.getOriginalAssetAddress(...)`. See [`../breaking-changes/architecture.md`](../breaking-changes/architecture.md) § 2. |
|
|
33
|
+
| `getHubChainConfig()` (free function) | `sodax.config.getHubChainConfig()` (now a method on `ConfigService`, accessed via the `Sodax` instance). For module-scope reads (before a `Sodax` instance exists), see [`sodax-config.md`](sodax-config.md) § "Pitfall — module-scope reads". |
|
|
34
|
+
| `EvmWalletAbstraction` (class) | `sodax.hubProvider.getUserHubWalletAddress(...)` (the equivalent functionality lives on `EvmHubProvider`, accessed via the `Sodax` instance). |
|
|
35
|
+
| `HubService` (class) + `HubService.getUserHubWalletAddress(spokeAddress, spokeChainId, hubProvider)` (static method) | `sodax.hubProvider.getUserHubWalletAddress(spokeAddress, spokeChainKey)` (instance method on `EvmHubProvider`; doesn't take `hubProvider` arg — `this` is the hub provider). v1 callers in `dex/AssetService.ts`, `mm/useATokensBalances.ts`, `shared/useGetUserHubWalletAddress.ts` all flatten to this single shape. |
|
|
36
|
+
|
|
37
|
+
### Type aliases
|
|
38
|
+
|
|
39
|
+
| v1 export | v2 replacement |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `ChainId` (type) | `SpokeChainKey` (or `ChainKey` for the broader union including the hub). |
|
|
42
|
+
| `SpokeChainId` (type) | `SpokeChainKey`. |
|
|
43
|
+
| `EvmChainId` (type) | `EvmChainKey` (subset of `SpokeChainKey`). |
|
|
44
|
+
| `HubChainId` (type) | `HubChainKey` (literal `'sonic'`). |
|
|
45
|
+
| `Token` (type) | `XToken`. **Fully removed — no legacy alias.** `import type { Token } from '@sodax/types'` fails with `TS2305: '"@sodax/types"' has no exported member named 'Token'. Did you mean 'XToken'?`. The shape also changed (added `vault`, `hubAsset`; renamed `xChainId` → `chainKey`) — see [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 4. |
|
|
46
|
+
| `AddressType` (type — `'P2PKH' \| 'P2SH' \| 'P2WPKH' \| 'P2TR'`) | `BtcAddressType` (renamed; same shape). See [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 7. |
|
|
47
|
+
|
|
48
|
+
> Note: `BtcWalletAddressType` (`'taproot' | 'segwit'`, wallet-UI choice) is preserved in v2 with the same shape — it is **not** the same thing as `BtcAddressType` (on-chain address format). They coexist; do not blindly rename one to the other.
|
|
49
|
+
|
|
50
|
+
### Constants
|
|
51
|
+
|
|
52
|
+
| v1 export | v2 replacement |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `*_MAINNET_CHAIN_ID` (20 constants) | `ChainKeys.*` (single namespace). See [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 1 for the full table. |
|
|
55
|
+
|
|
56
|
+
### Wallet shims
|
|
57
|
+
|
|
58
|
+
| v1 export | v2 replacement |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `CustomProvider` (Hana-wallet window typedecl) | **Pick by what you actually use:** (a) **You only declared `window.hanaWallet.ethereum: CustomProvider` for typedecl quietness, never called methods on it** → replace the type with `unknown` (`declare global { interface Window { hanaWallet: { ethereum: unknown } } }`). 1-line fix. (b) **You called `window.hanaWallet.ethereum.request(...)` or built a custom Hana wallet** → import the named helpers `requestAddress`, `requestSigning`, `requestJsonRpc` from `@sodax/sdk` and use them in place of the raw provider calls. These are the same low-level Hana-extension helpers v1 wrapped, now first-class exports. |
|
|
61
|
+
|
|
62
|
+
### Error types and guards
|
|
63
|
+
|
|
64
|
+
#### Error types — name preserved, shape replaced
|
|
65
|
+
|
|
66
|
+
The following v1 error types were **plain object literals** `{ code: T; data: GetXxxError<T> }`. v2 keeps the same export names but redefines them as type aliases for the canonical `SodaxError<NarrowCode>` class instance. **A v1 `import { MoneyMarketError } from '@sodax/sdk'` still compiles** — but reading `err.data` will silently fail at runtime because the v2 shape is `{ name, code, feature, message, stack, context, cause }`. Treat these as "shape replaced" rather than deleted.
|
|
67
|
+
|
|
68
|
+
| v1 shape | v2 shape | What to read |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `MoneyMarketError<MoneyMarketErrorCode> = { code, data }` | `MoneyMarketError = SodaxError<MoneyMarketErrorCode>` (class instance) | `err.code`, `err.feature === 'moneyMarket'`, `err.context`, `err.cause`. See [`error-code-crosswalk.md`](error-code-crosswalk.md) for code crosswalk. |
|
|
71
|
+
| `BridgeError<BridgeErrorCode> = { code, data }` | `BridgeError = SodaxError<BridgeErrorCode>` | Same pattern; `err.feature === 'bridge'`. |
|
|
72
|
+
| `StakingError<StakingErrorCode> = { code, data }` | `StakingError = SodaxError<StakingErrorCode>` | Same pattern; `err.feature === 'staking'`. |
|
|
73
|
+
| `MigrationError<MigrationErrorCode> = { code, data }` | `MigrationError = SodaxError<MigrationErrorCode>` | Same pattern; `err.feature === 'migration'`. |
|
|
74
|
+
|
|
75
|
+
#### Error types — fully deleted
|
|
76
|
+
|
|
77
|
+
| v1 export | v2 replacement |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `IntentError<IntentErrorCode>`, plus `IntentErrorCode`, `IntentErrorData` | `SwapError = SodaxError<SwapErrorCode>` (renamed). `feature: 'swap'`. |
|
|
80
|
+
| `AssetServiceError<AssetServiceErrorCode>`, plus the union | `DexError = SodaxError<DexErrorCode>`. `feature: 'dex'`. |
|
|
81
|
+
| `ConcentratedLiquidityError<ConcentratedLiquidityErrorCode>`, plus the union | `DexError = SodaxError<DexErrorCode>` (asset + CL collapsed into one feature). |
|
|
82
|
+
| `RelayError<RelayErrorCode>`, plus the union | `SodaxError<C>` with the lower-level relay code on `error.context.relayCode`. |
|
|
83
|
+
| `SetSwapPreferenceError`, `CreateIntentAutoSwapError`, `WaitIntentAutoSwapError`, `UnknownIntentAutoSwapError`, `ExecuteIntentAutoSwapError` (5 distinct partner error types in `PartnerFeeClaimService.ts`) | `PartnerError = SodaxError<PartnerErrorCode>`. `feature: 'partner'`. |
|
|
84
|
+
|
|
85
|
+
#### Type guards — deleted
|
|
86
|
+
|
|
87
|
+
v1 only exposed **specific per-failure-mode guards**. v2 deleted all of these and instead ships **feature-level guards** + helper builders (`isFeatureError('<feature>')`, `isCodeMember(codeSet)`).
|
|
88
|
+
|
|
89
|
+
| v1 deleted guard | v2 replacement |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `isIntentCreationFailedError(e)` | `isSwapCreateIntentError(e)` or `isSodaxError(e) && e.code === 'INTENT_CREATION_FAILED' && e.feature === 'swap'`. |
|
|
92
|
+
| `isIntentSubmitTxFailedError(e)` | `isSodaxError(e) && e.code === 'TX_SUBMIT_FAILED'`. |
|
|
93
|
+
| `isIntentPostExecutionFailedError(e)` | `isSodaxError(e) && e.feature === 'swap' && e.code === 'EXECUTION_FAILED' && e.context?.phase === 'postExecution'`. |
|
|
94
|
+
| `isWaitUntilIntentExecutedFailed(e)` | `isSodaxError(e) && e.feature === 'swap' && e.code === 'RELAY_TIMEOUT'`. The v1 guard fired when the destination packet never reached `executed`; in v2 that surfaces as the unified `RELAY_TIMEOUT` code (with the underlying relay code on `error.context.relayCode`). |
|
|
95
|
+
| `isIntentCreationUnknownError(e)` | `isSodaxError(e) && e.code === 'UNKNOWN' && e.feature === 'swap'`. |
|
|
96
|
+
| `isMoneyMarketSubmitTxFailedError`, `isMoneyMarketRelayTimeoutError`, `isMoneyMarketCreate{Supply,Borrow,Withdraw,Repay}IntentFailedError`, `isMoneyMarket{Supply,Borrow,Withdraw,Repay}UnknownError` (10 specific guards) | `isMoneyMarketError(e)` (new in v2) for the feature-level check, then narrow on `e.code` / `e.context.action`. |
|
|
97
|
+
| `isCreateIntentAutoSwapError`, `isWaitIntentAutoSwapError`, `isUnknownIntentAutoSwapError`, `isSetSwapPreferenceError` (4 partner guards) | `isPartnerError(e)` (new in v2) for the feature-level check, then narrow on `e.code` / `e.context.action`. |
|
|
98
|
+
|
|
99
|
+
> Note: `isMoneyMarketError`, `isBridgeError`, `isStakingError`, `isMigrationError`, `isSwapError`, `isDexError`, `isPartnerError`, `isRecoveryError` did **not** exist in v1 — v2 added them as new feature-level guards alongside `isSodaxError` and the `isFeatureError('<feature>')` factory. See [`../breaking-changes/result-and-errors.md`](../breaking-changes/result-and-errors.md) § 6 for migration patterns.
|
|
100
|
+
|
|
101
|
+
### Per-feature param shape
|
|
102
|
+
|
|
103
|
+
These types changed shape (typically: gained a generic `<K extends SpokeChainKey>`, gained `srcChainKey` and `srcAddress` required fields). The v1 names still exist but with a different signature — fixing imports won't compile, you also need to update construction.
|
|
104
|
+
|
|
105
|
+
| v1 type | v2 type | Required additions in v2 |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| `MoneyMarketSupplyParams` | `MoneyMarketSupplyParams<K extends SpokeChainKey>` | `srcChainKey: K`, `srcAddress: GetAddressType<K>` |
|
|
108
|
+
| `MoneyMarketBorrowParams` | `MoneyMarketBorrowParams<K>` | Same; plus optional `dstChainKey`, `dstAddress` for cross-chain. |
|
|
109
|
+
| `MoneyMarketWithdrawParams` | `MoneyMarketWithdrawParams<K>` | Same. |
|
|
110
|
+
| `MoneyMarketRepayParams` | `MoneyMarketRepayParams<K>` | Same; plus optional `dstChainKey`/`dstAddress` (debt chain). |
|
|
111
|
+
| `StakeParams`, `UnstakeParams`, `InstantUnstakeParams`, `ClaimParams`, `CancelUnstakeParams` | All gained `<K>` generic | `srcChainKey: K`, `srcAddress: GetAddressType<K>`. v1 `account` field renamed to `srcAddress`. |
|
|
112
|
+
| `MigrationParams` | `MigrationParams<K>` | Same. |
|
|
113
|
+
| `UnifiedBnUSDMigrateParams` | `UnifiedBnUSDMigrateParams<K>` | Same. |
|
|
114
|
+
| `CreateAssetDepositParams`, `CreateAssetWithdrawParams`, `ClSupplyParams`, `ClIncreaseLiquidityParams`, `ClDecreaseLiquidityParams`, `ClClaimRewardsParams` | All gained `<K>` generic | `srcChainKey`, `srcAddress`. |
|
|
115
|
+
| `CreateIntentParams`, `CreateLimitOrderParams` | All gained `<K>` generic | Field renames `srcChain` → `srcChainKey`, `dstChain` → `dstChainKey` (v1 `srcChain` was a chain id type, now `srcChainKey: K`). |
|
|
116
|
+
|
|
117
|
+
The [`error TS1360`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#smarter-type-alias-preservation) pattern (`Type '{ token, amount, action }' does not satisfy the expected type 'MoneyMarketSupplyParams'`) is the typecheck signature: a literal that matches v1's shape but missing v2's required `srcChainKey` and `srcAddress`. Add both.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Cross-references
|
|
123
|
+
|
|
124
|
+
- [`README.md`](README.md) — migration reference index.
|
|
125
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
126
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|
|
127
|
+
- [`../breaking-changes/architecture.md`](../breaking-changes/architecture.md) § 2 — guidance for v1 static constants that are still exported in v2.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# v1 ↔ v2 code crosswalk
|
|
2
|
+
|
|
3
|
+
The widest-impact migration table in this file. v1 had per-module `*ErrorCode` unions; v2 reuses the 13 unified codes plus `feature` discrimination. **Match by intent, not by name** — the v1 `CREATE_SUPPLY_INTENT_FAILED` code is now `INTENT_CREATION_FAILED` with `feature: 'moneyMarket'` and `context.action: 'supply'`.
|
|
4
|
+
|
|
5
|
+
### Money Market (`MoneyMarketErrorCode` → `feature: 'moneyMarket'`)
|
|
6
|
+
|
|
7
|
+
| v1 code | v2 code | v2 context |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `CREATE_SUPPLY_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'supply'` |
|
|
10
|
+
| `CREATE_BORROW_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'borrow'` |
|
|
11
|
+
| `CREATE_WITHDRAW_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'withdraw'` |
|
|
12
|
+
| `CREATE_REPAY_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'repay'` |
|
|
13
|
+
| `SUPPLY_FAILED` | `EXECUTION_FAILED` | `action: 'supply'` |
|
|
14
|
+
| `BORROW_FAILED` | `EXECUTION_FAILED` | `action: 'borrow'` |
|
|
15
|
+
| `WITHDRAW_FAILED` | `EXECUTION_FAILED` | `action: 'withdraw'` |
|
|
16
|
+
| `REPAY_FAILED` | `EXECUTION_FAILED` | `action: 'repay'` |
|
|
17
|
+
| `ALLOWANCE_CHECK_FAILED` | `ALLOWANCE_CHECK_FAILED` | (unchanged) |
|
|
18
|
+
| `APPROVE_FAILED` | `APPROVE_FAILED` | (unchanged) |
|
|
19
|
+
| `GAS_ESTIMATION_FAILED` | `GAS_ESTIMATION_FAILED` | (unchanged) |
|
|
20
|
+
|
|
21
|
+
### Swap (`IntentErrorCode` → `feature: 'swap'`)
|
|
22
|
+
|
|
23
|
+
| v1 code | v2 code | v2 context |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `CREATE_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'createIntent'` |
|
|
26
|
+
| `CREATE_LIMIT_ORDER_FAILED` | `INTENT_CREATION_FAILED` | `action: 'createLimitOrder'` |
|
|
27
|
+
| `POST_EXECUTION_FAILED` | `EXECUTION_FAILED` | `action: 'swap'`, `phase: 'postExecution'` |
|
|
28
|
+
| `SOLVER_API_ERROR` | `EXTERNAL_API_ERROR` | `api: 'solver'`, `solverCode`/`solverDetail` on context |
|
|
29
|
+
| `SIMULATION_FAILED` | `EXECUTION_FAILED` | `phase: 'execution'` |
|
|
30
|
+
|
|
31
|
+
### Staking (`StakingErrorCode` → `feature: 'staking'`)
|
|
32
|
+
|
|
33
|
+
| v1 code | v2 code | v2 context |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `STAKE_FAILED` | `EXECUTION_FAILED` | `action: 'stake'` |
|
|
36
|
+
| `UNSTAKE_FAILED` | `EXECUTION_FAILED` | `action: 'unstake'` |
|
|
37
|
+
| `INSTANT_UNSTAKE_FAILED` | `EXECUTION_FAILED` | `action: 'instantUnstake'` |
|
|
38
|
+
| `CLAIM_FAILED` | `EXECUTION_FAILED` | `action: 'claim'` |
|
|
39
|
+
| `CANCEL_UNSTAKE_FAILED` | `EXECUTION_FAILED` | `action: 'cancelUnstake'` |
|
|
40
|
+
| `GET_STAKING_INFO_FAILED` | `LOOKUP_FAILED` | `method: 'getStakingInfo'` |
|
|
41
|
+
| `GET_UNSTAKING_INFO_FAILED` | `LOOKUP_FAILED` | `method: 'getUnstakingInfo'` |
|
|
42
|
+
| `GET_STAKING_CONFIG_FAILED` | `LOOKUP_FAILED` | `method: 'getStakingConfig'` |
|
|
43
|
+
| `GET_STAKE_RATIO_FAILED` | `LOOKUP_FAILED` | `method: 'getStakeRatio'` |
|
|
44
|
+
|
|
45
|
+
### Bridge (`BridgeErrorCode` → `feature: 'bridge'`)
|
|
46
|
+
|
|
47
|
+
| v1 code | v2 code | v2 context |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `BRIDGE_FAILED` | `EXECUTION_FAILED` | `action: 'bridge'` |
|
|
50
|
+
| `CREATE_BRIDGE_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'bridge'` |
|
|
51
|
+
| `GET_BRIDGEABLE_AMOUNT_FAILED` | `LOOKUP_FAILED` | `method: 'getBridgeableAmount'` |
|
|
52
|
+
| `GET_BRIDGEABLE_TOKENS_FAILED` | `LOOKUP_FAILED` | `method: 'getBridgeableTokens'` |
|
|
53
|
+
|
|
54
|
+
### Migration (`MigrationErrorCode` → `feature: 'migration'`)
|
|
55
|
+
|
|
56
|
+
| v1 code | v2 code | v2 context |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `MIGRATE_BNUSD_FORWARD_FAILED` | `EXECUTION_FAILED` | `action: 'migratebnUSD'`, `direction: 'forward'` |
|
|
59
|
+
| `MIGRATE_BNUSD_REVERSE_FAILED` | `EXECUTION_FAILED` | `action: 'migratebnUSD'`, `direction: 'reverse'` |
|
|
60
|
+
| `MIGRATE_ICX_TO_SODA_FAILED` | `EXECUTION_FAILED` | `action: 'migrateIcxToSoda'` |
|
|
61
|
+
| `REVERT_MIGRATE_SODA_TO_ICX_FAILED` | `EXECUTION_FAILED` | `action: 'revertMigrateSodaToIcx'` |
|
|
62
|
+
| `MIGRATE_BALN_FAILED` | `EXECUTION_FAILED` | `action: 'migrateBaln'` |
|
|
63
|
+
| `GET_AVAILABLE_AMOUNT_FAILED` | `LOOKUP_FAILED` | `method: 'getAvailableAmount'` |
|
|
64
|
+
|
|
65
|
+
### DEX (`AssetServiceErrorCode` + `ConcentratedLiquidityErrorCode` → `feature: 'dex'`)
|
|
66
|
+
|
|
67
|
+
| v1 code | v2 code | v2 context |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `DEPOSIT_FAILED` | `EXECUTION_FAILED` | `action: 'deposit'` |
|
|
70
|
+
| `WITHDRAW_FAILED` | `EXECUTION_FAILED` | `action: 'withdraw'` |
|
|
71
|
+
| `SUPPLY_LIQUIDITY_FAILED` | `EXECUTION_FAILED` | `action: 'supplyLiquidity'` |
|
|
72
|
+
| `INCREASE_LIQUIDITY_FAILED` | `EXECUTION_FAILED` | `action: 'increaseLiquidity'` |
|
|
73
|
+
| `DECREASE_LIQUIDITY_FAILED` | `EXECUTION_FAILED` | `action: 'decreaseLiquidity'` |
|
|
74
|
+
| `CLAIM_REWARDS_FAILED` | `EXECUTION_FAILED` | `action: 'claimRewards'` |
|
|
75
|
+
| `GET_POOL_DATA_FAILED` | `LOOKUP_FAILED` | `method: 'getPoolData'` |
|
|
76
|
+
| `GET_POSITION_INFO_FAILED` | `LOOKUP_FAILED` | `method: 'getPositionInfo'` |
|
|
77
|
+
|
|
78
|
+
### Relay (`RelayErrorCode` → typically still on `context.relayCode`)
|
|
79
|
+
|
|
80
|
+
The relay-layer code strings are kept on `context.relayCode` of the surfaced `SodaxError`. They are also a stable public contract used by lower-level relay code:
|
|
81
|
+
|
|
82
|
+
| v1 code | v2 code on `error.code` | v2 `context.relayCode` |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `SUBMIT_TX_FAILED` | `TX_SUBMIT_FAILED` | `'SUBMIT_TX_FAILED'` |
|
|
85
|
+
| `RELAY_TIMEOUT` | `RELAY_TIMEOUT` | `'RELAY_TIMEOUT'` |
|
|
86
|
+
| `RELAY_POLLING_FAILED` | `RELAY_FAILED` | `'RELAY_POLLING_FAILED'` |
|
|
87
|
+
| (any unrecognised) | `RELAY_FAILED` | `'UNKNOWN'` |
|
|
88
|
+
|
|
89
|
+
### Partner (5 typed errors → `feature: 'partner'`)
|
|
90
|
+
|
|
91
|
+
All partner typed errors collapse to `EXECUTION_FAILED` with `action` discriminating between the 5 v1 operations.
|
|
92
|
+
|
|
93
|
+
### Recovery (no v1 typed errors — module is v2-new) → `feature: 'recovery'`
|
|
94
|
+
|
|
95
|
+
`EXECUTION_FAILED` for the recovery action; `LOOKUP_FAILED` for read methods.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## Cross-references
|
|
101
|
+
|
|
102
|
+
- [`README.md`](README.md) — migration reference index.
|
|
103
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
104
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Return-shape diffs per method
|
|
2
|
+
|
|
3
|
+
### `SwapService.createIntent`
|
|
4
|
+
|
|
5
|
+
```diff
|
|
6
|
+
- const [spokeTxHash, intent, relayData] = result;
|
|
7
|
+
+ const { tx, intent, relayData } = result.value;
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
v1 returned a tuple. v2 returns an object: `{ tx, intent, relayData }` where:
|
|
11
|
+
- `tx` is `TxReturnType<K, false>` (the spoke tx hash for `raw: false`, or the raw tx payload for `raw: true`).
|
|
12
|
+
- `intent` is the intent struct.
|
|
13
|
+
- `relayData` is `RelayExtraData` (`{ payload: string; ... }`).
|
|
14
|
+
|
|
15
|
+
If you use the backend submit-swap-tx API, the v1 `relayData` field on the request expects the **string**, not the object — pass `relayData.payload`.
|
|
16
|
+
|
|
17
|
+
### `BridgeService.bridge` and similar full-execution methods
|
|
18
|
+
|
|
19
|
+
```diff
|
|
20
|
+
- const txHash: string = await sodax.bridge.bridge(...);
|
|
21
|
+
+ const result = await sodax.bridge.bridge({ params, raw: false, walletProvider });
|
|
22
|
+
+ if (!result.ok) return;
|
|
23
|
+
+ const { srcChainTxHash, dstChainTxHash } = result.value;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
v2 cross-chain mutation methods return `TxHashPair = { srcChainTxHash, dstChainTxHash }` so the consumer has both legs of the relay. The same shape applies to `staking.stake`, `staking.unstake`, `staking.instantUnstake`, `staking.claim`, `staking.cancelUnstake`, `dex.assetService.deposit/withdraw`, `dex.clService.supplyLiquidity/increaseLiquidity/decreaseLiquidity/claimRewards`, and the 4 `migration.*` orchestrators (`migratebnUSD`, `migrateIcxToSoda`, `revertMigrateSodaToIcx`, `migrateBaln`). Consumers on the hub chain still get both fields populated (with the same hash) for shape consistency.
|
|
27
|
+
|
|
28
|
+
### `MoneyMarketService.{supply, borrow, withdraw, repay}`
|
|
29
|
+
|
|
30
|
+
```diff
|
|
31
|
+
- const txHash = await sodax.moneyMarket.supply(...);
|
|
32
|
+
+ const result = await sodax.moneyMarket.supply({ params, raw: false, walletProvider });
|
|
33
|
+
+ const { srcChainTxHash, dstChainTxHash } = result.value;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Same `TxHashPair` shape as every other cross-chain mutation in v2.
|
|
37
|
+
|
|
38
|
+
### Everything else
|
|
39
|
+
|
|
40
|
+
If a v1 method returned a single `string` tx hash, the v2 return is `Result<TxReturnType<K, false>>` — destructure as `result.value` (which is the hash for `raw: false`, or the chain-specific raw tx payload for `raw: true`).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Cross-references
|
|
46
|
+
|
|
47
|
+
- [`README.md`](README.md) — migration reference index.
|
|
48
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
49
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|