@onekeyfe/hd-core 0.3.40-alpha.1 → 0.3.40-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 (33) hide show
  1. package/dist/api/btc/BTCGetAddress.d.ts +11 -0
  2. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  3. package/dist/api/btc/BTCGetPublicKey.d.ts +11 -0
  4. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  5. package/dist/api/btc/BTCSignMessage.d.ts +11 -0
  6. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  7. package/dist/api/btc/BTCSignTransaction.d.ts +11 -0
  8. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  9. package/dist/api/btc/BTCVerifyMessage.d.ts +11 -0
  10. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  11. package/dist/api/btc/helpers/versionLimit.d.ts +12 -0
  12. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -0
  13. package/dist/api/nervos/NervosSignTransaction.d.ts +7 -3
  14. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  15. package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
  16. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +72 -32
  19. package/dist/types/api/deviceUpdateBootloader.d.ts +1 -1
  20. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  21. package/package.json +4 -4
  22. package/src/api/btc/BTCGetAddress.ts +5 -0
  23. package/src/api/btc/BTCGetPublicKey.ts +5 -0
  24. package/src/api/btc/BTCSignMessage.ts +5 -0
  25. package/src/api/btc/BTCSignTransaction.ts +5 -0
  26. package/src/api/btc/BTCVerifyMessage.ts +5 -0
  27. package/src/api/btc/helpers/versionLimit.ts +25 -0
  28. package/src/api/nervos/NervosGetAddress.ts +2 -2
  29. package/src/api/nervos/NervosSignTransaction.ts +26 -18
  30. package/src/api/sui/SuiSignTransaction.ts +11 -10
  31. package/src/data/coins/bitcoin.json +2 -1
  32. package/src/types/api/deviceUpdateBootloader.ts +1 -1
  33. package/src/utils/deviceFeaturesUtils.ts +1 -1
@@ -4,6 +4,17 @@ import { BTCAddress } from '../../types/api/btcGetAddress';
4
4
  export default class BTCGetAddress extends BaseMethod<GetAddress[]> {
5
5
  hasBundle: boolean;
6
6
  init(): void;
7
+ getVersionRange(): {
8
+ model_mini: {
9
+ min: string;
10
+ };
11
+ model_touch: {
12
+ min: string;
13
+ };
14
+ } | {
15
+ model_mini?: undefined;
16
+ model_touch?: undefined;
17
+ };
7
18
  run(): Promise<BTCAddress | BTCAddress[]>;
8
19
  }
9
20
  //# sourceMappingURL=BTCGetAddress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BTCGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCGetAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAuB,MAAM,+BAA+B,CAAC;AAGhF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CAAC,UAAU,EAAE,CAAC;IACjE,SAAS,UAAS;IAElB,IAAI;IA6CE,GAAG;CAwBV"}
1
+ {"version":3,"file":"BTCGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCGetAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAuB,MAAM,+BAA+B,CAAC;AAIhF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CAAC,UAAU,EAAE,CAAC;IACjE,SAAS,UAAS;IAElB,IAAI;IA6CJ,eAAe;;;;;;;;;;;IAIT,GAAG;CAwBV"}
@@ -5,6 +5,17 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
5
5
  hasBundle: boolean;
6
6
  init(): void;
7
7
  private isBtcNetwork;
8
+ getVersionRange(): {
9
+ model_mini: {
10
+ min: string;
11
+ };
12
+ model_touch: {
13
+ min: string;
14
+ };
15
+ } | {
16
+ model_mini?: undefined;
17
+ model_touch?: undefined;
18
+ };
8
19
  run(): Promise<BTCPublicKey | BTCPublicKey[]>;
9
20
  }
10
21
  //# sourceMappingURL=BTCGetPublicKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BTCGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,YAAY,EAAE,CAAC;IACrE,SAAS,UAAS;IAElB,IAAI;IA4CJ,OAAO,CAAC,YAAY;IAId,GAAG;CA8BV"}
1
+ {"version":3,"file":"BTCGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,YAAY,EAAE,CAAC;IACrE,SAAS,UAAS;IAElB,IAAI;IA4CJ,OAAO,CAAC,YAAY;IAIpB,eAAe;;;;;;;;;;;IAIT,GAAG;CA8BV"}
@@ -2,6 +2,17 @@ import { SignMessage } from '@onekeyfe/hd-transport';
2
2
  import { BaseMethod } from '../BaseMethod';
3
3
  export default class BTCSignMessage extends BaseMethod<SignMessage> {
4
4
  init(): void;
5
+ getVersionRange(): {
6
+ model_mini: {
7
+ min: string;
8
+ };
9
+ model_touch: {
10
+ min: string;
11
+ };
12
+ } | {
13
+ model_mini?: undefined;
14
+ model_touch?: undefined;
15
+ };
5
16
  run(): Promise<import("@onekeyfe/hd-transport").MessageSignature>;
6
17
  }
7
18
  //# sourceMappingURL=BTCSignMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BTCSignMessage.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,WAAW,CAAC;IACjE,IAAI;IA0BE,GAAG;CAOV"}
