@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.
- package/README.md +1 -2
- package/dist/index.cjs +1 -4
- package/dist/index.mjs +1 -4
- package/package.json +18 -11
- package/ai-exported/AGENTS.md +0 -139
- package/ai-exported/integration/README.md +0 -108
- package/ai-exported/integration/ai-rules.md +0 -141
- package/ai-exported/integration/architecture.md +0 -212
- package/ai-exported/integration/features/README.md +0 -22
- package/ai-exported/integration/features/bitcoin.md +0 -103
- package/ai-exported/integration/features/evm.md +0 -102
- package/ai-exported/integration/features/icon.md +0 -88
- package/ai-exported/integration/features/injective.md +0 -92
- package/ai-exported/integration/features/near.md +0 -92
- package/ai-exported/integration/features/solana.md +0 -104
- package/ai-exported/integration/features/stacks.md +0 -91
- package/ai-exported/integration/features/stellar.md +0 -95
- package/ai-exported/integration/features/sui.md +0 -96
- package/ai-exported/integration/quickstart.md +0 -259
- package/ai-exported/integration/recipes/README.md +0 -15
- package/ai-exported/integration/recipes/bridge-to-sdk.md +0 -145
- package/ai-exported/integration/recipes/defaults-and-overrides.md +0 -159
- package/ai-exported/integration/recipes/library-exports.md +0 -129
- package/ai-exported/integration/recipes/setup-browser-extension.md +0 -137
- package/ai-exported/integration/recipes/setup-private-key.md +0 -115
- package/ai-exported/integration/recipes/sign-and-broadcast.md +0 -201
- package/ai-exported/integration/recipes/testing.md +0 -163
- package/ai-exported/integration/reference/README.md +0 -13
- package/ai-exported/integration/reference/chain-support.md +0 -65
- package/ai-exported/integration/reference/glossary.md +0 -28
- package/ai-exported/integration/reference/interfaces.md +0 -131
- package/ai-exported/integration/reference/provider-classes.md +0 -54
- package/ai-exported/integration/reference/public-api.md +0 -128
- package/ai-exported/migration/README.md +0 -84
- package/ai-exported/migration/ai-rules.md +0 -139
- package/ai-exported/migration/breaking-changes/README.md +0 -14
- package/ai-exported/migration/breaking-changes/base-wallet-provider.md +0 -52
- package/ai-exported/migration/breaking-changes/defaults-config.md +0 -57
- package/ai-exported/migration/breaking-changes/folder-layout.md +0 -99
- package/ai-exported/migration/breaking-changes/library-exports.md +0 -58
- package/ai-exported/migration/checklist.md +0 -62
- package/ai-exported/migration/recipes/README.md +0 -12
- package/ai-exported/migration/recipes/adopt-defaults.md +0 -84
- package/ai-exported/migration/recipes/adopt-library-exports.md +0 -99
- package/ai-exported/migration/reference/README.md +0 -12
- package/ai-exported/migration/reference/added-fields.md +0 -71
- package/ai-exported/migration/reference/deleted-exports.md +0 -35
- package/ai-exported/migration/reference/renamed-symbols.md +0 -31
- package/ai-exported/migration/reference/return-shapes.md +0 -23
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Sodax wallet-sdk-core is a core wallet SDK package containing implementations of wallet providers that enable multi-chain wallet connectivity. This package provides TypeScript implementations of wallet providers for various blockchain networks, making them compatible with the Core Sodax SDK (@sodax/sdk).
|
|
4
4
|
|
|
5
|
-
> **AI-friendly docs:**
|
|
6
|
-
> Entry points: [`ai-exported/integration/`](./ai-exported/integration/) (new setup), [`ai-exported/migration/`](./ai-exported/migration/) (upgrading from older RCs).
|
|
5
|
+
> **AI-friendly docs:** shipped via [`@sodax/skills`](https://github.com/icon-project/sodax-sdks/tree/main/packages/skills) — [`skills` CLI](https://github.com/vercel-labs/skills) recommended; npm + `AGENTS.md` pointer as fallback. See [docs/ai-integration-guide.md](https://github.com/icon-project/sodax-sdks/blob/main/docs/ai-integration-guide.md) for all install modes and per-tool wiring.
|
|
7
6
|
|
|
8
7
|
## Installation
|
|
9
8
|
|
package/dist/index.cjs
CHANGED
|
@@ -327,7 +327,7 @@ var SodaTokens = {
|
|
|
327
327
|
sodaNEAR: {
|
|
328
328
|
symbol: "sodaNEAR",
|
|
329
329
|
name: "SODA NEAR",
|
|
330
|
-
decimals:
|
|
330
|
+
decimals: 18,
|
|
331
331
|
address: "0xf4ba497c9b805e4bd88a8a9e6a7b8f74984c3e39",
|
|
332
332
|
chainKey: ChainKeys.SONIC_MAINNET,
|
|
333
333
|
hubAsset: "0xf4ba497c9b805e4bd88a8a9e6a7b8f74984c3e39",
|
|
@@ -2918,7 +2918,6 @@ var hubConfig = {
|
|
|
2918
2918
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.USDT,
|
|
2919
2919
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.wS,
|
|
2920
2920
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.SODA,
|
|
2921
|
-
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.bnUSD,
|
|
2922
2921
|
...Object.values(SodaTokens)
|
|
2923
2922
|
]});
|
|
2924
2923
|
|
|
@@ -11682,5 +11681,3 @@ exports.isValidStellarPrivateKey = isValidStellarPrivateKey;
|
|
|
11682
11681
|
exports.requestAddress = requestAddress;
|
|
11683
11682
|
exports.requestJsonRpc = requestJsonRpc;
|
|
11684
11683
|
exports.requestSigning = requestSigning;
|
|
11685
|
-
//# sourceMappingURL=index.cjs.map
|
|
11686
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -301,7 +301,7 @@ var SodaTokens = {
|
|
|
301
301
|
sodaNEAR: {
|
|
302
302
|
symbol: "sodaNEAR",
|
|
303
303
|
name: "SODA NEAR",
|
|
304
|
-
decimals:
|
|
304
|
+
decimals: 18,
|
|
305
305
|
address: "0xf4ba497c9b805e4bd88a8a9e6a7b8f74984c3e39",
|
|
306
306
|
chainKey: ChainKeys.SONIC_MAINNET,
|
|
307
307
|
hubAsset: "0xf4ba497c9b805e4bd88a8a9e6a7b8f74984c3e39",
|
|
@@ -2892,7 +2892,6 @@ var hubConfig = {
|
|
|
2892
2892
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.USDT,
|
|
2893
2893
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.wS,
|
|
2894
2894
|
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.SODA,
|
|
2895
|
-
spokeChainConfig[ChainKeys.SONIC_MAINNET].supportedTokens.bnUSD,
|
|
2896
2895
|
...Object.values(SodaTokens)
|
|
2897
2896
|
]});
|
|
2898
2897
|
|
|
@@ -11606,5 +11605,3 @@ var BitcoinWalletProvider = class extends BaseWalletProvider {
|
|
|
11606
11605
|
*/
|
|
11607
11606
|
|
|
11608
11607
|
export { BaseWalletProvider, BigNumberToBigInt, BitcoinWalletError, BitcoinWalletProvider, EvmWalletProvider, IconWalletProvider, InjectiveWalletProvider, NearWalletProvider, SolanaWalletProvider, StacksWalletProvider, StellarWalletError, StellarWalletProvider, SuiWalletProvider, getEvmViemChain, hyper, isBrowserExtensionEvmWalletConfig, isBrowserExtensionIconWalletConfig, isBrowserExtensionInjectiveWalletConfig, isBrowserExtensionNearWalletConfig, isBrowserExtensionStacksWalletConfig, isBrowserExtensionStellarWalletConfig, isBrowserExtensionSuiWallet, isIconAddress, isIconBrowserExtensionWallet, isIconEoaAddress, isIconPkWallet, isJsonRpcPayloadResponse, isPkSuiWallet, isPrivateKeyEvmWalletConfig, isPrivateKeyIconWalletConfig, isPrivateKeyNearWalletConfig, isPrivateKeyStacksWalletConfig, isPrivateKeyStellarWalletConfig, isResponseAddressType, isResponseSigningType, isSecretInjectiveWalletConfig, isStellarBrowserExtensionWallet, isStellarPkWallet, isValidStellarNetwork, isValidStellarPrivateKey, requestAddress, requestJsonRpc, requestSigning };
|
|
11609
|
-
//# sourceMappingURL=index.mjs.map
|
|
11610
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.0-rc.
|
|
7
|
+
"version": "2.0.0-rc.4",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"description": "Sodax Wallet SDK Core",
|
|
10
10
|
"keywords": [
|
|
@@ -28,18 +28,24 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.mjs"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.d.cts",
|
|
37
|
+
"default": "./dist/index.cjs"
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
"engines": {
|
|
37
|
-
"node": ">=20.
|
|
42
|
+
"node": ">=20.12.0"
|
|
38
43
|
},
|
|
39
44
|
"files": [
|
|
40
45
|
"dist",
|
|
41
|
-
"
|
|
46
|
+
"!dist/**/*.map"
|
|
42
47
|
],
|
|
48
|
+
"sideEffects": false,
|
|
43
49
|
"dependencies": {
|
|
44
50
|
"@bitcoinerlab/secp256k1": "^1.2.0",
|
|
45
51
|
"@hot-labs/near-connect": "0.10.0",
|
|
@@ -63,17 +69,18 @@
|
|
|
63
69
|
"near-api-js": "7.2.0",
|
|
64
70
|
"secp256k1": "^5.0.1",
|
|
65
71
|
"viem": "2.29.2",
|
|
66
|
-
"@sodax/types": "2.0.0-rc.
|
|
72
|
+
"@sodax/types": "2.0.0-rc.4"
|
|
67
73
|
},
|
|
68
74
|
"devDependencies": {
|
|
69
75
|
"@arethetypeswrong/cli": "0.17.4",
|
|
70
76
|
"@changesets/cli": "2.29.7",
|
|
71
77
|
"@types/node": "22.18.1",
|
|
72
78
|
"@types/secp256k1": "^4.0.7",
|
|
73
|
-
"@vitest/coverage-v8": "2.
|
|
79
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
80
|
+
"knip": "5.30.5",
|
|
74
81
|
"tsup": "8.5.0",
|
|
75
82
|
"typescript": "5.5.4",
|
|
76
|
-
"vitest": "2.
|
|
83
|
+
"vitest": "3.2.4"
|
|
77
84
|
},
|
|
78
85
|
"scripts": {
|
|
79
86
|
"build": "tsup",
|
|
@@ -85,8 +92,8 @@
|
|
|
85
92
|
"checkTs": "tsc --noEmit",
|
|
86
93
|
"pretty": "biome format . --write",
|
|
87
94
|
"lint": "biome lint . --write",
|
|
88
|
-
"check-exports": "attw
|
|
89
|
-
"check
|
|
95
|
+
"check-exports": "attw --pack",
|
|
96
|
+
"check:knip": "knip",
|
|
90
97
|
"local-release": "changeset version && changeset publish",
|
|
91
98
|
"clean": "rm -rf node_modules && rm -rf dist && rm -rf .turbo"
|
|
92
99
|
}
|
package/ai-exported/AGENTS.md
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
# AGENTS.md — `@sodax/wallet-sdk-core` AI Export
|
|
2
|
-
|
|
3
|
-
You are a coding agent helping a developer **integrate** or **migrate** the `@sodax/wallet-sdk-core` package. This document is your entry point. Read this first, then route to the right sub-folder.
|
|
4
|
-
|
|
5
|
-
The files in this `ai-exported/` directory are designed for AI consumption: short, table-heavy, self-contained recipes, and machine-checkable checklists. Human-readable narrative lives in each folder's `README.md`.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## What this package is
|
|
10
|
-
|
|
11
|
-
`@sodax/wallet-sdk-core` is the **low-level** wallet layer of the SODAX stack — one provider class per chain family (9 in total: EVM, Solana, Sui, Bitcoin, Stellar, ICON, Injective, NEAR, Stacks). Each class accepts either a **private-key** config (server-side scripts, CI, Node) or a **browser-extension** config (consumer dApps with pre-built clients/wallet kits), signs transactions, and broadcasts them.
|
|
12
|
-
|
|
13
|
-
It is **not** a React layer (that is `@sodax/wallet-sdk-react`) and **not** a hooks layer (that is `@sodax/dapp-kit`). Most React consumers never touch this package directly — they get a typed `IXxxWalletProvider` via `useWalletProvider(...)` and hand it to `@sodax/sdk` calls. Direct usage of `wallet-sdk-core` is the right choice for:
|
|
14
|
-
|
|
15
|
-
- Backend / Node scripts (CI tests, indexers, bots).
|
|
16
|
-
- Custom browser flows that don't use React.
|
|
17
|
-
- Tests that need to sign with a deterministic key.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Step 1 — Identify the task
|
|
22
|
-
|
|
23
|
-
| User says... | Path | Start at |
|
|
24
|
-
|---|---|---|
|
|
25
|
-
| "sign a tx from a script", "instantiate `EvmWalletProvider`", "first time using this lib" | **integration** | `integration/ai-rules.md` |
|
|
26
|
-
| "configure default gas", "set up `defaults`", "shallow merge surprised me" | **integration** | `integration/recipes/defaults-and-overrides.md` |
|
|
27
|
-
| "where do I import `WalletClient` / `SuiClient` from", "avoid direct viem dep" | **integration** | `integration/recipes/library-exports.md` |
|
|
28
|
-
| "upgrade from v1 / sodax-frontend", "bump from older RC" | **migration** | `migration/ai-rules.md` |
|
|
29
|
-
| Deep import from `@sodax/wallet-sdk-core/wallet-providers/EvmWalletProvider` broke | **migration** | `migration/breaking-changes/folder-layout.md` |
|
|
30
|
-
| Looking up a provider class or its config shape | direct | `integration/reference/provider-classes.md` |
|
|
31
|
-
| Looking up the discriminated union shape per chain | direct | `integration/features/<chain>.md` |
|
|
32
|
-
|
|
33
|
-
The package name **did not change** across versions — both v1 and v2 publish as `@sodax/wallet-sdk-core`. **All v1→v2 surface changes are additive** — class names, config-type names, and config shapes are identical. The only mechanical migration is replacing deep imports from v1's flat `wallet-providers/*.ts` layout with barrel imports.
|
|
34
|
-
|
|
35
|
-
If a project does anything more than that at the wallet-sdk-core surface, you are almost certainly looking at an `@sodax/sdk` / `@sodax/types` migration, not this one. Route accordingly.
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Step 2 — Load the right context
|
|
40
|
-
|
|
41
|
-
**For integration tasks:**
|
|
42
|
-
|
|
43
|
-
1. `integration/ai-rules.md` — DO/DON'T + workflow + stop conditions
|
|
44
|
-
2. `integration/architecture.md` — mental model (BaseWalletProvider, discriminants, defaults merge)
|
|
45
|
-
3. `integration/quickstart.md` — copy-paste minimal example for the chain you need
|
|
46
|
-
4. `integration/features/<chain>.md` — per-chain config table, methods, gotchas
|
|
47
|
-
5. `integration/recipes/<task>.md` — task-specific guide (setup-private-key, bridge-to-sdk, …)
|
|
48
|
-
6. `integration/reference/*.md` — full barrel exports, interfaces, chain support
|
|
49
|
-
|
|
50
|
-
**For migration tasks:**
|
|
51
|
-
|
|
52
|
-
1. `migration/ai-rules.md` — DO/DON'T + workflow. The headline: **v1 code drops in unchanged.** No mandatory edits at the wallet-sdk-core surface.
|
|
53
|
-
2. `migration/README.md` — what (additively) changed, read order, TL;DR
|
|
54
|
-
3. `migration/breaking-changes/*.md` — narrative WHY behind each additive shift (folder layout, base-class, defaults, library-exports)
|
|
55
|
-
4. `migration/reference/*.md` — confirm no renames / no deletions exist
|
|
56
|
-
5. `migration/recipes/<task>.md` — paired before/after for **optional** cleanup (adopt-defaults, adopt-library-exports)
|
|
57
|
-
6. `migration/checklist.md` — verification loop
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## Step 3 — Honor flow-specific stop conditions
|
|
62
|
-
|
|
63
|
-
Each flow has its own list of conditions that **HARD STOP** code generation and require asking the user:
|
|
64
|
-
|
|
65
|
-
- Migration stops → [`migration/ai-rules.md`](./migration/ai-rules.md) § "Stop conditions"
|
|
66
|
-
- Integration stops → [`integration/ai-rules.md`](./integration/ai-rules.md) § "Stop conditions"
|
|
67
|
-
|
|
68
|
-
Read the relevant list **before** applying any change. When stopping, quote the offending file/line and present the user with concrete options. Do **not** guess.
|
|
69
|
-
|
|
70
|
-
Cross-flow signals (true regardless of flow):
|
|
71
|
-
|
|
72
|
-
- User asks for a chain family not in [`integration/reference/chain-support.md`](./integration/reference/chain-support.md). Adding a new chain is a maintainer task, not user-app integration.
|
|
73
|
-
- User wants to extend `BaseWalletProvider` directly. That is a maintainer-only path — confirm scope before writing code.
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Step 4 — Verification protocol
|
|
78
|
-
|
|
79
|
-
After **every** code change you make:
|
|
80
|
-
|
|
81
|
-
1. Run `pnpm checkTs` from the user's app root (or the package the change touched).
|
|
82
|
-
2. If errors mention `@sodax/wallet-sdk-core`, look up the symbol in `integration/reference/` or `migration/reference/`.
|
|
83
|
-
3. If a symbol isn't in any reference file, **stop and ask**. Do not invent migrations.
|
|
84
|
-
4. After all errors resolve, mark the relevant items in `migration/checklist.md` (for migrations) or move to the next recipe.
|
|
85
|
-
|
|
86
|
-
You are **done** when:
|
|
87
|
-
- `pnpm checkTs` exits clean for the user's project.
|
|
88
|
-
- All items in `migration/checklist.md` are checked (migration only).
|
|
89
|
-
- The user has confirmed the changed flow works in their dev / test environment.
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Conventions in this directory
|
|
94
|
-
|
|
95
|
-
- **Recipes are self-contained.** A recipe file in `recipes/` contains everything needed to apply the change — before/after code, steps, verification. Do not jump between files.
|
|
96
|
-
- **Reference files are tables.** `reference/*.md` contains markdown tables and paired code blocks. Treat them as lookup, not narrative.
|
|
97
|
-
- **Token budget**: Each file is sized to fit comfortably in your context. If you find yourself loading more than 3 files for a single task, you are probably doing it wrong — re-route via the table above.
|
|
98
|
-
- **Single source of truth**: Behavioral / breaking-change *explanations* live only in `migration/breaking-changes/*.md`. Other files reference them but do not duplicate the prose.
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Quick symbol lookup
|
|
103
|
-
|
|
104
|
-
If the user mentions a symbol you don't recognize, grep these files in order:
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
integration/reference/public-api.md — every named export from the package
|
|
108
|
-
integration/reference/provider-classes.md — provider class + config + interface mapping
|
|
109
|
-
integration/reference/interfaces.md — IXxxWalletProvider method signatures
|
|
110
|
-
integration/reference/chain-support.md — chain family → provider + dependencies
|
|
111
|
-
migration/reference/renamed-symbols.md — confirms zero renames between v1 and v2
|
|
112
|
-
migration/reference/deleted-exports.md — confirms zero deletions between v1 and v2
|
|
113
|
-
migration/reference/added-fields.md — additive `defaults` / `*WalletDefaults` / `*Policy` types
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
If still not found: the symbol may be **internal** (not exported from the package root) or **removed**. Ask the user to share the source file/line so you can decide.
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## Package context
|
|
121
|
-
|
|
122
|
-
- **Name**: `@sodax/wallet-sdk-core`
|
|
123
|
-
- **Version target**: latest RC / stable on npm.
|
|
124
|
-
- **Peer deps**: none — chain SDKs are direct dependencies and consumers can re-import types via `library-exports`.
|
|
125
|
-
- **Install**: `pnpm add @sodax/wallet-sdk-core`
|
|
126
|
-
- **Runtime**: Node ≥ 18 + browser (tsup `platform: 'neutral'`).
|
|
127
|
-
- **Audience**: backend engineers, script authors, and React-layer authors building higher-level wrappers (`@sodax/wallet-sdk-react`).
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## Pointers
|
|
132
|
-
|
|
133
|
-
- [`integration/README.md`](./integration/README.md) — start here for new integrations: file index, recommended reading order, install snippet, dual-config overview.
|
|
134
|
-
- [`migration/README.md`](./migration/README.md) — start here for upgrades: file index, reading order, cross-cutting checklist pointer.
|
|
135
|
-
- [`integration/quickstart.md`](./integration/quickstart.md) — minimal end-to-end example per chain.
|
|
136
|
-
- [`integration/architecture.md`](./integration/architecture.md) — mental model: `BaseWalletProvider`, defaults shallow merge, dual-config discriminants, `library-exports`.
|
|
137
|
-
- [`integration/features/`](./integration/features/) — per-chain config table, methods, gotchas (one file per chain).
|
|
138
|
-
- [`integration/reference/`](./integration/reference/) — public API, provider classes, interfaces, chain support, glossary.
|
|
139
|
-
- [`migration/breaking-changes/`](./migration/breaking-changes/) — narrative WHY behind each version-to-version shift.
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# Integration: First-time setup (Human-readable overview)
|
|
2
|
-
|
|
3
|
-
This folder helps you integrate `@sodax/wallet-sdk-core` into a fresh project — most commonly a Node script, a backend service, or a custom non-React frontend. It is the **human-facing** entry point for new integrations. If you are a coding agent, read [`ai-rules.md`](./ai-rules.md) first.
|
|
4
|
-
|
|
5
|
-
If you are upgrading from an older version of the package instead, see `../migration/`.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## What this package does
|
|
10
|
-
|
|
11
|
-
`@sodax/wallet-sdk-core` is a **low-level multi-chain wallet provider layer**. For each of the 9 chain families that SODAX supports it ships **one provider class** that:
|
|
12
|
-
|
|
13
|
-
- Accepts a **discriminated union config** — `PrivateKey*WalletConfig | BrowserExtension*WalletConfig`.
|
|
14
|
-
- Extends a small `BaseWalletProvider` to merge per-call options over a typed `defaults` shape.
|
|
15
|
-
- Implements the chain-specific `IXxxWalletProvider` interface from `@sodax/types`, so it can be passed straight into `@sodax/sdk` calls.
|
|
16
|
-
|
|
17
|
-
It is intentionally framework-agnostic — Node ≥ 18, browser, edge runtimes are all supported (tsup `platform: 'neutral'`).
|
|
18
|
-
|
|
19
|
-
| Chain family | Provider class | Underlying chain SDK |
|
|
20
|
-
|---|---|---|
|
|
21
|
-
| EVM (12 chains) | `EvmWalletProvider` | `viem` |
|
|
22
|
-
| Solana | `SolanaWalletProvider` | `@solana/web3.js` |
|
|
23
|
-
| Sui | `SuiWalletProvider` | `@mysten/sui` + `@mysten/wallet-standard` |
|
|
24
|
-
| Bitcoin | `BitcoinWalletProvider` | `bitcoinjs-lib` (+ `ecpair`, `secp256k1`) |
|
|
25
|
-
| Stellar | `StellarWalletProvider` | `@stellar/stellar-sdk` |
|
|
26
|
-
| ICON | `IconWalletProvider` | `icon-sdk-js` |
|
|
27
|
-
| Injective | `InjectiveWalletProvider` | `@injectivelabs/sdk-ts` + `@injectivelabs/wallet-core` |
|
|
28
|
-
| NEAR | `NearWalletProvider` | `near-api-js` + `@hot-labs/near-connect` |
|
|
29
|
-
| Stacks | `StacksWalletProvider` | `@stacks/transactions` + `@stacks/connect` |
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Recommended path (in order)
|
|
34
|
-
|
|
35
|
-
If this is your first time using the package:
|
|
36
|
-
|
|
37
|
-
1. [`architecture.md`](./architecture.md) — read once before any recipe. Explains `BaseWalletProvider`, the `defaults` shallow-merge model, dual-config discriminants, and the `library-exports` indirection. Picking the wrong config variant is the most common mistake — the mental model prevents it.
|
|
38
|
-
2. [`quickstart.md`](./quickstart.md) — minimal end-to-end example for the chain you need. Copy, edit, run.
|
|
39
|
-
3. [`features/<chain>.md`](./features/) — chain-specific config table, methods, and gotchas (one file per chain).
|
|
40
|
-
4. Pick the right recipes:
|
|
41
|
-
- [`recipes/setup-private-key.md`](./recipes/setup-private-key.md) — server-side / CI flow.
|
|
42
|
-
- [`recipes/setup-browser-extension.md`](./recipes/setup-browser-extension.md) — consumer dApp flow.
|
|
43
|
-
- [`recipes/bridge-to-sdk.md`](./recipes/bridge-to-sdk.md) — hand off the provider to `@sodax/sdk` calls.
|
|
44
|
-
- [`recipes/defaults-and-overrides.md`](./recipes/defaults-and-overrides.md) — merge semantics for the `defaults` config.
|
|
45
|
-
- [`recipes/library-exports.md`](./recipes/library-exports.md) — re-importing upstream chain-SDK types without a direct dep.
|
|
46
|
-
- [`recipes/sign-and-broadcast.md`](./recipes/sign-and-broadcast.md) — typical send-transaction flow per chain.
|
|
47
|
-
- [`recipes/testing.md`](./recipes/testing.md) — mocking providers in unit tests.
|
|
48
|
-
5. Reference docs (lookup as needed):
|
|
49
|
-
- [`reference/public-api.md`](./reference/public-api.md) — every named export from the package root.
|
|
50
|
-
- [`reference/provider-classes.md`](./reference/provider-classes.md) — provider × config × interface table.
|
|
51
|
-
- [`reference/interfaces.md`](./reference/interfaces.md) — `IXxxWalletProvider` method signatures.
|
|
52
|
-
- [`reference/chain-support.md`](./reference/chain-support.md) — chain family → spoke chain keys.
|
|
53
|
-
- [`reference/glossary.md`](./reference/glossary.md) — terms used across the docs.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## Install
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
pnpm add @sodax/wallet-sdk-core @sodax/types
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Most consumers will also need `@sodax/sdk` (for the hub/spoke services that accept the wallet provider) and one or more chain SDKs (for browser-extension wallet objects). Re-export the types you need via `library-exports` — see [`recipes/library-exports.md`](./recipes/library-exports.md).
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Two configuration modes
|
|
68
|
-
|
|
69
|
-
Every provider class supports **two** construction modes. Picking the wrong one is the most common integration mistake.
|
|
70
|
-
|
|
71
|
-
| Mode | When to use | Discriminant style |
|
|
72
|
-
|---|---|---|
|
|
73
|
-
| **Private-key** | Node scripts, CI tests, indexers, bots — anywhere you possess the raw key | Either field presence (EVM, Solana, Sui, ICON, Injective, NEAR, Stacks) OR `type: 'PRIVATE_KEY'` (Bitcoin, Stellar) |
|
|
74
|
-
| **Browser-extension** | Consumer dApps where a wallet extension provides a pre-built client / signer | Either field presence (different fields from PK variant) OR `type: 'BROWSER_EXTENSION'` (Bitcoin, Stellar) |
|
|
75
|
-
|
|
76
|
-
For a chain-by-chain breakdown of the exact discriminant shape, see [`features/`](./features/) and [`architecture.md`](./architecture.md) § "Discriminant variants".
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Pair with `@sodax/sdk` and `@sodax/wallet-sdk-react`
|
|
81
|
-
|
|
82
|
-
The most common stack:
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
@sodax/sdk ← business logic (swaps, lending, staking, …)
|
|
86
|
-
@sodax/wallet-sdk-react ← React layer that surfaces a typed IXxxWalletProvider via hooks
|
|
87
|
-
@sodax/wallet-sdk-core ← this package — concrete provider classes
|
|
88
|
-
@sodax/types ← shared type definitions
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
In a React dApp you usually consume this package **indirectly** — `useWalletProvider({ xChainId })` (from `@sodax/wallet-sdk-react`) returns a typed `IXxxWalletProvider` that comes from a `wallet-sdk-core` instance under the hood. You only construct provider classes from `wallet-sdk-core` directly when running scripts, tests, or non-React clients.
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## Conventions worth knowing
|
|
96
|
-
|
|
97
|
-
- **`defaults` is optional but powerful.** Every provider accepts a `defaults` config slice; per-call options shallow-merge over it. Use it to encode env-level fixed choices (RPC commitment, default gas, default memo) once.
|
|
98
|
-
- **Shallow merge, not deep.** Nested objects in `defaults` are **replaced wholesale** by per-call options of the same key. See `src/utils/merge.ts` and [`recipes/defaults-and-overrides.md`](./recipes/defaults-and-overrides.md).
|
|
99
|
-
- **`library-exports` removes upstream deps.** You can `import type { WalletClient } from '@sodax/wallet-sdk-core'` instead of taking a direct dep on `viem`. See [`recipes/library-exports.md`](./recipes/library-exports.md).
|
|
100
|
-
- **The barrel is the source of truth.** Internal utilities (`shallowMerge`, helper functions) are **not** exported. If something isn't on `@sodax/wallet-sdk-core`'s root, do not deep-import it.
|
|
101
|
-
- **No `as unknown as` casts.** The discriminated unions are precise — if TypeScript complains, your config is wrong, not the type.
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## Getting help
|
|
106
|
-
|
|
107
|
-
- API surface lookup: [`reference/`](./reference/).
|
|
108
|
-
- Bug or missing feature: [open an issue](https://github.com/icon-project/sodax-sdks/issues).
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# AI Rules — Fresh Integration
|
|
2
|
-
|
|
3
|
-
You are integrating `@sodax/wallet-sdk-core` into a user's project for the first time. Follow this protocol exactly.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Workflow (do these in order)
|
|
8
|
-
|
|
9
|
-
### 1. Survey the project
|
|
10
|
-
|
|
11
|
-
Before changing anything, gather context:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# Runtime — Node script? React dApp? Edge runtime?
|
|
15
|
-
cat <user>/package.json | grep -E '"type|"main|"module'
|
|
16
|
-
|
|
17
|
-
# Node version — must be >= 18
|
|
18
|
-
cat <user>/.nvmrc 2>/dev/null
|
|
19
|
-
node --version
|
|
20
|
-
|
|
21
|
-
# Is the user already using @sodax/wallet-sdk-react?
|
|
22
|
-
cat <user>/package.json | grep '"@sodax/wallet-sdk-react'
|
|
23
|
-
|
|
24
|
-
# Are upstream chain SDKs already direct deps? (may indicate they don't yet know about library-exports)
|
|
25
|
-
cat <user>/package.json | grep -E '"viem"|"@solana/web3.js"|"@mysten/sui"|"@stellar/stellar-sdk"|"@stacks/transactions"|"@injectivelabs"|"near-api-js"|"bitcoinjs-lib"|"icon-sdk-js"'
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**If Node < 18**, stop and tell the user — this package requires Node ≥ 18.
|
|
29
|
-
|
|
30
|
-
**If the user is already using `@sodax/wallet-sdk-react` in the same project**, ask whether they really need to construct providers directly. In a React app the answer is usually **no**: `useWalletProvider({ xChainId })` returns the typed provider for them. Direct construction is only correct for scripts, tests, or non-React clients.
|
|
31
|
-
|
|
32
|
-
### 2. Pick the right mode
|
|
33
|
-
|
|
34
|
-
For **each** chain the user wants to integrate, decide between:
|
|
35
|
-
|
|
36
|
-
| Mode | When to pick | Stop and ask if... |
|
|
37
|
-
|---|---|---|
|
|
38
|
-
| **Private-key** | A Node script, CI runner, indexer, or test that legitimately possesses a raw key. | The user pastes a real-looking key in a frontend file. Never embed a private key in a browser bundle. |
|
|
39
|
-
| **Browser-extension** | A dApp where a wallet extension (MetaMask, Phantom, Xverse, Hana, Freighter, Leather, …) provides the signing primitives. | The user has neither a key nor a wallet adapter on hand. They probably want `@sodax/wallet-sdk-react` instead. |
|
|
40
|
-
|
|
41
|
-
Ask the user which mode applies **before** writing code. Default to **private-key** for `apps/node`-style scripts and **browser-extension** for `apps/web`-style dApps.
|
|
42
|
-
|
|
43
|
-
### 3. Apply the matching recipe
|
|
44
|
-
|
|
45
|
-
- Private-key flow → [`recipes/setup-private-key.md`](./recipes/setup-private-key.md).
|
|
46
|
-
- Browser-extension flow → [`recipes/setup-browser-extension.md`](./recipes/setup-browser-extension.md).
|
|
47
|
-
|
|
48
|
-
Each recipe is self-contained — install snippet, config, first method call, verification.
|
|
49
|
-
|
|
50
|
-
### 4. Hand off to `@sodax/sdk` if needed
|
|
51
|
-
|
|
52
|
-
If the user wants to swap / bridge / stake / lend / migrate, they need to pass the provider to `@sodax/sdk` calls. Apply [`recipes/bridge-to-sdk.md`](./recipes/bridge-to-sdk.md). Do not invent your own bridging pattern.
|
|
53
|
-
|
|
54
|
-
### 5. Add advanced features as separate steps
|
|
55
|
-
|
|
56
|
-
Only after the basic flow works should you add:
|
|
57
|
-
|
|
58
|
-
- Default config slices ([`recipes/defaults-and-overrides.md`](./recipes/defaults-and-overrides.md))
|
|
59
|
-
- Importing upstream chain types via `library-exports` ([`recipes/library-exports.md`](./recipes/library-exports.md))
|
|
60
|
-
- Sign + broadcast flow for the chain ([`recipes/sign-and-broadcast.md`](./recipes/sign-and-broadcast.md))
|
|
61
|
-
- Mocking providers in tests ([`recipes/testing.md`](./recipes/testing.md))
|
|
62
|
-
|
|
63
|
-
Each is independent — apply only what the user asked for.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## DO
|
|
68
|
-
|
|
69
|
-
- **DO** use the discriminated union types in your `import` statement so TypeScript narrows the config correctly:
|
|
70
|
-
```ts
|
|
71
|
-
import { EvmWalletProvider, type EvmWalletConfig } from '@sodax/wallet-sdk-core';
|
|
72
|
-
```
|
|
73
|
-
- **DO** use chain key constants from `@sodax/types` (`ChainKeys.SONIC_MAINNET`, `ChainKeys.BSC_MAINNET`, …) instead of magic numbers / strings.
|
|
74
|
-
- **DO** re-export upstream chain types via `library-exports` (`import type { WalletClient } from '@sodax/wallet-sdk-core'`) — keeps direct chain-SDK deps out of `package.json`.
|
|
75
|
-
- **DO** pass an `IXxxWalletProvider` (the **interface** from `@sodax/types`), not the concrete class, to SDK calls. Interfaces are how the SDK stays decoupled from this package.
|
|
76
|
-
- **DO** put RPC URLs, network selectors, default gas, etc. in the `defaults` config slice — one place, one source of truth.
|
|
77
|
-
- **DO** consult [`features/<chain>.md`](./features/) for the chain you are integrating before writing the constructor call. Each chain has slightly different field names.
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## DO NOT
|
|
82
|
-
|
|
83
|
-
- **DO NOT** embed a private key in a frontend bundle. Browser-extension config exists for a reason.
|
|
84
|
-
- **DO NOT** import from `@sodax/wallet-sdk-core/src/...` deep paths. Only the package root is public.
|
|
85
|
-
- **DO NOT** deep-import the internal `shallowMerge` from `src/utils/merge.ts`. It is intentionally not exported.
|
|
86
|
-
- **DO NOT** extend `BaseWalletProvider` in user code unless you are adding a brand-new chain to this package. That is a maintainer-only path.
|
|
87
|
-
- **DO NOT** widen the discriminated union with a cast (e.g. `as EvmWalletConfig`). If TypeScript complains, your fields are wrong — fix the fields.
|
|
88
|
-
- **DO NOT** mutate `defaults` after construction. Providers freeze the `defaults` reference; later mutations are silently ignored.
|
|
89
|
-
- **DO NOT** mix discriminant styles for a chain. Bitcoin and Stellar **require** an uppercase `type: 'PRIVATE_KEY' | 'BROWSER_EXTENSION'`; every other chain uses **field presence**. See [`architecture.md`](./architecture.md) § "Discriminant variants".
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Stop conditions (defer to user)
|
|
94
|
-
|
|
95
|
-
| Signal | Why stop |
|
|
96
|
-
|---|---|
|
|
97
|
-
| User asks for a chain family not in [chain support](./reference/chain-support.md) | Adding a new chain is a maintainer task, not user-app integration. |
|
|
98
|
-
| User wants to extend `BaseWalletProvider` directly | Maintainer-only path. Confirm scope first. |
|
|
99
|
-
| User wants to deep-merge `defaults` with per-call options | Not supported — merge is **shallow** by design. See [`recipes/defaults-and-overrides.md`](./recipes/defaults-and-overrides.md). If the user really needs deep merge, they must combine before passing. |
|
|
100
|
-
| User wants to inject a custom `Transport` / `Connection` / `SuiClient` in private-key mode | Some chains expose this via `defaults`; others don't. Check the chain's [feature file](./features/) first. |
|
|
101
|
-
| User wants to use a wallet brand the chain SDK does not support | Out of scope — wallet brand support lives in the upstream chain SDK / kit. |
|
|
102
|
-
| User is in a React app and wants to construct providers in components | Almost always wrong. Direct user to `@sodax/wallet-sdk-react`'s `useWalletProvider` hook. |
|
|
103
|
-
| User asks "how do I sign with X without a key and without an extension" | They probably want a custom signer — this package does not currently model that. Flag as out of scope. |
|
|
104
|
-
|
|
105
|
-
When stopping, **quote the file/line** of the offending code and present the user with concrete options.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## Verification protocol (after every recipe)
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# 1. Type check passes
|
|
113
|
-
pnpm checkTs
|
|
114
|
-
|
|
115
|
-
# 2. No deep imports
|
|
116
|
-
grep -rn "@sodax/wallet-sdk-core/" <user-src> | grep -v "from '@sodax/wallet-sdk-core'"
|
|
117
|
-
# expect empty — only barrel imports allowed
|
|
118
|
-
|
|
119
|
-
# 3. No direct upstream chain-SDK imports for types that library-exports provides
|
|
120
|
-
grep -rn "from 'viem'" <user-src> | grep -E "WalletClient|PublicClient|TransactionReceipt"
|
|
121
|
-
# if any match, suggest re-importing via @sodax/wallet-sdk-core
|
|
122
|
-
|
|
123
|
-
# 4. Sample call works
|
|
124
|
-
# (manual — run a one-shot sign + broadcast on testnet)
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
If steps 1–3 pass and the user confirms step 4, the recipe is done.
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## Done criteria
|
|
132
|
-
|
|
133
|
-
The integration is complete when:
|
|
134
|
-
|
|
135
|
-
- [ ] `pnpm checkTs` exits clean.
|
|
136
|
-
- [ ] The user has at least one provider instance constructed via the correct discriminated union variant.
|
|
137
|
-
- [ ] Types are imported from `@sodax/wallet-sdk-core` (and `@sodax/types`) only — no deep paths.
|
|
138
|
-
- [ ] If using `@sodax/sdk`: the provider is passed via the `IXxxWalletProvider` interface, not the concrete class.
|
|
139
|
-
- [ ] A sign + broadcast (or get-address) call has succeeded against testnet or a local mock.
|
|
140
|
-
|
|
141
|
-
Do not declare integration done before all of the above are true.
|