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

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 (51) hide show
  1. package/README.md +1 -2
  2. package/dist/index.cjs +1 -4
  3. package/dist/index.mjs +1 -4
  4. package/package.json +18 -11
  5. package/ai-exported/AGENTS.md +0 -139
  6. package/ai-exported/integration/README.md +0 -108
  7. package/ai-exported/integration/ai-rules.md +0 -141
  8. package/ai-exported/integration/architecture.md +0 -212
  9. package/ai-exported/integration/features/README.md +0 -22
  10. package/ai-exported/integration/features/bitcoin.md +0 -103
  11. package/ai-exported/integration/features/evm.md +0 -102
  12. package/ai-exported/integration/features/icon.md +0 -88
  13. package/ai-exported/integration/features/injective.md +0 -92
  14. package/ai-exported/integration/features/near.md +0 -92
  15. package/ai-exported/integration/features/solana.md +0 -104
  16. package/ai-exported/integration/features/stacks.md +0 -91
  17. package/ai-exported/integration/features/stellar.md +0 -95
  18. package/ai-exported/integration/features/sui.md +0 -96
  19. package/ai-exported/integration/quickstart.md +0 -259
  20. package/ai-exported/integration/recipes/README.md +0 -15
  21. package/ai-exported/integration/recipes/bridge-to-sdk.md +0 -145
  22. package/ai-exported/integration/recipes/defaults-and-overrides.md +0 -159
  23. package/ai-exported/integration/recipes/library-exports.md +0 -129
  24. package/ai-exported/integration/recipes/setup-browser-extension.md +0 -137
  25. package/ai-exported/integration/recipes/setup-private-key.md +0 -115
  26. package/ai-exported/integration/recipes/sign-and-broadcast.md +0 -201
  27. package/ai-exported/integration/recipes/testing.md +0 -163
  28. package/ai-exported/integration/reference/README.md +0 -13
  29. package/ai-exported/integration/reference/chain-support.md +0 -65
  30. package/ai-exported/integration/reference/glossary.md +0 -28
  31. package/ai-exported/integration/reference/interfaces.md +0 -131
  32. package/ai-exported/integration/reference/provider-classes.md +0 -54
  33. package/ai-exported/integration/reference/public-api.md +0 -128
  34. package/ai-exported/migration/README.md +0 -84
  35. package/ai-exported/migration/ai-rules.md +0 -139
  36. package/ai-exported/migration/breaking-changes/README.md +0 -14
  37. package/ai-exported/migration/breaking-changes/base-wallet-provider.md +0 -52
  38. package/ai-exported/migration/breaking-changes/defaults-config.md +0 -57
  39. package/ai-exported/migration/breaking-changes/folder-layout.md +0 -99
  40. package/ai-exported/migration/breaking-changes/library-exports.md +0 -58
  41. package/ai-exported/migration/checklist.md +0 -62
  42. package/ai-exported/migration/recipes/README.md +0 -12
  43. package/ai-exported/migration/recipes/adopt-defaults.md +0 -84
  44. package/ai-exported/migration/recipes/adopt-library-exports.md +0 -99
  45. package/ai-exported/migration/reference/README.md +0 -12
  46. package/ai-exported/migration/reference/added-fields.md +0 -71
  47. package/ai-exported/migration/reference/deleted-exports.md +0 -35
  48. package/ai-exported/migration/reference/renamed-symbols.md +0 -31
  49. package/ai-exported/migration/reference/return-shapes.md +0 -23
  50. package/dist/index.cjs.map +0 -1
  51. package/dist/index.mjs.map +0 -1