1
+ {"version":3,"file":"BTCSignMessage.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,WAAW,CAAC;IACjE,IAAI;IA0BJ,eAAe;;;;;;;;;;;IAIT,GAAG;CAOV"}
@@ -11,6 +11,17 @@ type Params = {
11
11
  };
12
12
  export default class BTCSignTransaction extends BaseMethod<Params> {
13
13
  init(): void;
14
+ getVersionRange(): {
15
+ model_mini: {
16
+ min: string;
17
+ };
18
+ model_touch: {
19
+ min: string;
20
+ };
21
+ } | {
22
+ model_mini?: undefined;
23
+ model_touch?: undefined;
24
+ };
14
25
  run(): Promise<import("../../types/api/btcSignTransaction").SignedTransaction>;
15
26
  }
16
27
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"BTCSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAEhB,cAAc,EACd,kBAAkB,EACnB,MAAM,oCAAoC,CAAC;AAK5C,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAChE,IAAI;IAgGE,GAAG;CAmBV"}
1
+ {"version":3,"file":"BTCSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAEhB,cAAc,EACd,kBAAkB,EACnB,MAAM,oCAAoC,CAAC;AAM5C,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAChE,IAAI;IAgGJ,eAAe;;;;;;;;;;;IAIT,GAAG;CAmBV"}
@@ -2,6 +2,17 @@ import { VerifyMessage } from '@onekeyfe/hd-transport';
2
2
  import { BaseMethod } from '../BaseMethod';
3
3
  export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> {
4
4
  init(): void;
5
+ getVersionRange(): {
6
+ model_mini: {
7
+ min: string;
8
+ };
9
+ model_touch: {
10
+ min: string;
11
+ };
12
+ } | {
13
+ model_mini?: undefined;
14
+ model_touch?: undefined;
15
+ };
5
16
  run(): Promise<import("@onekeyfe/hd-transport").Success>;
6
17
  }
7
18
  //# sourceMappingURL=BTCVerifyMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BTCVerifyMessage.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCVerifyMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,aAAa,CAAC;IACrE,IAAI;IAwBE,GAAG;CAOV"}
1
+ {"version":3,"file":"BTCVerifyMessage.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCVerifyMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,aAAa,CAAC;IACrE,IAAI;IAwBJ,eAAe;;;;;;;;;;;IAIT,GAAG;CAOV"}
@@ -0,0 +1,12 @@
1
+ export declare function getBitcoinForkVersionRange(params: (string | undefined)[]): {
2
+ model_mini: {
3
+ min: string;
4
+ };
5
+ model_touch: {
6
+ min: string;
7
+ };
8
+ } | {
9
+ model_mini?: undefined;
10
+ model_touch?: undefined;
11
+ };
12
+ //# sourceMappingURL=versionLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionLimit.d.ts","sourceRoot":"","sources":["../../../../src/api/btc/helpers/versionLimit.ts"],"names":[],"mappings":"AAUA,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE;;;;;;;;;;EAcxE"}
@@ -1,8 +1,12 @@
1
+ /// <reference types="node" />
1
2
  import type { NervosSignTx as HardwareNervosSignTx, TypedCall } from '@onekeyfe/hd-transport';
2
3
  import { BaseMethod } from '../BaseMethod';
3
4
  import type { NervosSignedTx } from '../../types';
4
5
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
5
- export default class NervosSignTransaction extends BaseMethod<HardwareNervosSignTx> {
6
+ type NervosSignTx = Omit<HardwareNervosSignTx, 'data_initial_chunk' | 'data_length'> & {
7
+ raw_tx: Buffer;
8
+ };
9
+ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
6
10
  hasBundle: boolean;
7
11
  init(): void;
8
12
  getVersionRange(): {
@@ -14,8 +18,8 @@ export default class NervosSignTransaction extends BaseMethod<HardwareNervosSign
14
18
  };
15
19
  };
16
20
  chunkByteSize: number;
17
- processTxRequest: (typedCall: TypedCall, res: TypedResponseMessage<'NervosSignedTx'> | TypedResponseMessage<'NervosTxRequest'>, data: string, offset?: number) => Promise<NervosSignedTx>;
18
- min(a: number, b: number): number;
21
+ processTxRequest: (typedCall: TypedCall, res: TypedResponseMessage<'NervosSignedTx'> | TypedResponseMessage<'NervosTxRequest'>, data: Buffer, offset?: number) => Promise<NervosSignedTx>;
19
22
  run(): Promise<NervosSignedTx>;
20
23
  }
24
+ export {};
21
25
  //# sourceMappingURL=NervosSignTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NervosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/nervos/NervosSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,oBAAoB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAA+B,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,oBAAoB,CAAC;IACjF,SAAS,UAAS;IAElB,IAAI;IAwBJ,eAAe;;;;;;;;IAWf,aAAa,SAAQ;IAErB,gBAAgB,cACH,SAAS,OACf,qBAAqB,gBAAgB,CAAC,GAAG,qBAAqB,iBAAiB,CAAC,QAC/E,MAAM,sBAEX,QAAQ,cAAc,CAAC,CA6BxB;IAEF,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAIlB,GAAG;CAgBV"}
