@onekeyfe/hd-core 1.0.20-alpha.2 → 1.0.20
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/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts +0 -4
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/cardano/helper/auxiliaryData.d.ts.map +1 -1
- package/dist/api/cardano/helper/certificate.d.ts.map +1 -1
- package/dist/index.d.ts +11 -21
- package/dist/index.js +47 -222
- package/dist/types/api/cardano.d.ts +9 -20
- package/dist/types/api/cardano.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/FirmwareUpdateV2.ts +0 -10
- package/src/api/cardano/CardanoSignTransaction.ts +2 -87
- package/src/api/cardano/helper/auxiliaryData.ts +31 -56
- package/src/api/cardano/helper/certificate.ts +0 -47
- package/src/data/messages/messages.json +15 -68
- package/src/types/api/cardano.ts +9 -21
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
CardanoPoolMetadata,
|
|
10
10
|
CardanoPoolRelay,
|
|
11
11
|
CardanoPoolOwner,
|
|
12
|
-
CardanoDRep,
|
|
13
12
|
} from '../../../types/api/cardano';
|
|
14
13
|
import { PROTO } from '../../../constants';
|
|
15
14
|
|
|
@@ -157,37 +156,6 @@ const transformPoolParameters = (
|
|
|
157
156
|
};
|
|
158
157
|
};
|
|
159
158
|
|
|
160
|
-
const transformDRep = (dRep: CardanoDRep | undefined): PROTO.CardanoDRep | undefined => {
|
|
161
|
-
if (!dRep) {
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
validateParams(dRep, [
|
|
166
|
-
{ name: 'type', type: 'number', required: true },
|
|
167
|
-
{ name: 'keyHash', type: 'string' },
|
|
168
|
-
{ name: 'scriptHash', type: 'string' },
|
|
169
|
-
]);
|
|
170
|
-
|
|
171
|
-
if (dRep.type === PROTO.CardanoDRepType.KEY_HASH && !dRep.keyHash) {
|
|
172
|
-
throw ERRORS.TypedError(
|
|
173
|
-
HardwareErrorCode.CallMethodInvalidParameter,
|
|
174
|
-
'key_hash must be supplied for key_hash type'
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (dRep.type === PROTO.CardanoDRepType.SCRIPT_HASH && !dRep.scriptHash) {
|
|
179
|
-
throw ERRORS.TypedError(
|
|
180
|
-
HardwareErrorCode.CallMethodInvalidParameter,
|
|
181
|
-
'script_hash must be supplied for script_hash type'
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
return {
|
|
185
|
-
type: dRep.type,
|
|
186
|
-
key_hash: dRep.keyHash,
|
|
187
|
-
script_hash: dRep.scriptHash,
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
|
|
191
159
|
export const transformCertificate = (
|
|
192
160
|
certificate: CardanoCertificate
|
|
193
161
|
): CertificateWithPoolOwnersAndRelays => {
|
|
@@ -208,25 +176,12 @@ export const transformCertificate = (
|
|
|
208
176
|
paramsToValidate.push({ name: 'poolParameters', type: 'object', required: true });
|
|
209
177
|
}
|
|
210
178
|
|
|
211
|
-
if (
|
|
212
|
-
certificate.type === PROTO.CardanoCertificateType.STAKE_REGISTRATION_CONWAY ||
|
|
213
|
-
certificate.type === PROTO.CardanoCertificateType.STAKE_DEREGISTRATION_CONWAY
|
|
214
|
-
) {
|
|
215
|
-
paramsToValidate.push({ name: 'deposit', required: true });
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (certificate.type === PROTO.CardanoCertificateType.VOTE_DELEGATION) {
|
|
219
|
-
paramsToValidate.push({ name: 'dRep', type: 'object', required: true });
|
|
220
|
-
}
|
|
221
|
-
|
|
222
179
|
validateParams(certificate, paramsToValidate);
|
|
223
180
|
|
|
224
181
|
const { poolParameters, poolOwners, poolRelays } = transformPoolParameters(
|
|
225
182
|
certificate.poolParameters
|
|
226
183
|
);
|
|
227
184
|
|
|
228
|
-
const dRep = transformDRep(certificate.dRep);
|
|
229
|
-
|
|
230
185
|
return {
|
|
231
186
|
certificate: {
|
|
232
187
|
type: certificate.type,
|
|
@@ -235,8 +190,6 @@ export const transformCertificate = (
|
|
|
235
190
|
key_hash: certificate.keyHash,
|
|
236
191
|
pool: certificate.pool,
|
|
237
192
|
pool_parameters: poolParameters,
|
|
238
|
-
deposit: certificate.deposit,
|
|
239
|
-
drep: dRep,
|
|
240
193
|
},
|
|
241
194
|
poolOwners,
|
|
242
195
|
poolRelays,
|
|
@@ -345,6 +345,7 @@
|
|
|
345
345
|
"BenfenAddress": {
|
|
346
346
|
"fields": {
|
|
347
347
|
"address": {
|
|
348
|
+
"rule": "required",
|
|
348
349
|
"type": "string",
|
|
349
350
|
"id": 1
|
|
350
351
|
}
|
|
@@ -2015,18 +2016,7 @@
|
|
|
2015
2016
|
"STAKE_REGISTRATION": 0,
|
|
2016
2017
|
"STAKE_DEREGISTRATION": 1,
|
|
2017
2018
|
"STAKE_DELEGATION": 2,
|
|
2018
|
-
"STAKE_POOL_REGISTRATION": 3
|
|
2019
|
-
"STAKE_REGISTRATION_CONWAY": 7,
|
|
2020
|
-
"STAKE_DEREGISTRATION_CONWAY": 8,
|
|
2021
|
-
"VOTE_DELEGATION": 9
|
|
2022
|
-
}
|
|
2023
|
-
},
|
|
2024
|
-
"CardanoDRepType": {
|
|
2025
|
-
"values": {
|
|
2026
|
-
"KEY_HASH": 0,
|
|
2027
|
-
"SCRIPT_HASH": 1,
|
|
2028
|
-
"ABSTAIN": 2,
|
|
2029
|
-
"NO_CONFIDENCE": 3
|
|
2019
|
+
"STAKE_POOL_REGISTRATION": 3
|
|
2030
2020
|
}
|
|
2031
2021
|
},
|
|
2032
2022
|
"CardanoPoolRelayType": {
|
|
@@ -2039,10 +2029,10 @@
|
|
|
2039
2029
|
"CardanoTxAuxiliaryDataSupplementType": {
|
|
2040
2030
|
"values": {
|
|
2041
2031
|
"NONE": 0,
|
|
2042
|
-
"
|
|
2032
|
+
"GOVERNANCE_REGISTRATION_SIGNATURE": 1
|
|
2043
2033
|
}
|
|
2044
2034
|
},
|
|
2045
|
-
"
|
|
2035
|
+
"CardanoGovernanceRegistrationFormat": {
|
|
2046
2036
|
"values": {
|
|
2047
2037
|
"CIP15": 0,
|
|
2048
2038
|
"CIP36": 1
|
|
@@ -2216,10 +2206,6 @@
|
|
|
2216
2206
|
"rule": "required",
|
|
2217
2207
|
"type": "CardanoDerivationType",
|
|
2218
2208
|
"id": 6
|
|
2219
|
-
},
|
|
2220
|
-
"chunkify": {
|
|
2221
|
-
"type": "bool",
|
|
2222
|
-
"id": 7
|
|
2223
2209
|
}
|
|
2224
2210
|
}
|
|
2225
2211
|
},
|
|
@@ -2375,17 +2361,6 @@
|
|
|
2375
2361
|
"options": {
|
|
2376
2362
|
"default": 0
|
|
2377
2363
|
}
|
|
2378
|
-
},
|
|
2379
|
-
"chunkify": {
|
|
2380
|
-
"type": "bool",
|
|
2381
|
-
"id": 22
|
|
2382
|
-
},
|
|
2383
|
-
"tag_cbor_sets": {
|
|
2384
|
-
"type": "bool",
|
|
2385
|
-
"id": 23,
|
|
2386
|
-
"options": {
|
|
2387
|
-
"default": false
|
|
2388
|
-
}
|
|
2389
2364
|
}
|
|
2390
2365
|
}
|
|
2391
2366
|
},
|
|
@@ -2607,23 +2582,6 @@
|
|
|
2607
2582
|
}
|
|
2608
2583
|
}
|
|
2609
2584
|
},
|
|
2610
|
-
"CardanoDRep": {
|
|
2611
|
-
"fields": {
|
|
2612
|
-
"type": {
|
|
2613
|
-
"rule": "required",
|
|
2614
|
-
"type": "CardanoDRepType",
|
|
2615
|
-
"id": 1
|
|
2616
|
-
},
|
|
2617
|
-
"key_hash": {
|
|
2618
|
-
"type": "bytes",
|
|
2619
|
-
"id": 2
|
|
2620
|
-
},
|
|
2621
|
-
"script_hash": {
|
|
2622
|
-
"type": "bytes",
|
|
2623
|
-
"id": 3
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
},
|
|
2627
2585
|
"CardanoTxCertificate": {
|
|
2628
2586
|
"fields": {
|
|
2629
2587
|
"type": {
|
|
@@ -2654,14 +2612,6 @@
|
|
|
2654
2612
|
"key_hash": {
|
|
2655
2613
|
"type": "bytes",
|
|
2656
2614
|
"id": 6
|
|
2657
|
-
},
|
|
2658
|
-
"deposit": {
|
|
2659
|
-
"type": "uint64",
|
|
2660
|
-
"id": 7
|
|
2661
|
-
},
|
|
2662
|
-
"drep": {
|
|
2663
|
-
"type": "CardanoDRep",
|
|
2664
|
-
"id": 8
|
|
2665
2615
|
}
|
|
2666
2616
|
}
|
|
2667
2617
|
},
|
|
@@ -2690,9 +2640,9 @@
|
|
|
2690
2640
|
}
|
|
2691
2641
|
}
|
|
2692
2642
|
},
|
|
2693
|
-
"
|
|
2643
|
+
"CardanoGovernanceRegistrationDelegation": {
|
|
2694
2644
|
"fields": {
|
|
2695
|
-
"
|
|
2645
|
+
"voting_public_key": {
|
|
2696
2646
|
"rule": "required",
|
|
2697
2647
|
"type": "bytes",
|
|
2698
2648
|
"id": 1
|
|
@@ -2704,9 +2654,9 @@
|
|
|
2704
2654
|
}
|
|
2705
2655
|
}
|
|
2706
2656
|
},
|
|
2707
|
-
"
|
|
2657
|
+
"CardanoGovernanceRegistrationParametersType": {
|
|
2708
2658
|
"fields": {
|
|
2709
|
-
"
|
|
2659
|
+
"voting_public_key": {
|
|
2710
2660
|
"type": "bytes",
|
|
2711
2661
|
"id": 1
|
|
2712
2662
|
},
|
|
@@ -2718,7 +2668,8 @@
|
|
|
2718
2668
|
"packed": false
|
|
2719
2669
|
}
|
|
2720
2670
|
},
|
|
2721
|
-
"
|
|
2671
|
+
"reward_address_parameters": {
|
|
2672
|
+
"rule": "required",
|
|
2722
2673
|
"type": "CardanoAddressParametersType",
|
|
2723
2674
|
"id": 3
|
|
2724
2675
|
},
|
|
@@ -2728,7 +2679,7 @@
|
|
|
2728
2679
|
"id": 4
|
|
2729
2680
|
},
|
|
2730
2681
|
"format": {
|
|
2731
|
-
"type": "
|
|
2682
|
+
"type": "CardanoGovernanceRegistrationFormat",
|
|
2732
2683
|
"id": 5,
|
|
2733
2684
|
"options": {
|
|
2734
2685
|
"default": "CIP15"
|
|
@@ -2736,23 +2687,19 @@
|
|
|
2736
2687
|
},
|
|
2737
2688
|
"delegations": {
|
|
2738
2689
|
"rule": "repeated",
|
|
2739
|
-
"type": "
|
|
2690
|
+
"type": "CardanoGovernanceRegistrationDelegation",
|
|
2740
2691
|
"id": 6
|
|
2741
2692
|
},
|
|
2742
2693
|
"voting_purpose": {
|
|
2743
2694
|
"type": "uint64",
|
|
2744
2695
|
"id": 7
|
|
2745
|
-
},
|
|
2746
|
-
"payment_address": {
|
|
2747
|
-
"type": "string",
|
|
2748
|
-
"id": 8
|
|
2749
2696
|
}
|
|
2750
2697
|
}
|
|
2751
2698
|
},
|
|
2752
2699
|
"CardanoTxAuxiliaryData": {
|
|
2753
2700
|
"fields": {
|
|
2754
|
-
"
|
|
2755
|
-
"type": "
|
|
2701
|
+
"governance_registration_parameters": {
|
|
2702
|
+
"type": "CardanoGovernanceRegistrationParametersType",
|
|
2756
2703
|
"id": 1
|
|
2757
2704
|
},
|
|
2758
2705
|
"hash": {
|
|
@@ -2828,7 +2775,7 @@
|
|
|
2828
2775
|
"type": "bytes",
|
|
2829
2776
|
"id": 2
|
|
2830
2777
|
},
|
|
2831
|
-
"
|
|
2778
|
+
"governance_signature": {
|
|
2832
2779
|
"type": "bytes",
|
|
2833
2780
|
"id": 3
|
|
2834
2781
|
}
|
package/src/types/api/cardano.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { UintType } from '@onekeyfe/hd-transport';
|
|
2
1
|
import type { PROTO } from '../../constants';
|
|
3
2
|
|
|
4
3
|
export interface CardanoAddressParameters {
|
|
@@ -33,12 +32,6 @@ export type AssetGroupWithTokens = {
|
|
|
33
32
|
tokens: PROTO.CardanoToken[];
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
export interface CardanoDRep {
|
|
37
|
-
type: PROTO.CardanoDRepType;
|
|
38
|
-
keyHash?: string;
|
|
39
|
-
scriptHash?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
35
|
export interface CardanoCertificate {
|
|
43
36
|
type: PROTO.CardanoCertificateType;
|
|
44
37
|
path?: string | number[];
|
|
@@ -46,8 +39,6 @@ export interface CardanoCertificate {
|
|
|
46
39
|
poolParameters?: CardanoPoolParameters;
|
|
47
40
|
scriptHash?: string;
|
|
48
41
|
keyHash?: string;
|
|
49
|
-
deposit?: UintType;
|
|
50
|
-
dRep?: CardanoDRep;
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
export type CertificateWithPoolOwnersAndRelays = {
|
|
@@ -138,8 +129,8 @@ export interface CardanoReferenceInput {
|
|
|
138
129
|
prev_index: number;
|
|
139
130
|
}
|
|
140
131
|
|
|
141
|
-
export interface
|
|
142
|
-
|
|
132
|
+
export interface CardanoGovernanceRegistrationDelegation {
|
|
133
|
+
votingPublicKey: string;
|
|
143
134
|
weight: number;
|
|
144
135
|
}
|
|
145
136
|
|
|
@@ -150,20 +141,19 @@ export interface CardanoCatalystRegistrationParameters {
|
|
|
150
141
|
nonce: string;
|
|
151
142
|
}
|
|
152
143
|
|
|
153
|
-
export interface
|
|
154
|
-
|
|
144
|
+
export interface CardanoGovernanceRegistrationParameters {
|
|
145
|
+
votingPublicKey?: string;
|
|
155
146
|
stakingPath: string | number[];
|
|
156
|
-
|
|
147
|
+
rewardAddressParameters: CardanoAddressParameters;
|
|
157
148
|
nonce: string;
|
|
158
|
-
format?: PROTO.
|
|
159
|
-
delegations?:
|
|
149
|
+
format?: PROTO.CardanoGovernanceRegistrationFormat;
|
|
150
|
+
delegations?: CardanoGovernanceRegistrationDelegation[];
|
|
160
151
|
votingPurpose?: number;
|
|
161
|
-
paymentAddress?: string;
|
|
162
152
|
}
|
|
163
153
|
|
|
164
154
|
export interface CardanoAuxiliaryData {
|
|
165
155
|
hash?: string;
|
|
166
|
-
|
|
156
|
+
governanceRegistrationParameters?: CardanoGovernanceRegistrationParameters;
|
|
167
157
|
}
|
|
168
158
|
|
|
169
159
|
export interface CardanoSignTransaction {
|
|
@@ -188,8 +178,6 @@ export interface CardanoSignTransaction {
|
|
|
188
178
|
signingMode: PROTO.CardanoTxSigningMode;
|
|
189
179
|
derivationType?: PROTO.CardanoDerivationType;
|
|
190
180
|
includeNetworkId?: boolean;
|
|
191
|
-
chunkify?: boolean;
|
|
192
|
-
tagCborSets?: boolean;
|
|
193
181
|
}
|
|
194
182
|
|
|
195
183
|
export interface CardanoSignedTxWitness {
|
|
@@ -202,7 +190,7 @@ export interface CardanoSignedTxWitness {
|
|
|
202
190
|
export interface CardanoAuxiliaryDataSupplement {
|
|
203
191
|
type: PROTO.CardanoTxAuxiliaryDataSupplementType;
|
|
204
192
|
auxiliaryDataHash: string;
|
|
205
|
-
|
|
193
|
+
catalystSignature?: string;
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
export interface CardanoSignedTxData {
|