@sodax/wallet-sdk-core 1.5.7-beta → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +231 -1
  2. package/ai-exported/AGENTS.md +139 -0
  3. package/ai-exported/integration/README.md +108 -0
  4. package/ai-exported/integration/ai-rules.md +141 -0
  5. package/ai-exported/integration/architecture.md +212 -0
  6. package/ai-exported/integration/features/README.md +22 -0
  7. package/ai-exported/integration/features/bitcoin.md +103 -0
  8. package/ai-exported/integration/features/evm.md +102 -0
  9. package/ai-exported/integration/features/icon.md +88 -0
  10. package/ai-exported/integration/features/injective.md +92 -0
  11. package/ai-exported/integration/features/near.md +92 -0
  12. package/ai-exported/integration/features/solana.md +104 -0
  13. package/ai-exported/integration/features/stacks.md +91 -0
  14. package/ai-exported/integration/features/stellar.md +95 -0
  15. package/ai-exported/integration/features/sui.md +96 -0
  16. package/ai-exported/integration/quickstart.md +259 -0
  17. package/ai-exported/integration/recipes/README.md +15 -0
  18. package/ai-exported/integration/recipes/bridge-to-sdk.md +145 -0
  19. package/ai-exported/integration/recipes/defaults-and-overrides.md +159 -0
  20. package/ai-exported/integration/recipes/library-exports.md +129 -0
  21. package/ai-exported/integration/recipes/setup-browser-extension.md +137 -0
  22. package/ai-exported/integration/recipes/setup-private-key.md +115 -0
  23. package/ai-exported/integration/recipes/sign-and-broadcast.md +201 -0
  24. package/ai-exported/integration/recipes/testing.md +163 -0
  25. package/ai-exported/integration/reference/README.md +13 -0
  26. package/ai-exported/integration/reference/chain-support.md +65 -0
  27. package/ai-exported/integration/reference/glossary.md +28 -0
  28. package/ai-exported/integration/reference/interfaces.md +131 -0
  29. package/ai-exported/integration/reference/provider-classes.md +54 -0
  30. package/ai-exported/integration/reference/public-api.md +128 -0
  31. package/ai-exported/migration/README.md +84 -0
  32. package/ai-exported/migration/ai-rules.md +139 -0
  33. package/ai-exported/migration/breaking-changes/README.md +14 -0
  34. package/ai-exported/migration/breaking-changes/base-wallet-provider.md +52 -0
  35. package/ai-exported/migration/breaking-changes/defaults-config.md +57 -0
  36. package/ai-exported/migration/breaking-changes/folder-layout.md +99 -0
  37. package/ai-exported/migration/breaking-changes/library-exports.md +58 -0
  38. package/ai-exported/migration/checklist.md +62 -0
  39. package/ai-exported/migration/recipes/README.md +12 -0
  40. package/ai-exported/migration/recipes/adopt-defaults.md +84 -0
  41. package/ai-exported/migration/recipes/adopt-library-exports.md +99 -0
  42. package/ai-exported/migration/reference/README.md +12 -0
  43. package/ai-exported/migration/reference/added-fields.md +71 -0
  44. package/ai-exported/migration/reference/deleted-exports.md +35 -0
  45. package/ai-exported/migration/reference/renamed-symbols.md +31 -0
  46. package/ai-exported/migration/reference/return-shapes.md +23 -0
  47. package/dist/index.cjs +3200 -2392
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +415 -128
  50. package/dist/index.d.ts +415 -128
  51. package/dist/index.mjs +3197 -2395
  52. package/dist/index.mjs.map +1 -1
  53. package/package.json +10 -8