1
+ {"version":3,"file":"NervosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/nervos/NervosSignTransaction.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,oBAAoB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAA+B,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,KAAK,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,oBAAoB,GAAG,aAAa,CAAC,GAAG;IACrF,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,YAAY,CAAC;IACzE,SAAS,UAAS;IAElB,IAAI;IAwBJ,eAAe;;;;;;;;IAWf,aAAa,SAAQ;IAErB,gBAAgB,cACH,SAAS,OACf,qBAAqB,gBAAgB,CAAC,GAAG,qBAAqB,iBAAiB,CAAC,QAC/E,MAAM,sBAEX,QAAQ,cAAc,CAAC,CAoCxB;IAEI,GAAG;CAiBV"}
@@ -1,7 +1,9 @@
1
+ /// <reference types="node" />
1
2
  import { SuiSignTx as HardwareSuiSignTx, TypedCall, SuiSignedTx } from '@onekeyfe/hd-transport';
2
3
  import { BaseMethod } from '../BaseMethod';
3
4
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
4
- export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
5
+ type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx;
6
+ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
5
7
  init(): void;
6
8
  getVersionRange(): {
7
9
  model_mini: {
@@ -13,7 +15,8 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
13
15
  };
14
16
  supportChunkTransfer(): boolean;
15
17
  chunkByteSize: number;
16
- processTxRequest: (typedCall: TypedCall, res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>, data: string, offset?: number) => Promise<SuiSignedTx>;
18
+ processTxRequest: (typedCall: TypedCall, res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>, data: Buffer, offset?: number) => Promise<SuiSignedTx>;
17
19
  run(): Promise<SuiSignedTx>;
18
20
  }
21
+ export {};
19
22
  //# sourceMappingURL=SuiSignTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SuiSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/sui/SuiSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIhG,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC3E,IAAI;IAqBJ,eAAe;;;;;;;;IAWf,oBAAoB;IAiBpB,aAAa,SAAQ;IAErB,gBAAgB,cACH,SAAS,OACf,qBAAqB,aAAa,CAAC,GAAG,qBAAqB,cAAc,CAAC,QACzE,MAAM,sBAEX,QAAQ,WAAW,CAAC,CAuBrB;IAEI,GAAG;CAwBV"}
1
+ {"version":3,"file":"SuiSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/sui/SuiSignTransaction.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIhG,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,KAAK,SAAS,GAAG,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,aAAa,CAAC,GAAG,iBAAiB,CAAC;AAEnG,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU,CAAC,SAAS,CAAC;IACnE,IAAI;IAqBJ,eAAe;;;;;;;;IAWf,oBAAoB;IAiBpB,aAAa,SAAQ;IAErB,gBAAgB,cACH,SAAS,OACf,qBAAqB,aAAa,CAAC,GAAG,qBAAqB,cAAc,CAAC,QACzE,MAAM,sBAEX,QAAQ,WAAW,CAAC,CAuBrB;IAEI,GAAG;CAuBV"}
package/dist/index.d.ts CHANGED
@@ -424,7 +424,7 @@ declare function deviceFullyUploadResource(connectId: string, params: CommonPara
424
424
  binary?: ArrayBuffer;
425
425
  }): Response<Success$1>;
426
426
 
