@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.es6.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OpKind, RpcClient } from '@taquito/rpc';
|
|
2
2
|
export { OpKind } from '@taquito/rpc';
|
|
3
3
|
import { HttpResponseError, STATUS_CODE } from '@taquito/http-utils';
|
|
4
|
-
import { TezosToolkitConfigError, ParameterValidationError, RpcError, TaquitoError, NetworkError, InvalidOperationHashError, InvalidAddressError, InvalidOperationKindError as InvalidOperationKindError$1, InvalidStakingAddressError, InvalidFinalizeUnstakeAmountError, InvalidContractAddressError, InvalidViewParameterError, DeprecationError, InvalidChainIdError, PublicKeyNotFoundError, InvalidAmountError, InvalidKeyHashError } from '@taquito/core';
|
|
4
|
+
import { TezosToolkitConfigError, ParameterValidationError, RpcError, TaquitoError, NetworkError, InvalidOperationHashError, InvalidAddressError, InvalidOperationKindError as InvalidOperationKindError$1, InvalidStakingAddressError, InvalidFinalizeUnstakeAmountError, InvalidContractAddressError, InvalidViewParameterError, DeprecationError, InvalidChainIdError, PublicKeyNotFoundError, ProhibitedActionError, InvalidProofError, InvalidAmountError, InvalidKeyHashError } from '@taquito/core';
|
|
5
5
|
import { Observable, ReplaySubject, BehaviorSubject, throwError, defer, range, of, EMPTY, combineLatest, from, concat, Subject, NEVER, timer } from 'rxjs';
|
|
6
6
|
import { switchMap, timeout, concatMap, endWith, tap, shareReplay, map, filter, first, catchError, share, distinctUntilChanged, takeWhile, startWith, mergeMap, takeUntil, retry, distinctUntilKeyChanged } from 'rxjs/operators';
|
|
7
7
|
import { Schema, ParameterSchema, ViewSchema, EventSchema, MichelsonMap, Token } from '@taquito/michelson-encoder';
|
|
8
8
|
export { MichelsonMap, Token, UnitValue } from '@taquito/michelson-encoder';
|
|
9
|
-
import { format, validateOperation, ValidationResult, InvalidOperationKindError, validateAddress,
|
|
9
|
+
import { format, validateOperation, ValidationResult, InvalidOperationKindError, validateAddress, validateContractAddress, validateChain, b58DecodeAndCheckPrefix, publicKeyHashPrefixes, PrefixV2, publicKeyPrefixes, validateKeyHash, InvalidKeyHashError as InvalidKeyHashError$1, payloadLength, encodeExpr } from '@taquito/utils';
|
|
10
10
|
import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js';
|
|
11
11
|
import { Parser, packDataBytes } from '@taquito/michel-codec';
|
|
12
12
|
import { LocalForger } from '@taquito/local-forging';
|
|
@@ -287,7 +287,6 @@ var ChainIds;
|
|
|
287
287
|
ChainIds["RIONET"] = "NetXPdgaoabtBth";
|
|
288
288
|
ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
|
|
289
289
|
})(ChainIds || (ChainIds = {}));
|
|
290
|
-
// 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)
|
|
291
290
|
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
292
291
|
const getRevealGasLimitInternal = (address) => {
|
|
293
292
|
switch (address.substring(0, 3)) {
|
|
@@ -313,7 +312,7 @@ const getRevealFeeInternal = (address) => {
|
|
|
313
312
|
case 'tz3':
|
|
314
313
|
return REVEAL_FEE.TZ3;
|
|
315
314
|
case 'tz4':
|
|
316
|
-
return REVEAL_FEE.TZ4;
|
|
315
|
+
return REVEAL_FEE.TZ4 * 1.7;
|
|
317
316
|
default:
|
|
318
317
|
throw new Error(`Cannot estimate reveal fee for ${address}`);
|
|
319
318
|
}
|
|
@@ -526,7 +525,7 @@ const createRegisterDelegateOperation = (_a, source_1) => __awaiter(void 0, [_a,
|
|
|
526
525
|
delegate: source,
|
|
527
526
|
};
|
|
528
527
|
});
|
|
529
|
-
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit }, source, publicKey) {
|
|
528
|
+
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit, proof }, source, publicKey) {
|
|
530
529
|
return {
|
|
531
530
|
kind: OpKind.REVEAL,
|
|
532
531
|
fee,
|
|
@@ -534,6 +533,7 @@ const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [
|
|
|
534
533
|
source,
|
|
535
534
|
gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : getRevealGasLimit(source),
|
|
536
535
|
storage_limit: storageLimit,
|
|
536
|
+
proof,
|
|
537
537
|
};
|
|
538
538
|
});
|
|
539
539
|
const createRegisterGlobalConstantOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, source, fee, gasLimit, storageLimit, }) {
|
|
@@ -595,7 +595,7 @@ const createProposalsOperation = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
595
595
|
proposals,
|
|
596
596
|
};
|
|
597
597
|
});
|
|
598
|
-
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, }) {
|
|
598
|
+
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
599
599
|
return {
|
|
600
600
|
kind: OpKind.UPDATE_CONSENSUS_KEY,
|
|
601
601
|
source,
|
|
@@ -603,6 +603,18 @@ const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0
|
|
|
603
603
|
gas_limit: gasLimit,
|
|
604
604
|
storage_limit: storageLimit,
|
|
605
605
|
pk,
|
|
606
|
+
proof,
|
|
607
|
+
};
|
|
608
|
+
});
|
|
609
|
+
const createUpdateCompanionKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
610
|
+
return {
|
|
611
|
+
kind: OpKind.UPDATE_COMPANION_KEY,
|
|
612
|
+
source,
|
|
613
|
+
fee,
|
|
614
|
+
gas_limit: gasLimit,
|
|
615
|
+
storage_limit: storageLimit,
|
|
616
|
+
pk,
|
|
617
|
+
proof,
|
|
606
618
|
};
|
|
607
619
|
});
|
|
608
620
|
const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
|
|
@@ -655,7 +667,8 @@ const isKind = (op, kind) => {
|
|
|
655
667
|
return op.kind === kind;
|
|
656
668
|
};
|
|
657
669
|
const isOpWithGasBuffer = (op) => {
|
|
658
|
-
|
|
670
|
+
var _a;
|
|
671
|
+
if (op.kind === OpKind.TRANSACTION && ((_a = op.destination) === null || _a === void 0 ? void 0 : _a.startsWith('KT1'))) {
|
|
659
672
|
return true;
|
|
660
673
|
}
|
|
661
674
|
else {
|
|
@@ -664,6 +677,7 @@ const isOpWithGasBuffer = (op) => {
|
|
|
664
677
|
'register_global_constant',
|
|
665
678
|
'transfer_ticket',
|
|
666
679
|
'update_consensus_key',
|
|
680
|
+
'update_companion_key',
|
|
667
681
|
'smart_rollup_add_messages',
|
|
668
682
|
'smart_rollup_originate',
|
|
669
683
|
].indexOf(op.kind) !== -1);
|
|
@@ -679,6 +693,7 @@ const isOpWithFee = (op) => {
|
|
|
679
693
|
'increase_paid_storage',
|
|
680
694
|
'transfer_ticket',
|
|
681
695
|
'update_consensus_key',
|
|
696
|
+
'update_companion_key',
|
|
682
697
|
'smart_rollup_add_messages',
|
|
683
698
|
'smart_rollup_originate',
|
|
684
699
|
'smart_rollup_execute_outbox_message',
|
|
@@ -693,6 +708,7 @@ const isOpRequireReveal = (op) => {
|
|
|
693
708
|
'increase_paid_storage',
|
|
694
709
|
'transfer_ticket',
|
|
695
710
|
'update_consensus_key',
|
|
711
|
+
'update_companion_key',
|
|
696
712
|
'smart_rollup_add_messages',
|
|
697
713
|
'smart_rollup_originate',
|
|
698
714
|
'smart_rollup_execute_outbox_message',
|
|
@@ -1094,6 +1110,10 @@ class Provider {
|
|
|
1094
1110
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
1095
1111
|
case OpKind.INCREASE_PAID_STORAGE:
|
|
1096
1112
|
return createIncreasePaidStorageOperation(Object.assign({}, param));
|
|
1113
|
+
case OpKind.UPDATE_CONSENSUS_KEY:
|
|
1114
|
+
return createUpdateConsensusKeyOperation(Object.assign({}, param));
|
|
1115
|
+
case OpKind.UPDATE_COMPANION_KEY:
|
|
1116
|
+
return createUpdateCompanionKeyOperation(Object.assign({}, param));
|
|
1097
1117
|
case OpKind.TRANSFER_TICKET:
|
|
1098
1118
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
1099
1119
|
case OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -1188,7 +1208,7 @@ class WalletOperationBatch {
|
|
|
1188
1208
|
withTransfer(params) {
|
|
1189
1209
|
const toValidation = validateAddress(params.to);
|
|
1190
1210
|
if (toValidation !== ValidationResult.VALID) {
|
|
1191
|
-
throw new InvalidAddressError(params.to,
|
|
1211
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
1192
1212
|
}
|
|
1193
1213
|
this.operations.push(Object.assign({ kind: OpKind.TRANSACTION }, params));
|
|
1194
1214
|
return this;
|
|
@@ -1209,7 +1229,7 @@ class WalletOperationBatch {
|
|
|
1209
1229
|
var _a;
|
|
1210
1230
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1211
1231
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
1212
|
-
throw new InvalidAddressError(params.delegate,
|
|
1232
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
1213
1233
|
}
|
|
1214
1234
|
this.operations.push(Object.assign({ kind: OpKind.DELEGATION }, params));
|
|
1215
1235
|
return this;
|
|
@@ -1229,7 +1249,7 @@ class WalletOperationBatch {
|
|
|
1229
1249
|
withIncreasePaidStorage(params) {
|
|
1230
1250
|
const destinationValidation = validateAddress(params.destination);
|
|
1231
1251
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
1232
|
-
throw new InvalidAddressError(params.destination,
|
|
1252
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
1233
1253
|
}
|
|
1234
1254
|
this.operations.push(Object.assign({ kind: OpKind.INCREASE_PAID_STORAGE }, params));
|
|
1235
1255
|
return this;
|
|
@@ -1241,7 +1261,7 @@ class WalletOperationBatch {
|
|
|
1241
1261
|
withTransferTicket(params) {
|
|
1242
1262
|
const destinationValidation = validateAddress(params.destination);
|
|
1243
1263
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
1244
|
-
throw new InvalidAddressError(params.destination,
|
|
1264
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
1245
1265
|
}
|
|
1246
1266
|
this.operations.push(Object.assign({ kind: OpKind.TRANSFER_TICKET }, params));
|
|
1247
1267
|
return this;
|
|
@@ -1363,7 +1383,7 @@ class Wallet {
|
|
|
1363
1383
|
var _a;
|
|
1364
1384
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1365
1385
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
1366
|
-
throw new InvalidAddressError(params.delegate,
|
|
1386
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
1367
1387
|
}
|
|
1368
1388
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1369
1389
|
const mappedParams = yield this.walletProvider.mapDelegateParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1425,7 +1445,7 @@ class Wallet {
|
|
|
1425
1445
|
transfer(params) {
|
|
1426
1446
|
const toValidation = validateAddress(params.to);
|
|
1427
1447
|
if (toValidation !== ValidationResult.VALID) {
|
|
1428
|
-
throw new InvalidAddressError(params.to,
|
|
1448
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
1429
1449
|
}
|
|
1430
1450
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1431
1451
|
const mappedParams = yield this.walletProvider.mapTransferParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1441,7 +1461,7 @@ class Wallet {
|
|
|
1441
1461
|
transferTicket(params) {
|
|
1442
1462
|
const toValidation = validateAddress(params.destination);
|
|
1443
1463
|
if (toValidation !== ValidationResult.VALID) {
|
|
1444
|
-
throw new InvalidAddressError(params.destination,
|
|
1464
|
+
throw new InvalidAddressError(params.destination, toValidation);
|
|
1445
1465
|
}
|
|
1446
1466
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1447
1467
|
const mappedParams = yield this.walletProvider.mapTransferTicketParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1528,7 +1548,7 @@ class Wallet {
|
|
|
1528
1548
|
increasePaidStorage(params) {
|
|
1529
1549
|
const destinationValidation = validateAddress(params.destination);
|
|
1530
1550
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
1531
|
-
throw new InvalidAddressError(params.destination,
|
|
1551
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
1532
1552
|
}
|
|
1533
1553
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1534
1554
|
const mappedParams = yield this.walletProvider.mapIncreasePaidStorageWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1558,7 +1578,7 @@ class Wallet {
|
|
|
1558
1578
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
1559
1579
|
const addressValidation = validateContractAddress(address);
|
|
1560
1580
|
if (addressValidation !== ValidationResult.VALID) {
|
|
1561
|
-
throw new InvalidContractAddressError(address,
|
|
1581
|
+
throw new InvalidContractAddressError(address, addressValidation);
|
|
1562
1582
|
}
|
|
1563
1583
|
const rpc = this.context.withExtensions().rpc;
|
|
1564
1584
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -2306,7 +2326,7 @@ class ContractView {
|
|
|
2306
2326
|
throw new 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.`);
|
|
2307
2327
|
}
|
|
2308
2328
|
else if (chainId && chainIdValidation !== ValidationResult.VALID) {
|
|
2309
|
-
throw new InvalidChainIdError(chainId,
|
|
2329
|
+
throw new InvalidChainIdError(chainId, chainIdValidation);
|
|
2310
2330
|
}
|
|
2311
2331
|
const arg = this.parameterSchema.Encode(...this.args);
|
|
2312
2332
|
const result = yield this.rpc.runView({
|
|
@@ -2744,10 +2764,14 @@ class PrepareProvider extends Provider {
|
|
|
2744
2764
|
if (!publicKey) {
|
|
2745
2765
|
throw new PublicKeyNotFoundError(pkh);
|
|
2746
2766
|
}
|
|
2767
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(pkh, publicKeyHashPrefixes);
|
|
2747
2768
|
ops.unshift(yield createRevealOperation({
|
|
2748
2769
|
fee: getRevealFee(pkh),
|
|
2749
2770
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
2750
2771
|
gasLimit: getRevealGasLimit(pkh),
|
|
2772
|
+
proof: pkhPrefix === PrefixV2.BLS12_381PublicKeyHash
|
|
2773
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
2774
|
+
: undefined,
|
|
2751
2775
|
}, publicKeyHash, publicKey));
|
|
2752
2776
|
return ops;
|
|
2753
2777
|
}
|
|
@@ -2793,6 +2817,7 @@ class PrepareProvider extends Provider {
|
|
|
2793
2817
|
case OpKind.DELEGATION:
|
|
2794
2818
|
case OpKind.REGISTER_GLOBAL_CONSTANT:
|
|
2795
2819
|
case OpKind.UPDATE_CONSENSUS_KEY:
|
|
2820
|
+
case OpKind.UPDATE_COMPANION_KEY:
|
|
2796
2821
|
case OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
2797
2822
|
case OpKind.SMART_ROLLUP_ORIGINATE:
|
|
2798
2823
|
case OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
@@ -2848,17 +2873,31 @@ class PrepareProvider extends Provider {
|
|
|
2848
2873
|
/**
|
|
2849
2874
|
*
|
|
2850
2875
|
* @description Method to prepare a reveal operation
|
|
2851
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
2852
2876
|
* @param operation RPCOperation object or RPCOperation array
|
|
2853
2877
|
* @param source string or undefined source pkh
|
|
2854
2878
|
* @returns a PreparedOperation object
|
|
2855
2879
|
*/
|
|
2856
2880
|
reveal(_a) {
|
|
2857
|
-
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit }) {
|
|
2881
|
+
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit, proof }) {
|
|
2858
2882
|
const { pkh, publicKey } = yield this.getKeys();
|
|
2859
2883
|
if (!publicKey) {
|
|
2860
2884
|
throw new PublicKeyNotFoundError(pkh);
|
|
2861
2885
|
}
|
|
2886
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(pkh, publicKeyHashPrefixes);
|
|
2887
|
+
if (pkhPrefix === PrefixV2.BLS12_381PublicKeyHash) {
|
|
2888
|
+
if (proof) {
|
|
2889
|
+
b58DecodeAndCheckPrefix(proof, [PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
2890
|
+
}
|
|
2891
|
+
else {
|
|
2892
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
2893
|
+
proof = prefixSig;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
else {
|
|
2897
|
+
if (proof) {
|
|
2898
|
+
throw new ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2862
2901
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
2863
2902
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
2864
2903
|
const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
|
|
@@ -2866,6 +2905,7 @@ class PrepareProvider extends Provider {
|
|
|
2866
2905
|
fee: mergedEstimates.fee,
|
|
2867
2906
|
gasLimit: mergedEstimates.gasLimit,
|
|
2868
2907
|
storageLimit: mergedEstimates.storageLimit,
|
|
2908
|
+
proof,
|
|
2869
2909
|
}, pkh, publicKey);
|
|
2870
2910
|
const ops = this.convertIntoArray(op);
|
|
2871
2911
|
const hash = yield this.getBlockHash();
|
|
@@ -3149,7 +3189,6 @@ class PrepareProvider extends Provider {
|
|
|
3149
3189
|
/**
|
|
3150
3190
|
*
|
|
3151
3191
|
* @description Method to prepare an update_consensus_key operation
|
|
3152
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
3153
3192
|
* @param operation RPCOperation object or RPCOperation array
|
|
3154
3193
|
* @param source string or undefined source pkh
|
|
3155
3194
|
* @returns a PreparedOperation object
|
|
@@ -3158,6 +3197,17 @@ class PrepareProvider extends Provider {
|
|
|
3158
3197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3159
3198
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3160
3199
|
const { pkh } = yield this.getKeys();
|
|
3200
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(rest.pk, publicKeyPrefixes);
|
|
3201
|
+
if (pkPrefix === PrefixV2.BLS12_381PublicKey) {
|
|
3202
|
+
if (!rest.proof) {
|
|
3203
|
+
throw new InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
else {
|
|
3207
|
+
if (rest.proof) {
|
|
3208
|
+
throw new ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3161
3211
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3162
3212
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3163
3213
|
const op = yield createUpdateConsensusKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
@@ -3178,6 +3228,44 @@ class PrepareProvider extends Provider {
|
|
|
3178
3228
|
};
|
|
3179
3229
|
});
|
|
3180
3230
|
}
|
|
3231
|
+
/**
|
|
3232
|
+
*
|
|
3233
|
+
* @description Method to prepare an update_companion_key operation
|
|
3234
|
+
* @param operation RPCOperation object or RPCOperation array
|
|
3235
|
+
* @param source string or undefined source pkh
|
|
3236
|
+
* @returns a PreparedOperation object
|
|
3237
|
+
*/
|
|
3238
|
+
updateCompanionKey(_a, source) {
|
|
3239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3240
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3241
|
+
const { pkh } = yield this.getKeys();
|
|
3242
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(rest.pk, publicKeyPrefixes);
|
|
3243
|
+
if (pkPrefix !== PrefixV2.BLS12_381PublicKey) {
|
|
3244
|
+
throw new ProhibitedActionError('companion key must be a bls account');
|
|
3245
|
+
}
|
|
3246
|
+
if (!rest.proof) {
|
|
3247
|
+
throw new InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
3248
|
+
}
|
|
3249
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3250
|
+
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3251
|
+
const op = yield createUpdateCompanionKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
3252
|
+
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
3253
|
+
const ops = this.convertIntoArray(operation);
|
|
3254
|
+
const hash = yield this.getBlockHash();
|
|
3255
|
+
const protocol = yield this.getProtocolHash();
|
|
3256
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
3257
|
+
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
3258
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
3259
|
+
return {
|
|
3260
|
+
opOb: {
|
|
3261
|
+
branch: hash,
|
|
3262
|
+
contents,
|
|
3263
|
+
protocol,
|
|
3264
|
+
},
|
|
3265
|
+
counter: headCounter,
|
|
3266
|
+
};
|
|
3267
|
+
});
|
|
3268
|
+
}
|
|
3181
3269
|
/**
|
|
3182
3270
|
*
|
|
3183
3271
|
* @description Method to prepare an increase_paid_storage operation
|
|
@@ -3468,10 +3556,14 @@ class PrepareProvider extends Provider {
|
|
|
3468
3556
|
if (!publicKey) {
|
|
3469
3557
|
throw new PublicKeyNotFoundError(pkh);
|
|
3470
3558
|
}
|
|
3559
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(pkh, publicKeyHashPrefixes);
|
|
3471
3560
|
ops.unshift(yield createRevealOperation({
|
|
3472
3561
|
fee: getRevealFee(pkh),
|
|
3473
3562
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
3474
3563
|
gasLimit: getRevealGasLimit(pkh),
|
|
3564
|
+
proof: pkhPrefix === PrefixV2.BLS12_381PublicKeyHash
|
|
3565
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
3566
|
+
: undefined,
|
|
3475
3567
|
}, pkh, publicKey));
|
|
3476
3568
|
}
|
|
3477
3569
|
const hash = yield this.getBlockHash();
|
|
@@ -3588,7 +3680,7 @@ class OperationBatch extends Provider {
|
|
|
3588
3680
|
throw new InvalidAmountError(params.amount.toString());
|
|
3589
3681
|
}
|
|
3590
3682
|
if (toValidation !== ValidationResult.VALID) {
|
|
3591
|
-
throw new InvalidAddressError(params.to,
|
|
3683
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
3592
3684
|
}
|
|
3593
3685
|
this.operations.push(Object.assign({ kind: OpKind.TRANSACTION }, params));
|
|
3594
3686
|
return this;
|
|
@@ -3602,7 +3694,7 @@ class OperationBatch extends Provider {
|
|
|
3602
3694
|
withTransferTicket(params) {
|
|
3603
3695
|
const destinationValidation = validateAddress(params.destination);
|
|
3604
3696
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
3605
|
-
throw new InvalidAddressError(params.destination,
|
|
3697
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
3606
3698
|
}
|
|
3607
3699
|
this.operations.push(Object.assign({ kind: OpKind.TRANSFER_TICKET }, params));
|
|
3608
3700
|
return this;
|
|
@@ -3627,11 +3719,11 @@ class OperationBatch extends Provider {
|
|
|
3627
3719
|
var _a;
|
|
3628
3720
|
const sourceValidation = validateAddress(params.source);
|
|
3629
3721
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
3630
|
-
throw new InvalidAddressError(params.source,
|
|
3722
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
3631
3723
|
}
|
|
3632
3724
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
3633
3725
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
3634
|
-
throw new InvalidAddressError(params.delegate,
|
|
3726
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
3635
3727
|
}
|
|
3636
3728
|
this.operations.push(Object.assign({ kind: OpKind.DELEGATION }, params));
|
|
3637
3729
|
return this;
|
|
@@ -3646,7 +3738,7 @@ class OperationBatch extends Provider {
|
|
|
3646
3738
|
withActivation({ pkh, secret }) {
|
|
3647
3739
|
const pkhValidation = validateKeyHash(pkh);
|
|
3648
3740
|
if (pkhValidation !== ValidationResult.VALID) {
|
|
3649
|
-
throw new InvalidKeyHashError(pkh,
|
|
3741
|
+
throw new InvalidKeyHashError(pkh, pkhValidation);
|
|
3650
3742
|
}
|
|
3651
3743
|
this.operations.push({ kind: OpKind.ACTIVATION, pkh, secret });
|
|
3652
3744
|
return this;
|
|
@@ -3681,6 +3773,44 @@ class OperationBatch extends Provider {
|
|
|
3681
3773
|
this.operations.push(Object.assign({ kind: OpKind.INCREASE_PAID_STORAGE }, params));
|
|
3682
3774
|
return this;
|
|
3683
3775
|
}
|
|
3776
|
+
/**
|
|
3777
|
+
*
|
|
3778
|
+
* @description Add a update consensus key operation to the batch
|
|
3779
|
+
*
|
|
3780
|
+
* @param params UpdateConsensusKey operation parameter
|
|
3781
|
+
*/
|
|
3782
|
+
withUpdateConsensusKey(params) {
|
|
3783
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(params.pk, publicKeyPrefixes);
|
|
3784
|
+
if (pkPrefix === PrefixV2.BLS12_381PublicKey) {
|
|
3785
|
+
if (!params.proof) {
|
|
3786
|
+
throw new InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
else {
|
|
3790
|
+
if (params.proof) {
|
|
3791
|
+
throw new ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
this.operations.push(Object.assign({ kind: OpKind.UPDATE_CONSENSUS_KEY }, params));
|
|
3795
|
+
return this;
|
|
3796
|
+
}
|
|
3797
|
+
/**
|
|
3798
|
+
*
|
|
3799
|
+
* @description Add a update companion key operation to the batch
|
|
3800
|
+
*
|
|
3801
|
+
* @param params UpdateCompanionKey operation parameter
|
|
3802
|
+
*/
|
|
3803
|
+
withUpdateCompanionKey(params) {
|
|
3804
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(params.pk, publicKeyPrefixes);
|
|
3805
|
+
if (pkPrefix !== PrefixV2.BLS12_381PublicKey) {
|
|
3806
|
+
throw new ProhibitedActionError('companion key must be a bls account');
|
|
3807
|
+
}
|
|
3808
|
+
if (!params.proof) {
|
|
3809
|
+
throw new InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
3810
|
+
}
|
|
3811
|
+
this.operations.push(Object.assign({ kind: OpKind.UPDATE_COMPANION_KEY }, params));
|
|
3812
|
+
return this;
|
|
3813
|
+
}
|
|
3684
3814
|
/**
|
|
3685
3815
|
*
|
|
3686
3816
|
* @description Add a smart rollup add messages operation to the batch
|
|
@@ -3724,6 +3854,10 @@ class OperationBatch extends Provider {
|
|
|
3724
3854
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
3725
3855
|
case OpKind.INCREASE_PAID_STORAGE:
|
|
3726
3856
|
return createIncreasePaidStorageOperation(Object.assign({}, param));
|
|
3857
|
+
case OpKind.UPDATE_CONSENSUS_KEY:
|
|
3858
|
+
return createUpdateConsensusKeyOperation(Object.assign({}, param));
|
|
3859
|
+
case OpKind.UPDATE_COMPANION_KEY:
|
|
3860
|
+
return createUpdateCompanionKeyOperation(Object.assign({}, param));
|
|
3727
3861
|
case OpKind.TRANSFER_TICKET:
|
|
3728
3862
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
3729
3863
|
case OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -4020,7 +4154,7 @@ class RpcTzProvider extends Provider {
|
|
|
4020
4154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4021
4155
|
const addressValidation = validateAddress(address);
|
|
4022
4156
|
if (addressValidation !== ValidationResult.VALID) {
|
|
4023
|
-
throw new InvalidAddressError(address,
|
|
4157
|
+
throw new InvalidAddressError(address, addressValidation);
|
|
4024
4158
|
}
|
|
4025
4159
|
return this.context.readProvider.getBalance(address, 'head');
|
|
4026
4160
|
});
|
|
@@ -4029,7 +4163,7 @@ class RpcTzProvider extends Provider {
|
|
|
4029
4163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4030
4164
|
const addressValidation = validateAddress(address);
|
|
4031
4165
|
if (addressValidation !== ValidationResult.VALID) {
|
|
4032
|
-
throw new InvalidAddressError(address,
|
|
4166
|
+
throw new InvalidAddressError(address, addressValidation);
|
|
4033
4167
|
}
|
|
4034
4168
|
return this.context.readProvider.getSpendable(address, 'head');
|
|
4035
4169
|
});
|
|
@@ -4038,7 +4172,7 @@ class RpcTzProvider extends Provider {
|
|
|
4038
4172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4039
4173
|
const addressValidation = validateAddress(address);
|
|
4040
4174
|
if (addressValidation !== ValidationResult.VALID) {
|
|
4041
|
-
throw new InvalidAddressError(address,
|
|
4175
|
+
throw new InvalidAddressError(address, addressValidation);
|
|
4042
4176
|
}
|
|
4043
4177
|
return this.context.readProvider.getDelegate(address, 'head');
|
|
4044
4178
|
});
|
|
@@ -4047,7 +4181,7 @@ class RpcTzProvider extends Provider {
|
|
|
4047
4181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4048
4182
|
const pkhValidation = validateKeyHash(pkh);
|
|
4049
4183
|
if (pkhValidation !== ValidationResult.VALID) {
|
|
4050
|
-
throw new InvalidKeyHashError$1(pkh,
|
|
4184
|
+
throw new InvalidKeyHashError$1(pkh, pkhValidation);
|
|
4051
4185
|
}
|
|
4052
4186
|
const prepared = yield this.prepare.activate({ pkh, secret });
|
|
4053
4187
|
const forgedBytes = yield this.forge(prepared);
|
|
@@ -4201,7 +4335,8 @@ const STUB_SIGNATURE = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfL
|
|
|
4201
4335
|
class RPCEstimateProvider extends Provider {
|
|
4202
4336
|
constructor() {
|
|
4203
4337
|
super(...arguments);
|
|
4204
|
-
this.
|
|
4338
|
+
this.REVEAL_LENGTH = 324; // injecting size tz1=320, tz2=322, tz3=322
|
|
4339
|
+
this.REVEAL_LENGTH_TZ4 = 622; // injecting size tz4=620
|
|
4205
4340
|
this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
|
|
4206
4341
|
this.STORAGE_BUFFER = 20; // according to octez-client
|
|
4207
4342
|
this.prepare = new PrepareProvider(this.context);
|
|
@@ -4283,9 +4418,20 @@ class RPCEstimateProvider extends Provider {
|
|
|
4283
4418
|
: op.opOb.contents.length;
|
|
4284
4419
|
}
|
|
4285
4420
|
return opResponse.contents.map((x) => {
|
|
4421
|
+
const content = x;
|
|
4422
|
+
content.source = content.source || '';
|
|
4423
|
+
let revealSize, eachOpSize;
|
|
4424
|
+
if (content.source.startsWith(PrefixV2.BLS12_381PublicKeyHash)) {
|
|
4425
|
+
revealSize = this.REVEAL_LENGTH_TZ4 / 2;
|
|
4426
|
+
eachOpSize = (opbytes.length / 2 + payloadLength[PrefixV2.BLS12_381Signature]) / numberOfOps;
|
|
4427
|
+
}
|
|
4428
|
+
else {
|
|
4429
|
+
revealSize = this.REVEAL_LENGTH / 2;
|
|
4430
|
+
eachOpSize = (opbytes.length / 2 + payloadLength[PrefixV2.Ed25519Signature]) / numberOfOps;
|
|
4431
|
+
}
|
|
4286
4432
|
return this.getEstimationPropertiesFromOperationContent(x,
|
|
4287
4433
|
// diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
|
|
4288
|
-
x.kind === 'reveal' ?
|
|
4434
|
+
x.kind === 'reveal' ? revealSize : eachOpSize, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
|
|
4289
4435
|
);
|
|
4290
4436
|
});
|
|
4291
4437
|
});
|
|
@@ -4304,8 +4450,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4304
4450
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4305
4451
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4306
4452
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4453
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4454
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4455
|
+
: this.REVEAL_LENGTH / 2;
|
|
4307
4456
|
estimateProperties.shift();
|
|
4308
|
-
estimateProperties[0].opSize -=
|
|
4457
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4309
4458
|
}
|
|
4310
4459
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4311
4460
|
});
|
|
@@ -4324,11 +4473,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4324
4473
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4325
4474
|
const toValidation = validateAddress(rest.to);
|
|
4326
4475
|
if (toValidation !== ValidationResult.VALID) {
|
|
4327
|
-
throw new InvalidAddressError(rest.to,
|
|
4476
|
+
throw new InvalidAddressError(rest.to, toValidation);
|
|
4328
4477
|
}
|
|
4329
4478
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4330
4479
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4331
|
-
throw new InvalidAddressError(rest.source,
|
|
4480
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4332
4481
|
}
|
|
4333
4482
|
if (rest.amount < 0) {
|
|
4334
4483
|
throw new InvalidAmountError(rest.amount.toString());
|
|
@@ -4339,8 +4488,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4339
4488
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4340
4489
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4341
4490
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4491
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4492
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4493
|
+
: this.REVEAL_LENGTH / 2;
|
|
4342
4494
|
estimateProperties.shift();
|
|
4343
|
-
estimateProperties[0].opSize -=
|
|
4495
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4344
4496
|
}
|
|
4345
4497
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4346
4498
|
});
|
|
@@ -4359,7 +4511,7 @@ class RPCEstimateProvider extends Provider {
|
|
|
4359
4511
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4360
4512
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4361
4513
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4362
|
-
throw new InvalidAddressError(rest.source,
|
|
4514
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4363
4515
|
}
|
|
4364
4516
|
if (!rest.to) {
|
|
4365
4517
|
rest.to = rest.source;
|
|
@@ -4377,7 +4529,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4377
4529
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4378
4530
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4379
4531
|
estimateProperties.shift();
|
|
4380
|
-
|
|
4532
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4533
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4534
|
+
: this.REVEAL_LENGTH / 2;
|
|
4535
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4381
4536
|
}
|
|
4382
4537
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4383
4538
|
});
|
|
@@ -4396,7 +4551,7 @@ class RPCEstimateProvider extends Provider {
|
|
|
4396
4551
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4397
4552
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4398
4553
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4399
|
-
throw new InvalidAddressError(rest.source,
|
|
4554
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4400
4555
|
}
|
|
4401
4556
|
if (!rest.to) {
|
|
4402
4557
|
rest.to = rest.source;
|
|
@@ -4414,7 +4569,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4414
4569
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4415
4570
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4416
4571
|
estimateProperties.shift();
|
|
4417
|
-
|
|
4572
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4573
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4574
|
+
: this.REVEAL_LENGTH / 2;
|
|
4575
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4418
4576
|
}
|
|
4419
4577
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4420
4578
|
});
|
|
@@ -4433,7 +4591,7 @@ class RPCEstimateProvider extends Provider {
|
|
|
4433
4591
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4434
4592
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4435
4593
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4436
|
-
throw new InvalidAddressError(rest.source,
|
|
4594
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4437
4595
|
}
|
|
4438
4596
|
if (!rest.to) {
|
|
4439
4597
|
rest.to = rest.source;
|
|
@@ -4451,7 +4609,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4451
4609
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4452
4610
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4453
4611
|
estimateProperties.shift();
|
|
4454
|
-
|
|
4612
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4613
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4614
|
+
: this.REVEAL_LENGTH / 2;
|
|
4615
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4455
4616
|
}
|
|
4456
4617
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4457
4618
|
});
|
|
@@ -4470,11 +4631,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4470
4631
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4471
4632
|
const destinationValidation = validateAddress(rest.destination);
|
|
4472
4633
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
4473
|
-
throw new InvalidAddressError(rest.destination,
|
|
4634
|
+
throw new InvalidAddressError(rest.destination, destinationValidation);
|
|
4474
4635
|
}
|
|
4475
4636
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4476
4637
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4477
|
-
throw new InvalidAddressError(rest.source,
|
|
4638
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4478
4639
|
}
|
|
4479
4640
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4480
4641
|
const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
|
|
@@ -4483,7 +4644,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4483
4644
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4484
4645
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4485
4646
|
estimateProperties.shift();
|
|
4486
|
-
|
|
4647
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4648
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4649
|
+
: this.REVEAL_LENGTH / 2;
|
|
4650
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4487
4651
|
}
|
|
4488
4652
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4489
4653
|
});
|
|
@@ -4502,11 +4666,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4502
4666
|
var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
|
|
4503
4667
|
const sourceValidation = validateAddress(rest.source);
|
|
4504
4668
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4505
|
-
throw new InvalidAddressError(rest.source,
|
|
4669
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4506
4670
|
}
|
|
4507
4671
|
const delegateValidation = validateAddress((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
|
|
4508
4672
|
if (rest.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
4509
|
-
throw new InvalidAddressError(rest.delegate,
|
|
4673
|
+
throw new InvalidAddressError(rest.delegate, delegateValidation);
|
|
4510
4674
|
}
|
|
4511
4675
|
const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
|
|
4512
4676
|
storageLimit,
|
|
@@ -4515,7 +4679,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4515
4679
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4516
4680
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4517
4681
|
estimateProperties.shift();
|
|
4518
|
-
|
|
4682
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4683
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4684
|
+
: this.REVEAL_LENGTH / 2;
|
|
4685
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4519
4686
|
}
|
|
4520
4687
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4521
4688
|
});
|
|
@@ -4552,7 +4719,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4552
4719
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4553
4720
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4554
4721
|
estimateProperties.shift();
|
|
4555
|
-
|
|
4722
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4723
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4724
|
+
: this.REVEAL_LENGTH / 2;
|
|
4725
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4556
4726
|
}
|
|
4557
4727
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4558
4728
|
});
|
|
@@ -4560,7 +4730,6 @@ class RPCEstimateProvider extends Provider {
|
|
|
4560
4730
|
/**
|
|
4561
4731
|
*
|
|
4562
4732
|
* @description Estimate gasLimit, storageLimit and fees to reveal the current account
|
|
4563
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
4564
4733
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
|
|
4565
4734
|
*
|
|
4566
4735
|
* @param Estimate
|
|
@@ -4572,6 +4741,21 @@ class RPCEstimateProvider extends Provider {
|
|
|
4572
4741
|
throw new RevealEstimateError();
|
|
4573
4742
|
}
|
|
4574
4743
|
if (yield this.isAccountRevealRequired(publicKeyHash)) {
|
|
4744
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(publicKeyHash, publicKeyHashPrefixes);
|
|
4745
|
+
if (pkhPrefix === PrefixV2.BLS12_381PublicKeyHash) {
|
|
4746
|
+
if (params && params.proof) {
|
|
4747
|
+
b58DecodeAndCheckPrefix(params.proof, [PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
4748
|
+
}
|
|
4749
|
+
else {
|
|
4750
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
4751
|
+
params = Object.assign(Object.assign({}, params), { proof: prefixSig });
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
else {
|
|
4755
|
+
if (params && params.proof) {
|
|
4756
|
+
throw new ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4575
4759
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4576
4760
|
const preparedOperation = params
|
|
4577
4761
|
? yield this.prepare.reveal(params)
|
|
@@ -4599,7 +4783,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4599
4783
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4600
4784
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4601
4785
|
estimateProperties.shift();
|
|
4602
|
-
|
|
4786
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4787
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4788
|
+
: this.REVEAL_LENGTH / 2;
|
|
4789
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4603
4790
|
}
|
|
4604
4791
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4605
4792
|
});
|
|
@@ -4625,7 +4812,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4625
4812
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4626
4813
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4627
4814
|
estimateProperties.shift();
|
|
4628
|
-
|
|
4815
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4816
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4817
|
+
: this.REVEAL_LENGTH / 2;
|
|
4818
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4629
4819
|
}
|
|
4630
4820
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4631
4821
|
});
|
|
@@ -4633,18 +4823,59 @@ class RPCEstimateProvider extends Provider {
|
|
|
4633
4823
|
/**
|
|
4634
4824
|
*
|
|
4635
4825
|
* @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
|
|
4636
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
4637
4826
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4638
4827
|
* @param Estimate
|
|
4639
4828
|
*/
|
|
4640
4829
|
updateConsensusKey(params) {
|
|
4641
4830
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4831
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(params.pk, publicKeyPrefixes);
|
|
4832
|
+
if (pkPrefix === PrefixV2.BLS12_381PublicKey) {
|
|
4833
|
+
if (!params.proof) {
|
|
4834
|
+
throw new InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
else {
|
|
4838
|
+
if (params.proof) {
|
|
4839
|
+
throw new ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4642
4842
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4643
4843
|
const preparedOperation = yield this.prepare.updateConsensusKey(params);
|
|
4644
4844
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4645
4845
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4646
4846
|
estimateProperties.shift();
|
|
4647
|
-
|
|
4847
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4848
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4849
|
+
: this.REVEAL_LENGTH / 2;
|
|
4850
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4851
|
+
}
|
|
4852
|
+
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
/**
|
|
4856
|
+
*
|
|
4857
|
+
* @description Estimate gasLimit, storageLimit and fees for an Update Companion Key operation
|
|
4858
|
+
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4859
|
+
* @param Estimate
|
|
4860
|
+
*/
|
|
4861
|
+
updateCompanionKey(params) {
|
|
4862
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4863
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(params.pk, publicKeyPrefixes);
|
|
4864
|
+
if (pkPrefix !== PrefixV2.BLS12_381PublicKey) {
|
|
4865
|
+
throw new ProhibitedActionError('companion key must be a bls account');
|
|
4866
|
+
}
|
|
4867
|
+
if (!params.proof) {
|
|
4868
|
+
throw new InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
4869
|
+
}
|
|
4870
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4871
|
+
const preparedOperation = yield this.prepare.updateCompanionKey(params);
|
|
4872
|
+
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4873
|
+
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4874
|
+
estimateProperties.shift();
|
|
4875
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4876
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4877
|
+
: this.REVEAL_LENGTH / 2;
|
|
4878
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4648
4879
|
}
|
|
4649
4880
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4650
4881
|
});
|
|
@@ -4664,7 +4895,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4664
4895
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4665
4896
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4666
4897
|
estimateProperties.shift();
|
|
4667
|
-
|
|
4898
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4899
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4900
|
+
: this.REVEAL_LENGTH / 2;
|
|
4901
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4668
4902
|
}
|
|
4669
4903
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4670
4904
|
});
|
|
@@ -4684,7 +4918,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4684
4918
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4685
4919
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4686
4920
|
estimateProperties.shift();
|
|
4687
|
-
|
|
4921
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4922
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4923
|
+
: this.REVEAL_LENGTH / 2;
|
|
4924
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4688
4925
|
}
|
|
4689
4926
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4690
4927
|
});
|
|
@@ -4723,7 +4960,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4723
4960
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4724
4961
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4725
4962
|
estimateProperties.shift();
|
|
4726
|
-
|
|
4963
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(PrefixV2.BLS12_381PublicKeyHash)
|
|
4964
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4965
|
+
: this.REVEAL_LENGTH / 2;
|
|
4966
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4727
4967
|
}
|
|
4728
4968
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4729
4969
|
});
|
|
@@ -4941,6 +5181,14 @@ class RevealOperation extends Operation {
|
|
|
4941
5181
|
get publicKey() {
|
|
4942
5182
|
return this.params.public_key;
|
|
4943
5183
|
}
|
|
5184
|
+
get proof() {
|
|
5185
|
+
if (this.params.proof) {
|
|
5186
|
+
return this.params.proof;
|
|
5187
|
+
}
|
|
5188
|
+
else {
|
|
5189
|
+
throw new ProhibitedActionError('Only BLS key has proof');
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
4944
5192
|
sumProp(arr, prop) {
|
|
4945
5193
|
return arr.reduce((prev, current) => {
|
|
4946
5194
|
return prop in current ? Number(current[prop]) + prev : prev;
|
|
@@ -5111,6 +5359,67 @@ class UpdateConsensusKeyOperation extends Operation {
|
|
|
5111
5359
|
get pk() {
|
|
5112
5360
|
return this.params.pk;
|
|
5113
5361
|
}
|
|
5362
|
+
get proof() {
|
|
5363
|
+
if (this.params.proof) {
|
|
5364
|
+
return this.params.proof;
|
|
5365
|
+
}
|
|
5366
|
+
else {
|
|
5367
|
+
throw new ProhibitedActionError('Only updating consensus key to a BLS account has proof');
|
|
5368
|
+
}
|
|
5369
|
+
}
|
|
5370
|
+
get consumedMilliGas() {
|
|
5371
|
+
var _a;
|
|
5372
|
+
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
5373
|
+
}
|
|
5374
|
+
get errors() {
|
|
5375
|
+
var _a;
|
|
5376
|
+
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.errors;
|
|
5377
|
+
}
|
|
5378
|
+
}
|
|
5379
|
+
|
|
5380
|
+
/**
|
|
5381
|
+
*
|
|
5382
|
+
* @description UpdateCompanionKeyOperation provides utility to fetch properties for Operation of kind UpdateCompanionKey
|
|
5383
|
+
*
|
|
5384
|
+
*/
|
|
5385
|
+
class UpdateCompanionKeyOperation extends Operation {
|
|
5386
|
+
constructor(hash, params, source, raw, results, context) {
|
|
5387
|
+
super(hash, raw, results, context);
|
|
5388
|
+
this.params = params;
|
|
5389
|
+
this.source = source;
|
|
5390
|
+
}
|
|
5391
|
+
get operationResults() {
|
|
5392
|
+
const updateCompanionKeyOp = Array.isArray(this.results) &&
|
|
5393
|
+
this.results.find((op) => op.kind === 'update_companion_key');
|
|
5394
|
+
const result = updateCompanionKeyOp &&
|
|
5395
|
+
updateCompanionKeyOp.metadata &&
|
|
5396
|
+
updateCompanionKeyOp.metadata.operation_result;
|
|
5397
|
+
return result ? result : undefined;
|
|
5398
|
+
}
|
|
5399
|
+
get status() {
|
|
5400
|
+
var _a, _b;
|
|
5401
|
+
return (_b = (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'unknown';
|
|
5402
|
+
}
|
|
5403
|
+
get fee() {
|
|
5404
|
+
return Number(this.params.fee);
|
|
5405
|
+
}
|
|
5406
|
+
get gasLimit() {
|
|
5407
|
+
return Number(this.params.gas_limit);
|
|
5408
|
+
}
|
|
5409
|
+
get storageLimit() {
|
|
5410
|
+
return Number(this.params.storage_limit);
|
|
5411
|
+
}
|
|
5412
|
+
get pk() {
|
|
5413
|
+
return this.params.pk;
|
|
5414
|
+
}
|
|
5415
|
+
get proof() {
|
|
5416
|
+
if (this.params.proof) {
|
|
5417
|
+
return this.params.proof;
|
|
5418
|
+
}
|
|
5419
|
+
else {
|
|
5420
|
+
throw new ProhibitedActionError('Only updating companion key to a BLS account has proof');
|
|
5421
|
+
}
|
|
5422
|
+
}
|
|
5114
5423
|
get consumedMilliGas() {
|
|
5115
5424
|
var _a;
|
|
5116
5425
|
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
@@ -5408,7 +5717,7 @@ class RpcContractProvider extends Provider {
|
|
|
5408
5717
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5409
5718
|
const contractValidation = validateContractAddress(contract);
|
|
5410
5719
|
if (contractValidation !== ValidationResult.VALID) {
|
|
5411
|
-
throw new InvalidContractAddressError(contract,
|
|
5720
|
+
throw new InvalidContractAddressError(contract, contractValidation);
|
|
5412
5721
|
}
|
|
5413
5722
|
const script = yield this.context.readProvider.getScript(contract, 'head');
|
|
5414
5723
|
if (!schema) {
|
|
@@ -5440,7 +5749,7 @@ class RpcContractProvider extends Provider {
|
|
|
5440
5749
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5441
5750
|
const contractValidation = validateContractAddress(contract);
|
|
5442
5751
|
if (contractValidation !== ValidationResult.VALID) {
|
|
5443
|
-
throw new InvalidContractAddressError(contract,
|
|
5752
|
+
throw new InvalidContractAddressError(contract, contractValidation);
|
|
5444
5753
|
}
|
|
5445
5754
|
if (!schema) {
|
|
5446
5755
|
schema = (yield this.rpc.getContract(contract)).script;
|
|
@@ -5584,11 +5893,11 @@ class RpcContractProvider extends Provider {
|
|
|
5584
5893
|
var _a;
|
|
5585
5894
|
const sourceValidation = validateAddress(params.source);
|
|
5586
5895
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5587
|
-
throw new InvalidAddressError(params.source,
|
|
5896
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5588
5897
|
}
|
|
5589
5898
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
5590
5899
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
5591
|
-
throw new InvalidAddressError(params.delegate,
|
|
5900
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
5592
5901
|
}
|
|
5593
5902
|
// Since babylon delegation source cannot smart contract
|
|
5594
5903
|
if (/^kt1/i.test(params.source)) {
|
|
@@ -5636,11 +5945,11 @@ class RpcContractProvider extends Provider {
|
|
|
5636
5945
|
var _a;
|
|
5637
5946
|
const toValidation = validateAddress(params.to);
|
|
5638
5947
|
if (toValidation !== ValidationResult.VALID) {
|
|
5639
|
-
throw new InvalidAddressError(params.to,
|
|
5948
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
5640
5949
|
}
|
|
5641
5950
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5642
5951
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5643
|
-
throw new InvalidAddressError(params.source,
|
|
5952
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5644
5953
|
}
|
|
5645
5954
|
if (params.amount < 0) {
|
|
5646
5955
|
throw new InvalidAmountError(params.amount.toString());
|
|
@@ -5668,7 +5977,7 @@ class RpcContractProvider extends Provider {
|
|
|
5668
5977
|
var _a;
|
|
5669
5978
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5670
5979
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5671
|
-
throw new InvalidAddressError(params.source,
|
|
5980
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5672
5981
|
}
|
|
5673
5982
|
if (!params.to) {
|
|
5674
5983
|
params.to = params.source;
|
|
@@ -5704,7 +6013,7 @@ class RpcContractProvider extends Provider {
|
|
|
5704
6013
|
var _a;
|
|
5705
6014
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5706
6015
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5707
|
-
throw new InvalidAddressError(params.source,
|
|
6016
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5708
6017
|
}
|
|
5709
6018
|
if (!params.to) {
|
|
5710
6019
|
params.to = params.source;
|
|
@@ -5737,7 +6046,7 @@ class RpcContractProvider extends Provider {
|
|
|
5737
6046
|
var _a;
|
|
5738
6047
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5739
6048
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5740
|
-
throw new InvalidAddressError(params.source,
|
|
6049
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5741
6050
|
}
|
|
5742
6051
|
if (!params.to) {
|
|
5743
6052
|
params.to = params.source;
|
|
@@ -5771,11 +6080,11 @@ class RpcContractProvider extends Provider {
|
|
|
5771
6080
|
var _a, _b;
|
|
5772
6081
|
const destinationValidation = validateAddress(params.destination);
|
|
5773
6082
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
5774
|
-
throw new InvalidAddressError(params.destination,
|
|
6083
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
5775
6084
|
}
|
|
5776
6085
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5777
6086
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5778
|
-
throw new InvalidAddressError(params.source,
|
|
6087
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5779
6088
|
}
|
|
5780
6089
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5781
6090
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
@@ -5790,7 +6099,6 @@ class RpcContractProvider extends Provider {
|
|
|
5790
6099
|
/**
|
|
5791
6100
|
*
|
|
5792
6101
|
* @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
|
|
5793
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
5794
6102
|
* @returns An operation handle with the result from the rpc node
|
|
5795
6103
|
*
|
|
5796
6104
|
* @param RevealParams operation parameter
|
|
@@ -5798,6 +6106,21 @@ class RpcContractProvider extends Provider {
|
|
|
5798
6106
|
reveal(params) {
|
|
5799
6107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5800
6108
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6109
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(publicKeyHash, publicKeyHashPrefixes);
|
|
6110
|
+
if (pkhPrefix === PrefixV2.BLS12_381PublicKeyHash) {
|
|
6111
|
+
if (params.proof) {
|
|
6112
|
+
b58DecodeAndCheckPrefix(params.proof, [PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
6113
|
+
}
|
|
6114
|
+
else {
|
|
6115
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
6116
|
+
params.proof = prefixSig;
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
else {
|
|
6120
|
+
if (params.proof) {
|
|
6121
|
+
throw new ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
6122
|
+
}
|
|
6123
|
+
}
|
|
5801
6124
|
const estimateReveal = yield this.estimator.reveal(params);
|
|
5802
6125
|
if (estimateReveal) {
|
|
5803
6126
|
const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
|
|
@@ -5884,7 +6207,7 @@ class RpcContractProvider extends Provider {
|
|
|
5884
6207
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5885
6208
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5886
6209
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5887
|
-
throw new InvalidAddressError(params.source,
|
|
6210
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5888
6211
|
}
|
|
5889
6212
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5890
6213
|
const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5908,7 +6231,7 @@ class RpcContractProvider extends Provider {
|
|
|
5908
6231
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5909
6232
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5910
6233
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5911
|
-
throw new InvalidAddressError(params.source,
|
|
6234
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5912
6235
|
}
|
|
5913
6236
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5914
6237
|
const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5920,8 +6243,7 @@ class RpcContractProvider extends Provider {
|
|
|
5920
6243
|
}
|
|
5921
6244
|
/**
|
|
5922
6245
|
*
|
|
5923
|
-
* @description
|
|
5924
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
6246
|
+
* @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
|
|
5925
6247
|
* @returns An operation handle with the result from the rpc node
|
|
5926
6248
|
*
|
|
5927
6249
|
* @param UpdateConsensusKeyParams
|
|
@@ -5929,6 +6251,17 @@ class RpcContractProvider extends Provider {
|
|
|
5929
6251
|
updateConsensusKey(params) {
|
|
5930
6252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5931
6253
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6254
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(params.pk, publicKeyPrefixes);
|
|
6255
|
+
if (pkPrefix === PrefixV2.BLS12_381PublicKey) {
|
|
6256
|
+
if (!params.proof) {
|
|
6257
|
+
throw new InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
else {
|
|
6261
|
+
if (params.proof) {
|
|
6262
|
+
throw new ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
6263
|
+
}
|
|
6264
|
+
}
|
|
5932
6265
|
const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
|
|
5933
6266
|
const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
|
|
5934
6267
|
const content = prepared.opOb.contents.find((op) => op.kind === OpKind.UPDATE_CONSENSUS_KEY);
|
|
@@ -5937,6 +6270,31 @@ class RpcContractProvider extends Provider {
|
|
|
5937
6270
|
return new UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
5938
6271
|
});
|
|
5939
6272
|
}
|
|
6273
|
+
/**
|
|
6274
|
+
*
|
|
6275
|
+
* @description Updates the companion key of the delegate starting from the current cycle plus CONSENSUS_KEY_ACTIVATION_DELAY + 1
|
|
6276
|
+
* @returns An operation handle with the result from the rpc node
|
|
6277
|
+
*
|
|
6278
|
+
* @param UpdateCompanionKeyParams
|
|
6279
|
+
*/
|
|
6280
|
+
updateCompanionKey(params) {
|
|
6281
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6282
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6283
|
+
const [, pkPrefix] = b58DecodeAndCheckPrefix(params.pk, publicKeyPrefixes);
|
|
6284
|
+
if (pkPrefix !== PrefixV2.BLS12_381PublicKey) {
|
|
6285
|
+
throw new ProhibitedActionError('Proof field is only allowed for a bls account as companion key');
|
|
6286
|
+
}
|
|
6287
|
+
if (!params.proof) {
|
|
6288
|
+
throw new InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
6289
|
+
}
|
|
6290
|
+
const estimate = yield this.estimate(params, this.estimator.updateCompanionKey.bind(this.estimator));
|
|
6291
|
+
const prepared = yield this.prepare.updateCompanionKey(Object.assign(Object.assign({}, params), estimate));
|
|
6292
|
+
const content = prepared.opOb.contents.find((op) => op.kind === OpKind.UPDATE_COMPANION_KEY);
|
|
6293
|
+
const opBytes = yield this.forge(prepared);
|
|
6294
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
6295
|
+
return new UpdateCompanionKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
6296
|
+
});
|
|
6297
|
+
}
|
|
5940
6298
|
/**
|
|
5941
6299
|
* @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
|
|
5942
6300
|
* @param SmartRollupAddMessagesParams
|
|
@@ -6031,7 +6389,7 @@ class RpcContractProvider extends Provider {
|
|
|
6031
6389
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
6032
6390
|
const addressValidation = validateContractAddress(address);
|
|
6033
6391
|
if (addressValidation !== ValidationResult.VALID) {
|
|
6034
|
-
throw new InvalidContractAddressError(address,
|
|
6392
|
+
throw new InvalidContractAddressError(address, addressValidation);
|
|
6035
6393
|
}
|
|
6036
6394
|
const rpc = this.context.withExtensions().rpc;
|
|
6037
6395
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -6900,8 +7258,8 @@ class Context {
|
|
|
6900
7258
|
|
|
6901
7259
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
6902
7260
|
const VERSION = {
|
|
6903
|
-
"commitHash": "
|
|
6904
|
-
"version": "23.0.0-beta.
|
|
7261
|
+
"commitHash": "10b3de10de15ae68d47b1fca922d3129d2f79641",
|
|
7262
|
+
"version": "23.0.0-beta.1"
|
|
6905
7263
|
};
|
|
6906
7264
|
|
|
6907
7265
|
/**
|
|
@@ -7349,5 +7707,5 @@ class TezosToolkit {
|
|
|
7349
7707
|
}
|
|
7350
7708
|
}
|
|
7351
7709
|
|
|
7352
|
-
export { BallotOperation, BatchOperation, BigMapAbstraction, COST_PER_BYTE, ChainIds, CompositeForger, Context, ContractAbstraction, ContractMethod, ContractMethodObject, ContractView, DEFAULT_FEE, DEFAULT_GAS_LIMIT, DEFAULT_SMART_CONTRACT_METHOD_NAME, DEFAULT_STORAGE_LIMIT, DefaultGlobalConstantsProvider, DelegateOperation, DelegationWalletOperation, DrainDelegateOperation, Estimate, GlobalConstantNotFound, IncreasePaidStorageOperation, InvalidBalanceError, InvalidCodeParameter, InvalidDelegationSource, InvalidEstimateValueError, InvalidInitParameter, InvalidParameterError, InvalidViewSimulationContext, LegacyWalletProvider, MANAGER_LAMBDA, MichelCodecPacker, MichelCodecParser, NoopParser, ORIGINATION_SIZE, ObservableSubscription, Operation, OperationBatch, OriginationOperation, OriginationParameterError, OriginationWalletOperation, PollingSubscribeProvider, PrepareProvider, ProposalsOperation, Protocols, REVEAL_STORAGE_LIMIT, RPCEstimateProvider, RegisterGlobalConstantOperation, RevealEstimateError, RevealOperation, RevealOperationError, RpcForger, RpcInjector, RpcPacker, RpcReadAdapter, SaplingStateAbstraction, SmartRollupAddMessagesOperation, SmartRollupOriginateOperation, TaquitoLocalForger, TezosOperationError, TezosPreapplyFailureError, TezosToolkit, TransactionOperation, TransactionWalletOperation, TransferTicketOperation, TransferTicketWalletOperation, UnconfiguredGlobalConstantsProviderError, UpdateConsensusKeyOperation, VIEW_LAMBDA, ViewSimulationError, Wallet, WalletOperation, WalletOperationBatch, attachKind, compose, createActivationOperation, createBallotOperation, createDrainDelegateOperation, createIncreasePaidStorageOperation, createOriginationOperation, createProposalsOperation, createRegisterDelegateOperation, createRegisterGlobalConstantOperation, createRevealOperation, createSetDelegateOperation, createSmartRollupAddMessagesOperation, createSmartRollupExecuteOutboxMessageOperation, createSmartRollupOriginateOperation, createTransferOperation, createTransferTicketOperation, createUpdateConsensusKeyOperation, defaultConfigConfirmation, findWithKind, getRevealFee, getRevealFeeInternal, getRevealGasLimit, hasMetadata, hasMetadataWithInternalOperationResult, hasMetadataWithResult, isKind, isOpRequireReveal, isOpWithFee, isOpWithGasBuffer, isSourceOp, protocols, smartContractAbstractionSemantic, validateAndExtractFailwith };
|
|
7710
|
+
export { BallotOperation, BatchOperation, BigMapAbstraction, COST_PER_BYTE, ChainIds, CompositeForger, Context, ContractAbstraction, ContractMethod, ContractMethodObject, ContractView, DEFAULT_FEE, DEFAULT_GAS_LIMIT, DEFAULT_SMART_CONTRACT_METHOD_NAME, DEFAULT_STORAGE_LIMIT, DefaultGlobalConstantsProvider, DelegateOperation, DelegationWalletOperation, DrainDelegateOperation, Estimate, GlobalConstantNotFound, IncreasePaidStorageOperation, InvalidBalanceError, InvalidCodeParameter, InvalidDelegationSource, InvalidEstimateValueError, InvalidInitParameter, InvalidParameterError, InvalidViewSimulationContext, LegacyWalletProvider, MANAGER_LAMBDA, MichelCodecPacker, MichelCodecParser, NoopParser, ORIGINATION_SIZE, ObservableSubscription, Operation, OperationBatch, OriginationOperation, OriginationParameterError, OriginationWalletOperation, PollingSubscribeProvider, PrepareProvider, ProposalsOperation, Protocols, REVEAL_STORAGE_LIMIT, RPCEstimateProvider, RegisterGlobalConstantOperation, RevealEstimateError, RevealOperation, RevealOperationError, RpcForger, RpcInjector, RpcPacker, RpcReadAdapter, SaplingStateAbstraction, SmartRollupAddMessagesOperation, SmartRollupOriginateOperation, TaquitoLocalForger, TezosOperationError, TezosPreapplyFailureError, TezosToolkit, TransactionOperation, TransactionWalletOperation, TransferTicketOperation, TransferTicketWalletOperation, UnconfiguredGlobalConstantsProviderError, UpdateCompanionKeyOperation, UpdateConsensusKeyOperation, VIEW_LAMBDA, ViewSimulationError, Wallet, WalletOperation, WalletOperationBatch, attachKind, compose, createActivationOperation, createBallotOperation, createDrainDelegateOperation, createIncreasePaidStorageOperation, createOriginationOperation, createProposalsOperation, createRegisterDelegateOperation, createRegisterGlobalConstantOperation, createRevealOperation, createSetDelegateOperation, createSmartRollupAddMessagesOperation, createSmartRollupExecuteOutboxMessageOperation, createSmartRollupOriginateOperation, createTransferOperation, createTransferTicketOperation, createUpdateCompanionKeyOperation, createUpdateConsensusKeyOperation, defaultConfigConfirmation, findWithKind, getRevealFee, getRevealFeeInternal, getRevealGasLimit, hasMetadata, hasMetadataWithInternalOperationResult, hasMetadataWithResult, isKind, isOpRequireReveal, isOpWithFee, isOpWithGasBuffer, isSourceOp, protocols, smartContractAbstractionSemantic, validateAndExtractFailwith };
|
|
7353
7711
|
//# sourceMappingURL=taquito.es6.js.map
|