@onekeyfe/hd-core 1.2.10-alpha.1 → 1.2.10-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 (52) hide show
  1. package/__tests__/allNetworkGetAddress-privacy-networks.test.ts +1 -2
  2. package/__tests__/allNetworkGetAddress-skippable.test.ts +41 -0
  3. package/__tests__/logBlockEvent.test.ts +2 -2
  4. package/__tests__/protocol-v2-key-export-confirmation.test.ts +75 -0
  5. package/__tests__/zcash-protobuf.test.ts +28 -17
  6. package/__tests__/zcash-sign-pczt.test.ts +91 -12
  7. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +3 -0
  8. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  9. package/dist/api/index.d.ts +1 -0
  10. package/dist/api/index.d.ts.map +1 -1
  11. package/dist/api/monero/MoneroGetWatchKey.d.ts.map +1 -1
  12. package/dist/api/monero/MoneroKeyImageSync.d.ts.map +1 -1
  13. package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -1
  14. package/dist/api/zcash/ZcashGetFullViewingKey.d.ts +12 -0
  15. package/dist/api/zcash/ZcashGetFullViewingKey.d.ts.map +1 -0
  16. package/dist/api/zcash/helpers.d.ts +2 -0
  17. package/dist/api/zcash/helpers.d.ts.map +1 -0
  18. package/dist/events/logBlockEvent.d.ts.map +1 -1
  19. package/dist/index.d.ts +15 -5
  20. package/dist/index.js +174 -99
  21. package/dist/inject.d.ts.map +1 -1
  22. package/dist/protocols/protocol-v2/uiInteraction.d.ts +1 -0
  23. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
  24. package/dist/types/api/allNetworkGetAddress.d.ts +0 -1
  25. package/dist/types/api/allNetworkGetAddress.d.ts.map +1 -1
  26. package/dist/types/api/export.d.ts +1 -0
  27. package/dist/types/api/export.d.ts.map +1 -1
  28. package/dist/types/api/index.d.ts +2 -0
  29. package/dist/types/api/index.d.ts.map +1 -1
  30. package/dist/types/api/zcashGetAddress.d.ts +0 -2
  31. package/dist/types/api/zcashGetAddress.d.ts.map +1 -1
  32. package/dist/types/api/zcashGetFullViewingKey.d.ts +13 -0
  33. package/dist/types/api/zcashGetFullViewingKey.d.ts.map +1 -0
  34. package/dist/utils/patch.d.ts +1 -1
  35. package/dist/utils/patch.d.ts.map +1 -1
  36. package/package.json +4 -4
  37. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +10 -7
  38. package/src/api/index.ts +1 -0
  39. package/src/api/monero/MoneroGetWatchKey.ts +6 -0
  40. package/src/api/monero/MoneroKeyImageSync.ts +6 -0
  41. package/src/api/zcash/ZcashGetAddress.ts +4 -15
  42. package/src/api/zcash/ZcashGetFullViewingKey.ts +78 -0
  43. package/src/api/zcash/helpers.ts +16 -0
  44. package/src/data/messages/messages-protocol-v2.json +93 -78
  45. package/src/events/logBlockEvent.ts +1 -0
  46. package/src/inject.ts +2 -0
  47. package/src/protocols/protocol-v2/uiInteraction.ts +1 -1
  48. package/src/types/api/allNetworkGetAddress.ts +0 -1
  49. package/src/types/api/export.ts +1 -0
  50. package/src/types/api/index.ts +2 -0
  51. package/src/types/api/zcashGetAddress.ts +0 -3
  52. package/src/types/api/zcashGetFullViewingKey.ts +24 -0
@@ -0,0 +1,16 @@
1
+ import { toHardened, validateStrictPath } from '../helpers/pathUtils';
2
+ import { invalidParameter } from '../helpers/paramsValidator';
3
+
4
+ // ZIP-32 account path: m/32'/133'/account'
5
+ export function validateZcashAccountPath(path: string | number[]): number[] {
6
+ const addressN = validateStrictPath(path, 3);
7
+ if (
8
+ addressN.length !== 3 ||
9
+ addressN[0] !== toHardened(32) ||
10
+ addressN[1] !== toHardened(133) ||
11
+ addressN[2] < toHardened(0)
12
+ ) {
13
+ throw invalidParameter("Zcash requires a ZIP-32 account path m/32'/133'/account'");
14
+ }
15
+ return addressN;
16
+ }
@@ -11034,6 +11034,94 @@
11034
11034
  }
