@taquito/taquito 22.0.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 +18 -16
- 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 +466 -109
- 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 +464 -105
- 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 +4 -1
- 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 +9 -9
package/dist/taquito.umd.js
CHANGED
|
@@ -187,25 +187,25 @@
|
|
|
187
187
|
TRANSFER: 257,
|
|
188
188
|
REVEAL: 0,
|
|
189
189
|
};
|
|
190
|
-
// value is based on octez-client reveal operation gasLimit of each address type in
|
|
190
|
+
// value is based on octez-client reveal operation gasLimit of each address type in Seoul Protocol
|
|
191
191
|
const REVEAL_GAS_LIMIT = {
|
|
192
|
-
TZ1:
|
|
193
|
-
TZ2:
|
|
194
|
-
TZ3:
|
|
195
|
-
TZ4:
|
|
192
|
+
TZ1: 171,
|
|
193
|
+
TZ2: 157,
|
|
194
|
+
TZ3: 447,
|
|
195
|
+
TZ4: 3252,
|
|
196
196
|
};
|
|
197
|
-
// value is based on octez-client reveal operation fee of each address type in
|
|
197
|
+
// value is based on octez-client reveal operation fee of each address type in Seoul Protocol
|
|
198
198
|
const REVEAL_FEE = {
|
|
199
|
-
TZ1:
|
|
200
|
-
TZ2:
|
|
201
|
-
TZ3:
|
|
202
|
-
TZ4:
|
|
199
|
+
TZ1: 278,
|
|
200
|
+
TZ2: 277,
|
|
201
|
+
TZ3: 306,
|
|
202
|
+
TZ4: 736,
|
|
203
203
|
};
|
|
204
|
-
// value is based on octez-client reveal operation storageLimit of all address type in
|
|
204
|
+
// value is based on octez-client reveal operation storageLimit of all address type in Seoul Protocol
|
|
205
205
|
const REVEAL_STORAGE_LIMIT = 0;
|
|
206
|
-
// protocol constants in
|
|
206
|
+
// protocol constants in Seoul Protocol
|
|
207
207
|
const ORIGINATION_SIZE = 257;
|
|
208
|
-
// protocol constants in
|
|
208
|
+
// protocol constants in Seoul Protocol
|
|
209
209
|
const COST_PER_BYTE = 250;
|
|
210
210
|
exports.Protocols = void 0;
|
|
211
211
|
(function (Protocols) {
|
|
@@ -231,6 +231,7 @@
|
|
|
231
231
|
Protocols["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
|
|
232
232
|
Protocols["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
|
|
233
233
|
Protocols["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
|
|
234
|
+
Protocols["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
|
|
234
235
|
Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
235
236
|
})(exports.Protocols || (exports.Protocols = {}));
|
|
236
237
|
const protocols = {
|
|
@@ -252,7 +253,8 @@
|
|
|
252
253
|
'020': [exports.Protocols.PtParisBx, exports.Protocols.PsParisCZ],
|
|
253
254
|
'021': [exports.Protocols.PsQuebecn],
|
|
254
255
|
'022': [exports.Protocols.PsRiotuma],
|
|
255
|
-
'023': [exports.Protocols.
|
|
256
|
+
'023': [exports.Protocols.PtSeouLou],
|
|
257
|
+
'024': [exports.Protocols.ProtoALpha],
|
|
256
258
|
};
|
|
257
259
|
exports.ChainIds = void 0;
|
|
258
260
|
(function (ChainIds) {
|
|
@@ -276,8 +278,8 @@
|
|
|
276
278
|
ChainIds["PARISCNET"] = "NetXXWAHLEvre9b";
|
|
277
279
|
ChainIds["QUEBECNET"] = "NetXuTeGinLEqxp";
|
|
278
280
|
ChainIds["RIONET"] = "NetXPdgaoabtBth";
|
|
281
|
+
ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
|
|
279
282
|
})(exports.ChainIds || (exports.ChainIds = {}));
|
|
280
|
-
// 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)
|
|
281
283
|
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
282
284
|
const getRevealGasLimitInternal = (address) => {
|
|
283
285
|
switch (address.substring(0, 3)) {
|
|
@@ -303,7 +305,7 @@
|
|
|
303
305
|
case 'tz3':
|
|
304
306
|
return REVEAL_FEE.TZ3;
|
|
305
307
|
case 'tz4':
|
|
306
|
-
return REVEAL_FEE.TZ4;
|
|
308
|
+
return REVEAL_FEE.TZ4 * 1.7;
|
|
307
309
|
default:
|
|
308
310
|
throw new Error(`Cannot estimate reveal fee for ${address}`);
|
|
309
311
|
}
|
|
@@ -516,7 +518,7 @@
|
|
|
516
518
|
delegate: source,
|
|
517
519
|
};
|
|
518
520
|
});
|
|
519
|
-
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit }, source, publicKey) {
|
|
521
|
+
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit, proof }, source, publicKey) {
|
|
520
522
|
return {
|
|
521
523
|
kind: rpc.OpKind.REVEAL,
|
|
522
524
|
fee,
|
|
@@ -524,6 +526,7 @@
|
|
|
524
526
|
source,
|
|
525
527
|
gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : getRevealGasLimit(source),
|
|
526
528
|
storage_limit: storageLimit,
|
|
529
|
+
proof,
|
|
527
530
|
};
|
|
528
531
|
});
|
|
529
532
|
const createRegisterGlobalConstantOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, source, fee, gasLimit, storageLimit, }) {
|
|
@@ -585,7 +588,7 @@
|
|
|
585
588
|
proposals,
|
|
586
589
|
};
|
|
587
590
|
});
|
|
588
|
-
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, }) {
|
|
591
|
+
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
589
592
|
return {
|
|
590
593
|
kind: rpc.OpKind.UPDATE_CONSENSUS_KEY,
|
|
591
594
|
source,
|
|
@@ -593,6 +596,18 @@
|
|
|
593
596
|
gas_limit: gasLimit,
|
|
594
597
|
storage_limit: storageLimit,
|
|
595
598
|
pk,
|
|
599
|
+
proof,
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
const createUpdateCompanionKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
603
|
+
return {
|
|
604
|
+
kind: rpc.OpKind.UPDATE_COMPANION_KEY,
|
|
605
|
+
source,
|
|
606
|
+
fee,
|
|
607
|
+
gas_limit: gasLimit,
|
|
608
|
+
storage_limit: storageLimit,
|
|
609
|
+
pk,
|
|
610
|
+
proof,
|
|
596
611
|
};
|
|
597
612
|
});
|
|
598
613
|
const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
|
|
@@ -645,7 +660,8 @@
|
|
|
645
660
|
return op.kind === kind;
|
|
646
661
|
};
|
|
647
662
|
const isOpWithGasBuffer = (op) => {
|
|
648
|
-
|
|
663
|
+
var _a;
|
|
664
|
+
if (op.kind === rpc.OpKind.TRANSACTION && ((_a = op.destination) === null || _a === void 0 ? void 0 : _a.startsWith('KT1'))) {
|
|
649
665
|
return true;
|
|
650
666
|
}
|
|
651
667
|
else {
|
|
@@ -654,6 +670,7 @@
|
|
|
654
670
|
'register_global_constant',
|
|
655
671
|
'transfer_ticket',
|
|
656
672
|
'update_consensus_key',
|
|
673
|
+
'update_companion_key',
|
|
657
674
|
'smart_rollup_add_messages',
|
|
658
675
|
'smart_rollup_originate',
|
|
659
676
|
].indexOf(op.kind) !== -1);
|
|
@@ -669,6 +686,7 @@
|
|
|
669
686
|
'increase_paid_storage',
|
|
670
687
|
'transfer_ticket',
|
|
671
688
|
'update_consensus_key',
|
|
689
|
+
'update_companion_key',
|
|
672
690
|
'smart_rollup_add_messages',
|
|
673
691
|
'smart_rollup_originate',
|
|
674
692
|
'smart_rollup_execute_outbox_message',
|
|
@@ -683,6 +701,7 @@
|
|
|
683
701
|
'increase_paid_storage',
|
|
684
702
|
'transfer_ticket',
|
|
685
703
|
'update_consensus_key',
|
|
704
|
+
'update_companion_key',
|
|
686
705
|
'smart_rollup_add_messages',
|
|
687
706
|
'smart_rollup_originate',
|
|
688
707
|
'smart_rollup_execute_outbox_message',
|
|
@@ -1084,6 +1103,10 @@
|
|
|
1084
1103
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
1085
1104
|
case rpc.OpKind.INCREASE_PAID_STORAGE:
|
|
1086
1105
|
return createIncreasePaidStorageOperation(Object.assign({}, param));
|
|
1106
|
+
case rpc.OpKind.UPDATE_CONSENSUS_KEY:
|
|
1107
|
+
return createUpdateConsensusKeyOperation(Object.assign({}, param));
|
|
1108
|
+
case rpc.OpKind.UPDATE_COMPANION_KEY:
|
|
1109
|
+
return createUpdateCompanionKeyOperation(Object.assign({}, param));
|
|
1087
1110
|
case rpc.OpKind.TRANSFER_TICKET:
|
|
1088
1111
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
1089
1112
|
case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -1178,7 +1201,7 @@
|
|
|
1178
1201
|
withTransfer(params) {
|
|
1179
1202
|
const toValidation = utils.validateAddress(params.to);
|
|
1180
1203
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
1181
|
-
throw new core.InvalidAddressError(params.to,
|
|
1204
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
1182
1205
|
}
|
|
1183
1206
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSACTION }, params));
|
|
1184
1207
|
return this;
|
|
@@ -1199,7 +1222,7 @@
|
|
|
1199
1222
|
var _a;
|
|
1200
1223
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1201
1224
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
1202
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
1225
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
1203
1226
|
}
|
|
1204
1227
|
this.operations.push(Object.assign({ kind: rpc.OpKind.DELEGATION }, params));
|
|
1205
1228
|
return this;
|
|
@@ -1219,7 +1242,7 @@
|
|
|
1219
1242
|
withIncreasePaidStorage(params) {
|
|
1220
1243
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
1221
1244
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
1222
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1245
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
1223
1246
|
}
|
|
1224
1247
|
this.operations.push(Object.assign({ kind: rpc.OpKind.INCREASE_PAID_STORAGE }, params));
|
|
1225
1248
|
return this;
|
|
@@ -1231,7 +1254,7 @@
|
|
|
1231
1254
|
withTransferTicket(params) {
|
|
1232
1255
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
1233
1256
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
1234
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1257
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
1235
1258
|
}
|
|
1236
1259
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSFER_TICKET }, params));
|
|
1237
1260
|
return this;
|
|
@@ -1353,7 +1376,7 @@
|
|
|
1353
1376
|
var _a;
|
|
1354
1377
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
1355
1378
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
1356
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
1379
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
1357
1380
|
}
|
|
1358
1381
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1359
1382
|
const mappedParams = yield this.walletProvider.mapDelegateParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1415,7 +1438,7 @@
|
|
|
1415
1438
|
transfer(params) {
|
|
1416
1439
|
const toValidation = utils.validateAddress(params.to);
|
|
1417
1440
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
1418
|
-
throw new core.InvalidAddressError(params.to,
|
|
1441
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
1419
1442
|
}
|
|
1420
1443
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1421
1444
|
const mappedParams = yield this.walletProvider.mapTransferParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1431,7 +1454,7 @@
|
|
|
1431
1454
|
transferTicket(params) {
|
|
1432
1455
|
const toValidation = utils.validateAddress(params.destination);
|
|
1433
1456
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
1434
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1457
|
+
throw new core.InvalidAddressError(params.destination, toValidation);
|
|
1435
1458
|
}
|
|
1436
1459
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1437
1460
|
const mappedParams = yield this.walletProvider.mapTransferTicketParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1497,9 +1520,6 @@
|
|
|
1497
1520
|
if (!params.to) {
|
|
1498
1521
|
params.to = source;
|
|
1499
1522
|
}
|
|
1500
|
-
if (params.to !== source) {
|
|
1501
|
-
throw new core.InvalidStakingAddressError(params.to);
|
|
1502
|
-
}
|
|
1503
1523
|
if (!params.amount) {
|
|
1504
1524
|
params.amount = 0;
|
|
1505
1525
|
}
|
|
@@ -1521,7 +1541,7 @@
|
|
|
1521
1541
|
increasePaidStorage(params) {
|
|
1522
1542
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
1523
1543
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
1524
|
-
throw new core.InvalidAddressError(params.destination,
|
|
1544
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
1525
1545
|
}
|
|
1526
1546
|
return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
|
|
1527
1547
|
const mappedParams = yield this.walletProvider.mapIncreasePaidStorageWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
|
|
@@ -1551,7 +1571,7 @@
|
|
|
1551
1571
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
1552
1572
|
const addressValidation = utils.validateContractAddress(address);
|
|
1553
1573
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
1554
|
-
throw new core.InvalidContractAddressError(address,
|
|
1574
|
+
throw new core.InvalidContractAddressError(address, addressValidation);
|
|
1555
1575
|
}
|
|
1556
1576
|
const rpc = this.context.withExtensions().rpc;
|
|
1557
1577
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -1677,7 +1697,7 @@
|
|
|
1677
1697
|
connector: () => new rxjs.ReplaySubject(1),
|
|
1678
1698
|
resetOnError: false,
|
|
1679
1699
|
resetOnComplete: false,
|
|
1680
|
-
resetOnRefCountZero:
|
|
1700
|
+
resetOnRefCountZero: true,
|
|
1681
1701
|
}));
|
|
1682
1702
|
// Observable that emit once operation is seen in a block
|
|
1683
1703
|
this.confirmed$ = this.newHead$.pipe(operators.map((head) => {
|
|
@@ -1698,7 +1718,7 @@
|
|
|
1698
1718
|
connector: () => new rxjs.ReplaySubject(1),
|
|
1699
1719
|
resetOnError: false,
|
|
1700
1720
|
resetOnComplete: false,
|
|
1701
|
-
resetOnRefCountZero:
|
|
1721
|
+
resetOnRefCountZero: true,
|
|
1702
1722
|
}));
|
|
1703
1723
|
if (utils.validateOperation(this.opHash) !== utils.ValidationResult.VALID) {
|
|
1704
1724
|
throw new core.InvalidOperationHashError(this.opHash);
|
|
@@ -2299,7 +2319,7 @@
|
|
|
2299
2319
|
throw new core.DeprecationError(`Since version 12, the lambda view no longer depends on a lambda contract. The read method no longer accepts a contract address as a parameter.`);
|
|
2300
2320
|
}
|
|
2301
2321
|
else if (chainId && chainIdValidation !== utils.ValidationResult.VALID) {
|
|
2302
|
-
throw new core.InvalidChainIdError(chainId,
|
|
2322
|
+
throw new core.InvalidChainIdError(chainId, chainIdValidation);
|
|
2303
2323
|
}
|
|
2304
2324
|
const arg = this.parameterSchema.Encode(...this.args);
|
|
2305
2325
|
const result = yield this.rpc.runView({
|
|
@@ -2737,10 +2757,14 @@
|
|
|
2737
2757
|
if (!publicKey) {
|
|
2738
2758
|
throw new core.PublicKeyNotFoundError(pkh);
|
|
2739
2759
|
}
|
|
2760
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
|
|
2740
2761
|
ops.unshift(yield createRevealOperation({
|
|
2741
2762
|
fee: getRevealFee(pkh),
|
|
2742
2763
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
2743
2764
|
gasLimit: getRevealGasLimit(pkh),
|
|
2765
|
+
proof: pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash
|
|
2766
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
2767
|
+
: undefined,
|
|
2744
2768
|
}, publicKeyHash, publicKey));
|
|
2745
2769
|
return ops;
|
|
2746
2770
|
}
|
|
@@ -2786,6 +2810,7 @@
|
|
|
2786
2810
|
case rpc.OpKind.DELEGATION:
|
|
2787
2811
|
case rpc.OpKind.REGISTER_GLOBAL_CONSTANT:
|
|
2788
2812
|
case rpc.OpKind.UPDATE_CONSENSUS_KEY:
|
|
2813
|
+
case rpc.OpKind.UPDATE_COMPANION_KEY:
|
|
2789
2814
|
case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
2790
2815
|
case rpc.OpKind.SMART_ROLLUP_ORIGINATE:
|
|
2791
2816
|
case rpc.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
@@ -2846,11 +2871,26 @@
|
|
|
2846
2871
|
* @returns a PreparedOperation object
|
|
2847
2872
|
*/
|
|
2848
2873
|
reveal(_a) {
|
|
2849
|
-
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit }) {
|
|
2874
|
+
return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit, proof }) {
|
|
2850
2875
|
const { pkh, publicKey } = yield this.getKeys();
|
|
2851
2876
|
if (!publicKey) {
|
|
2852
2877
|
throw new core.PublicKeyNotFoundError(pkh);
|
|
2853
2878
|
}
|
|
2879
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
|
|
2880
|
+
if (pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash) {
|
|
2881
|
+
if (proof) {
|
|
2882
|
+
utils.b58DecodeAndCheckPrefix(proof, [utils.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
2883
|
+
}
|
|
2884
|
+
else {
|
|
2885
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
2886
|
+
proof = prefixSig;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
else {
|
|
2890
|
+
if (proof) {
|
|
2891
|
+
throw new core.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2854
2894
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
2855
2895
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
2856
2896
|
const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
|
|
@@ -2858,6 +2898,7 @@
|
|
|
2858
2898
|
fee: mergedEstimates.fee,
|
|
2859
2899
|
gasLimit: mergedEstimates.gasLimit,
|
|
2860
2900
|
storageLimit: mergedEstimates.storageLimit,
|
|
2901
|
+
proof,
|
|
2861
2902
|
}, pkh, publicKey);
|
|
2862
2903
|
const ops = this.convertIntoArray(op);
|
|
2863
2904
|
const hash = yield this.getBlockHash();
|
|
@@ -3016,11 +3057,11 @@
|
|
|
3016
3057
|
*/
|
|
3017
3058
|
finalizeUnstake(_a) {
|
|
3018
3059
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3019
|
-
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3060
|
+
var { fee, storageLimit, gasLimit, to } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit", "to"]);
|
|
3020
3061
|
const { pkh } = yield this.getKeys();
|
|
3021
3062
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3022
3063
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3023
|
-
const op = yield createTransferOperation(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { to: pkh, amount: 0 }), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)), { parameter: {
|
|
3064
|
+
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: {
|
|
3024
3065
|
entrypoint: 'finalize_unstake',
|
|
3025
3066
|
value: { prim: 'Unit' },
|
|
3026
3067
|
} }));
|
|
@@ -3149,6 +3190,17 @@
|
|
|
3149
3190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3150
3191
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3151
3192
|
const { pkh } = yield this.getKeys();
|
|
3193
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(rest.pk, utils.publicKeyPrefixes);
|
|
3194
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
3195
|
+
if (!rest.proof) {
|
|
3196
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
else {
|
|
3200
|
+
if (rest.proof) {
|
|
3201
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3152
3204
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3153
3205
|
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3154
3206
|
const op = yield createUpdateConsensusKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
@@ -3169,6 +3221,44 @@
|
|
|
3169
3221
|
};
|
|
3170
3222
|
});
|
|
3171
3223
|
}
|
|
3224
|
+
/**
|
|
3225
|
+
*
|
|
3226
|
+
* @description Method to prepare an update_companion_key operation
|
|
3227
|
+
* @param operation RPCOperation object or RPCOperation array
|
|
3228
|
+
* @param source string or undefined source pkh
|
|
3229
|
+
* @returns a PreparedOperation object
|
|
3230
|
+
*/
|
|
3231
|
+
updateCompanionKey(_a, source) {
|
|
3232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3233
|
+
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
3234
|
+
const { pkh } = yield this.getKeys();
|
|
3235
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(rest.pk, utils.publicKeyPrefixes);
|
|
3236
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
3237
|
+
throw new core.ProhibitedActionError('companion key must be a bls account');
|
|
3238
|
+
}
|
|
3239
|
+
if (!rest.proof) {
|
|
3240
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
3241
|
+
}
|
|
3242
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
3243
|
+
const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
|
|
3244
|
+
const op = yield createUpdateCompanionKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
|
|
3245
|
+
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
3246
|
+
const ops = this.convertIntoArray(operation);
|
|
3247
|
+
const hash = yield this.getBlockHash();
|
|
3248
|
+
const protocol = yield this.getProtocolHash();
|
|
3249
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
3250
|
+
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
3251
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
3252
|
+
return {
|
|
3253
|
+
opOb: {
|
|
3254
|
+
branch: hash,
|
|
3255
|
+
contents,
|
|
3256
|
+
protocol,
|
|
3257
|
+
},
|
|
3258
|
+
counter: headCounter,
|
|
3259
|
+
};
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3172
3262
|
/**
|
|
3173
3263
|
*
|
|
3174
3264
|
* @description Method to prepare an increase_paid_storage operation
|
|
@@ -3459,10 +3549,14 @@
|
|
|
3459
3549
|
if (!publicKey) {
|
|
3460
3550
|
throw new core.PublicKeyNotFoundError(pkh);
|
|
3461
3551
|
}
|
|
3552
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
|
|
3462
3553
|
ops.unshift(yield createRevealOperation({
|
|
3463
3554
|
fee: getRevealFee(pkh),
|
|
3464
3555
|
storageLimit: REVEAL_STORAGE_LIMIT,
|
|
3465
3556
|
gasLimit: getRevealGasLimit(pkh),
|
|
3557
|
+
proof: pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash
|
|
3558
|
+
? (yield this.signer.provePossession()).prefixSig
|
|
3559
|
+
: undefined,
|
|
3466
3560
|
}, pkh, publicKey));
|
|
3467
3561
|
}
|
|
3468
3562
|
const hash = yield this.getBlockHash();
|
|
@@ -3579,7 +3673,7 @@
|
|
|
3579
3673
|
throw new core.InvalidAmountError(params.amount.toString());
|
|
3580
3674
|
}
|
|
3581
3675
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
3582
|
-
throw new core.InvalidAddressError(params.to,
|
|
3676
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
3583
3677
|
}
|
|
3584
3678
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSACTION }, params));
|
|
3585
3679
|
return this;
|
|
@@ -3593,7 +3687,7 @@
|
|
|
3593
3687
|
withTransferTicket(params) {
|
|
3594
3688
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
3595
3689
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
3596
|
-
throw new core.InvalidAddressError(params.destination,
|
|
3690
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
3597
3691
|
}
|
|
3598
3692
|
this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSFER_TICKET }, params));
|
|
3599
3693
|
return this;
|
|
@@ -3618,11 +3712,11 @@
|
|
|
3618
3712
|
var _a;
|
|
3619
3713
|
const sourceValidation = utils.validateAddress(params.source);
|
|
3620
3714
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
3621
|
-
throw new core.InvalidAddressError(params.source,
|
|
3715
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
3622
3716
|
}
|
|
3623
3717
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
3624
3718
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
3625
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
3719
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
3626
3720
|
}
|
|
3627
3721
|
this.operations.push(Object.assign({ kind: rpc.OpKind.DELEGATION }, params));
|
|
3628
3722
|
return this;
|
|
@@ -3637,7 +3731,7 @@
|
|
|
3637
3731
|
withActivation({ pkh, secret }) {
|
|
3638
3732
|
const pkhValidation = utils.validateKeyHash(pkh);
|
|
3639
3733
|
if (pkhValidation !== utils.ValidationResult.VALID) {
|
|
3640
|
-
throw new core.InvalidKeyHashError(pkh,
|
|
3734
|
+
throw new core.InvalidKeyHashError(pkh, pkhValidation);
|
|
3641
3735
|
}
|
|
3642
3736
|
this.operations.push({ kind: rpc.OpKind.ACTIVATION, pkh, secret });
|
|
3643
3737
|
return this;
|
|
@@ -3672,6 +3766,44 @@
|
|
|
3672
3766
|
this.operations.push(Object.assign({ kind: rpc.OpKind.INCREASE_PAID_STORAGE }, params));
|
|
3673
3767
|
return this;
|
|
3674
3768
|
}
|
|
3769
|
+
/**
|
|
3770
|
+
*
|
|
3771
|
+
* @description Add a update consensus key operation to the batch
|
|
3772
|
+
*
|
|
3773
|
+
* @param params UpdateConsensusKey operation parameter
|
|
3774
|
+
*/
|
|
3775
|
+
withUpdateConsensusKey(params) {
|
|
3776
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
3777
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
3778
|
+
if (!params.proof) {
|
|
3779
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
else {
|
|
3783
|
+
if (params.proof) {
|
|
3784
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
this.operations.push(Object.assign({ kind: rpc.OpKind.UPDATE_CONSENSUS_KEY }, params));
|
|
3788
|
+
return this;
|
|
3789
|
+
}
|
|
3790
|
+
/**
|
|
3791
|
+
*
|
|
3792
|
+
* @description Add a update companion key operation to the batch
|
|
3793
|
+
*
|
|
3794
|
+
* @param params UpdateCompanionKey operation parameter
|
|
3795
|
+
*/
|
|
3796
|
+
withUpdateCompanionKey(params) {
|
|
3797
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
3798
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
3799
|
+
throw new core.ProhibitedActionError('companion key must be a bls account');
|
|
3800
|
+
}
|
|
3801
|
+
if (!params.proof) {
|
|
3802
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
3803
|
+
}
|
|
3804
|
+
this.operations.push(Object.assign({ kind: rpc.OpKind.UPDATE_COMPANION_KEY }, params));
|
|
3805
|
+
return this;
|
|
3806
|
+
}
|
|
3675
3807
|
/**
|
|
3676
3808
|
*
|
|
3677
3809
|
* @description Add a smart rollup add messages operation to the batch
|
|
@@ -3715,6 +3847,10 @@
|
|
|
3715
3847
|
return createRegisterGlobalConstantOperation(Object.assign({}, param));
|
|
3716
3848
|
case rpc.OpKind.INCREASE_PAID_STORAGE:
|
|
3717
3849
|
return createIncreasePaidStorageOperation(Object.assign({}, param));
|
|
3850
|
+
case rpc.OpKind.UPDATE_CONSENSUS_KEY:
|
|
3851
|
+
return createUpdateConsensusKeyOperation(Object.assign({}, param));
|
|
3852
|
+
case rpc.OpKind.UPDATE_COMPANION_KEY:
|
|
3853
|
+
return createUpdateCompanionKeyOperation(Object.assign({}, param));
|
|
3718
3854
|
case rpc.OpKind.TRANSFER_TICKET:
|
|
3719
3855
|
return createTransferTicketOperation(Object.assign({}, param));
|
|
3720
3856
|
case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
@@ -3929,7 +4065,7 @@
|
|
|
3929
4065
|
connector: () => new rxjs.ReplaySubject(1),
|
|
3930
4066
|
resetOnError: false,
|
|
3931
4067
|
resetOnComplete: false,
|
|
3932
|
-
resetOnRefCountZero:
|
|
4068
|
+
resetOnRefCountZero: true,
|
|
3933
4069
|
}));
|
|
3934
4070
|
};
|
|
3935
4071
|
class OperationFactory {
|
|
@@ -4011,7 +4147,7 @@
|
|
|
4011
4147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4012
4148
|
const addressValidation = utils.validateAddress(address);
|
|
4013
4149
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
4014
|
-
throw new core.InvalidAddressError(address,
|
|
4150
|
+
throw new core.InvalidAddressError(address, addressValidation);
|
|
4015
4151
|
}
|
|
4016
4152
|
return this.context.readProvider.getBalance(address, 'head');
|
|
4017
4153
|
});
|
|
@@ -4020,7 +4156,7 @@
|
|
|
4020
4156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4021
4157
|
const addressValidation = utils.validateAddress(address);
|
|
4022
4158
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
4023
|
-
throw new core.InvalidAddressError(address,
|
|
4159
|
+
throw new core.InvalidAddressError(address, addressValidation);
|
|
4024
4160
|
}
|
|
4025
4161
|
return this.context.readProvider.getSpendable(address, 'head');
|
|
4026
4162
|
});
|
|
@@ -4029,7 +4165,7 @@
|
|
|
4029
4165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4030
4166
|
const addressValidation = utils.validateAddress(address);
|
|
4031
4167
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
4032
|
-
throw new core.InvalidAddressError(address,
|
|
4168
|
+
throw new core.InvalidAddressError(address, addressValidation);
|
|
4033
4169
|
}
|
|
4034
4170
|
return this.context.readProvider.getDelegate(address, 'head');
|
|
4035
4171
|
});
|
|
@@ -4038,7 +4174,7 @@
|
|
|
4038
4174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4039
4175
|
const pkhValidation = utils.validateKeyHash(pkh);
|
|
4040
4176
|
if (pkhValidation !== utils.ValidationResult.VALID) {
|
|
4041
|
-
throw new utils.InvalidKeyHashError(pkh,
|
|
4177
|
+
throw new utils.InvalidKeyHashError(pkh, pkhValidation);
|
|
4042
4178
|
}
|
|
4043
4179
|
const prepared = yield this.prepare.activate({ pkh, secret });
|
|
4044
4180
|
const forgedBytes = yield this.forge(prepared);
|
|
@@ -4192,7 +4328,8 @@
|
|
|
4192
4328
|
class RPCEstimateProvider extends Provider {
|
|
4193
4329
|
constructor() {
|
|
4194
4330
|
super(...arguments);
|
|
4195
|
-
this.
|
|
4331
|
+
this.REVEAL_LENGTH = 324; // injecting size tz1=320, tz2=322, tz3=322
|
|
4332
|
+
this.REVEAL_LENGTH_TZ4 = 622; // injecting size tz4=620
|
|
4196
4333
|
this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
|
|
4197
4334
|
this.STORAGE_BUFFER = 20; // according to octez-client
|
|
4198
4335
|
this.prepare = new PrepareProvider(this.context);
|
|
@@ -4274,9 +4411,20 @@
|
|
|
4274
4411
|
: op.opOb.contents.length;
|
|
4275
4412
|
}
|
|
4276
4413
|
return opResponse.contents.map((x) => {
|
|
4414
|
+
const content = x;
|
|
4415
|
+
content.source = content.source || '';
|
|
4416
|
+
let revealSize, eachOpSize;
|
|
4417
|
+
if (content.source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)) {
|
|
4418
|
+
revealSize = this.REVEAL_LENGTH_TZ4 / 2;
|
|
4419
|
+
eachOpSize = (opbytes.length / 2 + utils.payloadLength[utils.PrefixV2.BLS12_381Signature]) / numberOfOps;
|
|
4420
|
+
}
|
|
4421
|
+
else {
|
|
4422
|
+
revealSize = this.REVEAL_LENGTH / 2;
|
|
4423
|
+
eachOpSize = (opbytes.length / 2 + utils.payloadLength[utils.PrefixV2.Ed25519Signature]) / numberOfOps;
|
|
4424
|
+
}
|
|
4277
4425
|
return this.getEstimationPropertiesFromOperationContent(x,
|
|
4278
4426
|
// diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
|
|
4279
|
-
x.kind === 'reveal' ?
|
|
4427
|
+
x.kind === 'reveal' ? revealSize : eachOpSize, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
|
|
4280
4428
|
);
|
|
4281
4429
|
});
|
|
4282
4430
|
});
|
|
@@ -4295,8 +4443,11 @@
|
|
|
4295
4443
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4296
4444
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4297
4445
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4446
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4447
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4448
|
+
: this.REVEAL_LENGTH / 2;
|
|
4298
4449
|
estimateProperties.shift();
|
|
4299
|
-
estimateProperties[0].opSize -=
|
|
4450
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4300
4451
|
}
|
|
4301
4452
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4302
4453
|
});
|
|
@@ -4315,11 +4466,11 @@
|
|
|
4315
4466
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4316
4467
|
const toValidation = utils.validateAddress(rest.to);
|
|
4317
4468
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
4318
|
-
throw new core.InvalidAddressError(rest.to,
|
|
4469
|
+
throw new core.InvalidAddressError(rest.to, toValidation);
|
|
4319
4470
|
}
|
|
4320
4471
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4321
4472
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4322
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4473
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4323
4474
|
}
|
|
4324
4475
|
if (rest.amount < 0) {
|
|
4325
4476
|
throw new core.InvalidAmountError(rest.amount.toString());
|
|
@@ -4330,8 +4481,11 @@
|
|
|
4330
4481
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4331
4482
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4332
4483
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4484
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4485
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4486
|
+
: this.REVEAL_LENGTH / 2;
|
|
4333
4487
|
estimateProperties.shift();
|
|
4334
|
-
estimateProperties[0].opSize -=
|
|
4488
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4335
4489
|
}
|
|
4336
4490
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4337
4491
|
});
|
|
@@ -4350,7 +4504,7 @@
|
|
|
4350
4504
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4351
4505
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4352
4506
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4353
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4507
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4354
4508
|
}
|
|
4355
4509
|
if (!rest.to) {
|
|
4356
4510
|
rest.to = rest.source;
|
|
@@ -4368,7 +4522,10 @@
|
|
|
4368
4522
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4369
4523
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4370
4524
|
estimateProperties.shift();
|
|
4371
|
-
|
|
4525
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4526
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4527
|
+
: this.REVEAL_LENGTH / 2;
|
|
4528
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4372
4529
|
}
|
|
4373
4530
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4374
4531
|
});
|
|
@@ -4387,7 +4544,7 @@
|
|
|
4387
4544
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4388
4545
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4389
4546
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4390
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4547
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4391
4548
|
}
|
|
4392
4549
|
if (!rest.to) {
|
|
4393
4550
|
rest.to = rest.source;
|
|
@@ -4405,7 +4562,10 @@
|
|
|
4405
4562
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4406
4563
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4407
4564
|
estimateProperties.shift();
|
|
4408
|
-
|
|
4565
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4566
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4567
|
+
: this.REVEAL_LENGTH / 2;
|
|
4568
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4409
4569
|
}
|
|
4410
4570
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4411
4571
|
});
|
|
@@ -4424,14 +4584,11 @@
|
|
|
4424
4584
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4425
4585
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4426
4586
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4427
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4587
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4428
4588
|
}
|
|
4429
4589
|
if (!rest.to) {
|
|
4430
4590
|
rest.to = rest.source;
|
|
4431
4591
|
}
|
|
4432
|
-
if (rest.to && rest.to !== rest.source) {
|
|
4433
|
-
throw new core.InvalidStakingAddressError(rest.to);
|
|
4434
|
-
}
|
|
4435
4592
|
if (!rest.amount) {
|
|
4436
4593
|
rest.amount = 0;
|
|
4437
4594
|
}
|
|
@@ -4445,7 +4602,10 @@
|
|
|
4445
4602
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4446
4603
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4447
4604
|
estimateProperties.shift();
|
|
4448
|
-
|
|
4605
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4606
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4607
|
+
: this.REVEAL_LENGTH / 2;
|
|
4608
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4449
4609
|
}
|
|
4450
4610
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4451
4611
|
});
|
|
@@ -4464,11 +4624,11 @@
|
|
|
4464
4624
|
var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
|
|
4465
4625
|
const destinationValidation = utils.validateAddress(rest.destination);
|
|
4466
4626
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
4467
|
-
throw new core.InvalidAddressError(rest.destination,
|
|
4627
|
+
throw new core.InvalidAddressError(rest.destination, destinationValidation);
|
|
4468
4628
|
}
|
|
4469
4629
|
const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
|
|
4470
4630
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4471
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4631
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4472
4632
|
}
|
|
4473
4633
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4474
4634
|
const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
|
|
@@ -4477,7 +4637,10 @@
|
|
|
4477
4637
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4478
4638
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4479
4639
|
estimateProperties.shift();
|
|
4480
|
-
|
|
4640
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4641
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4642
|
+
: this.REVEAL_LENGTH / 2;
|
|
4643
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4481
4644
|
}
|
|
4482
4645
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4483
4646
|
});
|
|
@@ -4496,11 +4659,11 @@
|
|
|
4496
4659
|
var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
|
|
4497
4660
|
const sourceValidation = utils.validateAddress(rest.source);
|
|
4498
4661
|
if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
4499
|
-
throw new core.InvalidAddressError(rest.source,
|
|
4662
|
+
throw new core.InvalidAddressError(rest.source, sourceValidation);
|
|
4500
4663
|
}
|
|
4501
4664
|
const delegateValidation = utils.validateAddress((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
|
|
4502
4665
|
if (rest.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
4503
|
-
throw new core.InvalidAddressError(rest.delegate,
|
|
4666
|
+
throw new core.InvalidAddressError(rest.delegate, delegateValidation);
|
|
4504
4667
|
}
|
|
4505
4668
|
const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
|
|
4506
4669
|
storageLimit,
|
|
@@ -4509,7 +4672,10 @@
|
|
|
4509
4672
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4510
4673
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4511
4674
|
estimateProperties.shift();
|
|
4512
|
-
|
|
4675
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4676
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4677
|
+
: this.REVEAL_LENGTH / 2;
|
|
4678
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4513
4679
|
}
|
|
4514
4680
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4515
4681
|
});
|
|
@@ -4546,7 +4712,10 @@
|
|
|
4546
4712
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4547
4713
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4548
4714
|
estimateProperties.shift();
|
|
4549
|
-
|
|
4715
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4716
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4717
|
+
: this.REVEAL_LENGTH / 2;
|
|
4718
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4550
4719
|
}
|
|
4551
4720
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4552
4721
|
});
|
|
@@ -4554,7 +4723,6 @@
|
|
|
4554
4723
|
/**
|
|
4555
4724
|
*
|
|
4556
4725
|
* @description Estimate gasLimit, storageLimit and fees to reveal the current account
|
|
4557
|
-
*
|
|
4558
4726
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
|
|
4559
4727
|
*
|
|
4560
4728
|
* @param Estimate
|
|
@@ -4566,6 +4734,21 @@
|
|
|
4566
4734
|
throw new RevealEstimateError();
|
|
4567
4735
|
}
|
|
4568
4736
|
if (yield this.isAccountRevealRequired(publicKeyHash)) {
|
|
4737
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(publicKeyHash, utils.publicKeyHashPrefixes);
|
|
4738
|
+
if (pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash) {
|
|
4739
|
+
if (params && params.proof) {
|
|
4740
|
+
utils.b58DecodeAndCheckPrefix(params.proof, [utils.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
4741
|
+
}
|
|
4742
|
+
else {
|
|
4743
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
4744
|
+
params = Object.assign(Object.assign({}, params), { proof: prefixSig });
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
else {
|
|
4748
|
+
if (params && params.proof) {
|
|
4749
|
+
throw new core.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4569
4752
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4570
4753
|
const preparedOperation = params
|
|
4571
4754
|
? yield this.prepare.reveal(params)
|
|
@@ -4593,7 +4776,10 @@
|
|
|
4593
4776
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4594
4777
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4595
4778
|
estimateProperties.shift();
|
|
4596
|
-
|
|
4779
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4780
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4781
|
+
: this.REVEAL_LENGTH / 2;
|
|
4782
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4597
4783
|
}
|
|
4598
4784
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4599
4785
|
});
|
|
@@ -4619,7 +4805,10 @@
|
|
|
4619
4805
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4620
4806
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4621
4807
|
estimateProperties.shift();
|
|
4622
|
-
|
|
4808
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4809
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4810
|
+
: this.REVEAL_LENGTH / 2;
|
|
4811
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4623
4812
|
}
|
|
4624
4813
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4625
4814
|
});
|
|
@@ -4627,19 +4816,59 @@
|
|
|
4627
4816
|
/**
|
|
4628
4817
|
*
|
|
4629
4818
|
* @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
|
|
4630
|
-
*
|
|
4631
4819
|
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4632
|
-
*
|
|
4633
4820
|
* @param Estimate
|
|
4634
4821
|
*/
|
|
4635
4822
|
updateConsensusKey(params) {
|
|
4636
4823
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4824
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
4825
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
4826
|
+
if (!params.proof) {
|
|
4827
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
else {
|
|
4831
|
+
if (params.proof) {
|
|
4832
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4637
4835
|
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4638
4836
|
const preparedOperation = yield this.prepare.updateConsensusKey(params);
|
|
4639
4837
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4640
4838
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4641
4839
|
estimateProperties.shift();
|
|
4642
|
-
|
|
4840
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4841
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4842
|
+
: this.REVEAL_LENGTH / 2;
|
|
4843
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4844
|
+
}
|
|
4845
|
+
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4846
|
+
});
|
|
4847
|
+
}
|
|
4848
|
+
/**
|
|
4849
|
+
*
|
|
4850
|
+
* @description Estimate gasLimit, storageLimit and fees for an Update Companion Key operation
|
|
4851
|
+
* @returns An estimation of gasLimit, storageLimit and fees for the operation
|
|
4852
|
+
* @param Estimate
|
|
4853
|
+
*/
|
|
4854
|
+
updateCompanionKey(params) {
|
|
4855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4856
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
4857
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
4858
|
+
throw new core.ProhibitedActionError('companion key must be a bls account');
|
|
4859
|
+
}
|
|
4860
|
+
if (!params.proof) {
|
|
4861
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
4862
|
+
}
|
|
4863
|
+
const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
|
|
4864
|
+
const preparedOperation = yield this.prepare.updateCompanionKey(params);
|
|
4865
|
+
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4866
|
+
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4867
|
+
estimateProperties.shift();
|
|
4868
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4869
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4870
|
+
: this.REVEAL_LENGTH / 2;
|
|
4871
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4643
4872
|
}
|
|
4644
4873
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4645
4874
|
});
|
|
@@ -4659,7 +4888,10 @@
|
|
|
4659
4888
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4660
4889
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4661
4890
|
estimateProperties.shift();
|
|
4662
|
-
|
|
4891
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4892
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4893
|
+
: this.REVEAL_LENGTH / 2;
|
|
4894
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4663
4895
|
}
|
|
4664
4896
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4665
4897
|
});
|
|
@@ -4679,7 +4911,10 @@
|
|
|
4679
4911
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4680
4912
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4681
4913
|
estimateProperties.shift();
|
|
4682
|
-
|
|
4914
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4915
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4916
|
+
: this.REVEAL_LENGTH / 2;
|
|
4917
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4683
4918
|
}
|
|
4684
4919
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4685
4920
|
});
|
|
@@ -4718,7 +4953,10 @@
|
|
|
4718
4953
|
const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
|
|
4719
4954
|
if (preparedOperation.opOb.contents[0].kind === 'reveal') {
|
|
4720
4955
|
estimateProperties.shift();
|
|
4721
|
-
|
|
4956
|
+
const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils.PrefixV2.BLS12_381PublicKeyHash)
|
|
4957
|
+
? this.REVEAL_LENGTH_TZ4 / 2
|
|
4958
|
+
: this.REVEAL_LENGTH / 2;
|
|
4959
|
+
estimateProperties[0].opSize -= revealSize;
|
|
4722
4960
|
}
|
|
4723
4961
|
return Estimate.createEstimateInstanceFromProperties(estimateProperties);
|
|
4724
4962
|
});
|
|
@@ -4936,6 +5174,14 @@
|
|
|
4936
5174
|
get publicKey() {
|
|
4937
5175
|
return this.params.public_key;
|
|
4938
5176
|
}
|
|
5177
|
+
get proof() {
|
|
5178
|
+
if (this.params.proof) {
|
|
5179
|
+
return this.params.proof;
|
|
5180
|
+
}
|
|
5181
|
+
else {
|
|
5182
|
+
throw new core.ProhibitedActionError('Only BLS key has proof');
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
4939
5185
|
sumProp(arr, prop) {
|
|
4940
5186
|
return arr.reduce((prev, current) => {
|
|
4941
5187
|
return prop in current ? Number(current[prop]) + prev : prev;
|
|
@@ -5106,6 +5352,67 @@
|
|
|
5106
5352
|
get pk() {
|
|
5107
5353
|
return this.params.pk;
|
|
5108
5354
|
}
|
|
5355
|
+
get proof() {
|
|
5356
|
+
if (this.params.proof) {
|
|
5357
|
+
return this.params.proof;
|
|
5358
|
+
}
|
|
5359
|
+
else {
|
|
5360
|
+
throw new core.ProhibitedActionError('Only updating consensus key to a BLS account has proof');
|
|
5361
|
+
}
|
|
5362
|
+
}
|
|
5363
|
+
get consumedMilliGas() {
|
|
5364
|
+
var _a;
|
|
5365
|
+
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
5366
|
+
}
|
|
5367
|
+
get errors() {
|
|
5368
|
+
var _a;
|
|
5369
|
+
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.errors;
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
|
|
5373
|
+
/**
|
|
5374
|
+
*
|
|
5375
|
+
* @description UpdateCompanionKeyOperation provides utility to fetch properties for Operation of kind UpdateCompanionKey
|
|
5376
|
+
*
|
|
5377
|
+
*/
|
|
5378
|
+
class UpdateCompanionKeyOperation extends Operation {
|
|
5379
|
+
constructor(hash, params, source, raw, results, context) {
|
|
5380
|
+
super(hash, raw, results, context);
|
|
5381
|
+
this.params = params;
|
|
5382
|
+
this.source = source;
|
|
5383
|
+
}
|
|
5384
|
+
get operationResults() {
|
|
5385
|
+
const updateCompanionKeyOp = Array.isArray(this.results) &&
|
|
5386
|
+
this.results.find((op) => op.kind === 'update_companion_key');
|
|
5387
|
+
const result = updateCompanionKeyOp &&
|
|
5388
|
+
updateCompanionKeyOp.metadata &&
|
|
5389
|
+
updateCompanionKeyOp.metadata.operation_result;
|
|
5390
|
+
return result ? result : undefined;
|
|
5391
|
+
}
|
|
5392
|
+
get status() {
|
|
5393
|
+
var _a, _b;
|
|
5394
|
+
return (_b = (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'unknown';
|
|
5395
|
+
}
|
|
5396
|
+
get fee() {
|
|
5397
|
+
return Number(this.params.fee);
|
|
5398
|
+
}
|
|
5399
|
+
get gasLimit() {
|
|
5400
|
+
return Number(this.params.gas_limit);
|
|
5401
|
+
}
|
|
5402
|
+
get storageLimit() {
|
|
5403
|
+
return Number(this.params.storage_limit);
|
|
5404
|
+
}
|
|
5405
|
+
get pk() {
|
|
5406
|
+
return this.params.pk;
|
|
5407
|
+
}
|
|
5408
|
+
get proof() {
|
|
5409
|
+
if (this.params.proof) {
|
|
5410
|
+
return this.params.proof;
|
|
5411
|
+
}
|
|
5412
|
+
else {
|
|
5413
|
+
throw new core.ProhibitedActionError('Only updating companion key to a BLS account has proof');
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5109
5416
|
get consumedMilliGas() {
|
|
5110
5417
|
var _a;
|
|
5111
5418
|
return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
|
|
@@ -5403,7 +5710,7 @@
|
|
|
5403
5710
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5404
5711
|
const contractValidation = utils.validateContractAddress(contract);
|
|
5405
5712
|
if (contractValidation !== utils.ValidationResult.VALID) {
|
|
5406
|
-
throw new core.InvalidContractAddressError(contract,
|
|
5713
|
+
throw new core.InvalidContractAddressError(contract, contractValidation);
|
|
5407
5714
|
}
|
|
5408
5715
|
const script = yield this.context.readProvider.getScript(contract, 'head');
|
|
5409
5716
|
if (!schema) {
|
|
@@ -5435,7 +5742,7 @@
|
|
|
5435
5742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5436
5743
|
const contractValidation = utils.validateContractAddress(contract);
|
|
5437
5744
|
if (contractValidation !== utils.ValidationResult.VALID) {
|
|
5438
|
-
throw new core.InvalidContractAddressError(contract,
|
|
5745
|
+
throw new core.InvalidContractAddressError(contract, contractValidation);
|
|
5439
5746
|
}
|
|
5440
5747
|
if (!schema) {
|
|
5441
5748
|
schema = (yield this.rpc.getContract(contract)).script;
|
|
@@ -5579,14 +5886,14 @@
|
|
|
5579
5886
|
var _a;
|
|
5580
5887
|
const sourceValidation = utils.validateAddress(params.source);
|
|
5581
5888
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5582
|
-
throw new core.InvalidAddressError(params.source,
|
|
5889
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5583
5890
|
}
|
|
5584
5891
|
const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
5585
5892
|
if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
|
|
5586
|
-
throw new core.InvalidAddressError(params.delegate,
|
|
5893
|
+
throw new core.InvalidAddressError(params.delegate, delegateValidation);
|
|
5587
5894
|
}
|
|
5588
5895
|
// Since babylon delegation source cannot smart contract
|
|
5589
|
-
if (
|
|
5896
|
+
if (/^kt1/i.test(params.source)) {
|
|
5590
5897
|
throw new InvalidDelegationSource(params.source);
|
|
5591
5898
|
}
|
|
5592
5899
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
@@ -5631,11 +5938,11 @@
|
|
|
5631
5938
|
var _a;
|
|
5632
5939
|
const toValidation = utils.validateAddress(params.to);
|
|
5633
5940
|
if (toValidation !== utils.ValidationResult.VALID) {
|
|
5634
|
-
throw new core.InvalidAddressError(params.to,
|
|
5941
|
+
throw new core.InvalidAddressError(params.to, toValidation);
|
|
5635
5942
|
}
|
|
5636
5943
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5637
5944
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5638
|
-
throw new core.InvalidAddressError(params.source,
|
|
5945
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5639
5946
|
}
|
|
5640
5947
|
if (params.amount < 0) {
|
|
5641
5948
|
throw new core.InvalidAmountError(params.amount.toString());
|
|
@@ -5663,7 +5970,7 @@
|
|
|
5663
5970
|
var _a;
|
|
5664
5971
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5665
5972
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5666
|
-
throw new core.InvalidAddressError(params.source,
|
|
5973
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5667
5974
|
}
|
|
5668
5975
|
if (!params.to) {
|
|
5669
5976
|
params.to = params.source;
|
|
@@ -5699,7 +6006,7 @@
|
|
|
5699
6006
|
var _a;
|
|
5700
6007
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5701
6008
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5702
|
-
throw new core.InvalidAddressError(params.source,
|
|
6009
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5703
6010
|
}
|
|
5704
6011
|
if (!params.to) {
|
|
5705
6012
|
params.to = params.source;
|
|
@@ -5732,14 +6039,11 @@
|
|
|
5732
6039
|
var _a;
|
|
5733
6040
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5734
6041
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5735
|
-
throw new core.InvalidAddressError(params.source,
|
|
6042
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5736
6043
|
}
|
|
5737
6044
|
if (!params.to) {
|
|
5738
6045
|
params.to = params.source;
|
|
5739
6046
|
}
|
|
5740
|
-
if (params.to && params.to !== params.source) {
|
|
5741
|
-
throw new core.InvalidStakingAddressError(params.to);
|
|
5742
|
-
}
|
|
5743
6047
|
if (!params.amount) {
|
|
5744
6048
|
params.amount = 0;
|
|
5745
6049
|
}
|
|
@@ -5769,11 +6073,11 @@
|
|
|
5769
6073
|
var _a, _b;
|
|
5770
6074
|
const destinationValidation = utils.validateAddress(params.destination);
|
|
5771
6075
|
if (destinationValidation !== utils.ValidationResult.VALID) {
|
|
5772
|
-
throw new core.InvalidAddressError(params.destination,
|
|
6076
|
+
throw new core.InvalidAddressError(params.destination, destinationValidation);
|
|
5773
6077
|
}
|
|
5774
6078
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5775
6079
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5776
|
-
throw new core.InvalidAddressError(params.source,
|
|
6080
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5777
6081
|
}
|
|
5778
6082
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5779
6083
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
@@ -5787,8 +6091,7 @@
|
|
|
5787
6091
|
}
|
|
5788
6092
|
/**
|
|
5789
6093
|
*
|
|
5790
|
-
* @description Reveal the current address. Will throw an error if the address is already revealed.
|
|
5791
|
-
*
|
|
6094
|
+
* @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
|
|
5792
6095
|
* @returns An operation handle with the result from the rpc node
|
|
5793
6096
|
*
|
|
5794
6097
|
* @param RevealParams operation parameter
|
|
@@ -5796,6 +6099,21 @@
|
|
|
5796
6099
|
reveal(params) {
|
|
5797
6100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5798
6101
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6102
|
+
const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(publicKeyHash, utils.publicKeyHashPrefixes);
|
|
6103
|
+
if (pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash) {
|
|
6104
|
+
if (params.proof) {
|
|
6105
|
+
utils.b58DecodeAndCheckPrefix(params.proof, [utils.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
6106
|
+
}
|
|
6107
|
+
else {
|
|
6108
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
6109
|
+
params.proof = prefixSig;
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
else {
|
|
6113
|
+
if (params.proof) {
|
|
6114
|
+
throw new core.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
6115
|
+
}
|
|
6116
|
+
}
|
|
5799
6117
|
const estimateReveal = yield this.estimator.reveal(params);
|
|
5800
6118
|
if (estimateReveal) {
|
|
5801
6119
|
const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
|
|
@@ -5882,7 +6200,7 @@
|
|
|
5882
6200
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5883
6201
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5884
6202
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5885
|
-
throw new core.InvalidAddressError(params.source,
|
|
6203
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5886
6204
|
}
|
|
5887
6205
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5888
6206
|
const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5906,7 +6224,7 @@
|
|
|
5906
6224
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
5907
6225
|
const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
5908
6226
|
if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
|
|
5909
|
-
throw new core.InvalidAddressError(params.source,
|
|
6227
|
+
throw new core.InvalidAddressError(params.source, sourceValidation);
|
|
5910
6228
|
}
|
|
5911
6229
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
5912
6230
|
const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -5918,8 +6236,7 @@
|
|
|
5918
6236
|
}
|
|
5919
6237
|
/**
|
|
5920
6238
|
*
|
|
5921
|
-
* @description
|
|
5922
|
-
*
|
|
6239
|
+
* @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
|
|
5923
6240
|
* @returns An operation handle with the result from the rpc node
|
|
5924
6241
|
*
|
|
5925
6242
|
* @param UpdateConsensusKeyParams
|
|
@@ -5927,6 +6244,17 @@
|
|
|
5927
6244
|
updateConsensusKey(params) {
|
|
5928
6245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5929
6246
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6247
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
6248
|
+
if (pkPrefix === utils.PrefixV2.BLS12_381PublicKey) {
|
|
6249
|
+
if (!params.proof) {
|
|
6250
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
else {
|
|
6254
|
+
if (params.proof) {
|
|
6255
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
5930
6258
|
const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
|
|
5931
6259
|
const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
|
|
5932
6260
|
const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.UPDATE_CONSENSUS_KEY);
|
|
@@ -5935,6 +6263,31 @@
|
|
|
5935
6263
|
return new UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
5936
6264
|
});
|
|
5937
6265
|
}
|
|
6266
|
+
/**
|
|
6267
|
+
*
|
|
6268
|
+
* @description Updates the companion key of the delegate starting from the current cycle plus CONSENSUS_KEY_ACTIVATION_DELAY + 1
|
|
6269
|
+
* @returns An operation handle with the result from the rpc node
|
|
6270
|
+
*
|
|
6271
|
+
* @param UpdateCompanionKeyParams
|
|
6272
|
+
*/
|
|
6273
|
+
updateCompanionKey(params) {
|
|
6274
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6275
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
6276
|
+
const [, pkPrefix] = utils.b58DecodeAndCheckPrefix(params.pk, utils.publicKeyPrefixes);
|
|
6277
|
+
if (pkPrefix !== utils.PrefixV2.BLS12_381PublicKey) {
|
|
6278
|
+
throw new core.ProhibitedActionError('Proof field is only allowed for a bls account as companion key');
|
|
6279
|
+
}
|
|
6280
|
+
if (!params.proof) {
|
|
6281
|
+
throw new core.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
6282
|
+
}
|
|
6283
|
+
const estimate = yield this.estimate(params, this.estimator.updateCompanionKey.bind(this.estimator));
|
|
6284
|
+
const prepared = yield this.prepare.updateCompanionKey(Object.assign(Object.assign({}, params), estimate));
|
|
6285
|
+
const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.UPDATE_COMPANION_KEY);
|
|
6286
|
+
const opBytes = yield this.forge(prepared);
|
|
6287
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
6288
|
+
return new UpdateCompanionKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
6289
|
+
});
|
|
6290
|
+
}
|
|
5938
6291
|
/**
|
|
5939
6292
|
* @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
|
|
5940
6293
|
* @param SmartRollupAddMessagesParams
|
|
@@ -6029,7 +6382,7 @@
|
|
|
6029
6382
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
6030
6383
|
const addressValidation = utils.validateContractAddress(address);
|
|
6031
6384
|
if (addressValidation !== utils.ValidationResult.VALID) {
|
|
6032
|
-
throw new core.InvalidContractAddressError(address,
|
|
6385
|
+
throw new core.InvalidContractAddressError(address, addressValidation);
|
|
6033
6386
|
}
|
|
6034
6387
|
const rpc = this.context.withExtensions().rpc;
|
|
6035
6388
|
const readProvider = this.context.withExtensions().readProvider;
|
|
@@ -6666,7 +7019,7 @@
|
|
|
6666
7019
|
constructor(context, config = {}) {
|
|
6667
7020
|
this.context = context;
|
|
6668
7021
|
this._config$ = new rxjs.BehaviorSubject(Object.assign(Object.assign({}, defaultConfigStreamer), config));
|
|
6669
|
-
this.timer$ = this._config$.pipe(operators.
|
|
7022
|
+
this.timer$ = this._config$.pipe(operators.map((x) => x === null || x === void 0 ? void 0 : x.pollingIntervalMilliseconds), operators.switchMap((pollingIntervalMilliseconds) => {
|
|
6670
7023
|
if (!pollingIntervalMilliseconds) {
|
|
6671
7024
|
return rxjs.from(this.getConfirmationPollingInterval()).pipe(operators.switchMap((interval) => {
|
|
6672
7025
|
return rxjs.timer(0, interval);
|
|
@@ -6676,7 +7029,11 @@
|
|
|
6676
7029
|
return rxjs.timer(0, pollingIntervalMilliseconds);
|
|
6677
7030
|
}
|
|
6678
7031
|
}));
|
|
6679
|
-
this.newBlock$ = this.timer$.pipe(operators.switchMap(() => getLastBlock(this.context)), operators.distinctUntilKeyChanged('hash'), operators.
|
|
7032
|
+
this.newBlock$ = this.timer$.pipe(operators.switchMap(() => getLastBlock(this.context)), operators.distinctUntilKeyChanged('hash'), operators.share({
|
|
7033
|
+
resetOnError: false,
|
|
7034
|
+
resetOnComplete: false,
|
|
7035
|
+
resetOnRefCountZero: true,
|
|
7036
|
+
}));
|
|
6680
7037
|
}
|
|
6681
7038
|
get config() {
|
|
6682
7039
|
return this._config$.getValue();
|
|
@@ -6708,7 +7065,7 @@
|
|
|
6708
7065
|
return new ObservableSubscription(this.newBlock$, this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
|
|
6709
7066
|
}
|
|
6710
7067
|
subscribe(_filter) {
|
|
6711
|
-
return new ObservableSubscription(this.newBlock$.pipe(operators.
|
|
7068
|
+
return new ObservableSubscription(this.newBlock$.pipe(operators.map((x) => x === null || x === void 0 ? void 0 : x.hash)), this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
|
|
6712
7069
|
}
|
|
6713
7070
|
subscribeOperation(filter) {
|
|
6714
7071
|
return new ObservableSubscription(this.newBlock$.pipe(applyFilter(filter)), this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
|
|
@@ -6894,8 +7251,8 @@
|
|
|
6894
7251
|
|
|
6895
7252
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
6896
7253
|
const VERSION = {
|
|
6897
|
-
"commitHash": "
|
|
6898
|
-
"version": "
|
|
7254
|
+
"commitHash": "13639ef56845fbb7e93bcbd37d3f6d0457b0872b",
|
|
7255
|
+
"version": "23.0.0-RC.0"
|
|
6899
7256
|
};
|
|
6900
7257
|
|
|
6901
7258
|
/**
|
|
@@ -7424,6 +7781,7 @@
|
|
|
7424
7781
|
exports.TransferTicketOperation = TransferTicketOperation;
|
|
7425
7782
|
exports.TransferTicketWalletOperation = TransferTicketWalletOperation;
|
|
7426
7783
|
exports.UnconfiguredGlobalConstantsProviderError = UnconfiguredGlobalConstantsProviderError;
|
|
7784
|
+
exports.UpdateCompanionKeyOperation = UpdateCompanionKeyOperation;
|
|
7427
7785
|
exports.UpdateConsensusKeyOperation = UpdateConsensusKeyOperation;
|
|
7428
7786
|
exports.VIEW_LAMBDA = VIEW_LAMBDA;
|
|
7429
7787
|
exports.ViewSimulationError = ViewSimulationError;
|
|
@@ -7447,6 +7805,7 @@
|
|
|
7447
7805
|
exports.createSmartRollupOriginateOperation = createSmartRollupOriginateOperation;
|
|
7448
7806
|
exports.createTransferOperation = createTransferOperation;
|
|
7449
7807
|
exports.createTransferTicketOperation = createTransferTicketOperation;
|
|
7808
|
+
exports.createUpdateCompanionKeyOperation = createUpdateCompanionKeyOperation;
|
|
7450
7809
|
exports.createUpdateConsensusKeyOperation = createUpdateConsensusKeyOperation;
|
|
7451
7810
|
exports.defaultConfigConfirmation = defaultConfigConfirmation;
|
|
7452
7811
|
exports.findWithKind = findWithKind;
|