@sodax/wallet-sdk-core 1.5.6-beta → 2.0.0-rc.1

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