@onekeyfe/hwk-keystone-adapter 1.2.8-alpha.107 → 1.2.8-alpha.109

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/dist/index.d.mts CHANGED
@@ -84,9 +84,12 @@ interface KeystoneBtcSignatureResult {
84
84
  }
85
85
  /** SLIP-10 secp256k1 (EVM/BTC) and ed25519 (SOL); Cardano BIP32-Ed25519 is out of scope. */
86
86
  type KeystoneDerivationCurve = 'secp256k1' | 'ed25519';
87
+ /** Chain types firmware before 3.0.4 checks each requested path against. */
88
+ type KeystoneHardwareCallChainType = 'ETH' | 'SOL' | 'TRX' | 'BTC_LEGACY' | 'BTC' | 'BTC_NATIVE_SEGWIT' | 'BTC_TAPROOT';
87
89
  interface KeystoneKeySchema {
88
90
  path: string;
89
91
  curve?: KeystoneDerivationCurve;
92
+ chainType?: KeystoneHardwareCallChainType;
90
93
  }
91
94
  interface KeystoneKeyDerivationRequestInput {
92
95
  schemas: KeystoneKeySchema[];
@@ -433,4 +436,4 @@ declare function splitAccountPath(path: string): {
433
436
  /** BIP-44/49/84/86 purpose to script type; undefined for any other purpose. */
434
437
  declare function btcScriptTypeFromPath(path: string): BtcScriptType | undefined;
435
438
 
436
- export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
439
+ export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneHardwareCallChainType, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
package/dist/index.d.ts CHANGED
@@ -84,9 +84,12 @@ interface KeystoneBtcSignatureResult {
84
84
  }
85
85
  /** SLIP-10 secp256k1 (EVM/BTC) and ed25519 (SOL); Cardano BIP32-Ed25519 is out of scope. */
86
86
  type KeystoneDerivationCurve = 'secp256k1' | 'ed25519';
87
+ /** Chain types firmware before 3.0.4 checks each requested path against. */
88
+ type KeystoneHardwareCallChainType = 'ETH' | 'SOL' | 'TRX' | 'BTC_LEGACY' | 'BTC' | 'BTC_NATIVE_SEGWIT' | 'BTC_TAPROOT';
87
89
  interface KeystoneKeySchema {
88
90
  path: string;
89
91
  curve?: KeystoneDerivationCurve;
92
+ chainType?: KeystoneHardwareCallChainType;
90
93
  }
91
94
  interface KeystoneKeyDerivationRequestInput {
92
95
  schemas: KeystoneKeySchema[];
@@ -433,4 +436,4 @@ declare function splitAccountPath(path: string): {
433
436
  /** BIP-44/49/84/86 purpose to script type; undefined for any other purpose. */
434
437
  declare function btcScriptTypeFromPath(path: string): BtcScriptType | undefined;
435
438
 
436
- export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
439
+ export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneHardwareCallChainType, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
package/dist/index.js CHANGED
@@ -251,7 +251,8 @@ var KeystoneUrEngine = class {
251
251
  const ur = this.sdk.generateKeyDerivationCall({
252
252
  schemas: input.schemas.map((schema) => ({
253
253
  path: schema.path,
254
- curve: DERIVATION_CURVE[schema.curve ?? "secp256k1"]
254
+ curve: DERIVATION_CURVE[schema.curve ?? "secp256k1"],
255
+ chainType: schema.chainType
255
256
  })),
256
257
  origin: input.origin,
257
258
  version: import_keystone_sdk.QRHardwareCallVersion.V1
@@ -608,8 +609,28 @@ function keystoneBtcParamsFailure(params) {
608
609
  }
609
610
  var KEYSTONE_USB_REATTACH_PROBE_ATTEMPTS = 4;
610
611
  var KEYSTONE_USB_REATTACH_PROBE_INTERVAL_MS = 500;
612
+ var CHAIN_TYPE_BY_CHAIN = {
613
+ evm: "ETH",
614
+ sol: "SOL",
615
+ tron: "TRX"
616
+ };
617
+ var BTC_CHAIN_TYPE_BY_PURPOSE = {
618
+ 44: "BTC_LEGACY",
619
+ 49: "BTC",
620
+ 84: "BTC_NATIVE_SEGWIT",
621
+ 86: "BTC_TAPROOT"
622
+ };
623
+ function hardwareCallChainType(chain, path) {
624
+ if (chain !== "btc") return CHAIN_TYPE_BY_CHAIN[chain];
625
+ const purpose = normalizePath(path).match(/^m\/(\d+)'/)?.[1];
626
+ return purpose ? BTC_CHAIN_TYPE_BY_PURPOSE[Number(purpose)] : void 0;
627
+ }
611
628
  function keySchema(chain, path) {
612
- return { path, curve: chain === "sol" ? "ed25519" : "secp256k1" };
629
+ return {
630
+ path,
631
+ curve: chain === "sol" ? "ed25519" : "secp256k1",
632
+ chainType: hardwareCallChainType(chain, path)
633
+ };
613
634
  }
614
635
  function waitForKeystoneUsbReattachProbe() {
615
636
  return new Promise((resolve) => {