427
- declare function deviceUpdateBootloader(connectId: string, params: {
427
+ declare function deviceUpdateBootloader(connectId: string, params?: {
428
428
  binary?: ArrayBuffer;
429
429
  }): Response<Success$1>;
430
430
 
package/dist/index.js CHANGED
@@ -23578,7 +23578,7 @@ const getDeviceTypeByDeviceId = (deviceId) => {
23578
23578
  const getDeviceUUID = (features) => {
23579
23579
  var _a, _b;
23580
23580
  const deviceType = getDeviceType(features);
23581
- if (features.onekey_serial_no)
23581
+ if (features === null || features === void 0 ? void 0 : features.onekey_serial_no)
23582
23582
  return features.onekey_serial_no;
23583
23583
  if (deviceType === 'classic') {
23584
23584
  return (_a = features.onekey_serial) !== null && _a !== void 0 ? _a : '';
@@ -26716,6 +26716,11 @@ var bitcoin = [
26716
26716
  name: "Zcash Testnet",
26717
26717
  label: "TAZ",
26718
26718
  slip44: 1
26719
+ },
26720
+ {
26721
+ name: "Neurai",
26722
+ label: "XNA",
26723
+ slip44: 1900
26719
26724
  }
26720
26725
  ];
26721
26726
 
@@ -26758,6 +26763,29 @@ const getCoinAndScriptType = (path, coin, multisig) => {
26758
26763
  };
26759
26764
  };
26760
26765
 
26766
+ function doesCoinExistByParams(coinName, params) {
26767
+ for (let i = 0; i < params.length; i++) {
26768
+ const coin_name = params[i];
26769
+ if ((coin_name === null || coin_name === void 0 ? void 0 : coin_name.toLowerCase()) === (coinName === null || coinName === void 0 ? void 0 : coinName.toLowerCase())) {
26770
+ return true;
26771
+ }
26772
+ }
26773
+ return false;
26774
+ }
26775
+ function getBitcoinForkVersionRange(params) {
26776
+ if (doesCoinExistByParams('Neurai', params)) {
26777
+ return {
26778
+ model_mini: {
26779
+ min: '3.7.0',
26780
+ },
26781
+ model_touch: {
26782
+ min: '4.9.0',
26783
+ },
26784
+ };
26785
+ }
26786
+ return {};
26787
+ }
26788
+
26761
26789
  class BTCGetAddress extends BaseMethod {
26762
26790
  constructor() {
26763
26791
  super(...arguments);
@@ -26799,6 +26827,9 @@ class BTCGetAddress extends BaseMethod {
26799
26827
  });
26800
26828
  });
26801
26829
  }
26830
+ getVersionRange() {
26831
+ return getBitcoinForkVersionRange(this.params.map(param => param.coin_name));
26832
+ }
26802
26833
  run() {
26803
26834
  return __awaiter(this, void 0, void 0, function* () {
26804
26835
  const responses = [];
@@ -26859,6 +26890,9 @@ class BTCGetPublicKey extends BaseMethod {
26859
26890
  isBtcNetwork(param) {
26860
26891
  return param.coin_name === 'Testnet' || param.coin_name === 'Bitcoin';
26861
26892
  }
26893
+ getVersionRange() {
26894
+ return getBitcoinForkVersionRange(this.params.map(param => param.coin_name));
26895
+ }
26862
26896
  run() {
26863
26897
  return __awaiter(this, void 0, void 0, function* () {
26864
26898
  const responses = [];
@@ -26901,6 +26935,9 @@ class BTCSignMessage extends BaseMethod {
26901
26935
  no_script_type: noScriptType,
26902
26936
  };
26903
26937
  }
26938
+ getVersionRange() {
26939
+ return getBitcoinForkVersionRange([this.params.coin_name]);
26940
+ }
26904
26941
  run() {
26905
26942
  return __awaiter(this, void 0, void 0, function* () {
26906
26943
  const res = yield this.device.commands.typedCall('SignMessage', 'MessageSignature', Object.assign({}, this.params));
@@ -27260,6 +27297,9 @@ class BTCSignTransaction extends BaseMethod {
27260
27297
  coinName,
27261
27298
  };
27262
27299
  }
27300
+ getVersionRange() {
27301
+ return getBitcoinForkVersionRange([this.params.coinName]);
27302
+ }
27263
27303
  run() {
27264
27304
  return __awaiter(this, void 0, void 0, function* () {
27265
27305
  const { device, params } = this;
@@ -27292,6 +27332,9 @@ class BTCVerifyMessage extends BaseMethod {
27292
27332
  coin_name: coinName,
27293
27333
  };
27294
27334
  }
27335
+ getVersionRange() {
27336
+ return getBitcoinForkVersionRange([this.params.coin_name]);
27337
+ }
27295
27338
  run() {
27296
27339
  return __awaiter(this, void 0, void 0, function* () {
27297
27340
  const res = yield this.device.commands.typedCall('VerifyMessage', 'Success', Object.assign({}, this.params));
@@ -30282,10 +30325,10 @@ class SuiSignTransaction extends BaseMethod {
30282
30325
  if (!data_length) {
30283
30326
  return res.message;
30284
30327
  }
30285
- const payload = data.slice(offset, offset + data_length * 2);
30328
+ const payload = data.subarray(offset, offset + data_length);
30286
30329
  const newOffset = offset + payload.length;
30287
30330
  const resourceAckParams = {
30288
- data_chunk: payload,
30331
+ data_chunk: payload.toString('hex'),
30289
30332
  };
30290
30333
  const response = yield typedCall('SuiTxAck', ['SuiSignedTx', 'SuiTxRequest'], Object.assign({}, resourceAckParams));
30291
30334
  return this.processTxRequest(typedCall, response, data, newOffset);
@@ -30333,17 +30376,16 @@ class SuiSignTransaction extends BaseMethod {
30333
30376
  run() {
30334
30377
  return __awaiter(this, void 0, void 0, function* () {
30335
30378
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
30336
- const dataLength = this.params.raw_tx.length / 2;
30337
30379
  let offset = 0;
30338
- let data = '';
30380
+ let data;
30339
30381
  if (this.supportChunkTransfer()) {
30340
- offset = this.chunkByteSize * 2;
30341
- data = this.params.raw_tx;
30382
+ offset = this.chunkByteSize;
30383
+ data = Buffer.from(this.params.raw_tx, 'hex');
30342
30384
  this.params = {
30343
30385
  address_n: this.params.address_n,
30344
30386
  raw_tx: '',
30345
- data_initial_chunk: this.params.raw_tx.slice(0, this.chunkByteSize * 2),
30346
- data_length: dataLength,
30387
+ data_initial_chunk: data.subarray(0, this.chunkByteSize).toString('hex'),
30388
+ data_length: data.length,
30347
30389
  };
30348
30390
  }
30349
30391
  const res = yield typedCall('SuiSignTx', ['SuiSignedTx', 'SuiTxRequest'], Object.assign({}, this.params));
@@ -32404,10 +32446,10 @@ class NervosGetAddress extends BaseMethod {
32404
32446
  getVersionRange() {
32405
32447
  return {
32406
32448
  model_mini: {
32407
- min: '3.2.0',
32449
+ min: '3.7.0',
32408
32450
  },
32409
32451
  model_touch: {
32410
- min: '4.4.0',
32452
+ min: '4.9.0',
32411
32453
  },
32412
32454
  };
32413
32455
  }
@@ -32436,23 +32478,24 @@ class NervosSignTransaction extends BaseMethod {
32436
32478
  this.hasBundle = false;
32437
32479
  this.chunkByteSize = 1024;
32438
32480
  this.processTxRequest = (typedCall, res, data, offset = 0) => __awaiter(this, void 0, void 0, function* () {
32481
+ var _a, _b;
32439
32482
  if (res.type === 'NervosSignedTx') {
32440
- return {
32441
- path: serializedPath(this.params.address_n),
32442
- signature: res.message.signature,
32443
- };
32483
+ if (!((_a = res === null || res === void 0 ? void 0 : res.message) === null || _a === void 0 ? void 0 : _a.signature)) {
32484
+ throw new Error('No signature returned');
32485
+ }
32486
+ return Object.assign(Object.assign({}, res.message), { path: serializedPath(this.params.address_n) });
32444
32487
  }
32445
32488
  const { data_length } = res.message;
32446
32489
  if (!data_length) {
32447
- return {
32448
- path: serializedPath(this.params.address_n),
32449
- signature: res.message.signature,
32450
- };
32490
+ if (!((_b = res === null || res === void 0 ? void 0 : res.message) === null || _b === void 0 ? void 0 : _b.signature)) {
32491
+ throw new Error('No signature returned');
32492
+ }
32493
+ return Object.assign(Object.assign({}, res.message), { path: serializedPath(this.params.address_n) });
32451
32494
  }
32452
- const payload = data.slice(offset, offset + data_length * 2);
32495
+ const payload = data.subarray(offset, offset + data_length);
32453
32496
  const newOffset = offset + payload.length;
32454
32497
  const resourceAckParams = {
32455
- data_chunk: payload,
32498
+ data_chunk: payload.toString('hex'),
32456
32499
  };
32457
32500
  const response = yield typedCall('NervosTxAck', ['NervosSignedTx', 'NervosTxRequest'], Object.assign({}, resourceAckParams));
32458
32501
  return this.processTxRequest(typedCall, response, data, newOffset);
@@ -32471,7 +32514,7 @@ class NervosSignTransaction extends BaseMethod {
32471
32514
  const addressN = validatePath(path, 3);
32472
32515
  this.params = {
32473
32516
  address_n: addressN,
32474
- raw_tx: formatAnyHex(rawTx),
32517
+ raw_tx: Buffer.from(formatAnyHex(rawTx), 'hex'),
32475
32518
  witness_buffer: formatAnyHex(witnessHex),
32476
32519
  network,
32477
32520
  };
@@ -32479,29 +32522,26 @@ class NervosSignTransaction extends BaseMethod {
32479
32522
  getVersionRange() {
32480
32523
  return {
32481
32524
  model_mini: {
32482
- min: '2.10.0',
32525
+ min: '3.7.0',
32483
32526
  },
32484
32527
  model_touch: {
32485
- min: '4.0.0',
32528
+ min: '4.9.0',
32486
32529
  },
32487
32530
  };
32488
32531
  }
32489
- min(a, b) {
32490
- return a < b ? a : b;
32491
- }
32492
32532
  run() {
32493
32533
  return __awaiter(this, void 0, void 0, function* () {
32494
- const dataLength = this.params.raw_tx.length / 2;
32495
- const offset = this.min(this.params.raw_tx.length, this.chunkByteSize * 2);
32534
+ const dataLength = this.params.raw_tx.length;
32535
+ const offset = dataLength;
32496
32536
  const data = this.params.raw_tx;
32497
- const res = yield this.device.commands.typedCall('NervosSignTx', 'NervosSignedTx', {
32537
+ const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
32538
+ const res = yield typedCall('NervosSignTx', 'NervosSignedTx', {
32498
32539
  address_n: this.params.address_n,
32499
- data_initial_chunk: this.params.raw_tx.slice(0, offset),
32540
+ data_initial_chunk: data.subarray(0, offset).toString('hex'),
32500
32541
  data_length: dataLength,
32501
32542
  witness_buffer: this.params.witness_buffer,
32502
32543
  network: this.params.network,
32503
32544
  });
32504
- const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
32505
32545
  return this.processTxRequest(typedCall, res, data, offset);
32506
32546
  });
32507
32547
  }
@@ -1,6 +1,6 @@
1
1
  import { Success } from '@onekeyfe/hd-transport';
2
2
  import type { Response } from '../params';
3
- export declare function deviceUpdateBootloader(connectId: string, params: {
3
+ export declare function deviceUpdateBootloader(connectId: string, params?: {
4
4
  binary?: ArrayBuffer;
5
5
  }): Response<Success>;
6
6
  //# sourceMappingURL=deviceUpdateBootloader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deviceUpdateBootloader.d.ts","sourceRoot":"","sources":["../../../src/types/api/deviceUpdateBootloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IACN,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GACA,QAAQ,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"deviceUpdateBootloader.d.ts","sourceRoot":"","sources":["../../../src/types/api/deviceUpdateBootloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE;IACP,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GACA,QAAQ,CAAC,OAAO,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "0.3.40-alpha.1",
3
+ "version": "0.3.40-alpha.2",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "^0.3.40-alpha.1",
29
- "@onekeyfe/hd-transport": "^0.3.40-alpha.1",
28
+ "@onekeyfe/hd-shared": "^0.3.40-alpha.2",
29
+ "@onekeyfe/hd-transport": "^0.3.40-alpha.2",
30
30
  "axios": "^0.27.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/semver": "^7.3.9",
45
45
  "ripple-keypairs": "^1.1.4"
46
46
  },
47
- "gitHead": "455e71107390795e90651ecb46ef32cd8c8be5e2"
47
+ "gitHead": "d8f28d911d6acf1dcc0d6bfdae53aee23ee9f4de"
48
48
  }
@@ -5,6 +5,7 @@ import { BaseMethod } from '../BaseMethod';
5
5
  import { validateParams } from '../helpers/paramsValidator';
6
6
  import { BTCAddress, BTCGetAddressParams } from '../../types/api/btcGetAddress';
7
7
  import { getCoinInfo } from './helpers/btcParamsUtils';
8
+ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
8
9
 
9
10
  export default class BTCGetAddress extends BaseMethod<GetAddress[]> {
10
11
  hasBundle = false;
@@ -54,6 +55,10 @@ export default class BTCGetAddress extends BaseMethod<GetAddress[]> {
54
55
  });
55
56
  }
56
57
 
58
+ getVersionRange() {
59
+ return getBitcoinForkVersionRange(this.params.map(param => param.coin_name));
60
+ }
61
+
57
62
  async run() {
58
63
  const responses: BTCAddress[] = [];
59
64
 
@@ -6,6 +6,7 @@ import { validateParams } from '../helpers/paramsValidator';
6
6
  import { BTCGetAddressParams } from '../../types/api/btcGetAddress';
7
7
  import { getCoinInfo } from './helpers/btcParamsUtils';
8
8
  import { BTCPublicKey } from '../../types/api/btcGetPublicKey';
9
+ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
9
10
 
10
11
  export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
11
12
  hasBundle = false;
@@ -58,6 +59,10 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
58
59
  return param.coin_name === 'Testnet' || param.coin_name === 'Bitcoin';
59
60
  }
60
61
 
62
+ getVersionRange() {
63
+ return getBitcoinForkVersionRange(this.params.map(param => param.coin_name));
64
+ }
65
+
61
66
  async run() {
62
67
  const responses: BTCPublicKey[] = [];
63
68
 
@@ -5,6 +5,7 @@ import { BaseMethod } from '../BaseMethod';
5
5
  import { validateParams } from '../helpers/paramsValidator';
6
6
  import { formatAnyHex } from '../helpers/hexUtils';
7
7
  import { getCoinAndScriptType } from './helpers/btcParamsUtils';
8
+ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
8
9
 
9
10
  export default class BTCSignMessage extends BaseMethod<SignMessage> {
10
11
  init() {
@@ -33,6 +34,10 @@ export default class BTCSignMessage extends BaseMethod<SignMessage> {
33
34
  };
34
35
  }
35
36
 
37
+ getVersionRange() {
38
+ return getBitcoinForkVersionRange([this.params.coin_name]);
39
+ }
40
+
36
41
  async run() {
37
42
  const res = await this.device.commands.typedCall('SignMessage', 'MessageSignature', {
38
43
  ...this.params,
@@ -14,6 +14,7 @@ import {
14
14
  import signtx from './helpers/signtx';
15
15
  import signtxLegacy from './helpers/signtxLegacy';
16
16
  import { getCoinInfo } from './helpers/btcParamsUtils';
17
+ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
17
18
 
18
19
  type Params = {
19
20
  inputs: TxInputType[];
@@ -120,6 +121,10 @@ export default class BTCSignTransaction extends BaseMethod<Params> {
120
121
  };
121
122
  }
122
123
 
124
+ getVersionRange() {
125
+ return getBitcoinForkVersionRange([this.params.coinName]);
126
+ }
127
+
123
128
  async run() {
124
129
  const { device, params } = this;
125
130
 
@@ -5,6 +5,7 @@ import { BaseMethod } from '../BaseMethod';
5
5
  import { validateParams } from '../helpers/paramsValidator';
6
6
  import { formatAnyHex } from '../helpers/hexUtils';
7
7
  import { getCoinInfo } from './helpers/btcParamsUtils';
8
+ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
8
9
 
9
10
  export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> {
10
11
  init() {
@@ -31,6 +32,10 @@ export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> {
31
32
  };
32
33
  }
33
34
 
35
+ getVersionRange() {
36
+ return getBitcoinForkVersionRange([this.params.coin_name]);
37
+ }
38
+
34
39
  async run() {
35
40
  const res = await this.device.commands.typedCall('VerifyMessage', 'Success', {
36
41
  ...this.params,
@@ -0,0 +1,25 @@
1
+ function doesCoinExistByParams(coinName: string, params: (string | undefined)[]) {
2
+ for (let i = 0; i < params.length; i++) {
3
+ const coin_name = params[i];
4
+ if (coin_name?.toLowerCase() === coinName?.toLowerCase()) {
5
+ return true;
6
+ }
7
+ }
8
+ return false;
9
+ }
10
+
11
+ export function getBitcoinForkVersionRange(params: (string | undefined)[]) {
12
+ if (doesCoinExistByParams('Neurai', params)) {
13
+ return {
14
+ model_mini: {
15
+ min: '3.7.0',
16
+ },
17
+ model_touch: {
18
+ min: '4.9.0',
19
+ },
20
+ };
21
+ }
22
+
23
+ // No version restrictions for other coins
24
+ return {};
25
+ }
@@ -43,10 +43,10 @@ export default class NervosGetAddress extends BaseMethod<HardwareNervosGetAddres
43
43
  getVersionRange() {
44
44
  return {
45
45
  model_mini: {
46
- min: '3.2.0',
46
+ min: '3.7.0',
47
47
  },
48
48
  model_touch: {
49
- min: '4.4.0',
49
+ min: '4.9.0',
50
50
  },
51
51
  };
52
52
  }
@@ -6,7 +6,11 @@ import type { NervosSignTransactionParams, NervosSignedTx } from '../../types';
6
6
  import { formatAnyHex } from '../helpers/hexUtils';
7
7
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
8
8
 
9
- export default class NervosSignTransaction extends BaseMethod<HardwareNervosSignTx> {
9
+ type NervosSignTx = Omit<HardwareNervosSignTx, 'data_initial_chunk' | 'data_length'> & {
10
+ raw_tx: Buffer;
11
+ };
12
+
13
+ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
10
14
  hasBundle = false;
11
15
 
12
16
  init() {
@@ -27,7 +31,7 @@ export default class NervosSignTransaction extends BaseMethod<HardwareNervosSign
27
31
 
28
32
  this.params = {
29
33
  address_n: addressN,
30
- raw_tx: formatAnyHex(rawTx),
34
+ raw_tx: Buffer.from(formatAnyHex(rawTx), 'hex'),
31
35
  witness_buffer: formatAnyHex(witnessHex),
32
36
  network,
33
37
  };
@@ -36,10 +40,10 @@ export default class NervosSignTransaction extends BaseMethod<HardwareNervosSign
36
40
  getVersionRange() {
37
41
  return {
38
42
  model_mini: {
39
- min: '2.10.0',
43
+ min: '3.7.0',
40
44
  },
41
45
  model_touch: {
42
- min: '4.0.0',
46
+ min: '4.9.0',
43
47
  },
44
48
  };
45
49
  }
@@ -49,30 +53,37 @@ export default class NervosSignTransaction extends BaseMethod<HardwareNervosSign
49
53
  processTxRequest = async (
50
54
  typedCall: TypedCall,
51
55
  res: TypedResponseMessage<'NervosSignedTx'> | TypedResponseMessage<'NervosTxRequest'>,
52
- data: string,
56
+ data: Buffer,
53
57
  offset = 0
54
58
  ): Promise<NervosSignedTx> => {
55
59
  if (res.type === 'NervosSignedTx') {
60
+ if (!res?.message?.signature) {
61
+ throw new Error('No signature returned');
62
+ }
63
+
56
64
  return {
65
+ ...res.message,
57
66
  path: serializedPath(this.params.address_n),
58
- signature: res.message.signature,
59
67
  };
60
68
  }
61
69
 
62
70
  const { data_length } = res.message;
63
71
 
64
72
  if (!data_length) {
73
+ if (!res?.message?.signature) {
74
+ throw new Error('No signature returned');
75
+ }
65
76
  // sign Done
66
77
  return {
78
+ ...res.message,
67
79
  path: serializedPath(this.params.address_n),
68
- signature: res.message.signature,
69
80
  };
70
81
  }
71
82
 
72
- const payload = data.slice(offset, offset + data_length * 2);
83
+ const payload = data.subarray(offset, offset + data_length);
73
84
  const newOffset = offset + payload.length;
74
85
  const resourceAckParams = {
75
- data_chunk: payload,
86
+ data_chunk: payload.toString('hex'),
76
87
  };
77
88
 
78
89
  const response = await typedCall('NervosTxAck', ['NervosSignedTx', 'NervosTxRequest'], {
@@ -82,24 +93,21 @@ export default class NervosSignTransaction extends BaseMethod<HardwareNervosSign
82
93
  return this.processTxRequest(typedCall, response, data, newOffset);
83
94
  };
84
95
 
85
- min(a: number, b: number) {
86
- return a < b ? a : b;
87
- }
88
-
89
96
  async run() {
90
- const dataLength = this.params.raw_tx.length / 2;
91
- const offset = this.min(this.params.raw_tx.length, this.chunkByteSize * 2);
97
+ const dataLength = this.params.raw_tx.length;
98
+ const offset = dataLength;
92
99
  const data = this.params.raw_tx;
93
100
 
94
- const res = await this.device.commands.typedCall('NervosSignTx', 'NervosSignedTx', {
101
+ const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
102
+
103
+ const res = await typedCall('NervosSignTx', 'NervosSignedTx', {
95
104
  address_n: this.params.address_n,
96
- data_initial_chunk: this.params.raw_tx.slice(0, offset),
105
+ data_initial_chunk: data.subarray(0, offset).toString('hex'),
97
106
  data_length: dataLength,
98
107
  witness_buffer: this.params.witness_buffer,
99
108
  network: this.params.network,
100
109
  });
101
110
 
102
- const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
103
111
  return this.processTxRequest(typedCall, res, data, offset);
104
112
  }
105
113
  }
@@ -9,7 +9,9 @@ import { getDeviceFirmwareVersion, getDeviceType } from '../../utils/deviceFeatu
9
9
  import { DeviceModelToTypes } from '../../types';
10
10
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
11
11
 
12
- export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
12
+ type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx;
13
+
14
+ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
13
15
  init() {
14
16
  this.checkDeviceId = true;
15
17
  this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
@@ -64,7 +66,7 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
64
66
  processTxRequest = async (
65
67
  typedCall: TypedCall,
66
68
  res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>,
67
- data: string,
69
+ data: Buffer,
68
70
  offset = 0
69
71
  ): Promise<SuiSignedTx> => {
70
72
  if (res.type === 'SuiSignedTx') {
@@ -78,10 +80,10 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
78
80
  return res.message;
79
81
  }
80
82
 
81
- const payload = data.slice(offset, offset + data_length * 2);
83
+ const payload = data.subarray(offset, offset + data_length);
82
84
  const newOffset = offset + payload.length;
83
85
  const resourceAckParams = {
84
- data_chunk: payload,
86
+ data_chunk: payload.toString('hex'),
85
87
  };
86
88
 
87
89
  const response = await typedCall('SuiTxAck', ['SuiSignedTx', 'SuiTxRequest'], {
@@ -93,18 +95,17 @@ export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> {
93
95
 
94
96
  async run() {
95
97
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
96
- const dataLength = this.params.raw_tx.length / 2;
97
98
  let offset = 0;
98
- let data = '';
99
+ let data: Buffer;
99
100
 
100
101
  if (this.supportChunkTransfer()) {
101
- offset = this.chunkByteSize * 2;
102
- data = this.params.raw_tx;
102
+ offset = this.chunkByteSize;
103
+ data = Buffer.from(this.params.raw_tx, 'hex');
103
104
  this.params = {
104
105
  address_n: this.params.address_n,
105
106
  raw_tx: '',
106
- data_initial_chunk: this.params.raw_tx.slice(0, this.chunkByteSize * 2),
107
- data_length: dataLength,
107
+ data_initial_chunk: data.subarray(0, this.chunkByteSize).toString('hex'),
108
+ data_length: data.length,
108
109
  };
109
110
  }
110
111
 
@@ -39,5 +39,6 @@
39
39
  { "name": "Viacoin", "label": "VIA", "slip44": 14 },
40
40
  { "name": "ZCore", "label": "ZCR", "slip44": 428 },
41
41
  { "name": "Zcash", "label": "ZEC", "slip44": 133 },
42
- { "name": "Zcash Testnet", "label": "TAZ", "slip44": 1 }
42
+ { "name": "Zcash Testnet", "label": "TAZ", "slip44": 1 },
43
+ { "name": "Neurai", "label": "XNA", "slip44": 1900 }
43
44
  ]
@@ -3,7 +3,7 @@ import type { Response } from '../params';
3
3
 
4
4
  export declare function deviceUpdateBootloader(
5
5
  connectId: string,
6
- params: {
6
+ params?: {
7
7
  binary?: ArrayBuffer;
8
8
  }
9
9
  ): Response<Success>;
@@ -84,7 +84,7 @@ export const getDeviceTypeByDeviceId = (deviceId?: string): IDeviceType => {
84
84
  export const getDeviceUUID = (features: Features) => {
85
85
  const deviceType = getDeviceType(features);
86
86
 
87
- if (features.onekey_serial_no) return features.onekey_serial_no;
87
+ if (features?.onekey_serial_no) return features.onekey_serial_no;
88
88
 
89
89
  if (deviceType === 'classic') {
90
90
  return features.onekey_serial ?? '';