11035
11035
  }
11036
11036
  },
11037
+ "ZcashAddressType": {
11038
+ "values": {
11039
+ "UNIFIED_ORCHARD_P2PKH": 0,
11040
+ "TRANSPARENT_P2PKH": 1,
11041
+ "UNIFIED_ORCHARD": 2
11042
+ }
11043
+ },
11044
+ "ZcashAddressScope": {
11045
+ "values": {
11046
+ "EXTERNAL": 0,
11047
+ "INTERNAL": 1
11048
+ }
11049
+ },
11050
+ "ZcashGetAddress": {
11051
+ "fields": {
11052
+ "address_n": {
11053
+ "rule": "repeated",
11054
+ "type": "uint32",
11055
+ "id": 1,
11056
+ "options": {
11057
+ "packed": false
11058
+ }
11059
+ },
11060
+ "show_display": {
11061
+ "type": "bool",
11062
+ "id": 2
11063
+ },
11064
+ "include_seed_fingerprint": {
11065
+ "type": "bool",
11066
+ "id": 3
11067
+ },
11068
+ "diversifier_index": {
11069
+ "type": "uint32",
11070
+ "id": 5,
11071
+ "options": {
11072
+ "default": 0
11073
+ }
11074
+ },
11075
+ "address_type": {
11076
+ "type": "ZcashAddressType",
11077
+ "id": 6,
11078
+ "options": {
11079
+ "default": "UNIFIED_ORCHARD_P2PKH"
11080
+ }
11081
+ },
11082
+ "scope": {
11083
+ "type": "ZcashAddressScope",
11084
+ "id": 7,
11085
+ "options": {
11086
+ "default": "EXTERNAL"
11087
+ }
11088
+ }
11089
+ }
11090
+ },
11091
+ "ZcashAddress": {
11092
+ "fields": {
11093
+ "address": {
11094
+ "rule": "required",
11095
+ "type": "string",
11096
+ "id": 1
11097
+ },
11098
+ "seed_fingerprint": {
11099
+ "type": "bytes",
11100
+ "id": 3
11101
+ }
11102
+ }
11103
+ },
11104
+ "ZcashGetFullViewingKey": {
11105
+ "fields": {
11106
+ "address_n": {
11107
+ "rule": "repeated",
11108
+ "type": "uint32",
11109
+ "id": 1,
11110
+ "options": {
11111
+ "packed": false
11112
+ }
11113
+ }
11114
+ }
11115
+ },
11116
+ "ZcashFullViewingKey": {
11117
+ "fields": {
11118
+ "ufvk": {
11119
+ "rule": "required",
11120
+ "type": "string",
11121
+ "id": 1
11122
+ }
11123
+ }
11124
+ },
11037
11125
  "ZcashSignPczt": {
11038
11126
  "fields": {
11039
11127
  "pczt_length": {
@@ -11514,11 +11602,15 @@
11514
11602
  "MessageType_NeoAddress": 12302,
11515
11603
  "MessageType_NeoSignTx": 12303,
11516
11604
  "MessageType_NeoSignedTx": 12304,
11605
+ "MessageType_ZcashGetAddress": 12400,
11606
+ "MessageType_ZcashAddress": 12401,
11517
11607
  "MessageType_ZcashSignPczt": 12402,
11518
11608
  "MessageType_ZcashSignedPczt": 12403,
11519
11609
  "MessageType_ZcashPcztChunkRequest": 12404,
11520
11610
  "MessageType_ZcashPcztChunkAck": 12405,
11521
11611
  "MessageType_ZcashSignedPcztChunkRequest": 12406,
11612
+ "MessageType_ZcashGetFullViewingKey": 12407,
11613
+ "MessageType_ZcashFullViewingKey": 12408,
11522
11614
  "MessageType_DeviceFactoryInfoSet": 60000,
11523
11615
  "MessageType_DeviceFactoryInfoGet": 60001,
11524
11616
  "MessageType_DeviceFactoryInfo": 60002,
@@ -11571,9 +11663,7 @@
11571
11663
  "MessageType_PortfolioUpdate": 61400,
11572
11664
  "MessageType_NftUpdate": 61500,
11573
11665
  "MessageType_OnboardingStatusGet": 61600,
11574
- "MessageType_OnboardingStatus": 61601,
11575
- "MessageType_ZcashGetAddress": 12400,
11576
- "MessageType_ZcashAddress": 12401
11666
+ "MessageType_OnboardingStatus": 61601
11577
11667
  },
11578
11668
  "reserved": [
11579
11669
  [90, 92],
@@ -13792,81 +13882,6 @@
13792
13882
  }
13793
13883
  }
13794
13884
  }
