@taquito/taquito 22.0.0-beta.0 → 23.0.0-RC.0
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/400.taquito.min.js +1 -0
- package/dist/993.taquito.min.js +1 -0
- package/dist/lib/batch/rpc-batch-provider.js +47 -5
- package/dist/lib/constants.js +51 -19
- package/dist/lib/contract/contract.js +1 -1
- package/dist/lib/contract/prepare.js +17 -3
- package/dist/lib/contract/rpc-contract-provider.js +69 -22
- package/dist/lib/estimate/rpc-estimate-provider.js +133 -31
- 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 +78 -3
- package/dist/lib/provider.js +4 -0
- package/dist/lib/subscribe/polling-subcribe-provider.js +7 -3
- package/dist/lib/tz/rpc-tz-provider.js +4 -4
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/operation-factory.js +1 -1
- package/dist/lib/wallet/operation.js +2 -2
- package/dist/lib/wallet/wallet.js +9 -12
- package/dist/taquito.es6.js +498 -111
- 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 +499 -107
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/batch/rpc-batch-provider.d.ts +16 -2
- package/dist/types/constants.d.ts +35 -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 +12 -5
- package/dist/types/estimate/estimate-provider-interface.d.ts +9 -3
- package/dist/types/estimate/rpc-estimate-provider.d.ts +10 -5
- 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 -1
- package/dist/types/prepare/prepare-provider.d.ts +11 -3
- package/dist/types/provider.d.ts +1 -1
- package/dist/types/signer/interface.d.ts +18 -8
- package/package.json +10 -10
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
|
-
import { switchMap, timeout, concatMap, endWith, tap, shareReplay, map, filter, first, catchError, share, distinctUntilChanged, takeWhile, startWith, mergeMap, takeUntil, retry,
|
|
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';
|
|
@@ -164,25 +164,55 @@ function createObservableFromSubscription(sub) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated default reveal gasLimit please use getRevealGasLimit(address) instead, removing hardcoded gasLimit of delegation, origination and transfer
|
|
169
|
+
*/
|
|
170
|
+
const DEFAULT_GAS_LIMIT = {
|
|
171
|
+
DELEGATION: 10600,
|
|
172
|
+
ORIGINATION: 10600,
|
|
173
|
+
TRANSFER: 10600,
|
|
174
|
+
REVEAL_TZ1: 1000,
|
|
175
|
+
REVEAL_TZ2: 1000,
|
|
176
|
+
REVEAL_TZ3: 2000,
|
|
177
|
+
REVEAL_TZ4: 2000,
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated default reveal fee please use getRevealFee(address) instead, removing hardcoded fee of delegation, origination and transfer
|
|
181
|
+
*/
|
|
182
|
+
const DEFAULT_FEE = {
|
|
183
|
+
DELEGATION: 1257,
|
|
184
|
+
ORIGINATION: 10000,
|
|
185
|
+
TRANSFER: 10000,
|
|
186
|
+
REVEAL: 374,
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated default reveal storageLimit please use REVEAL_STORAGE_LIMIT instead, removing hardcoded storageLimit of delegation, origination and transfer
|
|
190
|
+
*/
|
|
191
|
+
const DEFAULT_STORAGE_LIMIT = {
|
|
192
|
+
DELEGATION: 0,
|
|
193
|
+
ORIGINATION: 257,
|
|
194
|
+
TRANSFER: 257,
|
|
195
|
+
REVEAL: 0,
|
|
196
|
+
};
|
|
197
|
+
// value is based on octez-client reveal operation gasLimit of each address type in Seoul Protocol
|
|
168
198
|
const REVEAL_GAS_LIMIT = {
|
|
169
|
-
TZ1:
|
|
170
|
-
TZ2:
|
|
171
|
-
TZ3:
|
|
172
|
-
TZ4:
|
|
199
|
+
TZ1: 171,
|
|
200
|
+
TZ2: 157,
|
|
201
|
+
TZ3: 447,
|
|
202
|
+
TZ4: 3252,
|
|
173
203
|
};
|
|
174
|
-
// value is based on octez-client reveal operation fee of each address type in
|
|
204
|
+
// value is based on octez-client reveal operation fee of each address type in Seoul Protocol
|
|
175
205
|
const REVEAL_FEE = {
|
|
176
|
-
TZ1:
|
|
177
|
-
TZ2:
|
|
178
|
-
TZ3:
|
|
179
|
-
TZ4:
|
|
206
|
+
TZ1: 278,
|
|
207
|
+
TZ2: 277,
|
|
208
|
+
TZ3: 306,
|
|
209
|
+
TZ4: 736,
|
|
180
210
|
};
|
|
181
|
-
// value is based on octez-client reveal operation storageLimit of all address type in
|
|
211
|
+
// value is based on octez-client reveal operation storageLimit of all address type in Seoul Protocol
|
|
182
212
|
const REVEAL_STORAGE_LIMIT = 0;
|
|
183
|
-
// protocol constants in
|
|
213
|
+
// protocol constants in Seoul Protocol
|
|
184
214
|
const ORIGINATION_SIZE = 257;
|
|
185
|
-
// protocol constants in
|
|
215
|
+
// protocol constants in Seoul Protocol
|
|
186
216
|
const COST_PER_BYTE = 250;
|
|
187
217
|
var Protocols;
|
|
188
218
|
(function (Protocols) {
|
|
@@ -208,6 +238,7 @@ var Protocols;
|
|
|
208
238
|
Protocols["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
|
|
209
239
|
Protocols["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
|
|
210
240
|
Protocols["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
|
|
241
|
+
Protocols["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
|
|
211
242
|
Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
212
243
|
})(Protocols || (Protocols = {}));
|
|
213
244
|
const protocols = {
|
|
@@ -229,7 +260,8 @@ const protocols = {
|
|
|
229
260
|
'020': [Protocols.PtParisBx, Protocols.PsParisCZ],
|
|
230
261
|
'021': [Protocols.PsQuebecn],
|
|
231
262
|
'022': [Protocols.PsRiotuma],
|
|
232
|
-
'023': [Protocols.
|
|
263
|
+
'023': [Protocols.PtSeouLou],
|
|
264
|
+
'024': [Protocols.ProtoALpha],
|
|
233
265
|
};
|
|
234
266
|
var ChainIds;
|
|
235
267
|
(function (ChainIds) {
|
|
@@ -251,10 +283,10 @@ var ChainIds;
|
|
|
251
283
|
ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
|
|
252
284
|
ChainIds["PARISBNET"] = "NetXo8SqH1c38SS";
|
|
253
285
|
ChainIds["PARISCNET"] = "NetXXWAHLEvre9b";
|
|
254
|
-
ChainIds["
|
|
255
|
-
ChainIds["
|
|
286
|
+
ChainIds["QUEBECNET"] = "NetXuTeGinLEqxp";
|
|
287
|
+
ChainIds["RIONET"] = "NetXPdgaoabtBth";
|
|
288
|
+
ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
|
|
256
289
|
})(ChainIds || (ChainIds = {}));
|
|
257
|
-
// 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)
|
|
258
290
|
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
259
291
|
const getRevealGasLimitInternal = (address) => {
|
|
260
292
|
switch (address.substring(0, 3)) {
|
|
@@ -280,7 +312,7 @@ const getRevealFeeInternal = (address) => {
|
|
|
280
312
|
case 'tz3':
|
|
281
313
|
return REVEAL_FEE.TZ3;
|
|
282
314
|
case 'tz4':
|
|
283
|
-
return REVEAL_FEE.TZ4;
|
|
315
|
+
return REVEAL_FEE.TZ4 * 1.7;
|
|
284
316
|
default:
|
|
285
317
|
throw new Error(`Cannot estimate reveal fee for ${address}`);
|
|
286
318
|
}
|
|
@@ -493,7 +525,7 @@ const createRegisterDelegateOperation = (_a, source_1) => __awaiter(void 0, [_a,
|
|
|
493
525
|
delegate: source,
|
|
494
526
|
};
|
|
495
527
|
});
|
|
496
|
-
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) {
|
|
497
529
|
return {
|
|
498
530
|
kind: OpKind.REVEAL,
|
|
499
531
|
fee,
|
|
@@ -501,6 +533,7 @@ const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [
|
|
|
501
533
|
source,
|
|
502
534
|
gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : getRevealGasLimit(source),
|
|
503
535
|
storage_limit: storageLimit,
|
|
536
|
+
proof,
|
|
504
537
|
};
|
|
505
538
|
});
|
|
506
539
|
const createRegisterGlobalConstantOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, source, fee, gasLimit, storageLimit, }) {
|
|
@@ -562,7 +595,7 @@ const createProposalsOperation = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
562
595
|
proposals,
|
|
563
596
|
};
|
|
564
597
|
});
|
|
565
|
-
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, }) {
|
|
566
599
|
return {
|
|
567
600
|
kind: OpKind.UPDATE_CONSENSUS_KEY,
|
|
568
601
|
source,
|
|
@@ -570,6 +603,18 @@ const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0
|
|
|
570
603
|
gas_limit: gasLimit,
|
|
571
604
|
storage_limit: storageLimit,
|
|
572
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,
|
|
573
618
|
};
|
|
574
619
|
});
|
|
575
620
|
const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
|
|
@@ -622,7 +667,8 @@ const isKind = (op, kind) => {
|
|
|
622
667
|
return op.kind === kind;
|
|
623
668
|
};
|
|
624
669
|
const isOpWithGasBuffer = (op) => {
|
|
625
|
-
|
|
670
|
+
var _a;
|
|
671
|
+
if (op.kind === OpKind.TRANSACTION && ((_a = op.destination) === null || _a === void 0 ? void 0 : _a.startsWith('KT1'))) {
|
|
626
672
|
return true;
|
|
627
673
|
}
|
|
628
674
|
else {
|
|
@@ -631,6 +677,7 @@ const isOpWithGasBuffer = (op) => {
|
|
|
631
677
|
'register_global_constant',
|
|
632
678
|
'transfer_ticket',
|
|
633
679
|
'update_consensus_key',
|
|
680
|
+
'update_companion_key',
|
|
634
681
|
'smart_rollup_add_messages',
|
|
635
682
|
'smart_rollup_originate',
|
|
636
683
|
].indexOf(op.kind) !== -1);
|
|
@@ -646,6 +693,7 @@ const isOpWithFee = (op) => {
|
|
|
646
693
|
'increase_paid_storage',
|
|
647
694
|
'transfer_ticket',
|
|
648
695
|
'update_consensus_key',
|
|
696
|
+
'update_companion_key',
|
|
649
697
|
'smart_rollup_add_messages',
|
|
650
698
|
'smart_rollup_originate',
|
|
651
699
|
'smart_rollup_execute_outbox_message',
|
|
@@ -660,6 +708,7 @@ const isOpRequireReveal = (op) => {
|
|
|
660
708
|
'increase_paid_storage',
|
|
661
709
|
'transfer_ticket',
|
|
662
710
|
'update_consensus_key',
|
|
711
|
+
'update_companion_key',
|
|
663
712
|
'smart_rollup_add_messages',
|
|
664
713
|
'smart_rollup_originate',
|
|
665
714
|
'smart_rollup_execute_outbox_message',
|
|
@@ -1061,6 +1110,10 @@ class Provider {
|
|
|
1061
1110
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
1062
1111
|
case OpKind.INCREASE_PAID_STORAGE:
|
|
1063
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));
|
|
1064
1117
|
case OpKind.TRANSFER_TICKET:
|
|
1065
1118
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
1066
1119
|
case OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -1155,7 +1208,7 @@ class WalletOperationBatch {
|
|
|
1155
1208
|
withTransfer(params) {
|
|
1156
1209
|
const toValidation = validateAddress(params.to);
|
|
1157
1210
|
if (toValidation !== ValidationResult.VALID) {
|
|
1158
|
-
throw new InvalidAddressError(params.to,
|
|
1211
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
1159
1212
|
}
|
|
1160
1213
|
this.operations.push(Object.assign({ kind: OpKind.TRANSACTION }, params));
|
|
1161
1214
|
return this;
|
|
@@ -1176,7 +1229,7 @@ class WalletOperationBatch {
|
|
|
1176
1229
|
var _a;
|
|
1177
1230
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1178
1231
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
1179
|
-
throw new InvalidAddressError(params.delegate,
|
|
1232
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
1180
1233
|
}
|
|
1181
1234
|
this.operations.push(Object.assign({ kind: OpKind.DELEGATION }, params));
|
|
1182
1235
|
return this;
|
|
@@ -1196,7 +1249,7 @@ class WalletOperationBatch {
|
|
|
1196
1249
|
withIncreasePaidStorage(params) {
|
|
1197
1250
|
const destinationValidation = validateAddress(params.destination);
|
|
1198
1251
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
1199
|
-
throw new InvalidAddressError(params.destination,
|
|
1252
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
1200
1253
|
}
|
|
1201
1254
|
this.operations.push(Object.assign({ kind: OpKind.INCREASE_PAID_STORAGE }, params));
|
|
1202
1255
|
return this;
|
|
@@ -1208,7 +1261,7 @@ class WalletOperationBatch {
|
|
|
1208
1261
|
withTransferTicket(params) {
|
|
1209
1262
|
const destinationValidation = validateAddress(params.destination);
|
|
1210
1263
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
1211
|
-
throw new InvalidAddressError(params.destination,
|
|
1264
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
1212
1265
|
}
|
|
1213
1266
|
this.operations.push(Object.assign({ kind: OpKind.TRANSFER_TICKET }, params));
|
|
1214
1267
|
return this;
|
|
@@ -1330,7 +1383,7 @@ class Wallet {
|
|
|
1330
1383
|
var _a;
|
|
1331
1384
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1332
1385
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
1333
|
-
throw new InvalidAddressError(params.delegate,
|
|
1386
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
1334
1387
|
}
|
|
1335
1388
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1336
1389
|
const mappedParams = yield this.walletProvider.mapDelegateParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1392,7 +1445,7 @@ class Wallet {
|
|
|
1392
1445
|
transfer(params) {
|
|
1393
1446
|
const toValidation = validateAddress(params.to);
|
|
1394
1447
|
if (toValidation !== ValidationResult.VALID) {
|
|
1395
|
-
throw new InvalidAddressError(params.to,
|
|
1448
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
1396
1449
|
}
|
|
1397
1450
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1398
1451
|
const mappedParams = yield this.walletProvider.mapTransferParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1408,7 +1461,7 @@ class Wallet {
|
|
|
1408
1461
|
transferTicket(params) {
|
|
1409
1462
|
const toValidation = validateAddress(params.destination);
|
|
1410
1463
|
if (toValidation !== ValidationResult.VALID) {
|
|
1411
|
-
throw new InvalidAddressError(params.destination,
|
|
1464
|
+
throw new InvalidAddressError(params.destination, toValidation);
|
|
1412
1465
|
}
|
|
1413
1466
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1414
1467
|
const mappedParams = yield this.walletProvider.mapTransferTicketParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1474,9 +1527,6 @@ class Wallet {
|
|
|
1474
1527
|
if (!params.to) {
|
|
1475
1528
|
params.to = source;
|
|
1476
1529
|
}
|
|
1477
|
-
if (params.to !== source) {
|
|
1478
|
-
throw new InvalidStakingAddressError(params.to);
|
|
1479
|
-
}
|
|
1480
1530
|
if (!params.amount) {
|
|
1481
1531
|
params.amount = 0;
|
|
1482
1532
|
}
|
|
@@ -1498,7 +1548,7 @@ class Wallet {
|
|
|
1498
1548
|
increasePaidStorage(params) {
|
|
1499
1549
|
const destinationValidation = validateAddress(params.destination);
|
|
1500
1550
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
1501
|
-
throw new InvalidAddressError(params.destination,
|
|
1551
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
1502
1552
|
}
|
|
1503
1553
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1504
1554
|
const mappedParams = yield this.walletProvider.mapIncreasePaidStorageWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1528,7 +1578,7 @@ class Wallet {
|
|
|
1528
1578
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
1529
1579
|
const addressValidation = validateContractAddress(address);
|
|
1530
1580
|
if (addressValidation !== ValidationResult.VALID) {
|
|
1531
|
-
throw new InvalidContractAddressError(address,
|
|
1581
|
+
throw new InvalidContractAddressError(address, addressValidation);
|
|
1532
1582
|
}
|
|
1533
1583
|
const rpc = this.context.withExtensions().rpc;
|
|
1534
1584
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -1654,7 +1704,7 @@ class WalletOperation {
|
|
|
1654
1704
|
connector: () => new ReplaySubject(1),
|
|
1655
1705
|
resetOnError: false,
|
|
1656
1706
|
resetOnComplete: false,
|
|
1657
|
-
resetOnRefCountZero:
|
|
1707
|
+
resetOnRefCountZero: true,
|
|
1658
1708
|
}));
|
|
1659
1709
|
// Observable that emit once operation is seen in a block
|
|
1660
1710
|
this.confirmed$ = this.newHead$.pipe(map((head) => {
|
|
@@ -1675,7 +1725,7 @@ class WalletOperation {
|
|
|
1675
1725
|
connector: () => new ReplaySubject(1),
|
|
1676
1726
|
resetOnError: false,
|
|
1677
1727
|
resetOnComplete: false,
|
|
1678
|
-
resetOnRefCountZero:
|
|
1728
|
+
resetOnRefCountZero: true,
|
|
1679
1729
|
}));
|
|
1680
1730
|
if (validateOperation(this.opHash) !== ValidationResult.VALID) {
|
|
1681
1731
|
throw new InvalidOperationHashError(this.opHash);
|
|
@@ -2276,7 +2326,7 @@ class ContractView {
|
|
|
2276
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.`);
|
|
2277
2327
|
}
|
|
2278
2328
|
else if (chainId && chainIdValidation !== ValidationResult.VALID) {
|
|
2279
|
-
throw new InvalidChainIdError(chainId,
|
|
2329
|
+
throw new InvalidChainIdError(chainId, chainIdValidation);
|
|
2280
2330
|
}
|
|
2281
2331
|
const arg = this.parameterSchema.Encode(...this.args);
|
|
2282
2332
|
const result = yield this.rpc.runView({
|
|
@@ -2714,10 +2764,14 @@ class PrepareProvider extends Provider {
|
|
|
2714
2764
|
if (!publicKey) {
|
|
2715
2765
|
throw new PublicKeyNotFoundError(pkh);
|
|
2716
2766
|
}
|
|
2767
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(pkh, publicKeyHashPrefixes);
|
|
2717
2768
|
ops.unshift(yield createRevealOperation({
|
|
2718
2769
|
fee: getRevealFee(pkh),
|
|
2719
2770
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
2720
2771
|
gasLimit: getRevealGasLimit(pkh),
|
|
2772
|
+
proof: pkhPrefix === PrefixV2.BLS12_381PublicKeyHash
|
|
2773
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
2774
|
+
: undefined,
|
|
2721
2775
|
}, publicKeyHash, publicKey));
|
|
2722
2776
|
return ops;
|
|
2723
2777
|
}
|
|
@@ -2763,6 +2817,7 @@ class PrepareProvider extends Provider {
|
|
|
2763
2817
|
case OpKind.DELEGATION:
|
|
2764
2818
|
case OpKind.REGISTER_GLOBAL_CONSTANT:
|
|
2765
2819
|
case OpKind.UPDATE_CONSENSUS_KEY:
|
|
2820
|
+
case OpKind.UPDATE_COMPANION_KEY:
|
|
2766
2821
|
case OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
2767
2822
|
case OpKind.SMART_ROLLUP_ORIGINATE:
|
|
2768
2823
|
case OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
@@ -2823,11 +2878,26 @@ class PrepareProvider extends Provider {
|
|
|
2823
2878
|
* @returns a PreparedOperation object
|
|
2824
2879
|
*/
|
|
2825
2880
|
reveal(_a) {
|
|
2826
|
-
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit }) {
|
|
2881
|
+
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit, proof }) {
|
|
2827
2882
|
const { pkh, publicKey } = yield this.getKeys();
|
|
2828
2883
|
if (!publicKey) {
|
|
2829
2884
|
throw new PublicKeyNotFoundError(pkh);
|
|
2830
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
|
+
}
|
|
2831
2901
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
2832
2902
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
2833
2903
|
const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
|
|
@@ -2835,6 +2905,7 @@ class PrepareProvider extends Provider {
|
|
|
2835
2905
|
fee: mergedEstimates.fee,
|
|
2836
2906
|
gasLimit: mergedEstimates.gasLimit,
|
|
2837
2907
|
storageLimit: mergedEstimates.storageLimit,
|
|
2908
|
+
proof,
|
|
2838
2909
|
}, pkh, publicKey);
|
|
2839
2910
|
const ops = this.convertIntoArray(op);
|
|
2840
2911
|
const hash = yield this.getBlockHash();
|
|
@@ -2993,11 +3064,11 @@ class PrepareProvider extends Provider {
|
|
|
2993
3064
|
*/
|
|
2994
3065
|
finalizeUnstake(_a) {
|
|
2995
3066
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2996
|
-
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3067
|
+
var { fee, storageLimit, gasLimit, to } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit", "to"]);
|
|
2997
3068
|
const { pkh } = yield this.getKeys();
|
|
2998
3069
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
2999
3070
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3000
|
-
const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh, amount: 0 }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
|
|
3071
|
+
const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: to ? to : pkh, amount: 0 }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
|
|
3001
3072
|
entrypoint: 'finalize_unstake',
|
|
3002
3073
|
value: { prim: 'Unit' },
|
|
3003
3074
|
} }));
|
|
@@ -3126,6 +3197,17 @@ class PrepareProvider extends Provider {
|
|
|
3126
3197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3127
3198
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3128
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
|
+
}
|
|
3129
3211
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3130
3212
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3131
3213
|
const op = yield createUpdateConsensusKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
@@ -3146,6 +3228,44 @@ class PrepareProvider extends Provider {
|
|
|
3146
3228
|
};
|
|
3147
3229
|
});
|
|
3148
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
|
+
}
|
|
3149
3269
|
/**
|
|
3150
3270
|
*
|
|
3151
3271
|
* @description Method to prepare an increase_paid_storage operation
|
|
@@ -3436,10 +3556,14 @@ class PrepareProvider extends Provider {
|
|
|
3436
3556
|
if (!publicKey) {
|
|
3437
3557
|
throw new PublicKeyNotFoundError(pkh);
|
|
3438
3558
|
}
|
|
3559
|
+
const [, pkhPrefix] = b58DecodeAndCheckPrefix(pkh, publicKeyHashPrefixes);
|
|
3439
3560
|
ops.unshift(yield createRevealOperation({
|
|
3440
3561
|
fee: getRevealFee(pkh),
|
|
3441
3562
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
3442
3563
|
gasLimit: getRevealGasLimit(pkh),
|
|
3564
|
+
proof: pkhPrefix === PrefixV2.BLS12_381PublicKeyHash
|
|
3565
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
3566
|
+
: undefined,
|
|
3443
3567
|
}, pkh, publicKey));
|
|
3444
3568
|
}
|
|
3445
3569
|
const hash = yield this.getBlockHash();
|
|
@@ -3556,7 +3680,7 @@ class OperationBatch extends Provider {
|
|
|
3556
3680
|
throw new InvalidAmountError(params.amount.toString());
|
|
3557
3681
|
}
|
|
3558
3682
|
if (toValidation !== ValidationResult.VALID) {
|
|
3559
|
-
throw new InvalidAddressError(params.to,
|
|
3683
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
3560
3684
|
}
|
|
3561
3685
|
this.operations.push(Object.assign({ kind: OpKind.TRANSACTION }, params));
|
|
3562
3686
|
return this;
|
|
@@ -3570,7 +3694,7 @@ class OperationBatch extends Provider {
|
|
|
3570
3694
|
withTransferTicket(params) {
|
|
3571
3695
|
const destinationValidation = validateAddress(params.destination);
|
|
3572
3696
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
3573
|
-
throw new InvalidAddressError(params.destination,
|
|
3697
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
3574
3698
|
}
|
|
3575
3699
|
this.operations.push(Object.assign({ kind: OpKind.TRANSFER_TICKET }, params));
|
|
3576
3700
|
return this;
|
|
@@ -3595,11 +3719,11 @@ class OperationBatch extends Provider {
|
|
|
3595
3719
|
var _a;
|
|
3596
3720
|
const sourceValidation = validateAddress(params.source);
|
|
3597
3721
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
3598
|
-
throw new InvalidAddressError(params.source,
|
|
3722
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
3599
3723
|
}
|
|
3600
3724
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
3601
3725
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
3602
|
-
throw new InvalidAddressError(params.delegate,
|
|
3726
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
3603
3727
|
}
|
|
3604
3728
|
this.operations.push(Object.assign({ kind: OpKind.DELEGATION }, params));
|
|
3605
3729
|
return this;
|
|
@@ -3614,7 +3738,7 @@ class OperationBatch extends Provider {
|
|
|
3614
3738
|
withActivation({ pkh, secret }) {
|
|
3615
3739
|
const pkhValidation = validateKeyHash(pkh);
|
|
3616
3740
|
if (pkhValidation !== ValidationResult.VALID) {
|
|
3617
|
-
throw new InvalidKeyHashError(pkh,
|
|
3741
|
+
throw new InvalidKeyHashError(pkh, pkhValidation);
|
|
3618
3742
|
}
|
|
3619
3743
|
this.operations.push({ kind: OpKind.ACTIVATION, pkh, secret });
|
|
3620
3744
|
return this;
|
|
@@ -3649,6 +3773,44 @@ class OperationBatch extends Provider {
|
|
|
3649
3773
|
this.operations.push(Object.assign({ kind: OpKind.INCREASE_PAID_STORAGE }, params));
|
|
3650
3774
|
return this;
|
|
3651
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
|
+
}
|
|
3652
3814
|
/**
|
|
3653
3815
|
*
|
|
3654
3816
|
* @description Add a smart rollup add messages operation to the batch
|
|
@@ -3692,6 +3854,10 @@ class OperationBatch extends Provider {
|
|
|
3692
3854
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
3693
3855
|
case OpKind.INCREASE_PAID_STORAGE:
|
|
3694
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));
|
|
3695
3861
|
case OpKind.TRANSFER_TICKET:
|
|
3696
3862
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
3697
3863
|
case OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -3906,7 +4072,7 @@ const createNewPollingBasedHeadObservable = (sharedHeadOb, context, _scheduler)
|
|
|
3906
4072
|
connector: () => new ReplaySubject(1),
|
|
3907
4073
|
resetOnError: false,
|
|
3908
4074
|
resetOnComplete: false,
|
|
3909
|
-
resetOnRefCountZero:
|
|
4075
|
+
resetOnRefCountZero: true,
|
|
3910
4076
|
}));
|
|
3911
4077
|
};
|
|
3912
4078
|
class OperationFactory {
|
|
@@ -3988,7 +4154,7 @@ class RpcTzProvider extends Provider {
|
|
|
3988
4154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3989
4155
|
const addressValidation = validateAddress(address);
|
|
3990
4156
|
if (addressValidation !== ValidationResult.VALID) {
|
|
3991
|
-
throw new InvalidAddressError(address,
|
|
4157
|
+
throw new InvalidAddressError(address, addressValidation);
|
|
3992
4158
|
}
|
|
3993
4159
|
return this.context.readProvider.getBalance(address, 'head');
|
|
3994
4160
|
});
|
|
@@ -3997,7 +4163,7 @@ class RpcTzProvider extends Provider {
|
|
|
3997
4163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3998
4164
|
const addressValidation = validateAddress(address);
|
|
3999
4165
|
if (addressValidation !== ValidationResult.VALID) {
|
|
4000
|
-
throw new InvalidAddressError(address,
|
|
4166
|
+
throw new InvalidAddressError(address, addressValidation);
|
|
4001
4167
|
}
|
|
4002
4168
|
return this.context.readProvider.getSpendable(address, 'head');
|
|
4003
4169
|
});
|
|
@@ -4006,7 +4172,7 @@ class RpcTzProvider extends Provider {
|
|
|
4006
4172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4007
4173
|
const addressValidation = validateAddress(address);
|
|
4008
4174
|
if (addressValidation !== ValidationResult.VALID) {
|
|
4009
|
-
throw new InvalidAddressError(address,
|
|
4175
|
+
throw new InvalidAddressError(address, addressValidation);
|
|
4010
4176
|
}
|
|
4011
4177
|
return this.context.readProvider.getDelegate(address, 'head');
|
|
4012
4178
|
});
|
|
@@ -4015,7 +4181,7 @@ class RpcTzProvider extends Provider {
|
|
|
4015
4181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4016
4182
|
const pkhValidation = validateKeyHash(pkh);
|
|
4017
4183
|
if (pkhValidation !== ValidationResult.VALID) {
|
|
4018
|
-
throw new InvalidKeyHashError$1(pkh,
|
|
4184
|
+
throw new InvalidKeyHashError$1(pkh, pkhValidation);
|
|
4019
4185
|
}
|
|
4020
4186
|
const prepared = yield this.prepare.activate({ pkh, secret });
|
|
4021
4187
|
const forgedBytes = yield this.forge(prepared);
|
|
@@ -4169,7 +4335,8 @@ const STUB_SIGNATURE = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfL
|
|
|
4169
4335
|
class RPCEstimateProvider extends Provider {
|
|
4170
4336
|
constructor() {
|
|
4171
4337
|
super(...arguments);
|
|
4172
|
-
this.
|
|
4338
|
+
this.REVEAL_LENGTH = 324; // injecting size tz1=320, tz2=322, tz3=322
|
|
4339
|
+
this.REVEAL_LENGTH_TZ4 = 622; // injecting size tz4=620
|
|
4173
4340
|
this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
|
|
4174
4341
|
this.STORAGE_BUFFER = 20; // according to octez-client
|
|
4175
4342
|
this.prepare = new PrepareProvider(this.context);
|
|
@@ -4251,9 +4418,20 @@ class RPCEstimateProvider extends Provider {
|
|
|
4251
4418
|
: op.opOb.contents.length;
|
|
4252
4419
|
}
|
|
4253
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
|
+
}
|
|
4254
4432
|
return this.getEstimationPropertiesFromOperationContent(x,
|
|
4255
4433
|
// diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
|
|
4256
|
-
x.kind === 'reveal' ?
|
|
4434
|
+
x.kind === 'reveal' ? revealSize : eachOpSize, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
|
|
4257
4435
|
);
|
|
4258
4436
|
});
|
|
4259
4437
|
});
|
|
@@ -4272,8 +4450,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4272
4450
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4273
4451
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4274
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;
|
|
4275
4456
|
estimateProperties.shift();
|
|
4276
|
-
estimateProperties[0].opSize -=
|
|
4457
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4277
4458
|
}
|
|
4278
4459
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4279
4460
|
});
|
|
@@ -4292,11 +4473,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4292
4473
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4293
4474
|
const toValidation = validateAddress(rest.to);
|
|
4294
4475
|
if (toValidation !== ValidationResult.VALID) {
|
|
4295
|
-
throw new InvalidAddressError(rest.to,
|
|
4476
|
+
throw new InvalidAddressError(rest.to, toValidation);
|
|
4296
4477
|
}
|
|
4297
4478
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4298
4479
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4299
|
-
throw new InvalidAddressError(rest.source,
|
|
4480
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4300
4481
|
}
|
|
4301
4482
|
if (rest.amount < 0) {
|
|
4302
4483
|
throw new InvalidAmountError(rest.amount.toString());
|
|
@@ -4307,8 +4488,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4307
4488
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4308
4489
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4309
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;
|
|
4310
4494
|
estimateProperties.shift();
|
|
4311
|
-
estimateProperties[0].opSize -=
|
|
4495
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4312
4496
|
}
|
|
4313
4497
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4314
4498
|
});
|
|
@@ -4327,7 +4511,7 @@ class RPCEstimateProvider extends Provider {
|
|
|
4327
4511
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4328
4512
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4329
4513
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4330
|
-
throw new InvalidAddressError(rest.source,
|
|
4514
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4331
4515
|
}
|
|
4332
4516
|
if (!rest.to) {
|
|
4333
4517
|
rest.to = rest.source;
|
|
@@ -4345,7 +4529,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4345
4529
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4346
4530
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4347
4531
|
estimateProperties.shift();
|
|
4348
|
-
|
|
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;
|
|
4349
4536
|
}
|
|
4350
4537
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4351
4538
|
});
|
|
@@ -4364,7 +4551,7 @@ class RPCEstimateProvider extends Provider {
|
|
|
4364
4551
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4365
4552
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4366
4553
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4367
|
-
throw new InvalidAddressError(rest.source,
|
|
4554
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4368
4555
|
}
|
|
4369
4556
|
if (!rest.to) {
|
|
4370
4557
|
rest.to = rest.source;
|
|
@@ -4382,7 +4569,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4382
4569
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4383
4570
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4384
4571
|
estimateProperties.shift();
|
|
4385
|
-
|
|
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;
|
|
4386
4576
|
}
|
|
4387
4577
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4388
4578
|
});
|
|
@@ -4401,14 +4591,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4401
4591
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4402
4592
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4403
4593
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4404
|
-
throw new InvalidAddressError(rest.source,
|
|
4594
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4405
4595
|
}
|
|
4406
4596
|
if (!rest.to) {
|
|
4407
4597
|
rest.to = rest.source;
|
|
4408
4598
|
}
|
|
4409
|
-
if (rest.to && rest.to !== rest.source) {
|
|
4410
|
-
throw new InvalidStakingAddressError(rest.to);
|
|
4411
|
-
}
|
|
4412
4599
|
if (!rest.amount) {
|
|
4413
4600
|
rest.amount = 0;
|
|
4414
4601
|
}
|
|
@@ -4422,7 +4609,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4422
4609
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4423
4610
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4424
4611
|
estimateProperties.shift();
|
|
4425
|
-
|
|
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;
|
|
4426
4616
|
}
|
|
4427
4617
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4428
4618
|
});
|
|
@@ -4441,11 +4631,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4441
4631
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4442
4632
|
const destinationValidation = validateAddress(rest.destination);
|
|
4443
4633
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
4444
|
-
throw new InvalidAddressError(rest.destination,
|
|
4634
|
+
throw new InvalidAddressError(rest.destination, destinationValidation);
|
|
4445
4635
|
}
|
|
4446
4636
|
const sourceValidation = validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4447
4637
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4448
|
-
throw new InvalidAddressError(rest.source,
|
|
4638
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4449
4639
|
}
|
|
4450
4640
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4451
4641
|
const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
|
|
@@ -4454,7 +4644,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4454
4644
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4455
4645
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4456
4646
|
estimateProperties.shift();
|
|
4457
|
-
|
|
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;
|
|
4458
4651
|
}
|
|
4459
4652
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4460
4653
|
});
|
|
@@ -4473,11 +4666,11 @@ class RPCEstimateProvider extends Provider {
|
|
|
4473
4666
|
var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
|
|
4474
4667
|
const sourceValidation = validateAddress(rest.source);
|
|
4475
4668
|
if (rest.source && sourceValidation !== ValidationResult.VALID) {
|
|
4476
|
-
throw new InvalidAddressError(rest.source,
|
|
4669
|
+
throw new InvalidAddressError(rest.source, sourceValidation);
|
|
4477
4670
|
}
|
|
4478
4671
|
const delegateValidation = validateAddress((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
|
|
4479
4672
|
if (rest.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
4480
|
-
throw new InvalidAddressError(rest.delegate,
|
|
4673
|
+
throw new InvalidAddressError(rest.delegate, delegateValidation);
|
|
4481
4674
|
}
|
|
4482
4675
|
const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
|
|
4483
4676
|
storageLimit,
|
|
@@ -4486,7 +4679,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4486
4679
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4487
4680
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4488
4681
|
estimateProperties.shift();
|
|
4489
|
-
|
|
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;
|
|
4490
4686
|
}
|
|
4491
4687
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4492
4688
|
});
|
|
@@ -4523,7 +4719,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4523
4719
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4524
4720
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4525
4721
|
estimateProperties.shift();
|
|
4526
|
-
|
|
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;
|
|
4527
4726
|
}
|
|
4528
4727
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4529
4728
|
});
|
|
@@ -4531,7 +4730,6 @@ class RPCEstimateProvider extends Provider {
|
|
|
4531
4730
|
/**
|
|
4532
4731
|
*
|
|
4533
4732
|
* @description Estimate gasLimit, storageLimit and fees to reveal the current account
|
|
4534
|
-
*
|
|
4535
4733
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
|
|
4536
4734
|
*
|
|
4537
4735
|
* @param Estimate
|
|
@@ -4543,6 +4741,21 @@ class RPCEstimateProvider extends Provider {
|
|
|
4543
4741
|
throw new RevealEstimateError();
|
|
4544
4742
|
}
|
|
4545
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
|
+
}
|
|
4546
4759
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4547
4760
|
const preparedOperation = params
|
|
4548
4761
|
? yield this.prepare.reveal(params)
|
|
@@ -4570,7 +4783,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4570
4783
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4571
4784
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4572
4785
|
estimateProperties.shift();
|
|
4573
|
-
|
|
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;
|
|
4574
4790
|
}
|
|
4575
4791
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4576
4792
|
});
|
|
@@ -4596,7 +4812,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4596
4812
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4597
4813
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4598
4814
|
estimateProperties.shift();
|
|
4599
|
-
|
|
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;
|
|
4600
4819
|
}
|
|
4601
4820
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4602
4821
|
});
|
|
@@ -4604,19 +4823,59 @@ class RPCEstimateProvider extends Provider {
|
|
|
4604
4823
|
/**
|
|
4605
4824
|
*
|
|
4606
4825
|
* @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
|
|
4607
|
-
*
|
|
4608
4826
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4609
|
-
*
|
|
4610
4827
|
* @param Estimate
|
|
4611
4828
|
*/
|
|
4612
4829
|
updateConsensusKey(params) {
|
|
4613
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
|
+
}
|
|
4614
4842
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4615
4843
|
const preparedOperation = yield this.prepare.updateConsensusKey(params);
|
|
4616
4844
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4617
4845
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4618
4846
|
estimateProperties.shift();
|
|
4619
|
-
|
|
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;
|
|
4620
4879
|
}
|
|
4621
4880
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4622
4881
|
});
|
|
@@ -4636,7 +4895,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4636
4895
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4637
4896
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4638
4897
|
estimateProperties.shift();
|
|
4639
|
-
|
|
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;
|
|
4640
4902
|
}
|
|
4641
4903
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4642
4904
|
});
|
|
@@ -4656,7 +4918,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4656
4918
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4657
4919
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4658
4920
|
estimateProperties.shift();
|
|
4659
|
-
|
|
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;
|
|
4660
4925
|
}
|
|
4661
4926
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4662
4927
|
});
|
|
@@ -4695,7 +4960,10 @@ class RPCEstimateProvider extends Provider {
|
|
|
4695
4960
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4696
4961
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4697
4962
|
estimateProperties.shift();
|
|
4698
|
-
|
|
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;
|
|
4699
4967
|
}
|
|
4700
4968
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4701
4969
|
});
|
|
@@ -4913,6 +5181,14 @@ class RevealOperation extends Operation {
|
|
|
4913
5181
|
get publicKey() {
|
|
4914
5182
|
return this.params.public_key;
|
|
4915
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
|
+
}
|
|
4916
5192
|
sumProp(arr, prop) {
|
|
4917
5193
|
return arr.reduce((prev, current) => {
|
|
4918
5194
|
return prop in current ? Number(current[prop]) + prev : prev;
|
|
@@ -5083,6 +5359,67 @@ class UpdateConsensusKeyOperation extends Operation {
|
|
|
5083
5359
|
get pk() {
|
|
5084
5360
|
return this.params.pk;
|
|
5085
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
|
+
}
|
|
5086
5423
|
get consumedMilliGas() {
|
|
5087
5424
|
var _a;
|
|
5088
5425
|
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
@@ -5380,7 +5717,7 @@ class RpcContractProvider extends Provider {
|
|
|
5380
5717
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5381
5718
|
const contractValidation = validateContractAddress(contract);
|
|
5382
5719
|
if (contractValidation !== ValidationResult.VALID) {
|
|
5383
|
-
throw new InvalidContractAddressError(contract,
|
|
5720
|
+
throw new InvalidContractAddressError(contract, contractValidation);
|
|
5384
5721
|
}
|
|
5385
5722
|
const script = yield this.context.readProvider.getScript(contract, 'head');
|
|
5386
5723
|
if (!schema) {
|
|
@@ -5412,7 +5749,7 @@ class RpcContractProvider extends Provider {
|
|
|
5412
5749
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5413
5750
|
const contractValidation = validateContractAddress(contract);
|
|
5414
5751
|
if (contractValidation !== ValidationResult.VALID) {
|
|
5415
|
-
throw new InvalidContractAddressError(contract,
|
|
5752
|
+
throw new InvalidContractAddressError(contract, contractValidation);
|
|
5416
5753
|
}
|
|
5417
5754
|
if (!schema) {
|
|
5418
5755
|
schema = (yield this.rpc.getContract(contract)).script;
|
|
@@ -5556,14 +5893,14 @@ class RpcContractProvider extends Provider {
|
|
|
5556
5893
|
var _a;
|
|
5557
5894
|
const sourceValidation = validateAddress(params.source);
|
|
5558
5895
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5559
|
-
throw new InvalidAddressError(params.source,
|
|
5896
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5560
5897
|
}
|
|
5561
5898
|
const delegateValidation = validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
5562
5899
|
if (params.delegate && delegateValidation !== ValidationResult.VALID) {
|
|
5563
|
-
throw new InvalidAddressError(params.delegate,
|
|
5900
|
+
throw new InvalidAddressError(params.delegate, delegateValidation);
|
|
5564
5901
|
}
|
|
5565
5902
|
// Since babylon delegation source cannot smart contract
|
|
5566
|
-
if (
|
|
5903
|
+
if (/^kt1/i.test(params.source)) {
|
|
5567
5904
|
throw new InvalidDelegationSource(params.source);
|
|
5568
5905
|
}
|
|
5569
5906
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
@@ -5608,11 +5945,11 @@ class RpcContractProvider extends Provider {
|
|
|
5608
5945
|
var _a;
|
|
5609
5946
|
const toValidation = validateAddress(params.to);
|
|
5610
5947
|
if (toValidation !== ValidationResult.VALID) {
|
|
5611
|
-
throw new InvalidAddressError(params.to,
|
|
5948
|
+
throw new InvalidAddressError(params.to, toValidation);
|
|
5612
5949
|
}
|
|
5613
5950
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5614
5951
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5615
|
-
throw new InvalidAddressError(params.source,
|
|
5952
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5616
5953
|
}
|
|
5617
5954
|
if (params.amount < 0) {
|
|
5618
5955
|
throw new InvalidAmountError(params.amount.toString());
|
|
@@ -5640,7 +5977,7 @@ class RpcContractProvider extends Provider {
|
|
|
5640
5977
|
var _a;
|
|
5641
5978
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5642
5979
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5643
|
-
throw new InvalidAddressError(params.source,
|
|
5980
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5644
5981
|
}
|
|
5645
5982
|
if (!params.to) {
|
|
5646
5983
|
params.to = params.source;
|
|
@@ -5676,7 +6013,7 @@ class RpcContractProvider extends Provider {
|
|
|
5676
6013
|
var _a;
|
|
5677
6014
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5678
6015
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5679
|
-
throw new InvalidAddressError(params.source,
|
|
6016
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5680
6017
|
}
|
|
5681
6018
|
if (!params.to) {
|
|
5682
6019
|
params.to = params.source;
|
|
@@ -5709,14 +6046,11 @@ class RpcContractProvider extends Provider {
|
|
|
5709
6046
|
var _a;
|
|
5710
6047
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5711
6048
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5712
|
-
throw new InvalidAddressError(params.source,
|
|
6049
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5713
6050
|
}
|
|
5714
6051
|
if (!params.to) {
|
|
5715
6052
|
params.to = params.source;
|
|
5716
6053
|
}
|
|
5717
|
-
if (params.to && params.to !== params.source) {
|
|
5718
|
-
throw new InvalidStakingAddressError(params.to);
|
|
5719
|
-
}
|
|
5720
6054
|
if (!params.amount) {
|
|
5721
6055
|
params.amount = 0;
|
|
5722
6056
|
}
|
|
@@ -5746,11 +6080,11 @@ class RpcContractProvider extends Provider {
|
|
|
5746
6080
|
var _a, _b;
|
|
5747
6081
|
const destinationValidation = validateAddress(params.destination);
|
|
5748
6082
|
if (destinationValidation !== ValidationResult.VALID) {
|
|
5749
|
-
throw new InvalidAddressError(params.destination,
|
|
6083
|
+
throw new InvalidAddressError(params.destination, destinationValidation);
|
|
5750
6084
|
}
|
|
5751
6085
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5752
6086
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5753
|
-
throw new InvalidAddressError(params.source,
|
|
6087
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5754
6088
|
}
|
|
5755
6089
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5756
6090
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
@@ -5764,8 +6098,7 @@ class RpcContractProvider extends Provider {
|
|
|
5764
6098
|
}
|
|
5765
6099
|
/**
|
|
5766
6100
|
*
|
|
5767
|
-
* @description Reveal the current address. Will throw an error if the address is already revealed.
|
|
5768
|
-
*
|
|
6101
|
+
* @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
|
|
5769
6102
|
* @returns An operation handle with the result from the rpc node
|
|
5770
6103
|
*
|
|
5771
6104
|
* @param RevealParams operation parameter
|
|
@@ -5773,6 +6106,21 @@ class RpcContractProvider extends Provider {
|
|
|
5773
6106
|
reveal(params) {
|
|
5774
6107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5775
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
|
+
}
|
|
5776
6124
|
const estimateReveal = yield this.estimator.reveal(params);
|
|
5777
6125
|
if (estimateReveal) {
|
|
5778
6126
|
const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
|
|
@@ -5859,7 +6207,7 @@ class RpcContractProvider extends Provider {
|
|
|
5859
6207
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5860
6208
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5861
6209
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5862
|
-
throw new InvalidAddressError(params.source,
|
|
6210
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5863
6211
|
}
|
|
5864
6212
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5865
6213
|
const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5883,7 +6231,7 @@ class RpcContractProvider extends Provider {
|
|
|
5883
6231
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5884
6232
|
const sourceValidation = validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5885
6233
|
if (params.source && sourceValidation !== ValidationResult.VALID) {
|
|
5886
|
-
throw new InvalidAddressError(params.source,
|
|
6234
|
+
throw new InvalidAddressError(params.source, sourceValidation);
|
|
5887
6235
|
}
|
|
5888
6236
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5889
6237
|
const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5895,8 +6243,7 @@ class RpcContractProvider extends Provider {
|
|
|
5895
6243
|
}
|
|
5896
6244
|
/**
|
|
5897
6245
|
*
|
|
5898
|
-
* @description
|
|
5899
|
-
*
|
|
6246
|
+
* @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
|
|
5900
6247
|
* @returns An operation handle with the result from the rpc node
|
|
5901
6248
|
*
|
|
5902
6249
|
* @param UpdateConsensusKeyParams
|
|
@@ -5904,6 +6251,17 @@ class RpcContractProvider extends Provider {
|
|
|
5904
6251
|
updateConsensusKey(params) {
|
|
5905
6252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5906
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
|
+
}
|
|
5907
6265
|
const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
|
|
5908
6266
|
const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
|
|
5909
6267
|
const content = prepared.opOb.contents.find((op) => op.kind === OpKind.UPDATE_CONSENSUS_KEY);
|
|
@@ -5912,6 +6270,31 @@ class RpcContractProvider extends Provider {
|
|
|
5912
6270
|
return new UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
5913
6271
|
});
|
|
5914
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
|
+
}
|
|
5915
6298
|
/**
|
|
5916
6299
|
* @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
|
|
5917
6300
|
* @param SmartRollupAddMessagesParams
|
|
@@ -6006,7 +6389,7 @@ class RpcContractProvider extends Provider {
|
|
|
6006
6389
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
6007
6390
|
const addressValidation = validateContractAddress(address);
|
|
6008
6391
|
if (addressValidation !== ValidationResult.VALID) {
|
|
6009
|
-
throw new InvalidContractAddressError(address,
|
|
6392
|
+
throw new InvalidContractAddressError(address, addressValidation);
|
|
6010
6393
|
}
|
|
6011
6394
|
const rpc = this.context.withExtensions().rpc;
|
|
6012
6395
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -6643,7 +7026,7 @@ class PollingSubscribeProvider {
|
|
|
6643
7026
|
constructor(context, config = {}) {
|
|
6644
7027
|
this.context = context;
|
|
6645
7028
|
this._config$ = new BehaviorSubject(Object.assign(Object.assign({}, defaultConfigStreamer), config));
|
|
6646
|
-
this.timer$ = this._config$.pipe(
|
|
7029
|
+
this.timer$ = this._config$.pipe(map((x) => x === null || x === void 0 ? void 0 : x.pollingIntervalMilliseconds), switchMap((pollingIntervalMilliseconds) => {
|
|
6647
7030
|
if (!pollingIntervalMilliseconds) {
|
|
6648
7031
|
return from(this.getConfirmationPollingInterval()).pipe(switchMap((interval) => {
|
|
6649
7032
|
return timer(0, interval);
|
|
@@ -6653,7 +7036,11 @@ class PollingSubscribeProvider {
|
|
|
6653
7036
|
return timer(0, pollingIntervalMilliseconds);
|
|
6654
7037
|
}
|
|
6655
7038
|
}));
|
|
6656
|
-
this.newBlock$ = this.timer$.pipe(switchMap(() => getLastBlock(this.context)), distinctUntilKeyChanged('hash'),
|
|
7039
|
+
this.newBlock$ = this.timer$.pipe(switchMap(() => getLastBlock(this.context)), distinctUntilKeyChanged('hash'), share({
|
|
7040
|
+
resetOnError: false,
|
|
7041
|
+
resetOnComplete: false,
|
|
7042
|
+
resetOnRefCountZero: true,
|
|
7043
|
+
}));
|
|
6657
7044
|
}
|
|
6658
7045
|
get config() {
|
|
6659
7046
|
return this._config$.getValue();
|
|
@@ -6685,7 +7072,7 @@ class PollingSubscribeProvider {
|
|
|
6685
7072
|
return new ObservableSubscription(this.newBlock$, this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
|
|
6686
7073
|
}
|
|
6687
7074
|
subscribe(_filter) {
|
|
6688
|
-
return new ObservableSubscription(this.newBlock$.pipe(
|
|
7075
|
+
return new ObservableSubscription(this.newBlock$.pipe(map((x) => x === null || x === void 0 ? void 0 : x.hash)), this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
|
|
6689
7076
|
}
|
|
6690
7077
|
subscribeOperation(filter) {
|
|
6691
7078
|
return new ObservableSubscription(this.newBlock$.pipe(applyFilter(filter)), this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
|
|
@@ -6871,8 +7258,8 @@ class Context {
|
|
|
6871
7258
|
|
|
6872
7259
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
6873
7260
|
const VERSION = {
|
|
6874
|
-
"commitHash": "
|
|
6875
|
-
"version": "
|
|
7261
|
+
"commitHash": "13639ef56845fbb7e93bcbd37d3f6d0457b0872b",
|
|
7262
|
+
"version": "23.0.0-RC.0"
|
|
6876
7263
|
};
|
|
6877
7264
|
|
|
6878
7265
|
/**
|
|
@@ -7320,5 +7707,5 @@ class TezosToolkit {
|
|
|
7320
7707
|
}
|
|
7321
7708
|
}
|
|
7322
7709
|
|
|
7323
|
-
export { BallotOperation, BatchOperation, BigMapAbstraction, COST_PER_BYTE, ChainIds, CompositeForger, Context, ContractAbstraction, ContractMethod, ContractMethodObject, ContractView, DEFAULT_SMART_CONTRACT_METHOD_NAME, 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 };
|
|
7324
7711
|
//# sourceMappingURL=taquito.es6.js.map
|