@taquito/taquito 23.0.0-beta.0 → 23.0.0-beta.1
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/README.md +1 -1
- package/dist/lib/batch/rpc-batch-provider.js +47 -5
- package/dist/lib/constants.js +1 -2
- package/dist/lib/contract/contract.js +1 -1
- package/dist/lib/contract/prepare.js +17 -3
- package/dist/lib/contract/rpc-contract-provider.js +67 -17
- package/dist/lib/estimate/rpc-estimate-provider.js +133 -27
- package/dist/lib/operations/index.js +3 -1
- package/dist/lib/operations/reveal-operation.js +9 -0
- package/dist/lib/operations/types.js +5 -1
- package/dist/lib/operations/update-companion-key-operation.js +58 -0
- package/dist/lib/operations/update-consensus-key-operation.js +9 -0
- package/dist/lib/prepare/prepare-provider.js +76 -3
- package/dist/lib/provider.js +4 -0
- package/dist/lib/tz/rpc-tz-provider.js +4 -4
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/wallet.js +9 -9
- package/dist/taquito.es6.js +434 -76
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.min.js.LICENSE.txt +2 -0
- package/dist/taquito.umd.js +433 -73
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/batch/rpc-batch-provider.d.ts +16 -2
- package/dist/types/contract/interface.d.ts +10 -3
- package/dist/types/contract/prepare.d.ts +4 -3
- package/dist/types/contract/rpc-contract-provider.d.ts +11 -4
- package/dist/types/estimate/estimate-provider-interface.d.ts +9 -3
- package/dist/types/estimate/rpc-estimate-provider.d.ts +10 -4
- package/dist/types/operations/index.d.ts +1 -0
- package/dist/types/operations/reveal-operation.d.ts +1 -0
- package/dist/types/operations/types.d.ts +26 -5
- package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
- package/dist/types/operations/update-consensus-key-operation.d.ts +1 -0
- package/dist/types/prepare/interface.d.ts +8 -3
- package/dist/types/prepare/prepare-provider.d.ts +10 -4
- package/dist/types/provider.d.ts +1 -1
- package/dist/types/signer/interface.d.ts +18 -8
- package/package.json +9 -9
package/dist/taquito.umd.js
CHANGED
|
@@ -280,7 +280,6 @@
|
|
|
280
280
|
ChainIds["RIONET"] = "NetXPdgaoabtBth";
|
|
281
281
|
ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
|
|
282
282
|
})(exports.ChainIds || (exports.ChainIds = {}));
|
|
283
|
-
// A fixed fee reveal operation gasLimit accepted by both simulate and injection endpoint is between 1.2-5 times of actual gas consumption (3.5 fails occasionally with gas exhausted; 4 fails occasionally with fee too low)
|
|
284
283
|
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
285
284
|
const getRevealGasLimitInternal = (address) => {
|
|
286
285
|
switch (address.substring(0, 3)) {
|
|
@@ -306,7 +305,7 @@
|
|
|
306
305
|
case 'tz3':
|
|
307
306
|
return REVEAL_FEE.TZ3;
|
|
308
307
|
case 'tz4':
|
|
309
|
-
return REVEAL_FEE.TZ4;
|
|
308
|
+
return REVEAL_FEE.TZ4 * 1.7;
|
|
310
309
|
default:
|
|
311
310
|
throw new Error(`Cannot estimate reveal fee for ${address}`);
|
|
312
311
|
}
|
|
@@ -519,7 +518,7 @@
|
|
|
519
518
|
delegate: source,
|
|
520
519
|
};
|
|
521
520
|
});
|
|
522
|
-
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit }, source, publicKey) {
|
|
521
|
+
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit, proof }, source, publicKey) {
|
|
523
522
|
return {
|
|
524
523
|
kind: rpc.OpKind.REVEAL,
|
|
525
524
|
fee,
|
|
@@ -527,6 +526,7 @@
|
|
|
527
526
|
source,
|
|
528
527
|
gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : getRevealGasLimit(source),
|
|
529
528
|
storage_limit: storageLimit,
|
|
529
|
+
proof,
|
|
530
530
|
};
|
|
531
531
|
});
|
|
532
532
|
const createRegisterGlobalConstantOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, source, fee, gasLimit, storageLimit, }) {
|
|
@@ -588,7 +588,7 @@
|
|
|
588
588
|
proposals,
|
|
589
589
|
};
|
|
590
590
|
});
|
|
591
|
-
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, }) {
|
|
591
|
+
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
592
592
|
return {
|
|
593
593
|
kind: rpc.OpKind.UPDATE_CONSENSUS_KEY,
|
|
594
594
|
source,
|
|
@@ -596,6 +596,18 @@
|
|
|
596
596
|
gas_limit: gasLimit,
|
|
597
597
|
storage_limit: storageLimit,
|
|
598
598
|
pk,
|
|
599
|
+
proof,
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
const createUpdateCompanionKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
603
|
+
return {
|
|
604
|
+
kind: rpc.OpKind.UPDATE_COMPANION_KEY,
|
|
605
|
+
source,
|
|
606
|
+
fee,
|
|
607
|
+
gas_limit: gasLimit,
|
|
608
|
+
storage_limit: storageLimit,
|
|
609
|
+
pk,
|
|
610
|
+
proof,
|
|
599
611
|
};
|
|
600
612
|
});
|
|
601
613
|
const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
|
|
@@ -648,7 +660,8 @@
|
|
|
648
660
|
return op.kind === kind;
|
|
649
661
|
};
|
|
650
662
|
const isOpWithGasBuffer = (op) => {
|
|
651
|
-
|
|
663
|
+
var _a;
|
|
664
|
+
if (op.kind === rpc.OpKind.TRANSACTION && ((_a = op.destination) === null || _a === void 0 ? void 0 : _a.startsWith('KT1'))) {
|
|
652
665
|
return true;
|
|
653
666
|
}
|
|
654
667
|
else {
|
|
@@ -657,6 +670,7 @@
|
|
|
657
670
|
'register_global_constant',
|
|
658
671
|
'transfer_ticket',
|
|
659
672
|
'update_consensus_key',
|
|
673
|
+
'update_companion_key',
|
|
660
674
|
'smart_rollup_add_messages',
|
|
661
675
|
'smart_rollup_originate',
|
|
662
676
|
].indexOf(op.kind) !== -1);
|
|
@@ -672,6 +686,7 @@
|
|
|
672
686
|
'increase_paid_storage',
|
|
673
687
|
'transfer_ticket',
|
|
674
688
|
'update_consensus_key',
|
|
689
|
+
'update_companion_key',
|
|
675
690
|
'smart_rollup_add_messages',
|
|
676
691
|
'smart_rollup_originate',
|
|
677
692
|
'smart_rollup_execute_outbox_message',
|
|
@@ -686,6 +701,7 @@
|
|
|
686
701
|
'increase_paid_storage',
|
|
687
702
|
'transfer_ticket',
|
|
688
703
|
'update_consensus_key',
|
|
704
|
+
'update_companion_key',
|
|
689
705
|
'smart_rollup_add_messages',
|
|
690
706
|
'smart_rollup_originate',
|
|
691
707
|
'smart_rollup_execute_outbox_message',
|
|
@@ -1087,6 +1103,10 @@
|
|
|
1087
1103
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
1088
1104
|
case rpc.OpKind.INCREASE_PAID_STORAGE:
|
|
1089
1105
|
return createIncreasePaidStorageOperation(Object.assign({}, param));
|
|
1106
|
+
case rpc.OpKind.UPDATE_CONSENSUS_KEY:
|
|
1107
|
+
return createUpdateConsensusKeyOperation(Object.assign({}, param));
|
|
1108
|
+
case rpc.OpKind.UPDATE_COMPANION_KEY:
|
|
1109
|
+
return createUpdateCompanionKeyOperation(Object.assign({}, param));
|
|
1090
1110
|
case rpc.OpKind.TRANSFER_TICKET:
|
|
1091
1111
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
1092
1112
|
case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -1181,7 +1201,7 @@
|
|
|
1181
1201
|
withTransfer(params) {
|
|
1182
1202
|
const toValidation = utils.validateAddress(params.to);
|
|
1183
1203
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
1184
|
-
throw new core.InvalidAddressError(params.to,
|
|
1204
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
1185
1205
|
}
|
|
1186
1206
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSACTION }, params));
|
|
1187
1207
|
return this;
|
|
@@ -1202,7 +1222,7 @@
|
|
|
1202
1222
|
var _a;
|
|
1203
1223
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1204
1224
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
1205
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
1225
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
1206
1226
|
}
|
|
1207
1227
|
this.operations.push(Object.assign({ kind: rpc.OpKind.DELEGATION }, params));
|
|
1208
1228
|
return this;
|
|
@@ -1222,7 +1242,7 @@
|
|
|
1222
1242
|
withIncreasePaidStorage(params) {
|
|
1223
1243
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
1224
1244
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
1225
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1245
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
1226
1246
|
}
|
|
1227
1247
|
this.operations.push(Object.assign({ kind: rpc.OpKind.INCREASE_PAID_STORAGE }, params));
|
|
1228
1248
|
return this;
|
|
@@ -1234,7 +1254,7 @@
|
|
|
1234
1254
|
withTransferTicket(params) {
|
|
1235
1255
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
1236
1256
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
1237
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1257
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
1238
1258
|
}
|
|
1239
1259
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSFER_TICKET }, params));
|
|
1240
1260
|
return this;
|
|
@@ -1356,7 +1376,7 @@
|
|
|
1356
1376
|
var _a;
|
|
1357
1377
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1358
1378
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
1359
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
1379
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
1360
1380
|
}
|
|
1361
1381
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1362
1382
|
const mappedParams = yield this.walletProvider.mapDelegateParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1418,7 +1438,7 @@
|
|
|
1418
1438
|
transfer(params) {
|
|
1419
1439
|
const toValidation = utils.validateAddress(params.to);
|
|
1420
1440
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
1421
|
-
throw new core.InvalidAddressError(params.to,
|
|
1441
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
1422
1442
|
}
|
|
1423
1443
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1424
1444
|
const mappedParams = yield this.walletProvider.mapTransferParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1434,7 +1454,7 @@
|
|
|
1434
1454
|
transferTicket(params) {
|
|
1435
1455
|
const toValidation = utils.validateAddress(params.destination);
|
|
1436
1456
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
1437
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1457
|
+
throw new core.InvalidAddressError(params.destination, toValidation);
|
|
1438
1458
|
}
|
|
1439
1459
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1440
1460
|
const mappedParams = yield this.walletProvider.mapTransferTicketParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1521,7 +1541,7 @@
|
|
|
1521
1541
|
increasePaidStorage(params) {
|
|
1522
1542
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
1523
1543
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
1524
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1544
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
1525
1545
|
}
|
|
1526
1546
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1527
1547
|
const mappedParams = yield this.walletProvider.mapIncreasePaidStorageWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1551,7 +1571,7 @@
|
|
|
1551
1571
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
1552
1572
|
const addressValidation = utils.validateContractAddress(address);
|
|
1553
1573
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
1554
|
-
throw new core.InvalidContractAddressError(address,
|
|
1574
|
+
throw new core.InvalidContractAddressError(address, addressValidation);
|
|
1555
1575
|
}
|
|
1556
1576
|
const rpc = this.context.withExtensions().rpc;
|
|
1557
1577
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -2299,7 +2319,7 @@
|
|
|
2299
2319
|
throw new core.DeprecationError(`Since version 12, the lambda view no longer depends on a lambda contract. The read method no longer accepts a contract address as a parameter.`);
|
|
2300
2320
|
}
|
|
2301
2321
|
else if (chainId && chainIdValidation !== utils.ValidationResult.VALID) {
|
|
2302
|
-
throw new core.InvalidChainIdError(chainId,
|
|
2322
|
+
throw new core.InvalidChainIdError(chainId, chainIdValidation);
|
|
2303
2323
|
}
|
|
2304
2324
|
const arg = this.parameterSchema.Encode(...this.args);
|
|
2305
2325
|
const result = yield this.rpc.runView({
|
|
@@ -2737,10 +2757,14 @@
|
|
|
2737
2757
|
if (!publicKey) {
|
|
2738
2758
|
throw new core.PublicKeyNotFoundError(pkh);
|
|
2739
2759
|
}
|
|
2760
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
|
|
2740
2761
|
ops.unshift(yield createRevealOperation({
|
|
2741
2762
|
fee: getRevealFee(pkh),
|
|
2742
2763
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
2743
2764
|
gasLimit: getRevealGasLimit(pkh),
|
|
2765
|
+
proof: pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash
|
|
2766
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
2767
|
+
: undefined,
|
|
2744
2768
|
}, publicKeyHash, publicKey));
|
|
2745
2769
|
return ops;
|
|
2746
2770
|
}
|
|
@@ -2786,6 +2810,7 @@
|
|
|
2786
2810
|
case rpc.OpKind.DELEGATION:
|
|
2787
2811
|
case rpc.OpKind.REGISTER_GLOBAL_CONSTANT:
|
|
2788
2812
|
case rpc.OpKind.UPDATE_CONSENSUS_KEY:
|
|
2813
|
+
case rpc.OpKind.UPDATE_COMPANION_KEY:
|
|
2789
2814
|
case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
2790
2815
|
case rpc.OpKind.SMART_ROLLUP_ORIGINATE:
|
|
2791
2816
|
case rpc.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
@@ -2841,17 +2866,31 @@
|
|
|
2841
2866
|
/**
|
|
2842
2867
|
*
|
|
2843
2868
|
* @description Method to prepare a reveal operation
|
|
2844
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
2845
2869
|
* @param operation RPCOperation object or RPCOperation array
|
|
2846
2870
|
* @param source string or undefined source pkh
|
|
2847
2871
|
* @returns a PreparedOperation object
|
|
2848
2872
|
*/
|
|
2849
2873
|
reveal(_a) {
|
|
2850
|
-
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit }) {
|
|
2874
|
+
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit, proof }) {
|
|
2851
2875
|
const { pkh, publicKey } = yield this.getKeys();
|
|
2852
2876
|
if (!publicKey) {
|
|
2853
2877
|
throw new core.PublicKeyNotFoundError(pkh);
|
|
2854
2878
|
}
|
|
2879
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
|
|
2880
|
+
if (pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash) {
|
|
2881
|
+
if (proof) {
|
|
2882
|
+
utils.b58DecodeAndCheckPrefix(proof, [utils.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
2883
|
+
}
|
|
2884
|
+
else {
|
|
2885
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
2886
|
+
proof = prefixSig;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
else {
|
|
2890
|
+
if (proof) {
|
|
2891
|
+
throw new core.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2855
2894
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
2856
2895
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
2857
2896
|
const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
|
|
@@ -2859,6 +2898,7 @@
|
|
|
2859
2898
|
fee: mergedEstimates.fee,
|
|
2860
2899
|
gasLimit: mergedEstimates.gasLimit,
|
|
2861
2900
|
storageLimit: mergedEstimates.storageLimit,
|
|
2901
|
+
proof,
|
|
2862
2902
|
}, pkh, publicKey);
|
|
2863
2903
|
const ops = this.convertIntoArray(op);
|
|
2864
2904
|
const hash = yield this.getBlockHash();
|
|
@@ -3142,7 +3182,6 @@
|
|
|
3142
3182
|
/**
|
|
3143
3183
|
*
|
|
3144
3184
|
* @description Method to prepare an update_consensus_key operation
|
|
3145
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
3146
3185
|
* @param operation RPCOperation object or RPCOperation array
|
|
3147
3186
|
* @param source string or undefined source pkh
|
|
3148
3187
|
* @returns a PreparedOperation object
|
|
@@ -3151,6 +3190,17 @@
|
|
|
3151
3190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3152
3191
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3153
3192
|
const { pkh } = yield this.getKeys();
|
|
3193
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(rest.pk, utils.publicKeyPrefixes);
|
|
3194
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
3195
|
+
if (!rest.proof) {
|
|
3196
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
else {
|
|
3200
|
+
if (rest.proof) {
|
|
3201
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3154
3204
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3155
3205
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3156
3206
|
const op = yield createUpdateConsensusKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
@@ -3171,6 +3221,44 @@
|
|
|
3171
3221
|
};
|
|
3172
3222
|
});
|
|
3173
3223
|
}
|
|
3224
|
+
/**
|
|
3225
|
+
*
|
|
3226
|
+
* @description Method to prepare an update_companion_key operation
|
|
3227
|
+
* @param operation RPCOperation object or RPCOperation array
|
|
3228
|
+
* @param source string or undefined source pkh
|
|
3229
|
+
* @returns a PreparedOperation object
|
|
3230
|
+
*/
|
|
3231
|
+
updateCompanionKey(_a, source) {
|
|
3232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3233
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3234
|
+
const { pkh } = yield this.getKeys();
|
|
3235
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(rest.pk, utils.publicKeyPrefixes);
|
|
3236
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
3237
|
+
throw new core.ProhibitedActionError('companion key must be a bls account');
|
|
3238
|
+
}
|
|
3239
|
+
if (!rest.proof) {
|
|
3240
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
3241
|
+
}
|
|
3242
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3243
|
+
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3244
|
+
const op = yield createUpdateCompanionKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
3245
|
+
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
3246
|
+
const ops = this.convertIntoArray(operation);
|
|
3247
|
+
const hash = yield this.getBlockHash();
|
|
3248
|
+
const protocol = yield this.getProtocolHash();
|
|
3249
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
3250
|
+
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
3251
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
3252
|
+
return {
|
|
3253
|
+
opOb: {
|
|
3254
|
+
branch: hash,
|
|
3255
|
+
contents,
|
|
3256
|
+
protocol,
|
|
3257
|
+
},
|
|
3258
|
+
counter: headCounter,
|
|
3259
|
+
};
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3174
3262
|
/**
|
|
3175
3263
|
*
|
|
3176
3264
|
* @description Method to prepare an increase_paid_storage operation
|
|
@@ -3461,10 +3549,14 @@
|
|
|
3461
3549
|
if (!publicKey) {
|
|
3462
3550
|
throw new core.PublicKeyNotFoundError(pkh);
|
|
3463
3551
|
}
|
|
3552
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
|
|
3464
3553
|
ops.unshift(yield createRevealOperation({
|
|
3465
3554
|
fee: getRevealFee(pkh),
|
|
3466
3555
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
3467
3556
|
gasLimit: getRevealGasLimit(pkh),
|
|
3557
|
+
proof: pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash
|
|
3558
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
3559
|
+
: undefined,
|
|
3468
3560
|
}, pkh, publicKey));
|
|
3469
3561
|
}
|
|
3470
3562
|
const hash = yield this.getBlockHash();
|
|
@@ -3581,7 +3673,7 @@
|
|
|
3581
3673
|
throw new core.InvalidAmountError(params.amount.toString());
|
|
3582
3674
|
}
|
|
3583
3675
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
3584
|
-
throw new core.InvalidAddressError(params.to,
|
|
3676
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
3585
3677
|
}
|
|
3586
3678
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSACTION }, params));
|
|
3587
3679
|
return this;
|
|
@@ -3595,7 +3687,7 @@
|
|
|
3595
3687
|
withTransferTicket(params) {
|
|
3596
3688
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
3597
3689
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
3598
|
-
throw new core.InvalidAddressError(params.destination,
|
|
3690
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
3599
3691
|
}
|
|
3600
3692
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSFER_TICKET }, params));
|
|
3601
3693
|
return this;
|
|
@@ -3620,11 +3712,11 @@
|
|
|
3620
3712
|
var _a;
|
|
3621
3713
|
const sourceValidation = utils.validateAddress(params.source);
|
|
3622
3714
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
3623
|
-
throw new core.InvalidAddressError(params.source,
|
|
3715
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
3624
3716
|
}
|
|
3625
3717
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
3626
3718
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
3627
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
3719
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
3628
3720
|
}
|
|
3629
3721
|
this.operations.push(Object.assign({ kind: rpc.OpKind.DELEGATION }, params));
|
|
3630
3722
|
return this;
|
|
@@ -3639,7 +3731,7 @@
|
|
|
3639
3731
|
withActivation({ pkh, secret }) {
|
|
3640
3732
|
const pkhValidation = utils.validateKeyHash(pkh);
|
|
3641
3733
|
if (pkhValidation !== utils.ValidationResult.VALID) {
|
|
3642
|
-
throw new core.InvalidKeyHashError(pkh,
|
|
3734
|
+
throw new core.InvalidKeyHashError(pkh, pkhValidation);
|
|
3643
3735
|
}
|
|
3644
3736
|
this.operations.push({ kind: rpc.OpKind.ACTIVATION, pkh, secret });
|
|
3645
3737
|
return this;
|
|
@@ -3674,6 +3766,44 @@
|
|
|
3674
3766
|
this.operations.push(Object.assign({ kind: rpc.OpKind.INCREASE_PAID_STORAGE }, params));
|
|
3675
3767
|
return this;
|
|
3676
3768
|
}
|
|
3769
|
+
/**
|
|
3770
|
+
*
|
|
3771
|
+
* @description Add a update consensus key operation to the batch
|
|
3772
|
+
*
|
|
3773
|
+
* @param params UpdateConsensusKey operation parameter
|
|
3774
|
+
*/
|
|
3775
|
+
withUpdateConsensusKey(params) {
|
|
3776
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
3777
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
3778
|
+
if (!params.proof) {
|
|
3779
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
else {
|
|
3783
|
+
if (params.proof) {
|
|
3784
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
this.operations.push(Object.assign({ kind: rpc.OpKind.UPDATE_CONSENSUS_KEY }, params));
|
|
3788
|
+
return this;
|
|
3789
|
+
}
|
|
3790
|
+
/**
|
|
3791
|
+
*
|
|
3792
|
+
* @description Add a update companion key operation to the batch
|
|
3793
|
+
*
|
|
3794
|
+
* @param params UpdateCompanionKey operation parameter
|
|
3795
|
+
*/
|
|
3796
|
+
withUpdateCompanionKey(params) {
|
|
3797
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
3798
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
3799
|
+
throw new core.ProhibitedActionError('companion key must be a bls account');
|
|
3800
|
+
}
|
|
3801
|
+
if (!params.proof) {
|
|
3802
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
3803
|
+
}
|
|
3804
|
+
this.operations.push(Object.assign({ kind: rpc.OpKind.UPDATE_COMPANION_KEY }, params));
|
|
3805
|
+
return this;
|
|
3806
|
+
}
|
|
3677
3807
|
/**
|
|
3678
3808
|
*
|
|
3679
3809
|
* @description Add a smart rollup add messages operation to the batch
|
|
@@ -3717,6 +3847,10 @@
|
|
|
3717
3847
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
3718
3848
|
case rpc.OpKind.INCREASE_PAID_STORAGE:
|
|
3719
3849
|
return createIncreasePaidStorageOperation(Object.assign({}, param));
|
|
3850
|
+
case rpc.OpKind.UPDATE_CONSENSUS_KEY:
|
|
3851
|
+
return createUpdateConsensusKeyOperation(Object.assign({}, param));
|
|
3852
|
+
case rpc.OpKind.UPDATE_COMPANION_KEY:
|
|
3853
|
+
return createUpdateCompanionKeyOperation(Object.assign({}, param));
|
|
3720
3854
|
case rpc.OpKind.TRANSFER_TICKET:
|
|
3721
3855
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
3722
3856
|
case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -4013,7 +4147,7 @@
|
|
|
4013
4147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4014
4148
|
const addressValidation = utils.validateAddress(address);
|
|
4015
4149
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
4016
|
-
throw new core.InvalidAddressError(address,
|
|
4150
|
+
throw new core.InvalidAddressError(address, addressValidation);
|
|
4017
4151
|
}
|
|
4018
4152
|
return this.context.readProvider.getBalance(address, 'head');
|
|
4019
4153
|
});
|
|
@@ -4022,7 +4156,7 @@
|
|
|
4022
4156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4023
4157
|
const addressValidation = utils.validateAddress(address);
|
|
4024
4158
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
4025
|
-
throw new core.InvalidAddressError(address,
|
|
4159
|
+
throw new core.InvalidAddressError(address, addressValidation);
|
|
4026
4160
|
}
|
|
4027
4161
|
return this.context.readProvider.getSpendable(address, 'head');
|
|
4028
4162
|
});
|
|
@@ -4031,7 +4165,7 @@
|
|
|
4031
4165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4032
4166
|
const addressValidation = utils.validateAddress(address);
|
|
4033
4167
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
4034
|
-
throw new core.InvalidAddressError(address,
|
|
4168
|
+
throw new core.InvalidAddressError(address, addressValidation);
|
|
4035
4169
|
}
|
|
4036
4170
|
return this.context.readProvider.getDelegate(address, 'head');
|
|
4037
4171
|
});
|
|
@@ -4040,7 +4174,7 @@
|
|
|
4040
4174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4041
4175
|
const pkhValidation = utils.validateKeyHash(pkh);
|
|
4042
4176
|
if (pkhValidation !== utils.ValidationResult.VALID) {
|
|
4043
|
-
throw new utils.InvalidKeyHashError(pkh,
|
|
4177
|
+
throw new utils.InvalidKeyHashError(pkh, pkhValidation);
|
|
4044
4178
|
}
|
|
4045
4179
|
const prepared = yield this.prepare.activate({ pkh, secret });
|
|
4046
4180
|
const forgedBytes = yield this.forge(prepared);
|
|
@@ -4194,7 +4328,8 @@
|
|
|
4194
4328
|
class RPCEstimateProvider extends Provider {
|
|
4195
4329
|
constructor() {
|
|
4196
4330
|
super(...arguments);
|
|
4197
|
-
this.
|
|
4331
|
+
this.REVEAL_LENGTH = 324; // injecting size tz1=320, tz2=322, tz3=322
|
|
4332
|
+
this.REVEAL_LENGTH_TZ4 = 622; // injecting size tz4=620
|
|
4198
4333
|
this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
|
|
4199
4334
|
this.STORAGE_BUFFER = 20; // according to octez-client
|
|
4200
4335
|
this.prepare = new PrepareProvider(this.context);
|
|
@@ -4276,9 +4411,20 @@
|
|
|
4276
4411
|
: op.opOb.contents.length;
|
|
4277
4412
|
}
|
|
4278
4413
|
return opResponse.contents.map((x) => {
|
|
4414
|
+
const content = x;
|
|
4415
|
+
content.source = content.source || '';
|
|
4416
|
+
let revealSize, eachOpSize;
|
|
4417
|
+
if (content.source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)) {
|
|
4418
|
+
revealSize = this.REVEAL_LENGTH_TZ4 / 2;
|
|
4419
|
+
eachOpSize = (opbytes.length / 2 + utils.payloadLength[utils.PrefixV2.BLS12_381Signature]) / numberOfOps;
|
|
4420
|
+
}
|
|
4421
|
+
else {
|
|
4422
|
+
revealSize = this.REVEAL_LENGTH / 2;
|
|
4423
|
+
eachOpSize = (opbytes.length / 2 + utils.payloadLength[utils.PrefixV2.Ed25519Signature]) / numberOfOps;
|
|
4424
|
+
}
|
|
4279
4425
|
return this.getEstimationPropertiesFromOperationContent(x,
|
|
4280
4426
|
// diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
|
|
4281
|
-
x.kind === 'reveal' ?
|
|
4427
|
+
x.kind === 'reveal' ? revealSize : eachOpSize, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
|
|
4282
4428
|
);
|
|
4283
4429
|
});
|
|
4284
4430
|
});
|
|
@@ -4297,8 +4443,11 @@
|
|
|
4297
4443
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4298
4444
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4299
4445
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4446
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4447
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4448
|
+
: this.REVEAL_LENGTH / 2;
|
|
4300
4449
|
estimateProperties.shift();
|
|
4301
|
-
estimateProperties[0].opSize -=
|
|
4450
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4302
4451
|
}
|
|
4303
4452
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4304
4453
|
});
|
|
@@ -4317,11 +4466,11 @@
|
|
|
4317
4466
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4318
4467
|
const toValidation = utils.validateAddress(rest.to);
|
|
4319
4468
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
4320
|
-
throw new core.InvalidAddressError(rest.to,
|
|
4469
|
+
throw new core.InvalidAddressError(rest.to, toValidation);
|
|
4321
4470
|
}
|
|
4322
4471
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4323
4472
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4324
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4473
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4325
4474
|
}
|
|
4326
4475
|
if (rest.amount < 0) {
|
|
4327
4476
|
throw new core.InvalidAmountError(rest.amount.toString());
|
|
@@ -4332,8 +4481,11 @@
|
|
|
4332
4481
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4333
4482
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4334
4483
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4484
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4485
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4486
|
+
: this.REVEAL_LENGTH / 2;
|
|
4335
4487
|
estimateProperties.shift();
|
|
4336
|
-
estimateProperties[0].opSize -=
|
|
4488
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4337
4489
|
}
|
|
4338
4490
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4339
4491
|
});
|
|
@@ -4352,7 +4504,7 @@
|
|
|
4352
4504
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4353
4505
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4354
4506
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4355
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4507
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4356
4508
|
}
|
|
4357
4509
|
if (!rest.to) {
|
|
4358
4510
|
rest.to = rest.source;
|
|
@@ -4370,7 +4522,10 @@
|
|
|
4370
4522
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4371
4523
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4372
4524
|
estimateProperties.shift();
|
|
4373
|
-
|
|
4525
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4526
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4527
|
+
: this.REVEAL_LENGTH / 2;
|
|
4528
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4374
4529
|
}
|
|
4375
4530
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4376
4531
|
});
|
|
@@ -4389,7 +4544,7 @@
|
|
|
4389
4544
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4390
4545
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4391
4546
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4392
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4547
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4393
4548
|
}
|
|
4394
4549
|
if (!rest.to) {
|
|
4395
4550
|
rest.to = rest.source;
|
|
@@ -4407,7 +4562,10 @@
|
|
|
4407
4562
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4408
4563
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4409
4564
|
estimateProperties.shift();
|
|
4410
|
-
|
|
4565
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4566
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4567
|
+
: this.REVEAL_LENGTH / 2;
|
|
4568
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4411
4569
|
}
|
|
4412
4570
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4413
4571
|
});
|
|
@@ -4426,7 +4584,7 @@
|
|
|
4426
4584
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4427
4585
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4428
4586
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4429
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4587
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4430
4588
|
}
|
|
4431
4589
|
if (!rest.to) {
|
|
4432
4590
|
rest.to = rest.source;
|
|
@@ -4444,7 +4602,10 @@
|
|
|
4444
4602
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4445
4603
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4446
4604
|
estimateProperties.shift();
|
|
4447
|
-
|
|
4605
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4606
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4607
|
+
: this.REVEAL_LENGTH / 2;
|
|
4608
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4448
4609
|
}
|
|
4449
4610
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4450
4611
|
});
|
|
@@ -4463,11 +4624,11 @@
|
|
|
4463
4624
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4464
4625
|
const destinationValidation = utils.validateAddress(rest.destination);
|
|
4465
4626
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
4466
|
-
throw new core.InvalidAddressError(rest.destination,
|
|
4627
|
+
throw new core.InvalidAddressError(rest.destination, destinationValidation);
|
|
4467
4628
|
}
|
|
4468
4629
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4469
4630
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4470
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4631
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4471
4632
|
}
|
|
4472
4633
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4473
4634
|
const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
|
|
@@ -4476,7 +4637,10 @@
|
|
|
4476
4637
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4477
4638
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4478
4639
|
estimateProperties.shift();
|
|
4479
|
-
|
|
4640
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4641
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4642
|
+
: this.REVEAL_LENGTH / 2;
|
|
4643
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4480
4644
|
}
|
|
4481
4645
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4482
4646
|
});
|
|
@@ -4495,11 +4659,11 @@
|
|
|
4495
4659
|
var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
|
|
4496
4660
|
const sourceValidation = utils.validateAddress(rest.source);
|
|
4497
4661
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4498
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4662
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4499
4663
|
}
|
|
4500
4664
|
const delegateValidation = utils.validateAddress((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
|
|
4501
4665
|
if (rest.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
4502
|
-
throw new core.InvalidAddressError(rest.delegate,
|
|
4666
|
+
throw new core.InvalidAddressError(rest.delegate, delegateValidation);
|
|
4503
4667
|
}
|
|
4504
4668
|
const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
|
|
4505
4669
|
storageLimit,
|
|
@@ -4508,7 +4672,10 @@
|
|
|
4508
4672
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4509
4673
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4510
4674
|
estimateProperties.shift();
|
|
4511
|
-
|
|
4675
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4676
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4677
|
+
: this.REVEAL_LENGTH / 2;
|
|
4678
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4512
4679
|
}
|
|
4513
4680
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4514
4681
|
});
|
|
@@ -4545,7 +4712,10 @@
|
|
|
4545
4712
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4546
4713
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4547
4714
|
estimateProperties.shift();
|
|
4548
|
-
|
|
4715
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4716
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4717
|
+
: this.REVEAL_LENGTH / 2;
|
|
4718
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4549
4719
|
}
|
|
4550
4720
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4551
4721
|
});
|
|
@@ -4553,7 +4723,6 @@
|
|
|
4553
4723
|
/**
|
|
4554
4724
|
*
|
|
4555
4725
|
* @description Estimate gasLimit, storageLimit and fees to reveal the current account
|
|
4556
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
4557
4726
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
|
|
4558
4727
|
*
|
|
4559
4728
|
* @param Estimate
|
|
@@ -4565,6 +4734,21 @@
|
|
|
4565
4734
|
throw new RevealEstimateError();
|
|
4566
4735
|
}
|
|
4567
4736
|
if (yield this.isAccountRevealRequired(publicKeyHash)) {
|
|
4737
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(publicKeyHash, utils.publicKeyHashPrefixes);
|
|
4738
|
+
if (pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash) {
|
|
4739
|
+
if (params && params.proof) {
|
|
4740
|
+
utils.b58DecodeAndCheckPrefix(params.proof, [utils.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
4741
|
+
}
|
|
4742
|
+
else {
|
|
4743
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
4744
|
+
params = Object.assign(Object.assign({}, params), { proof: prefixSig });
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
else {
|
|
4748
|
+
if (params && params.proof) {
|
|
4749
|
+
throw new core.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4568
4752
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4569
4753
|
const preparedOperation = params
|
|
4570
4754
|
? yield this.prepare.reveal(params)
|
|
@@ -4592,7 +4776,10 @@
|
|
|
4592
4776
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4593
4777
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4594
4778
|
estimateProperties.shift();
|
|
4595
|
-
|
|
4779
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4780
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4781
|
+
: this.REVEAL_LENGTH / 2;
|
|
4782
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4596
4783
|
}
|
|
4597
4784
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4598
4785
|
});
|
|
@@ -4618,7 +4805,10 @@
|
|
|
4618
4805
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4619
4806
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4620
4807
|
estimateProperties.shift();
|
|
4621
|
-
|
|
4808
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4809
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4810
|
+
: this.REVEAL_LENGTH / 2;
|
|
4811
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4622
4812
|
}
|
|
4623
4813
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4624
4814
|
});
|
|
@@ -4626,18 +4816,59 @@
|
|
|
4626
4816
|
/**
|
|
4627
4817
|
*
|
|
4628
4818
|
* @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
|
|
4629
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
4630
4819
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4631
4820
|
* @param Estimate
|
|
4632
4821
|
*/
|
|
4633
4822
|
updateConsensusKey(params) {
|
|
4634
4823
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4824
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
4825
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
4826
|
+
if (!params.proof) {
|
|
4827
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
else {
|
|
4831
|
+
if (params.proof) {
|
|
4832
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4635
4835
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4636
4836
|
const preparedOperation = yield this.prepare.updateConsensusKey(params);
|
|
4637
4837
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4638
4838
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4639
4839
|
estimateProperties.shift();
|
|
4640
|
-
|
|
4840
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4841
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4842
|
+
: this.REVEAL_LENGTH / 2;
|
|
4843
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4844
|
+
}
|
|
4845
|
+
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4846
|
+
});
|
|
4847
|
+
}
|
|
4848
|
+
/**
|
|
4849
|
+
*
|
|
4850
|
+
* @description Estimate gasLimit, storageLimit and fees for an Update Companion Key operation
|
|
4851
|
+
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4852
|
+
* @param Estimate
|
|
4853
|
+
*/
|
|
4854
|
+
updateCompanionKey(params) {
|
|
4855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4856
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
4857
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
4858
|
+
throw new core.ProhibitedActionError('companion key must be a bls account');
|
|
4859
|
+
}
|
|
4860
|
+
if (!params.proof) {
|
|
4861
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
4862
|
+
}
|
|
4863
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4864
|
+
const preparedOperation = yield this.prepare.updateCompanionKey(params);
|
|
4865
|
+
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4866
|
+
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4867
|
+
estimateProperties.shift();
|
|
4868
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4869
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4870
|
+
: this.REVEAL_LENGTH / 2;
|
|
4871
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4641
4872
|
}
|
|
4642
4873
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4643
4874
|
});
|
|
@@ -4657,7 +4888,10 @@
|
|
|
4657
4888
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4658
4889
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4659
4890
|
estimateProperties.shift();
|
|
4660
|
-
|
|
4891
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4892
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4893
|
+
: this.REVEAL_LENGTH / 2;
|
|
4894
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4661
4895
|
}
|
|
4662
4896
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4663
4897
|
});
|
|
@@ -4677,7 +4911,10 @@
|
|
|
4677
4911
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4678
4912
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4679
4913
|
estimateProperties.shift();
|
|
4680
|
-
|
|
4914
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4915
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4916
|
+
: this.REVEAL_LENGTH / 2;
|
|
4917
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4681
4918
|
}
|
|
4682
4919
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4683
4920
|
});
|
|
@@ -4716,7 +4953,10 @@
|
|
|
4716
4953
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4717
4954
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4718
4955
|
estimateProperties.shift();
|
|
4719
|
-
|
|
4956
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4957
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4958
|
+
: this.REVEAL_LENGTH / 2;
|
|
4959
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4720
4960
|
}
|
|
4721
4961
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4722
4962
|
});
|
|
@@ -4934,6 +5174,14 @@
|
|
|
4934
5174
|
get publicKey() {
|
|
4935
5175
|
return this.params.public_key;
|
|
4936
5176
|
}
|
|
5177
|
+
get proof() {
|
|
5178
|
+
if (this.params.proof) {
|
|
5179
|
+
return this.params.proof;
|
|
5180
|
+
}
|
|
5181
|
+
else {
|
|
5182
|
+
throw new core.ProhibitedActionError('Only BLS key has proof');
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
4937
5185
|
sumProp(arr, prop) {
|
|
4938
5186
|
return arr.reduce((prev, current) => {
|
|
4939
5187
|
return prop in current ? Number(current[prop]) + prev : prev;
|
|
@@ -5104,6 +5352,67 @@
|
|
|
5104
5352
|
get pk() {
|
|
5105
5353
|
return this.params.pk;
|
|
5106
5354
|
}
|
|
5355
|
+
get proof() {
|
|
5356
|
+
if (this.params.proof) {
|
|
5357
|
+
return this.params.proof;
|
|
5358
|
+
}
|
|
5359
|
+
else {
|
|
5360
|
+
throw new core.ProhibitedActionError('Only updating consensus key to a BLS account has proof');
|
|
5361
|
+
}
|
|
5362
|
+
}
|
|
5363
|
+
get consumedMilliGas() {
|
|
5364
|
+
var _a;
|
|
5365
|
+
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
5366
|
+
}
|
|
5367
|
+
get errors() {
|
|
5368
|
+
var _a;
|
|
5369
|
+
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.errors;
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
|
|
5373
|
+
/**
|
|
5374
|
+
*
|
|
5375
|
+
* @description UpdateCompanionKeyOperation provides utility to fetch properties for Operation of kind UpdateCompanionKey
|
|
5376
|
+
*
|
|
5377
|
+
*/
|
|
5378
|
+
class UpdateCompanionKeyOperation extends Operation {
|
|
5379
|
+
constructor(hash, params, source, raw, results, context) {
|
|
5380
|
+
super(hash, raw, results, context);
|
|
5381
|
+
this.params = params;
|
|
5382
|
+
this.source = source;
|
|
5383
|
+
}
|
|
5384
|
+
get operationResults() {
|
|
5385
|
+
const updateCompanionKeyOp = Array.isArray(this.results) &&
|
|
5386
|
+
this.results.find((op) => op.kind === 'update_companion_key');
|
|
5387
|
+
const result = updateCompanionKeyOp &&
|
|
5388
|
+
updateCompanionKeyOp.metadata &&
|
|
5389
|
+
updateCompanionKeyOp.metadata.operation_result;
|
|
5390
|
+
return result ? result : undefined;
|
|
5391
|
+
}
|
|
5392
|
+
get status() {
|
|
5393
|
+
var _a, _b;
|
|
5394
|
+
return (_b = (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'unknown';
|
|
5395
|
+
}
|
|
5396
|
+
get fee() {
|
|
5397
|
+
return Number(this.params.fee);
|
|
5398
|
+
}
|
|
5399
|
+
get gasLimit() {
|
|
5400
|
+
return Number(this.params.gas_limit);
|
|
5401
|
+
}
|
|
5402
|
+
get storageLimit() {
|
|
5403
|
+
return Number(this.params.storage_limit);
|
|
5404
|
+
}
|
|
5405
|
+
get pk() {
|
|
5406
|
+
return this.params.pk;
|
|
5407
|
+
}
|
|
5408
|
+
get proof() {
|
|
5409
|
+
if (this.params.proof) {
|
|
5410
|
+
return this.params.proof;
|
|
5411
|
+
}
|
|
5412
|
+
else {
|
|
5413
|
+
throw new core.ProhibitedActionError('Only updating companion key to a BLS account has proof');
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5107
5416
|
get consumedMilliGas() {
|
|
5108
5417
|
var _a;
|
|
5109
5418
|
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
@@ -5401,7 +5710,7 @@
|
|
|
5401
5710
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5402
5711
|
const contractValidation = utils.validateContractAddress(contract);
|
|
5403
5712
|
if (contractValidation !== utils.ValidationResult.VALID) {
|
|
5404
|
-
throw new core.InvalidContractAddressError(contract,
|
|
5713
|
+
throw new core.InvalidContractAddressError(contract, contractValidation);
|
|
5405
5714
|
}
|
|
5406
5715
|
const script = yield this.context.readProvider.getScript(contract, 'head');
|
|
5407
5716
|
if (!schema) {
|
|
@@ -5433,7 +5742,7 @@
|
|
|
5433
5742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5434
5743
|
const contractValidation = utils.validateContractAddress(contract);
|
|
5435
5744
|
if (contractValidation !== utils.ValidationResult.VALID) {
|
|
5436
|
-
throw new core.InvalidContractAddressError(contract,
|
|
5745
|
+
throw new core.InvalidContractAddressError(contract, contractValidation);
|
|
5437
5746
|
}
|
|
5438
5747
|
if (!schema) {
|
|
5439
5748
|
schema = (yield this.rpc.getContract(contract)).script;
|
|
@@ -5577,11 +5886,11 @@
|
|
|
5577
5886
|
var _a;
|
|
5578
5887
|
const sourceValidation = utils.validateAddress(params.source);
|
|
5579
5888
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5580
|
-
throw new core.InvalidAddressError(params.source,
|
|
5889
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5581
5890
|
}
|
|
5582
5891
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
5583
5892
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
5584
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
5893
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
5585
5894
|
}
|
|
5586
5895
|
// Since babylon delegation source cannot smart contract
|
|
5587
5896
|
if (/^kt1/i.test(params.source)) {
|
|
@@ -5629,11 +5938,11 @@
|
|
|
5629
5938
|
var _a;
|
|
5630
5939
|
const toValidation = utils.validateAddress(params.to);
|
|
5631
5940
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
5632
|
-
throw new core.InvalidAddressError(params.to,
|
|
5941
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
5633
5942
|
}
|
|
5634
5943
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5635
5944
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5636
|
-
throw new core.InvalidAddressError(params.source,
|
|
5945
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5637
5946
|
}
|
|
5638
5947
|
if (params.amount < 0) {
|
|
5639
5948
|
throw new core.InvalidAmountError(params.amount.toString());
|
|
@@ -5661,7 +5970,7 @@
|
|
|
5661
5970
|
var _a;
|
|
5662
5971
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5663
5972
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5664
|
-
throw new core.InvalidAddressError(params.source,
|
|
5973
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5665
5974
|
}
|
|
5666
5975
|
if (!params.to) {
|
|
5667
5976
|
params.to = params.source;
|
|
@@ -5697,7 +6006,7 @@
|
|
|
5697
6006
|
var _a;
|
|
5698
6007
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5699
6008
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5700
|
-
throw new core.InvalidAddressError(params.source,
|
|
6009
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5701
6010
|
}
|
|
5702
6011
|
if (!params.to) {
|
|
5703
6012
|
params.to = params.source;
|
|
@@ -5730,7 +6039,7 @@
|
|
|
5730
6039
|
var _a;
|
|
5731
6040
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5732
6041
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5733
|
-
throw new core.InvalidAddressError(params.source,
|
|
6042
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5734
6043
|
}
|
|
5735
6044
|
if (!params.to) {
|
|
5736
6045
|
params.to = params.source;
|
|
@@ -5764,11 +6073,11 @@
|
|
|
5764
6073
|
var _a, _b;
|
|
5765
6074
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
5766
6075
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
5767
|
-
throw new core.InvalidAddressError(params.destination,
|
|
6076
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
5768
6077
|
}
|
|
5769
6078
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5770
6079
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5771
|
-
throw new core.InvalidAddressError(params.source,
|
|
6080
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5772
6081
|
}
|
|
5773
6082
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5774
6083
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
@@ -5783,7 +6092,6 @@
|
|
|
5783
6092
|
/**
|
|
5784
6093
|
*
|
|
5785
6094
|
* @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
|
|
5786
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
5787
6095
|
* @returns An operation handle with the result from the rpc node
|
|
5788
6096
|
*
|
|
5789
6097
|
* @param RevealParams operation parameter
|
|
@@ -5791,6 +6099,21 @@
|
|
|
5791
6099
|
reveal(params) {
|
|
5792
6100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5793
6101
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6102
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(publicKeyHash, utils.publicKeyHashPrefixes);
|
|
6103
|
+
if (pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash) {
|
|
6104
|
+
if (params.proof) {
|
|
6105
|
+
utils.b58DecodeAndCheckPrefix(params.proof, [utils.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
6106
|
+
}
|
|
6107
|
+
else {
|
|
6108
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
6109
|
+
params.proof = prefixSig;
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
else {
|
|
6113
|
+
if (params.proof) {
|
|
6114
|
+
throw new core.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
6115
|
+
}
|
|
6116
|
+
}
|
|
5794
6117
|
const estimateReveal = yield this.estimator.reveal(params);
|
|
5795
6118
|
if (estimateReveal) {
|
|
5796
6119
|
const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
|
|
@@ -5877,7 +6200,7 @@
|
|
|
5877
6200
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5878
6201
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5879
6202
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5880
|
-
throw new core.InvalidAddressError(params.source,
|
|
6203
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5881
6204
|
}
|
|
5882
6205
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5883
6206
|
const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5901,7 +6224,7 @@
|
|
|
5901
6224
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5902
6225
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5903
6226
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5904
|
-
throw new core.InvalidAddressError(params.source,
|
|
6227
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5905
6228
|
}
|
|
5906
6229
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5907
6230
|
const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5913,8 +6236,7 @@
|
|
|
5913
6236
|
}
|
|
5914
6237
|
/**
|
|
5915
6238
|
*
|
|
5916
|
-
* @description
|
|
5917
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
6239
|
+
* @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
|
|
5918
6240
|
* @returns An operation handle with the result from the rpc node
|
|
5919
6241
|
*
|
|
5920
6242
|
* @param UpdateConsensusKeyParams
|
|
@@ -5922,6 +6244,17 @@
|
|
|
5922
6244
|
updateConsensusKey(params) {
|
|
5923
6245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5924
6246
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6247
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
6248
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
6249
|
+
if (!params.proof) {
|
|
6250
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
else {
|
|
6254
|
+
if (params.proof) {
|
|
6255
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
5925
6258
|
const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
|
|
5926
6259
|
const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
|
|
5927
6260
|
const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.UPDATE_CONSENSUS_KEY);
|
|
@@ -5930,6 +6263,31 @@
|
|
|
5930
6263
|
return new UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
5931
6264
|
});
|
|
5932
6265
|
}
|
|
6266
|
+
/**
|
|
6267
|
+
*
|
|
6268
|
+
* @description Updates the companion key of the delegate starting from the current cycle plus CONSENSUS_KEY_ACTIVATION_DELAY + 1
|
|
6269
|
+
* @returns An operation handle with the result from the rpc node
|
|
6270
|
+
*
|
|
6271
|
+
* @param UpdateCompanionKeyParams
|
|
6272
|
+
*/
|
|
6273
|
+
updateCompanionKey(params) {
|
|
6274
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6275
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6276
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
6277
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
6278
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as companion key');
|
|
6279
|
+
}
|
|
6280
|
+
if (!params.proof) {
|
|
6281
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
6282
|
+
}
|
|
6283
|
+
const estimate = yield this.estimate(params, this.estimator.updateCompanionKey.bind(this.estimator));
|
|
6284
|
+
const prepared = yield this.prepare.updateCompanionKey(Object.assign(Object.assign({}, params), estimate));
|
|
6285
|
+
const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.UPDATE_COMPANION_KEY);
|
|
6286
|
+
const opBytes = yield this.forge(prepared);
|
|
6287
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
6288
|
+
return new UpdateCompanionKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
6289
|
+
});
|
|
6290
|
+
}
|
|
5933
6291
|
/**
|
|
5934
6292
|
* @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
|
|
5935
6293
|
* @param SmartRollupAddMessagesParams
|
|
@@ -6024,7 +6382,7 @@
|
|
|
6024
6382
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
6025
6383
|
const addressValidation = utils.validateContractAddress(address);
|
|
6026
6384
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
6027
|
-
throw new core.InvalidContractAddressError(address,
|
|
6385
|
+
throw new core.InvalidContractAddressError(address, addressValidation);
|
|
6028
6386
|
}
|
|
6029
6387
|
const rpc = this.context.withExtensions().rpc;
|
|
6030
6388
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -6893,8 +7251,8 @@
|
|
|
6893
7251
|
|
|
6894
7252
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
6895
7253
|
const VERSION = {
|
|
6896
|
-
"commitHash": "
|
|
6897
|
-
"version": "23.0.0-beta.
|
|
7254
|
+
"commitHash": "10b3de10de15ae68d47b1fca922d3129d2f79641",
|
|
7255
|
+
"version": "23.0.0-beta.1"
|
|
6898
7256
|
};
|
|
6899
7257
|
|
|
6900
7258
|
/**
|
|
@@ -7423,6 +7781,7 @@
|
|
|
7423
7781
|
exports.TransferTicketOperation = TransferTicketOperation;
|
|
7424
7782
|
exports.TransferTicketWalletOperation = TransferTicketWalletOperation;
|
|
7425
7783
|
exports.UnconfiguredGlobalConstantsProviderError = UnconfiguredGlobalConstantsProviderError;
|
|
7784
|
+
exports.UpdateCompanionKeyOperation = UpdateCompanionKeyOperation;
|
|
7426
7785
|
exports.UpdateConsensusKeyOperation = UpdateConsensusKeyOperation;
|
|
7427
7786
|
exports.VIEW_LAMBDA = VIEW_LAMBDA;
|
|
7428
7787
|
exports.ViewSimulationError = ViewSimulationError;
|
|
@@ -7446,6 +7805,7 @@
|
|
|
7446
7805
|
exports.createSmartRollupOriginateOperation = createSmartRollupOriginateOperation;
|
|
7447
7806
|
exports.createTransferOperation = createTransferOperation;
|
|
7448
7807
|
exports.createTransferTicketOperation = createTransferTicketOperation;
|
|
7808
|
+
exports.createUpdateCompanionKeyOperation = createUpdateCompanionKeyOperation;
|
|
7449
7809
|
exports.createUpdateConsensusKeyOperation = createUpdateConsensusKeyOperation;
|
|
7450
7810
|
exports.defaultConfigConfirmation = defaultConfigConfirmation;
|
|
7451
7811
|
exports.findWithKind = findWithKind;
|