@onekeyfe/hd-core 1.2.10-alpha.2 → 1.2.10-alpha.3
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/__tests__/allNetworkGetAddress-privacy-networks.test.ts +2 -1
- package/__tests__/logBlockEvent.test.ts +2 -2
- package/__tests__/zcash-protobuf.test.ts +17 -28
- package/__tests__/zcash-sign-pczt.test.ts +12 -91
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +0 -3
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/monero/MoneroGetWatchKey.d.ts.map +1 -1
- package/dist/api/monero/MoneroKeyImageSync.d.ts.map +1 -1
- package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +5 -15
- package/dist/index.js +99 -174
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +0 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/types/api/allNetworkGetAddress.d.ts +1 -0
- package/dist/types/api/allNetworkGetAddress.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +0 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +0 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/zcashGetAddress.d.ts +2 -0
- package/dist/types/api/zcashGetAddress.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +7 -10
- package/src/api/index.ts +0 -1
- package/src/api/monero/MoneroGetWatchKey.ts +0 -6
- package/src/api/monero/MoneroKeyImageSync.ts +0 -6
- package/src/api/zcash/ZcashGetAddress.ts +15 -4
- package/src/data/messages/messages-protocol-v2.json +78 -93
- package/src/events/logBlockEvent.ts +0 -1
- package/src/inject.ts +0 -2
- package/src/protocols/protocol-v2/uiInteraction.ts +1 -1
- package/src/types/api/allNetworkGetAddress.ts +1 -0
- package/src/types/api/export.ts +0 -1
- package/src/types/api/index.ts +0 -2
- package/src/types/api/zcashGetAddress.ts +3 -0
- package/__tests__/allNetworkGetAddress-skippable.test.ts +0 -41
- package/__tests__/protocol-v2-key-export-confirmation.test.ts +0 -75
- package/dist/api/zcash/ZcashGetFullViewingKey.d.ts +0 -12
- package/dist/api/zcash/ZcashGetFullViewingKey.d.ts.map +0 -1
- package/dist/api/zcash/helpers.d.ts +0 -2
- package/dist/api/zcash/helpers.d.ts.map +0 -1
- package/dist/types/api/zcashGetFullViewingKey.d.ts +0 -13
- package/dist/types/api/zcashGetFullViewingKey.d.ts.map +0 -1
- package/src/api/zcash/ZcashGetFullViewingKey.ts +0 -78
- package/src/api/zcash/helpers.ts +0 -16
- package/src/types/api/zcashGetFullViewingKey.ts +0 -24
|
@@ -11034,94 +11034,6 @@
|
|
|
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
|
-
},
|
|
11125
11037
|
"ZcashSignPczt": {
|
|
11126
11038
|
"fields": {
|
|
11127
11039
|
"pczt_length": {
|
|
@@ -11602,15 +11514,11 @@
|
|
|
11602
11514
|
"MessageType_NeoAddress": 12302,
|
|
11603
11515
|
"MessageType_NeoSignTx": 12303,
|
|
11604
11516
|
"MessageType_NeoSignedTx": 12304,
|
|
11605
|
-
"MessageType_ZcashGetAddress": 12400,
|
|
11606
|
-
"MessageType_ZcashAddress": 12401,
|
|
11607
11517
|
"MessageType_ZcashSignPczt": 12402,
|
|
11608
11518
|
"MessageType_ZcashSignedPczt": 12403,
|
|
11609
11519
|
"MessageType_ZcashPcztChunkRequest": 12404,
|
|
11610
11520
|
"MessageType_ZcashPcztChunkAck": 12405,
|
|
11611
11521
|
"MessageType_ZcashSignedPcztChunkRequest": 12406,
|
|
11612
|
-
"MessageType_ZcashGetFullViewingKey": 12407,
|
|
11613
|
-
"MessageType_ZcashFullViewingKey": 12408,
|
|
11614
11522
|
"MessageType_DeviceFactoryInfoSet": 60000,
|
|
11615
11523
|
"MessageType_DeviceFactoryInfoGet": 60001,
|
|
11616
11524
|
"MessageType_DeviceFactoryInfo": 60002,
|
|
@@ -11663,7 +11571,9 @@
|
|
|
11663
11571
|
"MessageType_PortfolioUpdate": 61400,
|
|
11664
11572
|
"MessageType_NftUpdate": 61500,
|
|
11665
11573
|
"MessageType_OnboardingStatusGet": 61600,
|
|
11666
|
-
"MessageType_OnboardingStatus": 61601
|
|
11574
|
+
"MessageType_OnboardingStatus": 61601,
|
|
11575
|
+
"MessageType_ZcashGetAddress": 12400,
|
|
11576
|
+
"MessageType_ZcashAddress": 12401
|
|
11667
11577
|
},
|
|
11668
11578
|
"reserved": [
|
|
11669
11579
|
[90, 92],
|
|
@@ -13882,6 +13792,81 @@
|
|
|
13882
13792
|
}
|
|
13883
13793
|
}
|
|
13884
13794
|
}
|
|
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
|
+
}
|
|
13885
13870
|
}
|
|
13886
13871
|
}
|
|
13887
13872
|
}
|
package/src/inject.ts
CHANGED
|
@@ -506,8 +506,6 @@ 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' }),
|
|
511
509
|
zcashSignPczt: (connectId, deviceId, params) =>
|
|
512
510
|
call({ ...params, connectId, deviceId, method: 'zcashSignPczt' }),
|
|
513
511
|
|
|
@@ -71,7 +71,7 @@ const getDisplayState = (value: unknown) => {
|
|
|
71
71
|
return { seen, enabled };
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
const createMethodInteraction = (
|
|
75
75
|
reason: 'address-confirmation' | 'public-key-confirmation' | 'signing-confirmation',
|
|
76
76
|
operation: string
|
|
77
77
|
): ProtocolV2InteractionDescriptor => ({
|
package/src/types/api/export.ts
CHANGED
|
@@ -228,7 +228,6 @@ 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';
|
|
232
231
|
export type { ZcashSignedPczt, ZcashSignPcztParams } from './zcashSignPczt';
|
|
233
232
|
|
|
234
233
|
export type { MoneroAddress, MoneroGetAddressParams } from './moneroGetAddress';
|
package/src/types/api/index.ts
CHANGED
|
@@ -155,7 +155,6 @@ 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';
|
|
159
158
|
import type { zcashSignPczt } from './zcashSignPczt';
|
|
160
159
|
import type { moneroGetAddress } from './moneroGetAddress';
|
|
161
160
|
import type { moneroGetWatchKey } from './moneroGetWatchKey';
|
|
@@ -484,7 +483,6 @@ export type CoreApi = {
|
|
|
484
483
|
* Zcash
|
|
485
484
|
*/
|
|
486
485
|
zcashGetAddress: typeof zcashGetAddress;
|
|
487
|
-
zcashGetFullViewingKey: typeof zcashGetFullViewingKey;
|
|
488
486
|
zcashSignPczt: typeof zcashSignPczt;
|
|
489
487
|
|
|
490
488
|
/**
|
|
@@ -5,6 +5,8 @@ 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;
|
|
8
10
|
// ZIP-32 seed fingerprint (hex), present when includeSeedFingerprint was requested
|
|
9
11
|
seedFingerprint?: string;
|
|
10
12
|
};
|
|
@@ -16,6 +18,7 @@ export type ZcashGetAddressParams = {
|
|
|
16
18
|
diversifierIndex?: number;
|
|
17
19
|
addressType?: ZcashAddressType;
|
|
18
20
|
scope?: ZcashAddressScope;
|
|
21
|
+
includeUfvk?: boolean;
|
|
19
22
|
includeSeedFingerprint?: boolean;
|
|
20
23
|
};
|
|
21
24
|
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
|
-
import { handleSkippableHardwareError } from '../src/api/allnetwork/AllNetworkGetAddressBase';
|
|
4
|
-
|
|
5
|
-
jest.mock('../src/data/config', () => ({
|
|
6
|
-
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
7
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
// Breaks the api/index -> AllNetworkGetAddress import cycle, as the tracing test does.
|
|
11
|
-
jest.mock('../src/api/utils', () => ({
|
|
12
|
-
findMethod: jest.fn(),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const device = {
|
|
16
|
-
getCurrentMethodVersionRange: jest.fn(() => undefined),
|
|
17
|
-
getCurrentFirmwareVersionString: jest.fn(() => '1.0.0'),
|
|
18
|
-
getCurrentFirmwareType: jest.fn(() => 'universal'),
|
|
19
|
-
} as any;
|
|
20
|
-
const method = { name: 'zcashGetAddress', getVersionRange: () => ({}) } as any;
|
|
21
|
-
|
|
22
|
-
describe('all-network chains the firmware lacks', () => {
|
|
23
|
-
test.each([
|
|
24
|
-
'Failure_UnexpectedMessage,Unknown message',
|
|
25
|
-
'Failure_UnknownMessage,Unknown message',
|
|
26
|
-
// Pro 2's wording for a message type it has no handler for.
|
|
27
|
-
'Failure_ProcessError,Handler not found: No handler for type: 12400',
|
|
28
|
-
])('skips the chain on %s', message => {
|
|
29
|
-
const error = handleSkippableHardwareError(new Error(message), device, method);
|
|
30
|
-
expect(error?.errorCode).toBe(HardwareErrorCode.DeviceNotSupportMethod);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('still fails the request on any other device error', () => {
|
|
34
|
-
const error = handleSkippableHardwareError(
|
|
35
|
-
new Error('Failure_ProcessError,Cancelled'),
|
|
36
|
-
device,
|
|
37
|
-
method
|
|
38
|
-
);
|
|
39
|
-
expect(error).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import MoneroGetWatchKey from '../src/api/monero/MoneroGetWatchKey';
|
|
2
|
-
import MoneroKeyImageSync from '../src/api/monero/MoneroKeyImageSync';
|
|
3
|
-
import ZcashGetFullViewingKey from '../src/api/zcash/ZcashGetFullViewingKey';
|
|
4
|
-
import { UI_REQUEST } from '../src/events';
|
|
5
|
-
import {
|
|
6
|
-
ProtocolV2UiInteractionCoordinator,
|
|
7
|
-
resolveProtocolV2UiInteraction,
|
|
8
|
-
} from '../src/protocols/protocol-v2/uiInteraction';
|
|
9
|
-
|
|
10
|
-
import type { BaseMethod } from '../src/api/BaseMethod';
|
|
11
|
-
|
|
12
|
-
jest.mock('../src/data/config', () => ({
|
|
13
|
-
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
14
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const key = (byte: number) => byte.toString(16).padStart(2, '0').repeat(32);
|
|
18
|
-
|
|
19
|
-
// Protocol V2 firmware sends no ButtonRequest, so these exports declare the prompt they cause.
|
|
20
|
-
test.each<[string, () => BaseMethod]>([
|
|
21
|
-
[
|
|
22
|
-
'zcashGetFullViewingKey',
|
|
23
|
-
() =>
|
|
24
|
-
new ZcashGetFullViewingKey({
|
|
25
|
-
id: 1,
|
|
26
|
-
payload: { method: 'zcashGetFullViewingKey', path: "m/32'/133'/0'" },
|
|
27
|
-
}),
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
'moneroGetWatchKey',
|
|
31
|
-
() =>
|
|
32
|
-
new MoneroGetWatchKey({
|
|
33
|
-
id: 1,
|
|
34
|
-
payload: { method: 'moneroGetWatchKey', path: "m/44'/128'/0'", networkType: 0 },
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
'moneroKeyImageSync',
|
|
39
|
-
() =>
|
|
40
|
-
new MoneroKeyImageSync({
|
|
41
|
-
id: 1,
|
|
42
|
-
payload: {
|
|
43
|
-
method: 'moneroKeyImageSync',
|
|
44
|
-
path: "m/44'/128'/0'",
|
|
45
|
-
networkType: 0,
|
|
46
|
-
transfers: [{ outKey: key(1), txPubKey: key(2), internalOutputIndex: 0 }],
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
],
|
|
50
|
-
])('%s asks the client to show the device confirmation', (name, createMethod) => {
|
|
51
|
-
const method = createMethod();
|
|
52
|
-
method.init();
|
|
53
|
-
const postMessage = jest.fn();
|
|
54
|
-
const device = {
|
|
55
|
-
isProtocolV2: () => true,
|
|
56
|
-
toMessageObject: () => ({ connectId: 'pro2-test', deviceType: 'pro2' }),
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// The same call the unlock-policy runner makes before run().
|
|
60
|
-
new ProtocolV2UiInteractionCoordinator(device as never, postMessage).enterMethodInteraction(
|
|
61
|
-
resolveProtocolV2UiInteraction(method)
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
expect(postMessage).toHaveBeenCalledTimes(1);
|
|
65
|
-
expect(postMessage).toHaveBeenCalledWith(
|
|
66
|
-
expect.objectContaining({
|
|
67
|
-
type: UI_REQUEST.REQUEST_BUTTON,
|
|
68
|
-
payload: expect.objectContaining({
|
|
69
|
-
reason: 'public-key-confirmation',
|
|
70
|
-
completion: 'operation-completed',
|
|
71
|
-
operation: name,
|
|
72
|
-
}),
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import type { ZcashGetFullViewingKey as HardwareZcashGetFullViewingKey } from '@onekeyfe/hd-transport';
|
|
3
|
-
import type { ZcashFullViewingKey } from '../../types/api/zcashGetFullViewingKey';
|
|
4
|
-
import type { DeviceFirmwareRange } from '../../types';
|
|
5
|
-
export default class ZcashGetFullViewingKey extends BaseMethod<HardwareZcashGetFullViewingKey[]> {
|
|
6
|
-
hasBundle: boolean;
|
|
7
|
-
getSupportedProtocols(): readonly ["V2"];
|
|
8
|
-
init(): void;
|
|
9
|
-
getVersionRange(): DeviceFirmwareRange;
|
|
10
|
-
run(): Promise<Partial<ZcashFullViewingKey> | Partial<ZcashFullViewingKey>[]>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ZcashGetFullViewingKey.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ZcashGetFullViewingKey.d.ts","sourceRoot":"","sources":["../../../src/api/zcash/ZcashGetFullViewingKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,OAAO,KAAK,EAAE,sBAAsB,IAAI,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,8BAA8B,EAAE,CAAC;IAC9F,SAAS,UAAS;IAElB,qBAAqB;IAIrB,IAAI;IAsBJ,eAAe,IAAI,mBAAmB;IAQhC,GAAG;CAyBV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/api/zcash/helpers.ts"],"names":[],"mappings":"AAIA,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAW1E"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CommonParams, Response } from '../params';
|
|
2
|
-
export type ZcashFullViewingKey = {
|
|
3
|
-
path: string;
|
|
4
|
-
ufvk: string;
|
|
5
|
-
};
|
|
6
|
-
export type ZcashGetFullViewingKeyParams = {
|
|
7
|
-
path: string | number[];
|
|
8
|
-
};
|
|
9
|
-
export declare function zcashGetFullViewingKey(connectId: string, deviceId: string, params: CommonParams & ZcashGetFullViewingKeyParams): Response<ZcashFullViewingKey>;
|
|
10
|
-
export declare function zcashGetFullViewingKey(connectId: string, deviceId: string, params: CommonParams & {
|
|
11
|
-
bundle?: ZcashGetFullViewingKeyParams[];
|
|
12
|
-
}): Response<Array<ZcashFullViewingKey>>;
|
|
13
|
-
//# sourceMappingURL=zcashGetFullViewingKey.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zcashGetFullViewingKey.d.ts","sourceRoot":"","sources":["../../../src/types/api/zcashGetFullViewingKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IAEzC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,4BAA4B,GAClD,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAEjC,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,4BAA4B,EAAE,CAAA;CAAE,GACjE,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { serializedPath } from '../helpers/pathUtils';
|
|
3
|
-
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
4
|
-
import { UI_REQUEST } from '../../constants/ui-request';
|
|
5
|
-
import { createMethodInteraction } from '../../protocols/protocol-v2/uiInteraction';
|
|
6
|
-
import { validateZcashAccountPath } from './helpers';
|
|
7
|
-
|
|
8
|
-
import type { ZcashGetFullViewingKey as HardwareZcashGetFullViewingKey } from '@onekeyfe/hd-transport';
|
|
9
|
-
import type {
|
|
10
|
-
ZcashFullViewingKey,
|
|
11
|
-
ZcashGetFullViewingKeyParams,
|
|
12
|
-
} from '../../types/api/zcashGetFullViewingKey';
|
|
13
|
-
import type { DeviceFirmwareRange } from '../../types';
|
|
14
|
-
|
|
15
|
-
// The device exports the UFVK only after the user confirms it on screen.
|
|
16
|
-
export default class ZcashGetFullViewingKey extends BaseMethod<HardwareZcashGetFullViewingKey[]> {
|
|
17
|
-
hasBundle = false;
|
|
18
|
-
|
|
19
|
-
getSupportedProtocols() {
|
|
20
|
-
return ['V2'] as const;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
init() {
|
|
24
|
-
this.checkDeviceId = true;
|
|
25
|
-
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
26
|
-
this.strictCheckDeviceSupport = true;
|
|
27
|
-
// The name matches no Protocol V2 confirmation rule, so the export prompt is declared here.
|
|
28
|
-
this.protocolV2UiInteraction = createMethodInteraction(
|
|
29
|
-
'public-key-confirmation',
|
|
30
|
-
'zcashGetFullViewingKey'
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
this.hasBundle = !!this.payload?.bundle;
|
|
34
|
-
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
35
|
-
|
|
36
|
-
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
37
|
-
|
|
38
|
-
this.params = [];
|
|
39
|
-
payload.bundle.forEach((batch: ZcashGetFullViewingKeyParams) => {
|
|
40
|
-
validateParams(batch, [{ name: 'path', required: true }]);
|
|
41
|
-
this.params.push({ address_n: validateZcashAccountPath(batch.path) });
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getVersionRange(): DeviceFirmwareRange {
|
|
46
|
-
return {
|
|
47
|
-
model_pro2: {
|
|
48
|
-
min: '0.0.0',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async run() {
|
|
54
|
-
// Missing fields stay undefined so validateResult rejects them.
|
|
55
|
-
const responses: Partial<ZcashFullViewingKey>[] = [];
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < this.params.length; i++) {
|
|
58
|
-
const param = this.params[i];
|
|
59
|
-
|
|
60
|
-
const res = await this.device.commands.typedCall(
|
|
61
|
-
'ZcashGetFullViewingKey',
|
|
62
|
-
'ZcashFullViewingKey',
|
|
63
|
-
{ ...param }
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
responses.push({
|
|
67
|
-
path: serializedPath(param.address_n),
|
|
68
|
-
ufvk: res.message.ufvk,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
validateResult(responses, ['ufvk'], {
|
|
73
|
-
expectedLength: this.params.length,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
77
|
-
}
|
|
78
|
-
}
|
package/src/api/zcash/helpers.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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>>;
|