@onekeyfe/hardware-cli 1.1.26-alpha.105 → 1.1.26-alpha.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 (41) hide show
  1. package/.eslintignore +4 -0
  2. package/dist/chains.d.ts +6 -0
  3. package/dist/chains.js +191 -87
  4. package/dist/cli.js +615 -496
  5. package/dist/index.d.ts +16 -89
  6. package/dist/index.js +1 -2
  7. package/dist/sdk.d.ts +15 -5
  8. package/dist/sdk.js +237 -131
  9. package/dist/session.d.ts +22 -0
  10. package/dist/session.js +83 -0
  11. package/dist/storage/index.d.ts +2 -0
  12. package/dist/storage/index.js +5 -0
  13. package/dist/storage/process-utils.d.ts +2 -0
  14. package/dist/storage/process-utils.js +44 -0
  15. package/dist/storage/secure-storage.linux.d.ts +11 -0
  16. package/dist/storage/secure-storage.linux.js +59 -0
  17. package/dist/storage/secure-storage.macos.d.ts +11 -0
  18. package/dist/storage/secure-storage.macos.js +65 -0
  19. package/dist/storage/storage-factory.d.ts +3 -0
  20. package/dist/storage/storage-factory.js +14 -0
  21. package/dist/storage/types.d.ts +18 -0
  22. package/dist/storage/types.js +2 -0
  23. package/package.json +15 -13
  24. package/src/chains.ts +229 -85
  25. package/src/cli.ts +620 -297
  26. package/src/sdk.ts +244 -125
  27. package/src/session.ts +89 -0
  28. package/src/storage/index.ts +2 -0
  29. package/src/storage/process-utils.ts +50 -0
  30. package/src/storage/secure-storage.linux.ts +68 -0
  31. package/src/storage/secure-storage.macos.ts +68 -0
  32. package/src/storage/storage-factory.ts +13 -0
  33. package/src/storage/types.ts +17 -0
  34. package/tsconfig.json +5 -7
  35. package/.claude-plugin/plugin.json +0 -14
  36. package/AGENTS.md +0 -40
  37. package/CLAUDE.md +0 -40
  38. package/README.md +0 -112
  39. package/evals/cases.json +0 -373
  40. package/evals/run-evals.sh +0 -136
  41. package/rollup.config.js +0 -28
package/.eslintignore ADDED
@@ -0,0 +1,4 @@
1
+ dist/
2
+ node_modules/
3
+ *.js
4
+ !src/**/*.ts
package/dist/chains.d.ts CHANGED
@@ -12,12 +12,18 @@ import type { CoreApi } from '@onekeyfe/hd-core';
12
12
  /**
13
13
  * Common params passed to all SDK methods.
14
14
  * Reference: packages/core/src/types/api/export.ts (CommonParams)
15
+ *
16
+ * `skipPassphraseCheck` is CLI-internal plumbing — runCommand sets it to
17
+ * true so the interactive REQUEST_PASSPHRASE handler can own the prompt
18
+ * flow without the SDK rejecting with error 114 first. Exposed on the
19
+ * interface so inner helpers (batch flows, etc.) can forward it safely.
15
20
  */
16
21
  export interface CommonCLIParams {
17
22
  connectId?: string;
18
23
  deviceId?: string;
19
24
  passphraseState?: string;
20
25
  useEmptyPassphrase?: boolean;
26
+ skipPassphraseCheck?: boolean;
21
27
  }