@@ -1,84 +0,0 @@
1
- # Migration: v1 → v2 (Human-readable overview)
2
-
3
- This folder documents how to upgrade an app from **v1** of `@sodax/wallet-sdk-core` (the legacy `sodax-frontend` codebase) to **v2** (this repo). The package name did not change — and **the public surface is intentionally backwards-compatible**. v1 consumer code drops in unchanged.
4
-
5
- This folder is the **human-facing** entry point for the upgrade. If you are a coding agent, read [`ai-rules.md`](./ai-rules.md) first. If you are integrating for the first time, see `../integration/` instead.
6
-
7
- ---
8
-
9
- ## Scope
10
-
11
- v1 (`sodax-frontend/packages/wallet-sdk-core`) and v2 (current) share:
12
-
13
- - **Identical class names**: `EvmWalletProvider`, `InjectiveWalletProvider`, `BitcoinWalletProvider`, … (all 9).
14
- - **Identical config-type names**: `PrivateKeyEvmWalletConfig`, `SecretInjectiveWalletConfig`, `BrowserExtension*WalletConfig`, …
15
- - **Identical config shapes**: same required fields, same discriminants, same Injective `secret: { privateKey | mnemonics }` nesting.
16
- - **Identical public method signatures**: `getWalletAddress`, `sendTransaction`, `signAndExecuteTxn`, …
17
-
18
- What v2 **added** (all optional, all additive):
19
-
20
- 1. **`defaults` config** — every `*WalletConfig` gained an optional `defaults?: *WalletDefaults` field. Used to encode env-level constants (default gas, default commitment, …) once at construction.
21
- 2. **`library-exports`** — types and a few runtime enums re-exported from `@sodax/wallet-sdk-core`. Lets consumers drop direct deps on `viem`, `@mysten/sui`, `@stellar/stellar-sdk`, etc. for type-only usage.
22
- 3. **`BaseWalletProvider<TDefaults>`** — abstract base class shared by every provider. Holds `defaults` and exposes shallow-merge helpers. Internal — consumer code does not extend it.
23
- 4. **`*WalletDefaults` and `*Policy` types** — exported alongside each chain's config types.
24
- 5. **Folder-per-chain source layout** — `wallet-providers/evm/EvmWalletProvider.ts` (v2) replaced `wallet-providers/EvmWalletProvider.ts` (v1). Only matters if you deep-imported from `src/`.
25
-
26
- What was **removed** or **renamed**: **nothing**. There is no mandatory edit.
27
-
28
- ---
29
-
30
- ## Read order
31
-
32
- If you are upgrading by hand, read in this order:
33
-
34
- 1. [`ai-rules.md`](./ai-rules.md) — workflow + stop conditions. **Drop-in upgrade is the default**; only adopt new features if you want them.
35
- 2. [`breaking-changes/README.md`](./breaking-changes/README.md) — every additive change, with a `Why:` line each.
36
- 3. [`recipes/`](./recipes/) — paired before/after **only** for optional cleanup tasks (adopt `defaults`, adopt `library-exports`).
37
- 4. [`checklist.md`](./checklist.md) — verification pass.
38
-
39
- If you are letting a coding agent drive the upgrade, point it at [`ai-rules.md`](./ai-rules.md) — that file gives the agent its workflow and verification protocol.
40
-
41
- ---
42
-
43
- ## TL;DR for the impatient
44
-
45
- ```bash
46
- # 1. Update version in package.json
47
- pnpm add @sodax/wallet-sdk-core@latest
48
-
49
- # 2. Type-check — expect zero errors from wallet-sdk-core surface
50
- pnpm exec tsc --noEmit | grep -iE "wallet-sdk-core|WalletProvider|WalletConfig"
51
- # (errors here indicate either v1 deep imports or a real bug — file an issue)
52
-
53
- # 3. Done. Optional cleanups in recipes/ when you have time.
54
- ```
55
-
56
- ---
57
-
58
- ## What is NOT covered here
59
-
60
- - **Other SODAX packages** (`@sodax/sdk`, `@sodax/types`, `@sodax/wallet-sdk-react`, `@sodax/dapp-kit`). They each have their own migration docs and **real** v1→v2 breaks.
61
- - **Upstream chain-SDK upgrades** (viem 2.x → 3.x, etc.) — out of scope.
62
- - **App framework upgrades** (Node, Vite, Next.js) — out of scope.
63
-
64
- ---
65
-
66
- ## Tip: typecheck-driven verification
67
-
68
- The repo includes `apps/node/` (Node scripts) and `apps/demo_v1/` (React demo). Running `pnpm exec tsc --noEmit` from either reveals breaking changes — but for wallet-sdk-core specifically, **none of those errors come from this package**. If you see `wallet-sdk-core` in the error output, it's most likely:
69
-
70
- - A deep import from `src/...` (never supported; the v2 source layout differs).
71
- - Indirect — a broken `@sodax/sdk` / `@sodax/types` signature that includes a wallet-provider type.
72
-
73
- ```bash
74
- # Filter to wallet-sdk-core specifically
75
- pnpm exec tsc --noEmit | grep -iE "from '@sodax/wallet-sdk-core'|@sodax/wallet-sdk-core/"
76
- ```
77
-
78
- That filtered output is your work list. In a typical project the list is empty.
79
-
80
- ---
81
-
82
- ## Getting help
83
-
84
- If you do hit a v1 pattern that doesn't compile against v2, [open an issue](https://github.com/icon-project/sodax-sdks/issues) with the source snippet — that means we missed a backwards-compat case and the migration scope needs to grow.
@@ -1,139 +0,0 @@
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.
@@ -1,14 +0,0 @@
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.
@@ -1,52 +0,0 @@
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.
@@ -1,57 +0,0 @@
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.
@@ -1,99 +0,0 @@
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
- ```
@@ -1,58 +0,0 @@
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".
@@ -1,62 +0,0 @@
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.
@@ -1,12 +0,0 @@
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.