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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,8 @@
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:** 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.
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
@@ -33,4 +35,231 @@ The package includes wallet provider implementations for:
33
35
  - Injective ✅
34
36
  - Near ✅
35
37
  - Stacks ✅
36
- - Bitcoin ✅
38
+ - Bitcoin ✅
39
+
40
+ ## Public API surface
41
+
42
+ The package root exports:
43
+
44
+ - Wallet providers from `src/wallet-providers/*` (e.g. `EvmWalletProvider`, `SolanaWalletProvider`, `BitcoinWalletProvider`)
45
+ - `library-exports` from `src/types/library-exports.ts` (types and a few runtime values re-exported from upstream chain SDKs)
46
+
47
+ Internal utilities (e.g. `shallowMerge` in `src/utils/merge.ts`) are **not** exported from the package root.
48
+
49
+ ## Config variants (private key vs browser/extension)
50
+
51
+ All providers support two modes, but **the union discriminant depends on the provider**:
52
+
53
+ - **Field presence (no `type` field in config)**: EVM, Solana, Sui, Near, Stacks, Icon, Injective
54
+ - **Explicit uppercase `type` field**: Bitcoin, Stellar (`'PRIVATE_KEY' | 'BROWSER_EXTENSION'`)
55
+
56
+ ### EVM
57
+
58
+ ```ts
59
+ import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
60
+ import { ChainKeys } from '@sodax/types';
61
+
62
+ // Private key (Node/scripts/CI)
63
+ const evmPk = new EvmWalletProvider({
64
+ privateKey: '0x...',
65
+ chainId: ChainKeys.SONIC_MAINNET,
66
+ rpcUrl: 'https://...',
67
+ defaults: {
68
+ sendTransaction: { gas: 3_000_000n },
69
+ },
70
+ });
71
+
72
+ // Browser/extension (consumer supplies viem clients)
73
+ const evmBrowser = new EvmWalletProvider({
74
+ walletClient: myViemWalletClient,
75
+ publicClient: myViemPublicClient,
76
+ });
77
+ ```
78
+
79
+ ### Solana
80
+
81
+ ```ts
82
+ import { SolanaWalletProvider } from '@sodax/wallet-sdk-core';
83
+
84
+ const solanaPk = new SolanaWalletProvider({
85
+ privateKey: new Uint8Array([]),
86
+ endpoint: 'https://api.mainnet-beta.solana.com',
87
+ });
88
+
89
+ const solanaBrowser = new SolanaWalletProvider({
90
+ wallet: {
91
+ publicKey: myPublicKeyOrNull,
92
+ signTransaction: mySignTransactionOrUndefined,
93
+ },
94
+ endpoint: 'https://api.mainnet-beta.solana.com',
95
+ });
96
+ ```
97
+
98
+ ### Bitcoin
99
+
100
+ ```ts
101
+ import { BitcoinWalletProvider } from '@sodax/wallet-sdk-core';
102
+
103
+ const btcPk = new BitcoinWalletProvider({
104
+ type: 'PRIVATE_KEY',
105
+ privateKey: '0x...',
106
+ network: 'TESTNET',
107
+ defaults: { defaultFinalize: true },
108
+ });
109
+
110
+ const btcBrowser = new BitcoinWalletProvider({
111
+ type: 'BROWSER_EXTENSION',
112
+ walletsKit: myWalletsKit,
113
+ network: 'TESTNET',
114
+ });
115
+ ```
116
+
117
+ ### Sui
118
+
119
+ Sui uses `mnemonics` (not `privateKey`) for private-key mode. Browser extension requires a pre-constructed `SuiClient`, wallet object, and active `WalletAccount`.
120
+
121
+ ```ts
122
+ import { SuiWalletProvider } from '@sodax/wallet-sdk-core';
123
+
124
+ // Private key (Node/scripts/CI) — field presence discriminant
125
+ const suiPk = new SuiWalletProvider({
126
+ rpcUrl: 'https://...',
127
+ mnemonics: '...',
128
+ });
129
+
130
+ // Browser/extension
131
+ const suiBrowser = new SuiWalletProvider({
132
+ client: mySuiClient,
133
+ wallet: myWalletWithFeatures,
134
+ account: myWalletAccount,
135
+ });
136
+ ```
137
+
138
+ ### Stellar
139
+
140
+ Stellar uses an explicit uppercase `type` field (`'PRIVATE_KEY' | 'BROWSER_EXTENSION'`).
141
+
142
+ ```ts
143
+ import { StellarWalletProvider } from '@sodax/wallet-sdk-core';
144
+
145
+ // Private key (Node/scripts/CI)
146
+ const stellarPk = new StellarWalletProvider({
147
+ type: 'PRIVATE_KEY',
148
+ privateKey: '0x...',
149
+ network: 'PUBLIC',
150
+ rpcUrl: 'https://...',
151
+ });
152
+
153
+ // Browser/extension
154
+ const stellarBrowser = new StellarWalletProvider({
155
+ type: 'BROWSER_EXTENSION',
156
+ walletsKit: myStellarWalletsKit,
157
+ network: 'PUBLIC',
158
+ });
159
+ ```
160
+
161
+ ### Stacks
162
+
163
+ Stacks discriminates by field presence (no `type` field). The private-key config has `privateKey`; the browser-extension config has `address` (and optionally a `StacksProvider`).
164
+
165
+ ```ts
166
+ import { StacksWalletProvider } from '@sodax/wallet-sdk-core';
167
+
168
+ // Private key (Node/scripts/CI)
169
+ const stacksPk = new StacksWalletProvider({
170
+ privateKey: '...',
171
+ endpoint: 'https://...',
172
+ });
173
+
174
+ // Browser/extension
175
+ const stacksBrowser = new StacksWalletProvider({
176
+ address: 'SP...',
177
+ endpoint: 'https://...',
178
+ provider: myStacksProvider,
179
+ });
180
+ ```
181
+
182
+ ### ICON
183
+
184
+ ICON discriminates by field presence. The browser-extension config uses an optional `walletAddress` field (not a client object); `rpcUrl` is required in both modes.
185
+
186
+ ```ts
187
+ import { IconWalletProvider } from '@sodax/wallet-sdk-core';
188
+
189
+ // Private key (Node/scripts/CI)
190
+ const iconPk = new IconWalletProvider({
191
+ privateKey: '0x...',
192
+ rpcUrl: 'https://...',
193
+ });
194
+
195
+ // Browser/extension (Hana wallet)
196
+ const iconBrowser = new IconWalletProvider({
197
+ walletAddress: 'hx...',
198
+ rpcUrl: 'https://...',
199
+ });
200
+ ```
201
+
202
+ ### Injective
203
+
204
+ Injective discriminates by field presence. The private-key config uses a nested `secret` object that accepts either `{ privateKey }` or `{ mnemonics }` — it is named `SecretInjectiveWalletConfig` rather than `PrivateKey*` to reflect this dual credential shape.
205
+
206
+ ```ts
207
+ import { InjectiveWalletProvider } from '@sodax/wallet-sdk-core';
208
+
209
+ // Private key path — via secret credential
210
+ const injectivePk = new InjectiveWalletProvider({
211
+ secret: { privateKey: '...' },
212
+ chainId: myChainId,
213
+ network: myNetwork,
214
+ });
215
+
216
+ // Mnemonics path — same config shape, different secret variant
217
+ const injectiveMnemonic = new InjectiveWalletProvider({
218
+ secret: { mnemonics: '...' },
219
+ chainId: myChainId,
220
+ network: myNetwork,
221
+ });
222
+
223
+ // Browser/extension
224
+ const injectiveBrowser = new InjectiveWalletProvider({
225
+ msgBroadcaster: myMsgBroadcaster,
226
+ });
227
+ ```
228
+
229
+ ### NEAR
230
+
231
+ NEAR discriminates by field presence. The private-key config requires `rpcUrl`, `accountId`, and `privateKey`; the browser-extension config wraps a `NearConnector`.
232
+
233
+ ```ts
234
+ import { NearWalletProvider } from '@sodax/wallet-sdk-core';
235
+
236
+ // Private key (Node/scripts/CI)
237
+ const nearPk = new NearWalletProvider({
238
+ rpcUrl: 'https://...',
239
+ accountId: '...',
240
+ privateKey: '...',
241
+ });
242
+
243
+ // Browser/extension
244
+ const nearBrowser = new NearWalletProvider({
245
+ wallet: myNearConnector,
246
+ });
247
+ ```
248
+
249
+ ## Defaults and merge semantics
250
+
251
+ Each provider accepts optional `defaults`, and most methods accept per-call options. The SDK combines layers using a **shallow merge**:
252
+
253
+ - Only top-level keys are merged; **nested objects are replaced**, not deep-merged.
254
+ - `undefined` layers are skipped.
255
+ - `undefined` values inside a layer are skipped (so `{ field: undefined }` means “don’t override the previous layer”).
256
+
257
+ ## `library-exports`
258
+
259
+ `library-exports` re-exports types (and a few runtime values) from underlying chain SDKs so consumers can reduce direct dependencies.
260
+
261
+ Example:
262
+
263
+ ```ts
264
+ import type { WalletClient, PublicClient } from '@sodax/wallet-sdk-core';
265
+ ```