13795
- },
13796
- "ZcashAddressType": {
13797
- "values": {
13798
- "UNIFIED_ORCHARD_P2PKH": 0,
13799
- "TRANSPARENT_P2PKH": 1,
13800
- "UNIFIED_ORCHARD": 2
13801
- }
13802
- },
13803
- "ZcashAddressScope": {
13804
- "values": {
13805
- "EXTERNAL": 0,
13806
- "INTERNAL": 1
13807
- }
13808
- },
13809
- "ZcashGetAddress": {
13810
- "fields": {
13811
- "address_n": {
13812
- "rule": "repeated",
13813
- "type": "uint32",
13814
- "id": 1,
13815
- "options": {
13816
- "packed": false
13817
- }
13818
- },
13819
- "show_display": {
13820
- "type": "bool",
13821
- "id": 2
13822
- },
13823
- "include_seed_fingerprint": {
13824
- "type": "bool",
13825
- "id": 3
13826
- },
13827
- "include_ufvk": {
13828
- "type": "bool",
13829
- "id": 4
13830
- },
13831
- "diversifier_index": {
13832
- "type": "uint32",
13833
- "id": 5,
13834
- "options": {
13835
- "default": 0
13836
- }
13837
- },
13838
- "address_type": {
13839
- "type": "ZcashAddressType",
13840
- "id": 6,
13841
- "options": {
13842
- "default": "UNIFIED_ORCHARD_P2PKH"
13843
- }
13844
- },
13845
- "scope": {
13846
- "type": "ZcashAddressScope",
13847
- "id": 7,
13848
- "options": {
13849
- "default": "EXTERNAL"
13850
- }
13851
- }
13852
- }
13853
- },
13854
- "ZcashAddress": {
13855
- "fields": {
13856
- "address": {
13857
- "rule": "required",
13858
- "type": "string",
13859
- "id": 1
13860
- },
13861
- "ufvk": {
13862
- "type": "string",
13863
- "id": 2
13864
- },
13865
- "seed_fingerprint": {
13866
- "type": "bytes",
13867
- "id": 3
13868
- }
13869
- }
13870
13885
  }
13871
13886
  }
13872
13887
  }
