@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
package/dist/index.js
CHANGED
|
@@ -1467,6 +1467,7 @@ var nested$1 = {
|
|
|
1467
1467
|
BenfenAddress: {
|
|
1468
1468
|
fields: {
|
|
1469
1469
|
address: {
|
|
1470
|
+
rule: "required",
|
|
1470
1471
|
type: "string",
|
|
1471
1472
|
id: 1
|
|
1472
1473
|
}
|
|
@@ -3138,18 +3139,7 @@ var nested$1 = {
|
|
|
3138
3139
|
STAKE_REGISTRATION: 0,
|
|
3139
3140
|
STAKE_DEREGISTRATION: 1,
|
|
3140
3141
|
STAKE_DELEGATION: 2,
|
|
3141
|
-
STAKE_POOL_REGISTRATION: 3
|
|
3142
|
-
STAKE_REGISTRATION_CONWAY: 7,
|
|
3143
|
-
STAKE_DEREGISTRATION_CONWAY: 8,
|
|
3144
|
-
VOTE_DELEGATION: 9
|
|
3145
|
-
}
|
|
3146
|
-
},
|
|
3147
|
-
CardanoDRepType: {
|
|
3148
|
-
values: {
|
|
3149
|
-
KEY_HASH: 0,
|
|
3150
|
-
SCRIPT_HASH: 1,
|
|
3151
|
-
ABSTAIN: 2,
|
|
3152
|
-
NO_CONFIDENCE: 3
|
|
3142
|
+
STAKE_POOL_REGISTRATION: 3
|
|
3153
3143
|
}
|
|
3154
3144
|
},
|
|
3155
3145
|
CardanoPoolRelayType: {
|
|
@@ -3162,10 +3152,10 @@ var nested$1 = {
|
|
|
3162
3152
|
CardanoTxAuxiliaryDataSupplementType: {
|
|
3163
3153
|
values: {
|
|
3164
3154
|
NONE: 0,
|
|
3165
|
-
|
|
3155
|
+
GOVERNANCE_REGISTRATION_SIGNATURE: 1
|
|
3166
3156
|
}
|
|
3167
3157
|
},
|
|
3168
|
-
|
|
3158
|
+
CardanoGovernanceRegistrationFormat: {
|
|
3169
3159
|
values: {
|
|
3170
3160
|
CIP15: 0,
|
|
3171
3161
|
CIP36: 1
|
|
@@ -3339,10 +3329,6 @@ var nested$1 = {
|
|
|
3339
3329
|
rule: "required",
|
|
3340
3330
|
type: "CardanoDerivationType",
|
|
3341
3331
|
id: 6
|
|
3342
|
-
},
|
|
3343
|
-
chunkify: {
|
|
3344
|
-
type: "bool",
|
|
3345
|
-
id: 7
|
|
3346
3332
|
}
|
|
3347
3333
|
}
|
|
3348
3334
|
},
|
|
@@ -3498,17 +3484,6 @@ var nested$1 = {
|
|
|
3498
3484
|
options: {
|
|
3499
3485
|
"default": 0
|
|
3500
3486
|
}
|
|
3501
|
-
},
|
|
3502
|
-
chunkify: {
|
|
3503
|
-
type: "bool",
|
|
3504
|
-
id: 22
|
|
3505
|
-
},
|
|
3506
|
-
tag_cbor_sets: {
|
|
3507
|
-
type: "bool",
|
|
3508
|
-
id: 23,
|
|
3509
|
-
options: {
|
|
3510
|
-
"default": false
|
|
3511
|
-
}
|
|
3512
3487
|
}
|
|
3513
3488
|
}
|
|
3514
3489
|
},
|
|
@@ -3730,23 +3705,6 @@ var nested$1 = {
|
|
|
3730
3705
|
}
|
|
3731
3706
|
}
|
|
3732
3707
|
},
|
|
3733
|
-
CardanoDRep: {
|
|
3734
|
-
fields: {
|
|
3735
|
-
type: {
|
|
3736
|
-
rule: "required",
|
|
3737
|
-
type: "CardanoDRepType",
|
|
3738
|
-
id: 1
|
|
3739
|
-
},
|
|
3740
|
-
key_hash: {
|
|
3741
|
-
type: "bytes",
|
|
3742
|
-
id: 2
|
|
3743
|
-
},
|
|
3744
|
-
script_hash: {
|
|
3745
|
-
type: "bytes",
|
|
3746
|
-
id: 3
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
},
|
|
3750
3708
|
CardanoTxCertificate: {
|
|
3751
3709
|
fields: {
|
|
3752
3710
|
type: {
|
|
@@ -3777,14 +3735,6 @@ var nested$1 = {
|
|
|
3777
3735
|
key_hash: {
|
|
3778
3736
|
type: "bytes",
|
|
3779
3737
|
id: 6
|
|
3780
|
-
},
|
|
3781
|
-
deposit: {
|
|
3782
|
-
type: "uint64",
|
|
3783
|
-
id: 7
|
|
3784
|
-
},
|
|
3785
|
-
drep: {
|
|
3786
|
-
type: "CardanoDRep",
|
|
3787
|
-
id: 8
|
|
3788
3738
|
}
|
|
3789
3739
|
}
|
|
3790
3740
|
},
|
|
@@ -3813,9 +3763,9 @@ var nested$1 = {
|
|
|
3813
3763
|
}
|
|
3814
3764
|
}
|
|
3815
3765
|
},
|
|
3816
|
-
|
|
3766
|
+
CardanoGovernanceRegistrationDelegation: {
|
|
3817
3767
|
fields: {
|
|
3818
|
-
|
|
3768
|
+
voting_public_key: {
|
|
3819
3769
|
rule: "required",
|
|
3820
3770
|
type: "bytes",
|
|
3821
3771
|
id: 1
|
|
@@ -3827,9 +3777,9 @@ var nested$1 = {
|
|
|
3827
3777
|
}
|
|
3828
3778
|
}
|
|
3829
3779
|
},
|
|
3830
|
-
|
|
3780
|
+
CardanoGovernanceRegistrationParametersType: {
|
|
3831
3781
|
fields: {
|
|
3832
|
-
|
|
3782
|
+
voting_public_key: {
|
|
3833
3783
|
type: "bytes",
|
|
3834
3784
|
id: 1
|
|
3835
3785
|
},
|
|
@@ -3841,7 +3791,8 @@ var nested$1 = {
|
|
|
3841
3791
|
packed: false
|
|
3842
3792
|
}
|
|
3843
3793
|
},
|
|
3844
|
-
|
|
3794
|
+
reward_address_parameters: {
|
|
3795
|
+
rule: "required",
|
|
3845
3796
|
type: "CardanoAddressParametersType",
|
|
3846
3797
|
id: 3
|
|
3847
3798
|
},
|
|
@@ -3851,7 +3802,7 @@ var nested$1 = {
|
|
|
3851
3802
|
id: 4
|
|
3852
3803
|
},
|
|
3853
3804
|
format: {
|
|
3854
|
-
type: "
|
|
3805
|
+
type: "CardanoGovernanceRegistrationFormat",
|
|
3855
3806
|
id: 5,
|
|
3856
3807
|
options: {
|
|
3857
3808
|
"default": "CIP15"
|
|
@@ -3859,23 +3810,19 @@ var nested$1 = {
|
|
|
3859
3810
|
},
|
|
3860
3811
|
delegations: {
|
|
3861
3812
|
rule: "repeated",
|
|
3862
|
-
type: "
|
|
3813
|
+
type: "CardanoGovernanceRegistrationDelegation",
|
|
3863
3814
|
id: 6
|
|
3864
3815
|
},
|
|
3865
3816
|
voting_purpose: {
|
|
3866
3817
|
type: "uint64",
|
|
3867
3818
|
id: 7
|
|
3868
|
-
},
|
|
3869
|
-
payment_address: {
|
|
3870
|
-
type: "string",
|
|
3871
|
-
id: 8
|
|
3872
3819
|
}
|
|
3873
3820
|
}
|
|
3874
3821
|
},
|
|
3875
3822
|
CardanoTxAuxiliaryData: {
|
|
3876
3823
|
fields: {
|
|
3877
|
-
|
|
3878
|
-
type: "
|
|
3824
|
+
governance_registration_parameters: {
|
|
3825
|
+
type: "CardanoGovernanceRegistrationParametersType",
|
|
3879
3826
|
id: 1
|
|
3880
3827
|
},
|
|
3881
3828
|
hash: {
|
|
@@ -3952,7 +3899,7 @@ var nested$1 = {
|
|
|
3952
3899
|
type: "bytes",
|
|
3953
3900
|
id: 2
|
|
3954
3901
|
},
|
|
3955
|
-
|
|
3902
|
+
governance_signature: {
|
|
3956
3903
|
type: "bytes",
|
|
3957
3904
|
id: 3
|
|
3958
3905
|
}
|
|
@@ -28066,29 +28013,19 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
28066
28013
|
}
|
|
28067
28014
|
}
|
|
28068
28015
|
checkDeviceToBootloader(connectId) {
|
|
28069
|
-
var _a, _b;
|
|
28070
28016
|
this.checkPromise = hdShared.createDeferred();
|
|
28071
28017
|
const env = DataManager.getSettings('env');
|
|
28072
28018
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
28073
28019
|
Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
28074
|
-
let isFirstCheck = true;
|
|
28075
|
-
const isTouchOrProDevice = getDeviceType((_a = this === null || this === void 0 ? void 0 : this.device) === null || _a === void 0 ? void 0 : _a.features) === 'touch' ||
|
|
28076
|
-
getDeviceType((_b = this === null || this === void 0 ? void 0 : this.device) === null || _b === void 0 ? void 0 : _b.features) === 'pro';
|
|
28077
28020
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
28078
|
-
var _c, _d, _e, _f, _g, _h
|
|
28079
|
-
Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
|
|
28080
|
-
if (isTouchOrProDevice && isFirstCheck) {
|
|
28081
|
-
isFirstCheck = false;
|
|
28082
|
-
Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
|
|
28083
|
-
yield wait(3000);
|
|
28084
|
-
}
|
|
28021
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
28085
28022
|
if (isBleReconnect) {
|
|
28086
28023
|
try {
|
|
28087
|
-
yield ((
|
|
28024
|
+
yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.device.originalDescriptor.id, null, true));
|
|
28088
28025
|
yield this.device.initialize();
|
|
28089
|
-
if ((
|
|
28026
|
+
if ((_b = this.device.features) === null || _b === void 0 ? void 0 : _b.bootloader_mode) {
|
|
28090
28027
|
clearInterval(intervalTimer);
|
|
28091
|
-
(
|
|
28028
|
+
(_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.resolve(true);
|
|
28092
28029
|
}
|
|
28093
28030
|
}
|
|
28094
28031
|
catch (e) {
|
|
@@ -28096,14 +28033,14 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
28096
28033
|
}
|
|
28097
28034
|
}
|
|
28098
28035
|
else {
|
|
28099
|
-
const deviceDiff = yield ((
|
|
28100
|
-
const devicesDescriptor = (
|
|
28036
|
+
const deviceDiff = yield ((_d = this.device.deviceConnector) === null || _d === void 0 ? void 0 : _d.enumerate());
|
|
28037
|
+
const devicesDescriptor = (_e = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _e !== void 0 ? _e : [];
|
|
28101
28038
|
const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, connectId);
|
|
28102
|
-
if (deviceList.length === 1 && ((
|
|
28039
|
+
if (deviceList.length === 1 && ((_g = (_f = deviceList[0]) === null || _f === void 0 ? void 0 : _f.features) === null || _g === void 0 ? void 0 : _g.bootloader_mode)) {
|
|
28103
28040
|
this.device.updateFromCache(deviceList[0]);
|
|
28104
28041
|
this.device.commands.disposed = false;
|
|
28105
28042
|
clearInterval(intervalTimer);
|
|
28106
|
-
(
|
|
28043
|
+
(_h = this.checkPromise) === null || _h === void 0 ? void 0 : _h.resolve(true);
|
|
28107
28044
|
}
|
|
28108
28045
|
}
|
|
28109
28046
|
}), isBleReconnect ? 3000 : 2000);
|
|
@@ -33288,27 +33225,6 @@ const transformPoolParameters = (poolParameters) => {
|
|
|
33288
33225
|
})),
|
|
33289
33226
|
};
|
|
33290
33227
|
};
|
|
33291
|
-
const transformDRep = (dRep) => {
|
|
33292
|
-
if (!dRep) {
|
|
33293
|
-
return undefined;
|
|
33294
|
-
}
|
|
33295
|
-
validateParams(dRep, [
|
|
33296
|
-
{ name: 'type', type: 'number', required: true },
|
|
33297
|
-
{ name: 'keyHash', type: 'string' },
|
|
33298
|
-
{ name: 'scriptHash', type: 'string' },
|
|
33299
|
-
]);
|
|
33300
|
-
if (dRep.type === hdTransport.Messages.CardanoDRepType.KEY_HASH && !dRep.keyHash) {
|
|
33301
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'key_hash must be supplied for key_hash type');
|
|
33302
|
-
}
|
|
33303
|
-
if (dRep.type === hdTransport.Messages.CardanoDRepType.SCRIPT_HASH && !dRep.scriptHash) {
|
|
33304
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'script_hash must be supplied for script_hash type');
|
|
33305
|
-
}
|
|
33306
|
-
return {
|
|
33307
|
-
type: dRep.type,
|
|
33308
|
-
key_hash: dRep.keyHash,
|
|
33309
|
-
script_hash: dRep.scriptHash,
|
|
33310
|
-
};
|
|
33311
|
-
};
|
|
33312
33228
|
const transformCertificate = (certificate) => {
|
|
33313
33229
|
const paramsToValidate = [
|
|
33314
33230
|
{ name: 'type', type: 'number', required: true },
|
|
@@ -33323,16 +33239,8 @@ const transformCertificate = (certificate) => {
|
|
|
33323
33239
|
if (certificate.type === hdTransport.Messages.CardanoCertificateType.STAKE_POOL_REGISTRATION) {
|
|
33324
33240
|
paramsToValidate.push({ name: 'poolParameters', type: 'object', required: true });
|
|
33325
33241
|
}
|
|
33326
|
-
if (certificate.type === hdTransport.Messages.CardanoCertificateType.STAKE_REGISTRATION_CONWAY ||
|
|
33327
|
-
certificate.type === hdTransport.Messages.CardanoCertificateType.STAKE_DEREGISTRATION_CONWAY) {
|
|
33328
|
-
paramsToValidate.push({ name: 'deposit', required: true });
|
|
33329
|
-
}
|
|
33330
|
-
if (certificate.type === hdTransport.Messages.CardanoCertificateType.VOTE_DELEGATION) {
|
|
33331
|
-
paramsToValidate.push({ name: 'dRep', type: 'object', required: true });
|
|
33332
|
-
}
|
|
33333
33242
|
validateParams(certificate, paramsToValidate);
|
|
33334
33243
|
const { poolParameters, poolOwners, poolRelays } = transformPoolParameters(certificate.poolParameters);
|
|
33335
|
-
const dRep = transformDRep(certificate.dRep);
|
|
33336
33244
|
return {
|
|
33337
33245
|
certificate: {
|
|
33338
33246
|
type: certificate.type,
|
|
@@ -33341,8 +33249,6 @@ const transformCertificate = (certificate) => {
|
|
|
33341
33249
|
key_hash: certificate.keyHash,
|
|
33342
33250
|
pool: certificate.pool,
|
|
33343
33251
|
pool_parameters: poolParameters,
|
|
33344
|
-
deposit: certificate.deposit,
|
|
33345
|
-
drep: dRep,
|
|
33346
33252
|
},
|
|
33347
33253
|
poolOwners,
|
|
33348
33254
|
poolRelays,
|
|
@@ -33351,56 +33257,37 @@ const transformCertificate = (certificate) => {
|
|
|
33351
33257
|
|
|
33352
33258
|
const MAX_DELEGATION_COUNT = 32;
|
|
33353
33259
|
const transformDelegation = (delegation) => {
|
|
33354
|
-
if (delegation.votingPublicKey) {
|
|
33355
|
-
console.warn('Please use votePublicKey instead of votingPublicKey.');
|
|
33356
|
-
delegation.votePublicKey = delegation.votingPublicKey;
|
|
33357
|
-
}
|
|
33358
33260
|
validateParams(delegation, [
|
|
33359
33261
|
{ name: 'votingPublicKey', type: 'string', required: true },
|
|
33360
33262
|
{ name: 'weight', type: 'uint', required: true },
|
|
33361
33263
|
]);
|
|
33362
33264
|
return {
|
|
33363
|
-
|
|
33265
|
+
voting_public_key: delegation.votingPublicKey,
|
|
33364
33266
|
weight: delegation.weight,
|
|
33365
33267
|
};
|
|
33366
33268
|
};
|
|
33367
|
-
const
|
|
33368
|
-
|
|
33369
|
-
|
|
33370
|
-
console.warn('Please use votePublicKey instead of votingPublicKey.');
|
|
33371
|
-
cVoteRegistrationParameters.votePublicKey = cVoteRegistrationParameters.votingPublicKey;
|
|
33372
|
-
}
|
|
33373
|
-
if (cVoteRegistrationParameters.rewardAddressParameters) {
|
|
33374
|
-
console.warn('Please use paymentAddressParameters instead of rewardAddressParameters.');
|
|
33375
|
-
cVoteRegistrationParameters.paymentAddressParameters =
|
|
33376
|
-
cVoteRegistrationParameters.rewardAddressParameters;
|
|
33377
|
-
}
|
|
33378
|
-
validateParams(cVoteRegistrationParameters, [
|
|
33379
|
-
{ name: 'votePublicKey', type: 'string' },
|
|
33269
|
+
const transformGovernanceRegistrationParameters = (governanceRegistrationParameters) => {
|
|
33270
|
+
validateParams(governanceRegistrationParameters, [
|
|
33271
|
+
{ name: 'votingPublicKey', type: 'string' },
|
|
33380
33272
|
{ name: 'stakingPath', required: true },
|
|
33381
33273
|
{ name: 'nonce', type: 'uint', required: true },
|
|
33382
33274
|
{ name: 'format', type: 'number' },
|
|
33383
33275
|
{ name: 'delegations', type: 'array', allowEmpty: true },
|
|
33384
33276
|
{ name: 'votingPurpose', type: 'uint' },
|
|
33385
|
-
{ name: 'paymentAddress', type: 'string' },
|
|
33386
33277
|
]);
|
|
33387
|
-
|
|
33388
|
-
|
|
33389
|
-
const { delegations } = cVoteRegistrationParameters;
|
|
33278
|
+
validateAddressParameters(governanceRegistrationParameters.rewardAddressParameters);
|
|
33279
|
+
const { delegations } = governanceRegistrationParameters;
|
|
33390
33280
|
if (delegations && delegations.length > MAX_DELEGATION_COUNT) {
|
|
33391
33281
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, `At most ${MAX_DELEGATION_COUNT} delegations are allowed in a governance registration`);
|
|
33392
33282
|
}
|
|
33393
33283
|
return {
|
|
33394
|
-
|
|
33395
|
-
staking_path: validatePath(
|
|
33396
|
-
|
|
33397
|
-
|
|
33398
|
-
|
|
33399
|
-
|
|
33400
|
-
|
|
33401
|
-
delegations: (_a = delegations === null || delegations === void 0 ? void 0 : delegations.map(transformDelegation)) !== null && _a !== void 0 ? _a : [],
|
|
33402
|
-
voting_purpose: cVoteRegistrationParameters.votingPurpose,
|
|
33403
|
-
payment_address: cVoteRegistrationParameters.paymentAddress,
|
|
33284
|
+
voting_public_key: governanceRegistrationParameters.votingPublicKey,
|
|
33285
|
+
staking_path: validatePath(governanceRegistrationParameters.stakingPath, 3),
|
|
33286
|
+
reward_address_parameters: addressParametersToProto(governanceRegistrationParameters.rewardAddressParameters),
|
|
33287
|
+
nonce: governanceRegistrationParameters.nonce,
|
|
33288
|
+
format: governanceRegistrationParameters.format,
|
|
33289
|
+
delegations: delegations === null || delegations === void 0 ? void 0 : delegations.map(transformDelegation),
|
|
33290
|
+
voting_purpose: governanceRegistrationParameters.votingPurpose,
|
|
33404
33291
|
};
|
|
33405
33292
|
};
|
|
33406
33293
|
const transformAuxiliaryData = (auxiliaryData) => {
|
|
@@ -33410,21 +33297,21 @@ const transformAuxiliaryData = (auxiliaryData) => {
|
|
|
33410
33297
|
type: 'string',
|
|
33411
33298
|
},
|
|
33412
33299
|
]);
|
|
33413
|
-
let
|
|
33414
|
-
if (auxiliaryData.
|
|
33415
|
-
|
|
33300
|
+
let governanceRegistrationParameters;
|
|
33301
|
+
if (auxiliaryData.governanceRegistrationParameters) {
|
|
33302
|
+
governanceRegistrationParameters = transformGovernanceRegistrationParameters(auxiliaryData.governanceRegistrationParameters);
|
|
33416
33303
|
}
|
|
33417
33304
|
return {
|
|
33418
33305
|
hash: auxiliaryData.hash,
|
|
33419
|
-
|
|
33306
|
+
governance_registration_parameters: governanceRegistrationParameters,
|
|
33420
33307
|
};
|
|
33421
33308
|
};
|
|
33422
33309
|
const modifyAuxiliaryDataForBackwardsCompatibility = (auxiliary_data) => {
|
|
33423
|
-
const {
|
|
33424
|
-
if (
|
|
33425
|
-
|
|
33426
|
-
modifyAddressParametersForBackwardsCompatibility(
|
|
33427
|
-
return Object.assign(Object.assign({}, auxiliary_data), {
|
|
33310
|
+
const { governance_registration_parameters } = auxiliary_data;
|
|
33311
|
+
if (governance_registration_parameters) {
|
|
33312
|
+
governance_registration_parameters.reward_address_parameters =
|
|
33313
|
+
modifyAddressParametersForBackwardsCompatibility(governance_registration_parameters.reward_address_parameters);
|
|
33314
|
+
return Object.assign(Object.assign({}, auxiliary_data), { governance_registration_parameters });
|
|
33428
33315
|
}
|
|
33429
33316
|
return auxiliary_data;
|
|
33430
33317
|
};
|
|
@@ -33473,55 +33360,6 @@ const gatherWitnessPaths = (inputsWithPath, certificatesWithPoolOwnersAndRelays,
|
|
|
33473
33360
|
};
|
|
33474
33361
|
|
|
33475
33362
|
class CardanoSignTransaction extends BaseMethod {
|
|
33476
|
-
constructor() {
|
|
33477
|
-
super(...arguments);
|
|
33478
|
-
this.hasConway = () => {
|
|
33479
|
-
var _a, _b;
|
|
33480
|
-
const payload = this.payload;
|
|
33481
|
-
if (payload.tagCborSets === true) {
|
|
33482
|
-
return true;
|
|
33483
|
-
}
|
|
33484
|
-
if (((_a = payload.auxiliaryData) === null || _a === void 0 ? void 0 : _a.cVoteRegistrationParameters) != null) {
|
|
33485
|
-
return true;
|
|
33486
|
-
}
|
|
33487
|
-
for (const certificate of (_b = payload.certificates) !== null && _b !== void 0 ? _b : []) {
|
|
33488
|
-
if (certificate.dRep != null) {
|
|
33489
|
-
return true;
|
|
33490
|
-
}
|
|
33491
|
-
if (certificate.deposit != null) {
|
|
33492
|
-
return true;
|
|
33493
|
-
}
|
|
33494
|
-
if (certificate.type === hdTransport.Messages.CardanoCertificateType.STAKE_REGISTRATION_CONWAY ||
|
|
33495
|
-
certificate.type === hdTransport.Messages.CardanoCertificateType.STAKE_DEREGISTRATION_CONWAY ||
|
|
33496
|
-
certificate.type === hdTransport.Messages.CardanoCertificateType.VOTE_DELEGATION) {
|
|
33497
|
-
return true;
|
|
33498
|
-
}
|
|
33499
|
-
}
|
|
33500
|
-
return false;
|
|
33501
|
-
};
|
|
33502
|
-
this.supportConwayVersionRange = () => ({
|
|
33503
|
-
pro: {
|
|
33504
|
-
min: '4.12.0',
|
|
33505
|
-
},
|
|
33506
|
-
touch: {
|
|
33507
|
-
min: '4.10.0',
|
|
33508
|
-
},
|
|
33509
|
-
});
|
|
33510
|
-
this.checkSupportConway = () => {
|
|
33511
|
-
var _a;
|
|
33512
|
-
if (!this.hasConway()) {
|
|
33513
|
-
return;
|
|
33514
|
-
}
|
|
33515
|
-
const firmwareVersion = (_a = getDeviceFirmwareVersion(this.device.features)) === null || _a === void 0 ? void 0 : _a.join('.');
|
|
33516
|
-
const versionRange = getMethodVersionRange(this.device.features, type => this.supportConwayVersionRange()[type]);
|
|
33517
|
-
if (!versionRange) {
|
|
33518
|
-
return;
|
|
33519
|
-
}
|
|
33520
|
-
if (!semver__default["default"].valid(firmwareVersion) || semver__default["default"].lt(firmwareVersion, versionRange.min)) {
|
|
33521
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware, `Device firmware version is too low, please update to ${versionRange.min}`, { current: firmwareVersion, require: versionRange.min });
|
|
33522
|
-
}
|
|
33523
|
-
};
|
|
33524
|
-
}
|
|
33525
33363
|
getVersionRange() {
|
|
33526
33364
|
return {
|
|
33527
33365
|
model_mini: {
|
|
@@ -33538,11 +33376,6 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
33538
33376
|
this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
33539
33377
|
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
33540
33378
|
const { payload } = this;
|
|
33541
|
-
if (payload.auxiliaryData && payload.auxiliaryData.governanceRegistrationParameters) {
|
|
33542
|
-
console.warn('Please use cVoteRegistrationParameters instead of governanceRegistrationParameters.');
|
|
33543
|
-
payload.auxiliaryData.cVoteRegistrationParameters =
|
|
33544
|
-
payload.auxiliaryData.governanceRegistrationParameters;
|
|
33545
|
-
}
|
|
33546
33379
|
validateParams(payload, [
|
|
33547
33380
|
{ name: 'signingMode', type: 'number', required: true },
|
|
33548
33381
|
{ name: 'inputs', type: 'array', required: true },
|
|
@@ -33563,8 +33396,6 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
33563
33396
|
{ name: 'additionalWitnessRequests', type: 'array', allowEmpty: true },
|
|
33564
33397
|
{ name: 'derivationType', type: 'number' },
|
|
33565
33398
|
{ name: 'includeNetworkId', type: 'boolean' },
|
|
33566
|
-
{ name: 'chunkify', type: 'boolean' },
|
|
33567
|
-
{ name: 'tagCborSets', type: 'boolean' },
|
|
33568
33399
|
]);
|
|
33569
33400
|
const inputsWithPath = payload.inputs.map(transformInput);
|
|
33570
33401
|
const outputsWithData = payload.outputs.map(transformOutput);
|
|
@@ -33646,8 +33477,6 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
33646
33477
|
? payload.derivationType
|
|
33647
33478
|
: hdTransport.Messages.CardanoDerivationType.ICARUS,
|
|
33648
33479
|
includeNetworkId: payload.includeNetworkId,
|
|
33649
|
-
chunkify: payload.chunkify,
|
|
33650
|
-
tagCborSets: payload.tagCborSets,
|
|
33651
33480
|
};
|
|
33652
33481
|
}
|
|
33653
33482
|
signTx() {
|
|
@@ -33676,8 +33505,6 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
33676
33505
|
reference_inputs_count: this.params.referenceInputs.length,
|
|
33677
33506
|
derivation_type: this.params.derivationType,
|
|
33678
33507
|
include_network_id: this.params.includeNetworkId,
|
|
33679
|
-
chunkify: this.params.chunkify,
|
|
33680
|
-
tag_cbor_sets: this.params.tagCborSets,
|
|
33681
33508
|
};
|
|
33682
33509
|
yield typedCall('CardanoSignTxInit', 'CardanoTxItemAck', signTxInitMessage);
|
|
33683
33510
|
for (const { input } of this.params.inputsWithPath) {
|
|
@@ -33711,9 +33538,8 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
33711
33538
|
auxiliaryDataSupplement = {
|
|
33712
33539
|
type: auxiliaryDataType,
|
|
33713
33540
|
auxiliaryDataHash: message.auxiliary_data_hash,
|
|
33714
|
-
|
|
33715
|
-
catalystSignature: message.
|
|
33716
|
-
governanceSignature: message.cvote_registration_signature,
|
|
33541
|
+
governanceSignature: message.governance_signature,
|
|
33542
|
+
catalystSignature: message.governance_signature,
|
|
33717
33543
|
};
|
|
33718
33544
|
}
|
|
33719
33545
|
yield typedCall('CardanoTxHostAck', 'CardanoTxItemAck');
|
|
@@ -33762,7 +33588,6 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
33762
33588
|
});
|
|
33763
33589
|
}
|
|
33764
33590
|
run() {
|
|
33765
|
-
this.checkSupportConway();
|
|
33766
33591
|
return this.signTx();
|
|
33767
33592
|
}
|
|
33768
33593
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { UintType } from '@onekeyfe/hd-transport';
|
|
2
1
|
import type { PROTO } from '../../constants';
|
|
3
2
|
export interface CardanoAddressParameters {
|
|
4
3
|
addressType: PROTO.CardanoAddressType;
|
|
@@ -27,11 +26,6 @@ export type AssetGroupWithTokens = {
|
|
|
27
26
|
policyId: string;
|
|
28
27
|
tokens: PROTO.CardanoToken[];
|
|
29
28
|
};
|
|
30
|
-
export interface CardanoDRep {
|
|
31
|
-
type: PROTO.CardanoDRepType;
|
|
32
|
-
keyHash?: string;
|
|
33
|
-
scriptHash?: string;
|
|
34
|
-
}
|
|
35
29
|
export interface CardanoCertificate {
|
|
36
30
|
type: PROTO.CardanoCertificateType;
|
|
37
31
|
path?: string | number[];
|
|
@@ -39,8 +33,6 @@ export interface CardanoCertificate {
|
|
|
39
33
|
poolParameters?: CardanoPoolParameters;
|
|
40
34
|
scriptHash?: string;
|
|
41
35
|
keyHash?: string;
|
|
42
|
-
deposit?: UintType;
|
|
43
|
-
dRep?: CardanoDRep;
|
|
44
36
|
}
|
|
45
37
|
export type CertificateWithPoolOwnersAndRelays = {
|
|
46
38
|
certificate: PROTO.CardanoTxCertificate;
|
|
@@ -114,8 +106,8 @@ export interface CardanoReferenceInput {
|
|
|
114
106
|
prev_hash: string;
|
|
115
107
|
prev_index: number;
|
|
116
108
|
}
|
|
117
|
-
export interface
|
|
118
|
-
|
|
109
|
+
export interface CardanoGovernanceRegistrationDelegation {
|
|
110
|
+
votingPublicKey: string;
|
|
119
111
|
weight: number;
|
|
120
112
|
}
|
|
121
113
|
export interface CardanoCatalystRegistrationParameters {
|
|
@@ -124,19 +116,18 @@ export interface CardanoCatalystRegistrationParameters {
|
|
|
124
116
|
rewardAddressParameters: CardanoAddressParameters;
|
|
125
117
|
nonce: string;
|
|
126
118
|
}
|
|
127
|
-
export interface
|
|
128
|
-
|
|
119
|
+
export interface CardanoGovernanceRegistrationParameters {
|
|
120
|
+
votingPublicKey?: string;
|
|
129
121
|
stakingPath: string | number[];
|
|
130
|
-
|
|
122
|
+
rewardAddressParameters: CardanoAddressParameters;
|
|
131
123
|
nonce: string;
|
|
132
|
-
format?: PROTO.
|
|
133
|
-
delegations?:
|
|
124
|
+
format?: PROTO.CardanoGovernanceRegistrationFormat;
|
|
125
|
+
delegations?: CardanoGovernanceRegistrationDelegation[];
|
|
134
126
|
votingPurpose?: number;
|
|
135
|
-
paymentAddress?: string;
|
|
136
127
|
}
|
|
137
128
|
export interface CardanoAuxiliaryData {
|
|
138
129
|
hash?: string;
|
|
139
|
-
|
|
130
|
+
governanceRegistrationParameters?: CardanoGovernanceRegistrationParameters;
|
|
140
131
|
}
|
|
141
132
|
export interface CardanoSignTransaction {
|
|
142
133
|
inputs: CardanoInput[];
|
|
@@ -160,8 +151,6 @@ export interface CardanoSignTransaction {
|
|
|
160
151
|
signingMode: PROTO.CardanoTxSigningMode;
|
|
161
152
|
derivationType?: PROTO.CardanoDerivationType;
|
|
162
153
|
includeNetworkId?: boolean;
|
|
163
|
-
chunkify?: boolean;
|
|
164
|
-
tagCborSets?: boolean;
|
|
165
154
|
}
|
|
166
155
|
export interface CardanoSignedTxWitness {
|
|
167
156
|
type: PROTO.CardanoTxWitnessType;
|
|
@@ -172,7 +161,7 @@ export interface CardanoSignedTxWitness {
|
|
|
172
161
|
export interface CardanoAuxiliaryDataSupplement {
|
|
173
162
|
type: PROTO.CardanoTxAuxiliaryDataSupplementType;
|
|
174
163
|
auxiliaryDataHash: string;
|
|
175
|
-
|
|
164
|
+
catalystSignature?: string;
|
|
176
165
|
}
|
|
177
166
|
export interface CardanoSignedTxData {
|
|
178
167
|
hash: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardano.d.ts","sourceRoot":"","sources":["../../../src/types/api/cardano.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"cardano.d.ts","sourceRoot":"","sources":["../../../src/types/api/cardano.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,KAAK,CAAC,kBAAkB,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,EAAE,CAAC;CAC9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,kBAAk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