22
28
  export interface GetAddressParams extends CommonCLIParams {
23
29
  chain: string;
package/dist/chains.js CHANGED
@@ -1,5 +1,4 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  /**
4
3
  * Chain Resolver — maps chain identifiers to the correct SDK API calls.
5
4
  * Handles derivation path defaults and chain-specific parameter transformations.
@@ -12,6 +11,26 @@
12
11
  */
13
12
  Object.defineProperty(exports, "__esModule", { value: true });
14
13
  exports.resolveBatchGetAddress = exports.resolveSignMessage = exports.resolveSignTransaction = exports.resolveGetPublicKey = exports.resolveGetAddress = void 0;
14
+ /**
15
+ * Extract params shared by every SDK method. Forwarded unconditionally:
16
+ *
17
+ * - `passphraseState` / `useEmptyPassphrase` — wallet selection.
18
+ * - `skipPassphraseCheck` — tells the SDK to skip its own
19
+ * `checkPassphraseStateSafety` + error-114 gate so our interactive
20
+ * `REQUEST_PASSPHRASE` handler can own the passphrase prompt flow.
21
+ * `runCommand` always sets this to `true` via `getCommonParams`.
22
+ *
23
+ * All three are forwarded even when falsy/undefined — SDK treats missing
24
+ * and undefined identically. This avoids silent losses when inner calls
25
+ * (e.g. `resolveBatchGetAddress`) reconstruct a params object manually.
26
+ */
27
+ function extractCommonParams(params) {
28
+ return {
29
+ passphraseState: params.passphraseState,
30
+ useEmptyPassphrase: params.useEmptyPassphrase,
31
+ skipPassphraseCheck: params.skipPassphraseCheck,
32
+ };
33
+ }
15
34
  // Default BIP44 derivation paths per chain
16
35
  // Sources: developer-portal core-api-guide.mdx + chain-specific docs
17
36
  const DEFAULT_PATHS = {
@@ -31,7 +50,7 @@ const DEFAULT_PATHS = {
31
50
  nostr: "m/44'/1237'/0'/0/0",
32
51
  filecoin: "m/44'/461'/0'/0/0",
33
52
  kaspa: "m/44'/111111'/0'/0/0",
34
- algo: "m/44'/283'/0'/0/0",
53
+ algo: "m/44'/283'/0'/0'/0'",
35
54
  conflux: "m/44'/503'/0'/0/0",
36
55
  nervos: "m/44'/309'/0'/0/0",
37
56
  alephium: "m/44'/1234'/0'/0/0",
@@ -81,13 +100,14 @@ async function resolveGetAddress(sdk, params) {
81
100
  const showOnOneKey = params.showOnDevice ?? true;
82
101
  const connectId = params.connectId || '';
83
102
  const deviceId = params.deviceId || '';
103
+ const commonParams = extractCommonParams(params);
84
104
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
105
  const chainMethodMap = {
86
- evm: () => sdk.evmGetAddress(connectId, deviceId, { path, showOnOneKey }),
87
- btc: () => sdk.btcGetAddress(connectId, deviceId, { path, showOnOneKey, coin: 'btc' }),
88
- sol: () => sdk.solGetAddress(connectId, deviceId, { path, showOnOneKey }),
89
- tron: () => sdk.tronGetAddress(connectId, deviceId, { path, showOnOneKey }),
90
- cosmos: () => sdk.cosmosGetAddress(connectId, deviceId, { path, showOnOneKey }),
106
+ evm: () => sdk.evmGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
107
+ btc: () => sdk.btcGetAddress(connectId, deviceId, { path, showOnOneKey, coin: 'btc', ...commonParams }),
108
+ sol: () => sdk.solGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
109
+ tron: () => sdk.tronGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
110
+ cosmos: () => sdk.cosmosGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
91
111
  // Cardano requires networkId, protocolMagic, derivationType
92
112
  cardano: () => sdk.cardanoGetAddress(connectId, deviceId, {
93
113
  addressParameters: { path, addressType: 0 },
@@ -95,6 +115,7 @@ async function resolveGetAddress(sdk, params) {
95
115
  protocolMagic: 764824073,
96
116
  derivationType: 1,
97
117
  showOnOneKey,
118
+ ...commonParams,
98
119
  }),
99
120
  // Polkadot requires network param
100
121
  polkadot: () => sdk.polkadotGetAddress(connectId, deviceId, {
@@ -102,26 +123,47 @@ async function resolveGetAddress(sdk, params) {
102
123
  prefix: 0,
103
124
  network: 'polkadot',
104
125
  showOnOneKey,
126
+ ...commonParams,
127
+ }),
128
+ aptos: () => sdk.aptosGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
129
+ sui: () => sdk.suiGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
130
+ near: () => sdk.nearGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
131
+ xrp: () => sdk.xrpGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
132
+ stellar: () => sdk.stellarGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
133
+ ton: () => sdk.tonGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
134
+ filecoin: () => sdk.filecoinGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
135
+ kaspa: () => sdk.kaspaGetAddress(connectId, deviceId, {
136
+ path,
137
+ showOnOneKey,
138
+ prefix: 'kaspa',
139
+ ...commonParams,
140
+ }),
141
+ algo: () => sdk.algoGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
142
+ conflux: () => sdk.confluxGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
143
+ nervos: () => sdk.nervosGetAddress(connectId, deviceId, {
144
+ path,
145
+ showOnOneKey,
146
+ network: 'ckb',
147
+ ...commonParams,
148
+ }),
149
+ alephium: () => sdk.alephiumGetAddress(connectId, deviceId, {
150
+ path,
151
+ showOnOneKey,
152
+ group: 0,
153
+ ...commonParams,
154
+ }),
155
+ neo: () => sdk.neoGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
156
+ starcoin: () => sdk.starcoinGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
157
+ nem: () => sdk.nemGetAddress(connectId, deviceId, { path, showOnOneKey, network: 104, ...commonParams }),
158
+ dnx: () => sdk.dnxGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
159
+ scdo: () => sdk.scdoGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
160
+ benfen: () => sdk.benfenGetAddress(connectId, deviceId, { path, showOnOneKey, ...commonParams }),
161
+ nexa: () => sdk.nexaGetAddress(connectId, deviceId, {
162
+ path,
163
+ showOnOneKey,
164
+ prefix: 'nexa',
165
+ ...commonParams,
105
166
  }),
106
- aptos: () => sdk.aptosGetAddress(connectId, deviceId, { path, showOnOneKey }),
107
- sui: () => sdk.suiGetAddress(connectId, deviceId, { path, showOnOneKey }),
108
- near: () => sdk.nearGetAddress(connectId, deviceId, { path, showOnOneKey }),
109
- xrp: () => sdk.xrpGetAddress(connectId, deviceId, { path, showOnOneKey }),
110
- stellar: () => sdk.stellarGetAddress(connectId, deviceId, { path, showOnOneKey }),
111
- ton: () => sdk.tonGetAddress(connectId, deviceId, { path, showOnOneKey }),
112
- filecoin: () => sdk.filecoinGetAddress(connectId, deviceId, { path, showOnOneKey }),
113
- kaspa: () => sdk.kaspaGetAddress(connectId, deviceId, { path, showOnOneKey, prefix: 'kaspa' }),
114
- algo: () => sdk.algoGetAddress(connectId, deviceId, { path, showOnOneKey }),
115
- conflux: () => sdk.confluxGetAddress(connectId, deviceId, { path, showOnOneKey }),
116
- nervos: () => sdk.nervosGetAddress(connectId, deviceId, { path, showOnOneKey, network: 'ckb' }),
117
- alephium: () => sdk.alephiumGetAddress(connectId, deviceId, { path, showOnOneKey, group: 0 }),
118
- neo: () => sdk.neoGetAddress(connectId, deviceId, { path, showOnOneKey }),
119
- starcoin: () => sdk.starcoinGetAddress(connectId, deviceId, { path, showOnOneKey }),
120
- nem: () => sdk.nemGetAddress(connectId, deviceId, { path, showOnOneKey, network: 104 }),
121
- dnx: () => sdk.dnxGetAddress(connectId, deviceId, { path, showOnOneKey }),
122
- scdo: () => sdk.scdoGetAddress(connectId, deviceId, { path, showOnOneKey }),
123
- benfen: () => sdk.benfenGetAddress(connectId, deviceId, { path, showOnOneKey }),
124
- nexa: () => sdk.nexaGetAddress(connectId, deviceId, { path, showOnOneKey, prefix: 'nexa' }),
125
167
  };
126
168
  const method = chainMethodMap[chain];
127
169
  if (!method) {
@@ -139,17 +181,18 @@ async function resolveGetPublicKey(sdk, params) {
139
181
  const path = params.path || getDefaultPath(chain);
140
182
  const connectId = params.connectId || '';
141
183
  const deviceId = params.deviceId || '';
184
+ const commonParams = extractCommonParams(params);
142
185
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
186
  const chainMethodMap = {
144
- evm: () => sdk.evmGetPublicKey(connectId, deviceId, { path }),
145
- btc: () => sdk.btcGetPublicKey(connectId, deviceId, { path, coin: 'btc' }),
146
- aptos: () => sdk.aptosGetPublicKey(connectId, deviceId, { path }),
147
- cosmos: () => sdk.cosmosGetPublicKey(connectId, deviceId, { path }),
148
- sui: () => sdk.suiGetPublicKey(connectId, deviceId, { path }),
149
- starcoin: () => sdk.starcoinGetPublicKey(connectId, deviceId, { path }),
150
- nostr: () => sdk.nostrGetPublicKey(connectId, deviceId, { path }),
151
- benfen: () => sdk.benfenGetPublicKey(connectId, deviceId, { path }),
152
- cardano: () => sdk.cardanoGetPublicKey(connectId, deviceId, { path, derivationType: 1 }),
187
+ evm: () => sdk.evmGetPublicKey(connectId, deviceId, { path, ...commonParams }),
188
+ btc: () => sdk.btcGetPublicKey(connectId, deviceId, { path, coin: 'btc', ...commonParams }),
189
+ aptos: () => sdk.aptosGetPublicKey(connectId, deviceId, { path, ...commonParams }),
190
+ cosmos: () => sdk.cosmosGetPublicKey(connectId, deviceId, { path, ...commonParams }),
191
+ sui: () => sdk.suiGetPublicKey(connectId, deviceId, { path, ...commonParams }),
192
+ starcoin: () => sdk.starcoinGetPublicKey(connectId, deviceId, { path, ...commonParams }),
193
+ nostr: () => sdk.nostrGetPublicKey(connectId, deviceId, { path, ...commonParams }),
194
+ benfen: () => sdk.benfenGetPublicKey(connectId, deviceId, { path, ...commonParams }),
195
+ cardano: () => sdk.cardanoGetPublicKey(connectId, deviceId, { path, derivationType: 1, ...commonParams }),
153
196
  };
154
197
  const method = chainMethodMap[chain];
155
198
  if (!method) {
@@ -165,50 +208,102 @@ async function resolveSignTransaction(sdk, params) {
165
208
  const connectId = params.connectId || '';
166
209
  const deviceId = params.deviceId || '';
167
210
  const tx = params.transaction;
211
+ const commonParams = extractCommonParams(params);
168
212
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
169
213
  const chainMethodMap = {
170
214
  // EVM: chainId is inside the transaction object, not top-level
171
- evm: () => sdk.evmSignTransaction(connectId, deviceId, { path, transaction: tx }),
172
- // BTC: requires inputs/outputs/refTxs/coin format
173
- btc: () => sdk.btcSignTransaction(connectId, deviceId, { coin: 'btc', ...tx }),
174
- sol: () => sdk.solSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
175
- tron: () => sdk.tronSignTransaction(connectId, deviceId, { path, transaction: tx }),
176
- cosmos: () => sdk.cosmosSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
177
- aptos: () => sdk.aptosSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
178
- sui: () => sdk.suiSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
179
- near: () => sdk.nearSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
180
- // XRP: implementation reads path + transaction from payload despite type declaration
215
+ evm: () => sdk.evmSignTransaction(connectId, deviceId, {
216
+ path,
217
+ transaction: tx,
218
+ ...commonParams,
219
+ }),
220
+ btc: () => sdk.btcSignTransaction(connectId, deviceId, { coin: 'btc', ...tx, ...commonParams }),
221
+ sol: () => sdk.solSignTransaction(connectId, deviceId, {
222
+ path,
223
+ rawTx: tx.rawTx,
224
+ ...commonParams,
225
+ }),
226
+ tron: () => sdk.tronSignTransaction(connectId, deviceId, {
227
+ path,
228
+ transaction: tx,
229
+ ...commonParams,
230
+ }),
231
+ cosmos: () => sdk.cosmosSignTransaction(connectId, deviceId, {
232
+ path,
233
+ rawTx: tx.rawTx,
234
+ ...commonParams,
235
+ }),
236
+ aptos: () => sdk.aptosSignTransaction(connectId, deviceId, {
237
+ path,
238
+ rawTx: tx.rawTx,
239
+ ...commonParams,
240
+ }),
241
+ sui: () => sdk.suiSignTransaction(connectId, deviceId, {
242
+ path,
243
+ rawTx: tx.rawTx,
244
+ ...commonParams,
245
+ }),
246
+ near: () => sdk.nearSignTransaction(connectId, deviceId, {
247
+ path,
248
+ rawTx: tx.rawTx,
249
+ ...commonParams,
250
+ }),
181
251
  // eslint-disable-next-line @typescript-eslint/ban-types
182
252
  xrp: () => sdk.xrpSignTransaction(connectId, deviceId, {
183
253
  path,
184
254
  transaction: tx,
255
+ ...commonParams,
185
256
  }),
186
257
  stellar: () => sdk.stellarSignTransaction(connectId, deviceId, {
187
258
  path,
188
259
  networkPassphrase: tx.networkPassphrase,
189
260
  transaction: tx.transaction,
261
+ ...commonParams,
190
262
  }),
191
- // Polkadot: requires prefix param
192
263
  polkadot: () => sdk.polkadotSignTransaction(connectId, deviceId, {
193
264
  path,
194
265
  rawTx: tx.rawTx,
195
266
  network: tx.network || 'polkadot',
196
267
  prefix: tx.prefix ?? 0,
268
+ ...commonParams,
269
+ }),
270
+ filecoin: () => sdk.filecoinSignTransaction(connectId, deviceId, {
271
+ path,
272
+ rawTx: tx.rawTx,
273
+ ...commonParams,
274
+ }),
275
+ kaspa: () => sdk.kaspaSignTransaction(connectId, deviceId, { ...tx, ...commonParams }),
276
+ algo: () => sdk.algoSignTransaction(connectId, deviceId, {
277
+ path,
278
+ rawTx: tx.rawTx,
279
+ ...commonParams,
280
+ }),
281
+ conflux: () => sdk.confluxSignTransaction(connectId, deviceId, {
282
+ path,
283
+ transaction: tx,
284
+ ...commonParams,
285
+ }),
286
+ nervos: () => sdk.nervosSignTransaction(connectId, deviceId, { ...tx, ...commonParams }),
287
+ alephium: () => sdk.alephiumSignTransaction(connectId, deviceId, {
288
+ path,
289
+ rawTx: tx.rawTx,
290
+ ...commonParams,
291
+ }),
292
+ neo: () => sdk.neoSignTransaction(connectId, deviceId, { path, ...tx, ...commonParams }),
293
+ dnx: () => sdk.dnxSignTransaction(connectId, deviceId, { path, ...tx, ...commonParams }),
294
+ scdo: () => sdk.scdoSignTransaction(connectId, deviceId, { path, ...tx, ...commonParams }),
295
+ benfen: () => sdk.benfenSignTransaction(connectId, deviceId, {
296
+ path,
297
+ rawTx: tx.rawTx,
298
+ ...commonParams,
299
+ }),
300
+ nexa: () => sdk.nexaSignTransaction(connectId, deviceId, { ...tx, ...commonParams }),
301
+ cardano: () => sdk.cardanoSignTransaction(connectId, deviceId, { ...tx, ...commonParams }),
302
+ starcoin: () => sdk.starcoinSignTransaction(connectId, deviceId, {
303
+ path,
304
+ rawTx: tx.rawTx,
305
+ ...commonParams,
197
306
  }),
198
- filecoin: () => sdk.filecoinSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
199
- kaspa: () => sdk.kaspaSignTransaction(connectId, deviceId, { ...tx }),
200
- algo: () => sdk.algoSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
201
- conflux: () => sdk.confluxSignTransaction(connectId, deviceId, { path, transaction: tx }),
202
- nervos: () => sdk.nervosSignTransaction(connectId, deviceId, { ...tx }),
203
- alephium: () => sdk.alephiumSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
204
- neo: () => sdk.neoSignTransaction(connectId, deviceId, { path, ...tx }),
205
- dnx: () => sdk.dnxSignTransaction(connectId, deviceId, { path, ...tx }),
206
- // SCDO: flat params (nonce, gasPrice, gasLimit, to, value, data), not wrapped
207
- scdo: () => sdk.scdoSignTransaction(connectId, deviceId, { path, ...tx }),
208
- benfen: () => sdk.benfenSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
209
- nexa: () => sdk.nexaSignTransaction(connectId, deviceId, { ...tx }),
210
- cardano: () => sdk.cardanoSignTransaction(connectId, deviceId, { ...tx }),
211
- starcoin: () => sdk.starcoinSignTransaction(connectId, deviceId, { path, rawTx: tx.rawTx }),
212
307
  };
213
308
  const method = chainMethodMap[chain];
214
309
  if (!method) {
@@ -223,6 +318,7 @@ async function resolveSignMessage(sdk, params) {
223
318
  const path = params.path || getDefaultPath(chain);
224
319
  const connectId = params.connectId || '';
225
320
  const deviceId = params.deviceId || '';
321
+ const commonParams = extractCommonParams(params);
226
322
  // Most chains use `messageHex` (hex-encoded). CLI accepts either:
227
323
  // - Already hex-encoded string (starts with "0x" or matches /^[0-9a-fA-F]+$/)
228
324
  // - Plain text string (auto-converted to hex)
@@ -231,43 +327,48 @@ async function resolveSignMessage(sdk, params) {
231
327
  const msg = isHex ? raw.replace(/^0x/, '') : Buffer.from(raw, 'utf8').toString('hex');
232
328
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
233
329
  const chainMethodMap = {
234
- evm: () => sdk.evmSignMessage(connectId, deviceId, { path, messageHex: msg }),
235
- // BTC: uses messageHex, not message
236
- btc: () => sdk.btcSignMessage(connectId, deviceId, { path, messageHex: msg, coin: 'btc' }),
237
- sol: () => sdk.solSignMessage(connectId, deviceId, { path, messageHex: msg }),
238
- // Tron: uses messageHex
239
- tron: () => sdk.tronSignMessage(connectId, deviceId, { path, messageHex: msg }),
240
- aptos: () => sdk.aptosSignMessage(connectId, deviceId, { path, payload: { message: msg } }),
241
- sui: () => sdk.suiSignMessage(connectId, deviceId, { path, messageHex: msg }),
242
- // Conflux: uses messageHex
243
- conflux: () => sdk.confluxSignMessage(connectId, deviceId, { path, messageHex: msg }),
244
- // Starcoin: uses messageHex
245
- starcoin: () => sdk.starcoinSignMessage(connectId, deviceId, { path, messageHex: msg }),
246
- // TON: tonSignMessage is transfer-signing, pass JSON params
330
+ evm: () => sdk.evmSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
331
+ btc: () => sdk.btcSignMessage(connectId, deviceId, {
332
+ path,
333
+ messageHex: msg,
334
+ coin: 'btc',
335
+ ...commonParams,
336
+ }),
337
+ sol: () => sdk.solSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
338
+ tron: () => sdk.tronSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
339
+ aptos: () => sdk.aptosSignMessage(connectId, deviceId, {
340
+ path,
341
+ payload: { message: msg },
342
+ ...commonParams,
343
+ }),
344
+ sui: () => sdk.suiSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
345
+ conflux: () => sdk.confluxSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
346
+ starcoin: () => sdk.starcoinSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
247
347
  ton: () => {
248
- const tonParams = JSON.parse(msg);
249
- return sdk.tonSignMessage(connectId, deviceId, { path, ...tonParams });
348
+ // TON expects structured params, parse from original raw input (not hex-encoded)
349
+ const tonParams = JSON.parse(raw);
350
+ return sdk.tonSignMessage(connectId, deviceId, { path, ...tonParams, ...commonParams });
250
351
  },
251
- // Nostr: event must be a NostrEvent object (kind, content, tags, created_at)
252
352
  nostr: () => {
253
- const event = JSON.parse(msg);
254
- return sdk.nostrSignEvent(connectId, deviceId, { path, event });
353
+ // Nostr expects a JSON event object, parse from original raw input (not hex-encoded)
354
+ const event = JSON.parse(raw);
355
+ return sdk.nostrSignEvent(connectId, deviceId, { path, event, ...commonParams });
255
356
  },
256
- // SCDO: uses messageHex
257
- scdo: () => sdk.scdoSignMessage(connectId, deviceId, { path, messageHex: msg }),
258
- // Alephium: requires messageType
357
+ scdo: () => sdk.scdoSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
259
358
  alephium: () => sdk.alephiumSignMessage(connectId, deviceId, {
260
359
  path,
261
360
  messageHex: msg,
262
361
  messageType: 'alephium',
362
+ ...commonParams,
263
363
  }),
264
- benfen: () => sdk.benfenSignMessage(connectId, deviceId, { path, messageHex: msg }),
364
+ benfen: () => sdk.benfenSignMessage(connectId, deviceId, { path, messageHex: msg, ...commonParams }),
265
365
  // Cardano: uses `message` field, requires networkId
266
366
  cardano: () => sdk.cardanoSignMessage(connectId, deviceId, {
267
367
  path,
268
368
  message: msg,
269
369
  derivationType: 1,
270
370
  networkId: 1,
371
+ ...commonParams,
271
372
  }),
272
373
  };
273
374
  const method = chainMethodMap[chain];
@@ -279,16 +380,19 @@ async function resolveSignMessage(sdk, params) {
279
380
  }
280
381
  exports.resolveSignMessage = resolveSignMessage;
281
382
  async function resolveBatchGetAddress(sdk, params) {
282
- // #13 FIX: Collect per-item results with error handling for partial failures
383
+ // Spread `common` so every CommonCLIParams field (including
384
+ // skipPassphraseCheck) propagates to each inner resolveGetAddress
385
+ // call. Enumerating fields manually used to drop skipPassphraseCheck
386
+ // and cause error 114 on hidden-wallet batch calls.
387
+ const { bundle, ...common } = params;
283
388
  const results = [];
284
- for (const item of params.bundle) {
389
+ for (const item of bundle) {
285
390
  try {
286
391
  const result = await resolveGetAddress(sdk, {
392
+ ...common,
287
393
  chain: item.chain,
288
394
  path: item.path,
289
395
  showOnDevice: item.showOnDevice ?? false,
290
- connectId: params.connectId,
291
- deviceId: params.deviceId,
292
396
  });
293
397
  results.push(result);
294
398
  }