@@ -0,0 +1,139 @@
1
+ # AI Rules — Migration
2
+
3
+ You are upgrading a user's app from **v1** of `@sodax/wallet-sdk-core` (the legacy `sodax-frontend` codebase) to **v2** (current). The package name did not change. The default expectation is **v1 code drops in unchanged** — there are no mandatory edits at the wallet-sdk-core surface. Follow this protocol exactly.
4
+
5
+ ---
6
+
7
+ ## Workflow (do these in order)
8
+
9
+ ### 1. Survey
10
+
11
+ Before changing anything, survey the user's project:
12
+
13
+ ```bash
14
+ # 1a. Find every wallet-sdk-core import site
15
+ grep -rn "from '@sodax/wallet-sdk-core'" <user-src>
16
+
17
+ # 1b. Find every provider construction site
18
+ grep -rnE "new [A-Z][a-zA-Z0-9]*WalletProvider\(" <user-src>
19
+
20
+ # 1c. Deep imports from src/... — were never supported, now broken
21
+ grep -rn "@sodax/wallet-sdk-core/" <user-src> | grep -v "from '@sodax/wallet-sdk-core'"
22
+
23
+ # 1d. Direct upstream-SDK type imports that library-exports could replace (optional cleanup)
24
+ grep -rn "from 'viem'" <user-src> | grep -E "WalletClient|PublicClient|TransactionReceipt|SendTransactionParameters|WaitForTransactionReceiptParameters"
25
+ grep -rn "from '@stellar/stellar-sdk'" <user-src> | grep "Networks"
26
+ grep -rn "from '@stacks/transactions'" <user-src> | grep -E "PostConditionMode|ClarityValue|PostConditionModeName"
27
+ grep -rn "from '@mysten/wallet-standard'" <user-src>
28
+ grep -rn "from '@solana/web3.js'" <user-src> | grep -E "Commitment|ConnectionConfig|SendOptions"
29
+
30
+ # 1e. Hand-rolled wrappers around providers (potential candidates for `defaults` adoption)
31
+ grep -rnE "function\s+(make|build|with)[A-Z][a-zA-Z0-9]*Provider" <user-src>
32
+ ```
33
+
34
+ Build a list of every file under each category. Show this list to the user before proceeding.
35
+
36
+ ### 2. Bump the package version
37
+
38
+ Update `@sodax/wallet-sdk-core` to the v2 target in the user's `package.json`. Run install.
39
+
40
+ ### 3. Type-check the project
41
+
42
+ ```bash
43
+ pnpm checkTs
44
+ ```
45
+
46
+ **Expected outcome: zero errors mentioning `@sodax/wallet-sdk-core` symbols.** v1 code is backwards-compatible with v2.
47
+
48
+ If errors **do** appear, narrow them:
49
+
50
+ ```bash
51
+ pnpm exec tsc --noEmit 2>&1 | grep -iE "from '@sodax/wallet-sdk-core'|@sodax/wallet-sdk-core/"
52
+ ```
53
+
54
+ For each error:
55
+
56
+ - **Deep import from `src/...`?** → Replace with barrel import (`from '@sodax/wallet-sdk-core'`). The v2 source layout uses `wallet-providers/<chain>/` folders; old flat paths no longer resolve.
57
+ - **Symbol not found on barrel?** → Look up in [`../integration/reference/public-api.md`](../integration/reference/public-api.md). If genuinely missing, **stop and ask the user** — this is a docs gap or a regression.
58
+ - **Anything else?** → Stop and ask. Do not guess.
59
+
60
+ ### 4. Optional cleanup (only if user requests)
61
+
62
+ After v3 confirms a green typecheck, the upgrade is **done**. Everything below is optional:
63
+
64
+ - **Adopt `defaults`** — apply [`recipes/adopt-defaults.md`](./recipes/adopt-defaults.md) only if the user has hand-rolled `make*Provider` / `with*Defaults` wrappers that inject options on every call.
65
+ - **Adopt `library-exports`** — apply [`recipes/adopt-library-exports.md`](./recipes/adopt-library-exports.md) only if the user imports types from upstream chain SDKs and wants to drop those direct deps.
66
+
67
+ Each is independent. Apply only what the user asked for.
68
+
69
+ ### 5. Verify with the checklist
70
+
71
+ Loop through every item in [`checklist.md`](./checklist.md). Most items are `grep` commands. Do not skip items. Report results back to the user.
72
+
73
+ ---
74
+
75
+ ## DO
76
+
77
+ - **DO** read [`breaking-changes/README.md`](./breaking-changes/README.md) once to internalise that v1→v2 is **additive-only**. There is no rename / removal / required-field addition.
78
+ - **DO** start with `pnpm checkTs`. If it passes with zero wallet-sdk-core errors, the upgrade is done.
79
+ - **DO** preserve user comments, formatting, and unrelated code.
80
+ - **DO** treat optional cleanups as **opt-in**, never automatic.
81
+ - **DO** prefer the official `recipes/` over inventing your own structural rewrite.
82
+
83
+ ---
84
+
85
+ ## DO NOT
86
+
87
+ - **DO NOT** invent breaking changes. If you find yourself rewriting a `*WalletConfig` shape, stop — v1 and v2 shapes are identical. The change is somewhere else (likely `@sodax/sdk` or `@sodax/types`).
88
+ - **DO NOT** rewrite all upstream-SDK imports unprompted. `library-exports` adoption is an optimisation, not a requirement.
89
+ - **DO NOT** rename `PrivateKey<Chain>WalletConfig` → anything else. v1 already used the same names.
90
+ - **DO NOT** rewrite Injective constructions from `{ privateKey }` to `{ secret: { privateKey } }`. v1 already used the `{ secret: { privateKey | mnemonics } }` shape.
91
+ - **DO NOT** "improve" surrounding code (refactor, restyle, add error handling, change variable names).
92
+ - **DO NOT** add `defaults` to existing constructions unless the user explicitly asked for it.
93
+
94
+ ---
95
+
96
+ ## Stop conditions (defer to user)
97
+
98
+ | Signal | Why stop |
99
+ |---|---|
100
+ | Any deep import from `@sodax/wallet-sdk-core/src/...` | Never supported. Replace with barrel import; if the symbol is not on the barrel, it is intentionally internal — ask the user what they were doing. |
101
+ | `pnpm checkTs` reports a `@sodax/wallet-sdk-core` symbol that does not exist | Confirm against [`../integration/reference/public-api.md`](../integration/reference/public-api.md). If missing, this is a regression — file an issue. Do not guess a replacement. |
102
+ | User extends `BaseWalletProvider` directly in their code | This class is new in v2 and not intended for consumer subclassing. Confirm scope — maintainer path only. |
103
+ | User imports `shallowMerge` or anything from `@sodax/wallet-sdk-core/utils/...` | Internal in both v1 and v2 (utils didn't even exist in v1). Replace with the `defaults` config or pass merged options at the call site. |
104
+ | `as unknown as` casts around provider construction | Likely a workaround for a previous-RC bug. Investigate — usually safe to remove now. |
105
+
106
+ When stopping, **quote the file/line** of the offending code and present the user with concrete options.
107
+
108
+ ---
109
+
110
+ ## Verification protocol (after every change)
111
+
112
+ ```bash
113
+ # 1. Type check
114
+ pnpm checkTs
115
+
116
+ # 2. No deep imports from src/
117
+ grep -rn "@sodax/wallet-sdk-core/" <user-src> | grep -v "from '@sodax/wallet-sdk-core'"
118
+ # expect empty
119
+
120
+ # 3. No imports of internal utilities
121
+ grep -rn "shallowMerge" <user-src>
122
+ # expect empty
123
+ ```
124
+
125
+ If all three pass and the [`checklist.md`](./checklist.md) is complete, the migration is done.
126
+
127
+ ---
128
+
129
+ ## Done criteria
130
+
131
+ The migration is complete when:
132
+
133
+ - [ ] `pnpm checkTs` exits clean.
134
+ - [ ] No deep imports from `@sodax/wallet-sdk-core/src/...`.
135
+ - [ ] No imports of internal utilities (`shallowMerge`).
136
+ - [ ] All items in [`checklist.md`](./checklist.md) are checked.
137
+ - [ ] The user has confirmed at least one signing flow still works in their dev / test environment.
138
+
139
+ Do not declare the migration done before all five are true.
@@ -0,0 +1,14 @@
1
+ # Breaking changes — narrative
2
+
3
+ One file per change, with the WHY behind it. Use this folder to understand intent; use [`../reference/`](../reference/) for mechanical name lookups; use [`../recipes/`](../recipes/) for paired before/after code.
4
+
5
+ **Every v1→v2 change at the wallet-sdk-core public surface is additive.** v1 consumer code drops in unchanged.
6
+
7
+ | File | Change | Action required |
8
+ |---|---|---|
9
+ | [`folder-layout.md`](./folder-layout.md) | Source layout: `wallet-providers/*.ts` (v1, flat) → `wallet-providers/<chain>/*.ts` (v2, folder-per-chain). | Only if user deep-imported `src/...`. Replace with barrel imports. |
10
+ | [`base-wallet-provider.md`](./base-wallet-provider.md) | `BaseWalletProvider<TDefaults>` introduced as shared abstract base. | None — internal. |
11
+ | [`defaults-config.md`](./defaults-config.md) | Every provider accepts an optional `defaults` slice. | None. Optional cleanup: drop hand-rolled default-injection wrappers. |
12
+ | [`library-exports.md`](./library-exports.md) | Upstream chain types re-exported from `@sodax/wallet-sdk-core`. | None. Optional cleanup: drop direct upstream-SDK deps for type-only usage. |
13
+
14
+ None of these are breaking at the type level. **There are no renames, no removals, no required-field additions.** If you see a v1 `*WalletConfig` symbol that doesn't compile against v2, file an issue — it's a regression, not a documented breaking change.
@@ -0,0 +1,52 @@
1
+ # `BaseWalletProvider` introduced
2
+
3
+ **Additive — no action required.** Older code continues to compile.
4
+
5
+ ---
6
+
7
+ ## What changed
8
+
9
+ Every provider class now extends a shared abstract base, `BaseWalletProvider<TDefaults>`:
10
+
11
+ ```ts
12
+ abstract class BaseWalletProvider<TDefaults extends object> {
13
+ protected readonly defaults: TDefaults;
14
+
15
+ constructor(defaults: TDefaults | undefined) {
16
+ this.defaults = (defaults ?? {}) as TDefaults;
17
+ }
18
+
19
+ abstract getWalletAddress(): Promise<string>;
20
+
21
+ protected mergePolicy<K extends keyof TDefaults>(key: K, options?: …): … { /* shallowMerge */ }
22
+ protected mergeDefaults(options?: Partial<TDefaults>): TDefaults { /* shallowMerge */ }
23
+ }
24
+ ```
25
+
26
+ Older RCs implemented each provider independently — some had ad-hoc default handling, others had none.
27
+
28
+ ## Why
29
+
30
+ Three reasons to unify:
31
+
32
+ 1. **Predictable merge semantics across chains.** Per-call options now shallow-merge over `defaults` the same way on every provider. No more chain-by-chain surprises.
33
+ 2. **One place to add cross-cutting features.** Future helpers (e.g. telemetry hooks, per-call validation) plug in at the base class.
34
+ 3. **Single source of truth for `getWalletAddress`.** Subclasses can narrow the return type to a chain-specific brand (`Address`, `IconEoaAddress`, …) without re-declaring the contract.
35
+
36
+ ## Consumer impact
37
+
38
+ None — the abstract base is a maintainer concern. Consumers continue to:
39
+
40
+ - Construct `EvmWalletProvider`, `SolanaWalletProvider`, etc. with the same discriminated unions.
41
+ - Pass them via the `IXxxWalletProvider` interface to `@sodax/sdk`.
42
+
43
+ You should **not** extend `BaseWalletProvider` in user code — see [`../ai-rules.md`](../ai-rules.md) § "Stop conditions".
44
+
45
+ ## How to verify it doesn't affect you
46
+
47
+ ```bash
48
+ pnpm checkTs
49
+ # Should pass without changes if you didn't subclass providers manually.
50
+ ```
51
+
52
+ If a typecheck fails because you previously declared `class Foo extends EvmWalletProvider` and overrode a private method, that override is now invalid — the base class made some helpers `protected`. Ask the user how they want to refactor.
@@ -0,0 +1,57 @@
1
+ # `defaults` config added to every provider
2
+
3
+ **Additive — no action required.** Older code continues to compile.
4
+
5
+ ---
6
+
7
+ ## What changed
8
+
9
+ Every `*WalletConfig` gained an optional `defaults?: *WalletDefaults` field. Per-call methods accept an `options?: …` parameter that **shallow-merges** over the relevant slice of `defaults`.
10
+
11
+ ```ts
12
+ // Older: explicit options on every call
13
+ const provider = new EvmWalletProvider({ privateKey, chainId });
14
+ await provider.sendTransaction(tx, { gas: 3_000_000n }); // every call needs gas
15
+
16
+ // Current: encode the default once, override per call when needed
17
+ const provider = new EvmWalletProvider({
18
+ privateKey,
19
+ chainId,
20
+ defaults: { sendTransaction: { gas: 3_000_000n } },
21
+ });
22
+ await provider.sendTransaction(tx); // gas applied automatically
23
+ await provider.sendTransaction(tx2, { gas: 5_000_000n }); // override per call
24
+ ```
25
+
26
+ ## Why
27
+
28
+ Three reasons:
29
+
30
+ 1. **Env-level constants belong with construction.** RPC commitment, default gas, default memo are tied to the **environment** (devnet vs mainnet, internal vs public RPC). Embedding them per-call leads to drift.
31
+ 2. **Hand-rolled wrappers were the previous workaround.** Older code often had a `makeProvider(opts)` helper that injected defaults at every call site. Now that lives in the provider.
32
+ 3. **Type-level safety.** Each chain's `*WalletDefaults` is precisely typed — invalid combinations fail at compile time, not at runtime.
33
+
34
+ ## Merge semantics
35
+
36
+ | Style | When used | Behavior |
37
+ |---|---|---|
38
+ | `mergePolicy('key', options)` | Defaults grouped per method (EVM, Solana, Sui) | `shallowMerge(defaults.key, options)` |
39
+ | `mergeDefaults(options)` | Defaults are a flat object (Bitcoin, Stellar, ICON, Injective, NEAR, Stacks) | `shallowMerge(defaults, options)` |
40
+
41
+ Shallow only. Nested objects are **replaced wholesale**, not deep-merged. See [`../../integration/recipes/defaults-and-overrides.md`](../../integration/recipes/defaults-and-overrides.md).
42
+
43
+ ## Consumer impact
44
+
45
+ | Older pattern | Replacement (optional) |
46
+ |---|---|
47
+ | `await provider.sendTransaction(tx, { gas })` on every call | `defaults: { sendTransaction: { gas } }` once at construction |
48
+ | `function makeEvmProvider(pk) { /* injects gas via closure */ }` | Remove the wrapper; pass `defaults` directly to the constructor |
49
+ | `Object.assign(provider.options, …)` (if hacked into older code) | Mutating internal state is **not** supported. Use `defaults` at construction. |
50
+
51
+ ## How to adopt
52
+
53
+ Only if you want the cleanup. Apply [`../recipes/adopt-defaults.md`](../recipes/adopt-defaults.md). Skip otherwise — the older per-call style still works.
54
+
55
+ ## Browser-extension caveat
56
+
57
+ In browser-extension mode the **constructor-time slices** of `defaults` (e.g. EVM's `transport`, `publicClient`, `walletClient`) are **ignored** — the consumer already supplied built clients. A one-time `console.warn` is logged. The method-grouped slices (`sendTransaction`, `waitForTransactionReceipt`, …) still apply.
@@ -0,0 +1,99 @@
1
+ # Source folder layout: flat → folder-per-chain
2
+
3
+ **Affects only deep imports from `src/...`.** Barrel imports (`from '@sodax/wallet-sdk-core'`) are unaffected.
4
+
5
+ ---
6
+
7
+ ## What changed
8
+
9
+ v1 (`sodax-frontend/packages/wallet-sdk-core`) used a **flat** layout:
10
+
11
+ ```
12
+ src/
13
+ ├── index.ts
14
+ └── wallet-providers/
15
+ ├── index.ts
16
+ ├── EvmWalletProvider.ts
17
+ ├── EvmWalletProvider.test.ts
18
+ ├── BTCWalletProvider.ts
19
+ ├── SuiWalletProvider.ts
20
+ ├── IconWalletProvider.ts
21
+ ├── InjectiveWalletProvider.ts
22
+ ├── SolanaWalletProvider.ts
23
+ ├── StellarWalletProvider.ts
24
+ ├── StacksWalletProvider.ts
25
+ └── NearWalletProvider.ts
26
+ ```
27
+
28
+ v2 reorganised into a **folder-per-chain** layout, with co-located types and tests:
29
+
30
+ ```
31
+ src/
32
+ ├── index.ts
33
+ ├── types/ # NEW — library-exports module
34
+ │ ├── index.ts
35
+ │ └── library-exports.ts
36
+ ├── utils/ # NEW — internal helpers
37
+ │ ├── index.ts
38
+ │ └── merge.ts
39
+ └── wallet-providers/
40
+ ├── index.ts
41
+ ├── BaseWalletProvider.ts # NEW
42
+ ├── evm/
43
+ │ ├── index.ts
44
+ │ ├── EvmWalletProvider.ts
45
+ │ ├── EvmWalletProvider.test.ts
46
+ │ └── types.ts
47
+ ├── bitcoin/ # new folder; file name kept as BTCWalletProvider.ts
48
+ │ ├── index.ts
49
+ │ ├── BTCWalletProvider.ts
50
+ │ ├── BTCWalletProvider.test.ts
51
+ │ └── types.ts
52
+ ├── sui/ { …same shape… }
53
+ ├── icon/ { …same shape… }
54
+ ├── injective/ { …same shape… }
55
+ ├── solana/ { …same shape… }
56
+ ├── stellar/ { …same shape… }
57
+ ├── stacks/ { …same shape… }
58
+ └── near/ { …same shape… }
59
+ ```
60
+
61
+ Class names and barrel exports are **unchanged**. `BitcoinWalletProvider`, `EvmWalletProvider`, etc. live at the same import path:
62
+
63
+ ```ts
64
+ // v1 — works
65
+ import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
66
+
67
+ // v2 — same, works identically
68
+ import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
69
+ ```
70
+
71
+ ## Why
72
+
73
+ Three reasons to fold each chain into a folder:
74
+
75
+ 1. **Co-located types.** Each chain's `*WalletConfig`, `*WalletDefaults`, `*WalletsKit` types now sit next to the provider that consumes them, in a `types.ts` file — easier to navigate.
76
+ 2. **Internal helpers per chain.** Some chains have non-trivial helper functions (ICON's Hana wallet bridge, EVM's chain-key → viem chain map, Bitcoin's PSBT helpers). Folder layout lets those live without polluting a single shared file.
77
+ 3. **Future expansion.** Adding a new chain now means dropping a single `src/wallet-providers/<chain>/` folder; the package barrel does not need a corresponding restructure.
78
+
79
+ ## Consumer impact
80
+
81
+ | User pattern | v1 | v2 |
82
+ |---|---|---|
83
+ | `import { EvmWalletProvider } from '@sodax/wallet-sdk-core'` | ✅ works | ✅ works |
84
+ | `import { BitcoinWalletProvider } from '@sodax/wallet-sdk-core'` | ✅ works | ✅ works |
85
+ | `import … from '@sodax/wallet-sdk-core/wallet-providers/EvmWalletProvider'` (deep) | ⚠ never officially supported | ❌ no longer resolves |
86
+ | `import … from '@sodax/wallet-sdk-core/src/wallet-providers/EvmWalletProvider'` (raw src) | ⚠ never officially supported | ❌ no longer resolves |
87
+
88
+ If user code has deep imports, replace with barrel imports.
89
+
90
+ ## How to verify
91
+
92
+ ```bash
93
+ # No deep imports
94
+ grep -rn "@sodax/wallet-sdk-core/" <user-src> | grep -v "from '@sodax/wallet-sdk-core'"
95
+ # expect empty
96
+
97
+ # Type check passes
98
+ pnpm checkTs
99
+ ```
@@ -0,0 +1,58 @@
1
+ # `library-exports` added
2
+
3
+ **Additive — no action required.** Older code continues to compile.
4
+
5
+ ---
6
+
7
+ ## What changed
8
+
9
+ `@sodax/wallet-sdk-core` now re-exports a curated set of types (and two runtime values) from each upstream chain SDK:
10
+
11
+ ```ts
12
+ // Now possible
13
+ import type { WalletClient, PublicClient, TransactionReceipt } from '@sodax/wallet-sdk-core';
14
+ import { Networks, PostConditionMode } from '@sodax/wallet-sdk-core';
15
+ ```
16
+
17
+ The full list lives at `src/types/library-exports.ts` and in [`../../integration/recipes/library-exports.md`](../../integration/recipes/library-exports.md).
18
+
19
+ ## Why
20
+
21
+ Consumer apps previously had to list every chain SDK explicitly in `package.json` just to import a few types:
22
+
23
+ ```jsonc
24
+ // Before — direct deps
25
+ {
26
+ "dependencies": {
27
+ "@sodax/wallet-sdk-core": "…",
28
+ "viem": "^2.x", // for WalletClient, PublicClient
29
+ "@stellar/stellar-sdk": "^11.x", // for Networks
30
+ "@stacks/transactions": "^6.x", // for PostConditionMode
31
+ "@mysten/wallet-standard": "^0.x" // for WalletAccount, WalletWithFeatures
32
+ }
33
+ }
34
+ ```
35
+
36
+ Three problems:
37
+
38
+ 1. **Version drift.** Consumer's `viem` could be a different minor than SODAX's, causing type incompatibilities.
39
+ 2. **Lockfile churn.** Every chain-SDK bump in SODAX propagated to consumer lockfiles.
40
+ 3. **Discoverability.** Consumers had to know which chain SDK each type lived in. The re-export pins types under one familiar namespace.
41
+
42
+ ## Consumer impact
43
+
44
+ | Older pattern | Replacement (optional) |
45
+ |---|---|
46
+ | `import type { WalletClient } from 'viem'` | `import type { WalletClient } from '@sodax/wallet-sdk-core'` |
47
+ | `import { Networks } from '@stellar/stellar-sdk'` | `import { Networks } from '@sodax/wallet-sdk-core'` |
48
+ | `import { PostConditionMode } from '@stacks/transactions'` | `import { PostConditionMode } from '@sodax/wallet-sdk-core'` |
49
+
50
+ **If 100% of upstream-SDK usage is covered by `library-exports`**, you can drop the direct chain-SDK dep from `package.json`. Most apps will still need some upstream package (e.g. `viem` for `createPublicClient`, `@solana/web3.js` for `Connection`, …) — adoption is a per-import decision.
51
+
52
+ ## How to adopt
53
+
54
+ Apply [`../recipes/adopt-library-exports.md`](../recipes/adopt-library-exports.md). Skip if you have no time — the older direct imports still work, just at a small cost in package size and version coupling.
55
+
56
+ ## What is NOT re-exported
57
+
58
+ The list is curated. Runtime helpers (`createWalletClient`, `Connection`, `Transaction`, `TransactionBuilder`, …) and lesser-used types are **not** included. See [`../../integration/recipes/library-exports.md`](../../integration/recipes/library-exports.md) § "When to NOT use re-exports".
@@ -0,0 +1,62 @@
1
+ # Migration checklist
2
+
3
+ Run through every item before declaring the migration done. Each item is machine-checkable.
4
+
5
+ ---
6
+
7
+ ## Mandatory
8
+
9
+ - [ ] **No deep imports from `@sodax/wallet-sdk-core/src/…`**
10
+ ```bash
11
+ grep -rn "@sodax/wallet-sdk-core/" <user-src> | grep -v "from '@sodax/wallet-sdk-core'"
12
+ # expect empty
13
+ ```
14
+ v1's flat layout (`wallet-providers/EvmWalletProvider.ts`) no longer resolves under v2's folder-per-chain layout. Only the barrel root is public.
15
+
16
+ - [ ] **No imports of internal utilities**
17
+ ```bash
18
+ grep -rn "shallowMerge" <user-src>
19
+ # expect empty
20
+ ```
21
+ `shallowMerge` is internal in v2 (and didn't exist in v1). Use `defaults` config + per-call options.
22
+
23
+ - [ ] **`pnpm checkTs` exits clean** with no `@sodax/wallet-sdk-core` symbol errors.
24
+
25
+ ---
26
+
27
+ ## Recommended (optional cleanup)
28
+
29
+ - [ ] **Drop direct upstream-SDK type imports covered by `library-exports`**
30
+ ```bash
31
+ grep -rn "from 'viem'" <user-src> | grep -E "WalletClient|PublicClient|TransactionReceipt|SendTransactionParameters|WaitForTransactionReceiptParameters|HttpTransportConfig|PublicClientConfig|WalletClientConfig"
32
+ grep -rn "from '@stellar/stellar-sdk'" <user-src> | grep "Networks"
33
+ grep -rn "from '@stacks/transactions'" <user-src> | grep -E "PostConditionMode|ClarityValue|PostConditionModeName"
34
+ grep -rn "from '@mysten/wallet-standard'" <user-src>
35
+ grep -rn "from '@solana/web3.js'" <user-src> | grep -E "Commitment|ConnectionConfig|SendOptions"
36
+ grep -rn "from '@injectivelabs/networks'" <user-src> | grep "Network"
37
+ grep -rn "from '@injectivelabs/ts-types'" <user-src> | grep -E "ChainId|EvmChainId"
38
+ grep -rn "from '@injectivelabs/wallet-core'" <user-src> | grep "MsgBroadcaster"
39
+ grep -rn "from '@hot-labs/near-connect'" <user-src> | grep "NearConnector"
40
+ grep -rn "from '@stacks/network'" <user-src> | grep "StacksNetwork"
41
+ grep -rn "from '@stacks/connect'" <user-src> | grep "StacksProvider"
42
+ # if any matches, decide whether to re-import via @sodax/wallet-sdk-core
43
+ ```
44
+
45
+ - [ ] **Direct upstream-SDK deps removed from `package.json`** (only if 100% replaced by library-exports)
46
+ ```bash
47
+ cat <user>/package.json | jq -r '.dependencies | keys[]' | grep -E '^(viem|@stellar/stellar-sdk|@stacks/transactions|@mysten/sui|@mysten/wallet-standard|@solana/web3.js|@injectivelabs/networks|@injectivelabs/ts-types|@injectivelabs/wallet-core|@hot-labs/near-connect|@stacks/network|@stacks/connect)$'
48
+ # confirm each remaining entry is genuinely needed for a runtime symbol library-exports doesn't cover
49
+ ```
50
+
51
+ - [ ] **`defaults` adopted in places where wrappers were hand-rolled**
52
+ Look for ad-hoc wrappers (`makeProvider`, `buildProvider`, `withDefaults`) that injected default gas / commitment / timeout values, and replace them with provider-level `defaults` config.
53
+
54
+ ---
55
+
56
+ ## Verification of behavior
57
+
58
+ - [ ] **Get-address smoke test** passes for every provider the user constructs.
59
+ - [ ] **One signing flow** runs end-to-end against a testnet (or recorded mock).
60
+ - [ ] **CI passes** (`pnpm lint && pnpm checkTs && pnpm test`).
61
+
62
+ When all mandatory + behavior items above are checked, the migration is done. Optional items are bonus.
@@ -0,0 +1,12 @@
1
+ # Migration recipes
2
+
3
+ Paired before/after for each migration task. Apply only what the user's project triggers.
4
+
5
+ **There are no mandatory migration recipes for wallet-sdk-core.** v1 consumer code drops in unchanged.
6
+
7
+ | Recipe | When to apply | Mandatory? |
8
+ |---|---|---|
9
+ | [`adopt-defaults.md`](./adopt-defaults.md) | User has hand-rolled wrappers (`makeProvider`, `buildProvider`, `withDefaults`) that injected default options. | No — additive cleanup. |
10
+ | [`adopt-library-exports.md`](./adopt-library-exports.md) | User imports types directly from upstream chain SDKs that `library-exports` now covers. | No — additive cleanup. |
11
+
12
+ If the user's only signal is "wallet-sdk-core was bumped to v2", **no recipe is needed**. Run `pnpm checkTs`, verify zero `@sodax/wallet-sdk-core` errors, and stop.
@@ -0,0 +1,84 @@
1
+ # Recipe: Adopt `defaults` (optional cleanup)
2
+
3
+ Replace hand-rolled wrappers with provider-level `defaults`. Optional — older per-call style still works.
4
+
5
+ **Apply when:** the user has a helper like `makeProvider(pk)` or `withDefaults(provider)` that injects fixed options on every call.
6
+
7
+ ---
8
+
9
+ ## Before — hand-rolled wrapper
10
+
11
+ ```ts
12
+ import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
13
+ import type { EvmRawTransaction } from '@sodax/types';
14
+ import { ChainKeys } from '@sodax/types';
15
+
16
+ function makeEvmProvider(pk: `0x${string}`) {
17
+ const provider = new EvmWalletProvider({ privateKey: pk, chainId: ChainKeys.SONIC_MAINNET });
18
+
19
+ return {
20
+ ...provider,
21
+ sendTransaction(tx: EvmRawTransaction) {
22
+ // hard-coded gas on every call
23
+ return provider.sendTransaction(tx, { gas: 3_000_000n });
24
+ },
25
+ };
26
+ }
27
+ ```
28
+
29
+ ## After — provider-level `defaults`
30
+
31
+ ```ts
32
+ import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
33
+ import { ChainKeys } from '@sodax/types';
34
+
35
+ const provider = new EvmWalletProvider({
36
+ privateKey: process.env.EVM_PK as `0x${string}`,
37
+ chainId: ChainKeys.SONIC_MAINNET,
38
+ defaults: {
39
+ sendTransaction: { gas: 3_000_000n },
40
+ },
41
+ });
42
+
43
+ // Use directly — defaults apply automatically; per-call override still works.
44
+ await provider.sendTransaction(tx);
45
+ await provider.sendTransaction(tx2, { gas: 5_000_000n });
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Steps
51
+
52
+ 1. **Identify the wrapper.** Look for functions that wrap a provider and inject options on every method call.
53
+ 2. **Move the injected options into `defaults`.** Pick the right slice — `defaults.sendTransaction` for EVM, `defaults.signAndExecuteTxn` for Sui, flat `defaults` for Bitcoin / Stellar / ICON / Injective / NEAR / Stacks.
54
+ 3. **Delete the wrapper.** Replace call sites with direct provider method calls.
55
+ 4. **Keep behavior for callers that already pass options.** Per-call options shallow-merge over defaults, so existing call sites that pass `{ gas: 5_000_000n }` still get exactly that gas value.
56
+
57
+ ---
58
+
59
+ ## When NOT to adopt
60
+
61
+ | Scenario | Why skip |
62
+ |---|---|
63
+ | The wrapper does more than inject defaults (e.g. logging, telemetry, retries) | `defaults` is just a config slice; it can't do behavior wrapping. Keep the wrapper. |
64
+ | The "default" actually changes per call (e.g. dynamic gas estimation) | That's not a default — it's per-call logic. Keep it inline. |
65
+ | The user's code base would gain churn for trivial savings | Migration cost > value. Leave it. |
66
+
67
+ ---
68
+
69
+ ## Verification
70
+
71
+ ```bash
72
+ # 1. Type check
73
+ pnpm checkTs
74
+
75
+ # 2. Search for remaining hand-rolled wrappers (heuristic)
76
+ grep -rnE "function\s+(make|build|with)(Wallet|Evm|Solana|Sui|Bitcoin|Stellar|Icon|Injective|Near|Stacks)Provider" <user-src>
77
+ # review each — confirm each is justified per the table above
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Why
83
+
84
+ See [`../breaking-changes/defaults-config.md`](../breaking-changes/defaults-config.md) for the model.