@@ -19,6 +19,7 @@ const LogPayloadBlockMethod: Set<string> = new Set([
19
19
  'fileWrite',
20
20
  'fileRead',
21
21
  'zcashGetAddress',
22
+ 'zcashGetFullViewingKey',
22
23
  'zcashSignPczt',
23
24
  'moneroGetAddress',
24
25
  'moneroGetWatchKey',
package/src/inject.ts CHANGED
@@ -506,6 +506,8 @@ export const createCoreApi = (
506
506
  call({ ...params, connectId, deviceId, method: 'neoSignTransaction' }),
507
507
  zcashGetAddress: (connectId, deviceId, params) =>
508
508
  call({ ...params, connectId, deviceId, method: 'zcashGetAddress' }),
509
+ zcashGetFullViewingKey: (connectId, deviceId, params) =>
510
+ call({ ...params, connectId, deviceId, method: 'zcashGetFullViewingKey' }),
509
511
  zcashSignPczt: (connectId, deviceId, params) =>
510
512
  call({ ...params, connectId, deviceId, method: 'zcashSignPczt' }),
511
513
 
@@ -71,7 +71,7 @@ const getDisplayState = (value: unknown) => {
71
71
  return { seen, enabled };
72
72
  };
73
73
 
74
- const createMethodInteraction = (
74
+ export const createMethodInteraction = (
75
75
  reason: 'address-confirmation' | 'public-key-confirmation' | 'signing-confirmation',
76
76
  operation: string
77
77
  ): ProtocolV2InteractionDescriptor => ({
@@ -71,7 +71,6 @@ type AllNetworkAddressPayload =
71
71
  | {
72
72
  // Zcash
73
73
  address: string;
74
- ufvk?: string;
75
74
  seedFingerprint?: string;
76
75
  }
77
76
  | {
@@ -228,6 +228,7 @@ export type { BenfenPublicKey, BenfenGetPublicKeyParams } from './benfenGetPubli
228
228
  export type { BenfenSignMessageParams } from './benfenSignMessage';
229
229
  export type { BenfenSignedTx, BenfenSignTransactionParams } from './benfenSignTransaction';
230
230
  export type { ZcashAddress, ZcashGetAddressParams } from './zcashGetAddress';
231
+ export type { ZcashFullViewingKey, ZcashGetFullViewingKeyParams } from './zcashGetFullViewingKey';
231
232
  export type { ZcashSignedPczt, ZcashSignPcztParams } from './zcashSignPczt';
232
233
 
233
234
  export type { MoneroAddress, MoneroGetAddressParams } from './moneroGetAddress';
@@ -155,6 +155,7 @@ import type { benfenSignMessage } from './benfenSignMessage';
155
155
  import type { neoGetAddress } from './neoGetAddress';
156
156
  import type { neoSignTransaction } from './neoSignTransaction';
157
157
  import type { zcashGetAddress } from './zcashGetAddress';
158
+ import type { zcashGetFullViewingKey } from './zcashGetFullViewingKey';
158
159
  import type { zcashSignPczt } from './zcashSignPczt';
159
160
  import type { moneroGetAddress } from './moneroGetAddress';
160
161
  import type { moneroGetWatchKey } from './moneroGetWatchKey';
@@ -483,6 +484,7 @@ export type CoreApi = {
483
484
  * Zcash
484
485
  */
485
486
  zcashGetAddress: typeof zcashGetAddress;
487
+ zcashGetFullViewingKey: typeof zcashGetFullViewingKey;
486
488
  zcashSignPczt: typeof zcashSignPczt;
487
489
 
488
490
  /**
@@ -5,8 +5,6 @@ export type ZcashAddress = {
5
5
  path: string;
6
6
  // ZIP-316 unified address or transparent P2PKH address
7
7
  address: string;
8
- // ZIP-316 unified full viewing key, present when includeUfvk was requested
9
- ufvk?: string;
10
8
  // ZIP-32 seed fingerprint (hex), present when includeSeedFingerprint was requested
11
9
  seedFingerprint?: string;
12
10
  };
@@ -18,7 +16,6 @@ export type ZcashGetAddressParams = {
18
16
  diversifierIndex?: number;
19
17
  addressType?: ZcashAddressType;
20
18
  scope?: ZcashAddressScope;
21
- includeUfvk?: boolean;
22
19
  includeSeedFingerprint?: boolean;
23
20
  };
24
21
 
@@ -0,0 +1,24 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type ZcashFullViewingKey = {
4
+ path: string;
5
+ // ZIP-316 unified full viewing key with transparent and Orchard components
6
+ ufvk: string;
7
+ };
8
+
9
+ export type ZcashGetFullViewingKeyParams = {
10
+ // ZIP-32 account path, m/32'/133'/account'
11
+ path: string | number[];
12
+ };
13
+
14
+ export declare function zcashGetFullViewingKey(
15
+ connectId: string,
16
+ deviceId: string,
17
+ params: CommonParams & ZcashGetFullViewingKeyParams
18
+ ): Response<ZcashFullViewingKey>;
19
+
20
+ export declare function zcashGetFullViewingKey(
21
+ connectId: string,
22
+ deviceId: string,
23
+ params: CommonParams & { bundle?: ZcashGetFullViewingKeyParams[] }
24
+ ): Response<Array<ZcashFullViewingKey>>;