@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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/400.taquito.min.js +1 -0
  3. package/dist/993.taquito.min.js +1 -0
  4. package/dist/lib/batch/rpc-batch-provider.js +47 -5
  5. package/dist/lib/constants.js +51 -19
  6. package/dist/lib/contract/contract.js +1 -1
  7. package/dist/lib/contract/prepare.js +17 -3
  8. package/dist/lib/contract/rpc-contract-provider.js +69 -22
  9. package/dist/lib/estimate/rpc-estimate-provider.js +133 -31
  10. package/dist/lib/operations/index.js +3 -1
  11. package/dist/lib/operations/reveal-operation.js +9 -0
  12. package/dist/lib/operations/types.js +5 -1
  13. package/dist/lib/operations/update-companion-key-operation.js +58 -0
  14. package/dist/lib/operations/update-consensus-key-operation.js +9 -0
  15. package/dist/lib/prepare/prepare-provider.js +78 -3
  16. package/dist/lib/provider.js +4 -0
  17. package/dist/lib/subscribe/polling-subcribe-provider.js +7 -3
  18. package/dist/lib/tz/rpc-tz-provider.js +4 -4
  19. package/dist/lib/version.js +2 -2
  20. package/dist/lib/wallet/operation-factory.js +1 -1
  21. package/dist/lib/wallet/operation.js +2 -2
  22. package/dist/lib/wallet/wallet.js +9 -12
  23. package/dist/taquito.es6.js +498 -111
  24. package/dist/taquito.es6.js.map +1 -1
  25. package/dist/taquito.min.js +1 -1
  26. package/dist/taquito.min.js.LICENSE.txt +2 -0
  27. package/dist/taquito.umd.js +499 -107
  28. package/dist/taquito.umd.js.map +1 -1
  29. package/dist/types/batch/rpc-batch-provider.d.ts +16 -2
  30. package/dist/types/constants.d.ts +35 -2
  31. package/dist/types/contract/interface.d.ts +10 -3
  32. package/dist/types/contract/prepare.d.ts +4 -3
  33. package/dist/types/contract/rpc-contract-provider.d.ts +12 -5
  34. package/dist/types/estimate/estimate-provider-interface.d.ts +9 -3
  35. package/dist/types/estimate/rpc-estimate-provider.d.ts +10 -5
  36. package/dist/types/operations/index.d.ts +1 -0
  37. package/dist/types/operations/reveal-operation.d.ts +1 -0
  38. package/dist/types/operations/types.d.ts +26 -5
  39. package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
  40. package/dist/types/operations/update-consensus-key-operation.d.ts +1 -0
  41. package/dist/types/prepare/interface.d.ts +8 -1
  42. package/dist/types/prepare/prepare-provider.d.ts +11 -3
  43. package/dist/types/provider.d.ts +1 -1
  44. package/dist/types/signer/interface.d.ts +18 -8
  45. package/package.json +10 -10
@@ -157,25 +157,55 @@
157
157
  });
158
158
  }
159
159
 
160
- // value is based on octez-client reveal operation gasLimit of each address type in Rio Protocol
160
+ /**
161
+ * @deprecated default reveal gasLimit please use getRevealGasLimit(address) instead, removing hardcoded gasLimit of delegation, origination and transfer
162
+ */
163
+ const DEFAULT_GAS_LIMIT = {
164
+ DELEGATION: 10600,
165
+ ORIGINATION: 10600,
166
+ TRANSFER: 10600,
167
+ REVEAL_TZ1: 1000,
168
+ REVEAL_TZ2: 1000,
169
+ REVEAL_TZ3: 2000,
170
+ REVEAL_TZ4: 2000,
171
+ };
172
+ /**
173
+ * @deprecated default reveal fee please use getRevealFee(address) instead, removing hardcoded fee of delegation, origination and transfer
174
+ */
175
+ const DEFAULT_FEE = {
176
+ DELEGATION: 1257,
177
+ ORIGINATION: 10000,
178
+ TRANSFER: 10000,
179
+ REVEAL: 374,
180
+ };
181
+ /**
182
+ * @deprecated default reveal storageLimit please use REVEAL_STORAGE_LIMIT instead, removing hardcoded storageLimit of delegation, origination and transfer
183
+ */
184
+ const DEFAULT_STORAGE_LIMIT = {
185
+ DELEGATION: 0,
186
+ ORIGINATION: 257,
187
+ TRANSFER: 257,
188
+ REVEAL: 0,
189
+ };
190
+ // value is based on octez-client reveal operation gasLimit of each address type in Seoul Protocol
161
191
  const REVEAL_GAS_LIMIT = {
162
- TZ1: 169,
163
- TZ2: 155,
164
- TZ3: 445,
165
- TZ4: 1674,
192
+ TZ1: 171,
193
+ TZ2: 157,
194
+ TZ3: 447,
195
+ TZ4: 3252,
166
196
  };
167
- // value is based on octez-client reveal operation fee of each address type in Rio Protocol
197
+ // value is based on octez-client reveal operation fee of each address type in Seoul Protocol
168
198
  const REVEAL_FEE = {
169
- TZ1: 276,
170
- TZ2: 276,
171
- TZ3: 305,
172
- TZ4: 477,
199
+ TZ1: 278,
200
+ TZ2: 277,
201
+ TZ3: 306,
202
+ TZ4: 736,
173
203
  };
174
- // value is based on octez-client reveal operation storageLimit of all address type in Rio Protocol
204
+ // value is based on octez-client reveal operation storageLimit of all address type in Seoul Protocol
175
205
  const REVEAL_STORAGE_LIMIT = 0;
176
- // protocol constants in Rio Protocol
206
+ // protocol constants in Seoul Protocol
177
207
  const ORIGINATION_SIZE = 257;
178
- // protocol constants in Rio Protocol
208
+ // protocol constants in Seoul Protocol
179
209
  const COST_PER_BYTE = 250;
180
210
  exports.Protocols = void 0;
181
211
  (function (Protocols) {
@@ -201,6 +231,7 @@
201
231
  Protocols["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
202
232
  Protocols["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
203
233
  Protocols["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
234
+ Protocols["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
204
235
  Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
205
236
  })(exports.Protocols || (exports.Protocols = {}));
206
237
  const protocols = {
@@ -222,7 +253,8 @@
222
253
  '020': [exports.Protocols.PtParisBx, exports.Protocols.PsParisCZ],
223
254
  '021': [exports.Protocols.PsQuebecn],
224
255
  '022': [exports.Protocols.PsRiotuma],
225
- '023': [exports.Protocols.ProtoALpha],
256
+ '023': [exports.Protocols.PtSeouLou],
257
+ '024': [exports.Protocols.ProtoALpha],
226
258
  };
227
259
  exports.ChainIds = void 0;
228
260
  (function (ChainIds) {
@@ -244,10 +276,10 @@
244
276
  ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
245
277
  ChainIds["PARISBNET"] = "NetXo8SqH1c38SS";
246
278
  ChainIds["PARISCNET"] = "NetXXWAHLEvre9b";
247
- ChainIds["QUEBECN"] = "NetXuTeGinLEqxp";
248
- ChainIds["RIOTUMANET"] = "NetXPdgaoabtBth";
279
+ ChainIds["QUEBECNET"] = "NetXuTeGinLEqxp";
280
+ ChainIds["RIONET"] = "NetXPdgaoabtBth";
281
+ ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
249
282
  })(exports.ChainIds || (exports.ChainIds = {}));
250
- // 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)
251
283
  const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
252
284
  const getRevealGasLimitInternal = (address) => {
253
285
  switch (address.substring(0, 3)) {
@@ -273,7 +305,7 @@
273
305
  case 'tz3':
274
306
  return REVEAL_FEE.TZ3;
275
307
  case 'tz4':
276
- return REVEAL_FEE.TZ4;
308
+ return REVEAL_FEE.TZ4 * 1.7;
277
309
  default:
278
310
  throw new Error(`Cannot estimate reveal fee for ${address}`);
279
311
  }
@@ -486,7 +518,7 @@
486
518
  delegate: source,
487
519
  };
488
520
  });
489
- 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) {
490
522
  return {
491
523
  kind: rpc.OpKind.REVEAL,
492
524
  fee,
@@ -494,6 +526,7 @@
494
526
  source,
495
527
  gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : getRevealGasLimit(source),
496
528
  storage_limit: storageLimit,
529
+ proof,
497
530
  };
498
531
  });
499
532
  const createRegisterGlobalConstantOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, source, fee, gasLimit, storageLimit, }) {
@@ -555,7 +588,7 @@
555
588
  proposals,
556
589
  };
557
590
  });
558
- 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, }) {
559
592
  return {
560
593
  kind: rpc.OpKind.UPDATE_CONSENSUS_KEY,
561
594
  source,
@@ -563,6 +596,18 @@
563
596
  gas_limit: gasLimit,
564
597
  storage_limit: storageLimit,
565
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,
566
611
  };
567
612
  });
568
613
  const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
@@ -615,7 +660,8 @@
615
660
  return op.kind === kind;
616
661
  };
617
662
  const isOpWithGasBuffer = (op) => {
618
- if (op.kind === rpc.OpKind.TRANSACTION && op.parameters) {
663
+ var _a;
664
+ if (op.kind === rpc.OpKind.TRANSACTION && ((_a = op.destination) === null || _a === void 0 ? void 0 : _a.startsWith('KT1'))) {
619
665
  return true;
620
666
  }
621
667
  else {
@@ -624,6 +670,7 @@
624
670
  'register_global_constant',
625
671
  'transfer_ticket',
626
672
  'update_consensus_key',
673
+ 'update_companion_key',
627
674
  'smart_rollup_add_messages',
628
675
  'smart_rollup_originate',
629
676
  ].indexOf(op.kind) !== -1);
@@ -639,6 +686,7 @@
639
686
  'increase_paid_storage',
640
687
  'transfer_ticket',
641
688
  'update_consensus_key',
689
+ 'update_companion_key',
642
690
  'smart_rollup_add_messages',
643
691
  'smart_rollup_originate',
644
692
  'smart_rollup_execute_outbox_message',
@@ -653,6 +701,7 @@
653
701
  'increase_paid_storage',
654
702
  'transfer_ticket',
655
703
  'update_consensus_key',
704
+ 'update_companion_key',
656
705
  'smart_rollup_add_messages',
657
706
  'smart_rollup_originate',
658
707
  'smart_rollup_execute_outbox_message',
@@ -1054,6 +1103,10 @@
1054
1103
  return createRegisterGlobalConstantOperation(Object.assign({}, param));
1055
1104
  case rpc.OpKind.INCREASE_PAID_STORAGE:
1056
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));
1057
1110
  case rpc.OpKind.TRANSFER_TICKET:
1058
1111
  return createTransferTicketOperation(Object.assign({}, param));
1059
1112
  case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
@@ -1148,7 +1201,7 @@
1148
1201
  withTransfer(params) {
1149
1202
  const toValidation = utils.validateAddress(params.to);
1150
1203
  if (toValidation !== utils.ValidationResult.VALID) {
1151
- throw new core.InvalidAddressError(params.to, utils.invalidDetail(toValidation));
1204
+ throw new core.InvalidAddressError(params.to, toValidation);
1152
1205
  }
1153
1206
  this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSACTION }, params));
1154
1207
  return this;
@@ -1169,7 +1222,7 @@
1169
1222
  var _a;
1170
1223
  const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
1171
1224
  if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
1172
- throw new core.InvalidAddressError(params.delegate, utils.invalidDetail(delegateValidation));
1225
+ throw new core.InvalidAddressError(params.delegate, delegateValidation);
1173
1226
  }
1174
1227
  this.operations.push(Object.assign({ kind: rpc.OpKind.DELEGATION }, params));
1175
1228
  return this;
@@ -1189,7 +1242,7 @@
1189
1242
  withIncreasePaidStorage(params) {
1190
1243
  const destinationValidation = utils.validateAddress(params.destination);
1191
1244
  if (destinationValidation !== utils.ValidationResult.VALID) {
1192
- throw new core.InvalidAddressError(params.destination, utils.invalidDetail(destinationValidation));
1245
+ throw new core.InvalidAddressError(params.destination, destinationValidation);
1193
1246
  }
1194
1247
  this.operations.push(Object.assign({ kind: rpc.OpKind.INCREASE_PAID_STORAGE }, params));
1195
1248
  return this;
@@ -1201,7 +1254,7 @@
1201
1254
  withTransferTicket(params) {
1202
1255
  const destinationValidation = utils.validateAddress(params.destination);
1203
1256
  if (destinationValidation !== utils.ValidationResult.VALID) {
1204
- throw new core.InvalidAddressError(params.destination, utils.invalidDetail(destinationValidation));
1257
+ throw new core.InvalidAddressError(params.destination, destinationValidation);
1205
1258
  }
1206
1259
  this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSFER_TICKET }, params));
1207
1260
  return this;
@@ -1323,7 +1376,7 @@
1323
1376
  var _a;
1324
1377
  const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
1325
1378
  if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
1326
- throw new core.InvalidAddressError(params.delegate, utils.invalidDetail(delegateValidation));
1379
+ throw new core.InvalidAddressError(params.delegate, delegateValidation);
1327
1380
  }
1328
1381
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1329
1382
  const mappedParams = yield this.walletProvider.mapDelegateParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -1385,7 +1438,7 @@
1385
1438
  transfer(params) {
1386
1439
  const toValidation = utils.validateAddress(params.to);
1387
1440
  if (toValidation !== utils.ValidationResult.VALID) {
1388
- throw new core.InvalidAddressError(params.to, utils.invalidDetail(toValidation));
1441
+ throw new core.InvalidAddressError(params.to, toValidation);
1389
1442
  }
1390
1443
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1391
1444
  const mappedParams = yield this.walletProvider.mapTransferParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -1401,7 +1454,7 @@
1401
1454
  transferTicket(params) {
1402
1455
  const toValidation = utils.validateAddress(params.destination);
1403
1456
  if (toValidation !== utils.ValidationResult.VALID) {
1404
- throw new core.InvalidAddressError(params.destination, utils.invalidDetail(toValidation));
1457
+ throw new core.InvalidAddressError(params.destination, toValidation);
1405
1458
  }
1406
1459
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1407
1460
  const mappedParams = yield this.walletProvider.mapTransferTicketParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -1467,9 +1520,6 @@
1467
1520
  if (!params.to) {
1468
1521
  params.to = source;
1469
1522
  }
1470
- if (params.to !== source) {
1471
- throw new core.InvalidStakingAddressError(params.to);
1472
- }
1473
1523
  if (!params.amount) {
1474
1524
  params.amount = 0;
1475
1525
  }
@@ -1491,7 +1541,7 @@
1491
1541
  increasePaidStorage(params) {
1492
1542
  const destinationValidation = utils.validateAddress(params.destination);
1493
1543
  if (destinationValidation !== utils.ValidationResult.VALID) {
1494
- throw new core.InvalidAddressError(params.destination, utils.invalidDetail(destinationValidation));
1544
+ throw new core.InvalidAddressError(params.destination, destinationValidation);
1495
1545
  }
1496
1546
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
1497
1547
  const mappedParams = yield this.walletProvider.mapIncreasePaidStorageWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -1521,7 +1571,7 @@
1521
1571
  return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
1522
1572
  const addressValidation = utils.validateContractAddress(address);
1523
1573
  if (addressValidation !== utils.ValidationResult.VALID) {
1524
- throw new core.InvalidContractAddressError(address, utils.invalidDetail(addressValidation));
1574
+ throw new core.InvalidContractAddressError(address, addressValidation);
1525
1575
  }
1526
1576
  const rpc = this.context.withExtensions().rpc;
1527
1577
  const readProvider = this.context.withExtensions().readProvider;
@@ -1647,7 +1697,7 @@
1647
1697
  connector: () => new rxjs.ReplaySubject(1),
1648
1698
  resetOnError: false,
1649
1699
  resetOnComplete: false,
1650
- resetOnRefCountZero: false,
1700
+ resetOnRefCountZero: true,
1651
1701
  }));
1652
1702
  // Observable that emit once operation is seen in a block
1653
1703
  this.confirmed$ = this.newHead$.pipe(operators.map((head) => {
@@ -1668,7 +1718,7 @@
1668
1718
  connector: () => new rxjs.ReplaySubject(1),
1669
1719
  resetOnError: false,
1670
1720
  resetOnComplete: false,
1671
- resetOnRefCountZero: false,
1721
+ resetOnRefCountZero: true,
1672
1722
  }));
1673
1723
  if (utils.validateOperation(this.opHash) !== utils.ValidationResult.VALID) {
1674
1724
  throw new core.InvalidOperationHashError(this.opHash);
@@ -2269,7 +2319,7 @@
2269
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.`);
2270
2320
  }
2271
2321
  else if (chainId && chainIdValidation !== utils.ValidationResult.VALID) {
2272
- throw new core.InvalidChainIdError(chainId, utils.invalidDetail(chainIdValidation));
2322
+ throw new core.InvalidChainIdError(chainId, chainIdValidation);
2273
2323
  }
2274
2324
  const arg = this.parameterSchema.Encode(...this.args);
2275
2325
  const result = yield this.rpc.runView({
@@ -2707,10 +2757,14 @@
2707
2757
  if (!publicKey) {
2708
2758
  throw new core.PublicKeyNotFoundError(pkh);
2709
2759
  }
2760
+ const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
2710
2761
  ops.unshift(yield createRevealOperation({
2711
2762
  fee: getRevealFee(pkh),
2712
2763
  storageLimit: REVEAL_STORAGE_LIMIT,
2713
2764
  gasLimit: getRevealGasLimit(pkh),
2765
+ proof: pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash
2766
+ ? (yield this.signer.provePossession()).prefixSig
2767
+ : undefined,
2714
2768
  }, publicKeyHash, publicKey));
2715
2769
  return ops;
2716
2770
  }
@@ -2756,6 +2810,7 @@
2756
2810
  case rpc.OpKind.DELEGATION:
2757
2811
  case rpc.OpKind.REGISTER_GLOBAL_CONSTANT:
2758
2812
  case rpc.OpKind.UPDATE_CONSENSUS_KEY:
2813
+ case rpc.OpKind.UPDATE_COMPANION_KEY:
2759
2814
  case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
2760
2815
  case rpc.OpKind.SMART_ROLLUP_ORIGINATE:
2761
2816
  case rpc.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
@@ -2816,11 +2871,26 @@
2816
2871
  * @returns a PreparedOperation object
2817
2872
  */
2818
2873
  reveal(_a) {
2819
- return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit }) {
2874
+ return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit, proof }) {
2820
2875
  const { pkh, publicKey } = yield this.getKeys();
2821
2876
  if (!publicKey) {
2822
2877
  throw new core.PublicKeyNotFoundError(pkh);
2823
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
+ }
2824
2894
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2825
2895
  const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2826
2896
  const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
@@ -2828,6 +2898,7 @@
2828
2898
  fee: mergedEstimates.fee,
2829
2899
  gasLimit: mergedEstimates.gasLimit,
2830
2900
  storageLimit: mergedEstimates.storageLimit,
2901
+ proof,
2831
2902
  }, pkh, publicKey);
2832
2903
  const ops = this.convertIntoArray(op);
2833
2904
  const hash = yield this.getBlockHash();
@@ -2986,11 +3057,11 @@
2986
3057
  */
2987
3058
  finalizeUnstake(_a) {
2988
3059
  return __awaiter(this, void 0, void 0, function* () {
2989
- 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"]);
2990
3061
  const { pkh } = yield this.getKeys();
2991
3062
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
2992
3063
  const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
2993
- 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: {
2994
3065
  entrypoint: 'finalize_unstake',
2995
3066
  value: { prim: 'Unit' },
2996
3067
  } }));
@@ -3119,6 +3190,17 @@
3119
3190
  return __awaiter(this, void 0, void 0, function* () {
3120
3191
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
3121
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
+ }
3122
3204
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
3123
3205
  const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
3124
3206
  const op = yield createUpdateConsensusKeyOperation(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
@@ -3139,6 +3221,44 @@
3139
3221
  };
3140
3222
  });
3141
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
+ }
3142
3262
  /**
3143
3263
  *
3144
3264
  * @description Method to prepare an increase_paid_storage operation
@@ -3429,10 +3549,14 @@
3429
3549
  if (!publicKey) {
3430
3550
  throw new core.PublicKeyNotFoundError(pkh);
3431
3551
  }
3552
+ const [, pkhPrefix] = utils.b58DecodeAndCheckPrefix(pkh, utils.publicKeyHashPrefixes);
3432
3553
  ops.unshift(yield createRevealOperation({
3433
3554
  fee: getRevealFee(pkh),
3434
3555
  storageLimit: REVEAL_STORAGE_LIMIT,
3435
3556
  gasLimit: getRevealGasLimit(pkh),
3557
+ proof: pkhPrefix === utils.PrefixV2.BLS12_381PublicKeyHash
3558
+ ? (yield this.signer.provePossession()).prefixSig
3559
+ : undefined,
3436
3560
  }, pkh, publicKey));
3437
3561
  }
3438
3562
  const hash = yield this.getBlockHash();
@@ -3549,7 +3673,7 @@
3549
3673
  throw new core.InvalidAmountError(params.amount.toString());
3550
3674
  }
3551
3675
  if (toValidation !== utils.ValidationResult.VALID) {
3552
- throw new core.InvalidAddressError(params.to, utils.invalidDetail(toValidation));
3676
+ throw new core.InvalidAddressError(params.to, toValidation);
3553
3677
  }
3554
3678
  this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSACTION }, params));
3555
3679
  return this;
@@ -3563,7 +3687,7 @@
3563
3687
  withTransferTicket(params) {
3564
3688
  const destinationValidation = utils.validateAddress(params.destination);
3565
3689
  if (destinationValidation !== utils.ValidationResult.VALID) {
3566
- throw new core.InvalidAddressError(params.destination, utils.invalidDetail(destinationValidation));
3690
+ throw new core.InvalidAddressError(params.destination, destinationValidation);
3567
3691
  }
3568
3692
  this.operations.push(Object.assign({ kind: rpc.OpKind.TRANSFER_TICKET }, params));
3569
3693
  return this;
@@ -3588,11 +3712,11 @@
3588
3712
  var _a;
3589
3713
  const sourceValidation = utils.validateAddress(params.source);
3590
3714
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
3591
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
3715
+ throw new core.InvalidAddressError(params.source, sourceValidation);
3592
3716
  }
3593
3717
  const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
3594
3718
  if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
3595
- throw new core.InvalidAddressError(params.delegate, utils.invalidDetail(delegateValidation));
3719
+ throw new core.InvalidAddressError(params.delegate, delegateValidation);
3596
3720
  }
3597
3721
  this.operations.push(Object.assign({ kind: rpc.OpKind.DELEGATION }, params));
3598
3722
  return this;
@@ -3607,7 +3731,7 @@
3607
3731
  withActivation({ pkh, secret }) {
3608
3732
  const pkhValidation = utils.validateKeyHash(pkh);
3609
3733
  if (pkhValidation !== utils.ValidationResult.VALID) {
3610
- throw new core.InvalidKeyHashError(pkh, utils.invalidDetail(pkhValidation));
3734
+ throw new core.InvalidKeyHashError(pkh, pkhValidation);
3611
3735
  }
3612
3736
  this.operations.push({ kind: rpc.OpKind.ACTIVATION, pkh, secret });
3613
3737
  return this;
@@ -3642,6 +3766,44 @@
3642
3766
  this.operations.push(Object.assign({ kind: rpc.OpKind.INCREASE_PAID_STORAGE }, params));
3643
3767
  return this;
3644
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
+ }
3645
3807
  /**
3646
3808
  *
3647
3809
  * @description Add a smart rollup add messages operation to the batch
@@ -3685,6 +3847,10 @@
3685
3847
  return createRegisterGlobalConstantOperation(Object.assign({}, param));
3686
3848
  case rpc.OpKind.INCREASE_PAID_STORAGE:
3687
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));
3688
3854
  case rpc.OpKind.TRANSFER_TICKET:
3689
3855
  return createTransferTicketOperation(Object.assign({}, param));
3690
3856
  case rpc.OpKind.SMART_ROLLUP_ADD_MESSAGES:
@@ -3899,7 +4065,7 @@
3899
4065
  connector: () => new rxjs.ReplaySubject(1),
3900
4066
  resetOnError: false,
3901
4067
  resetOnComplete: false,
3902
- resetOnRefCountZero: false,
4068
+ resetOnRefCountZero: true,
3903
4069
  }));
3904
4070
  };
3905
4071
  class OperationFactory {
@@ -3981,7 +4147,7 @@
3981
4147
  return __awaiter(this, void 0, void 0, function* () {
3982
4148
  const addressValidation = utils.validateAddress(address);
3983
4149
  if (addressValidation !== utils.ValidationResult.VALID) {
3984
- throw new core.InvalidAddressError(address, utils.invalidDetail(addressValidation));
4150
+ throw new core.InvalidAddressError(address, addressValidation);
3985
4151
  }
3986
4152
  return this.context.readProvider.getBalance(address, 'head');
3987
4153
  });
@@ -3990,7 +4156,7 @@
3990
4156
  return __awaiter(this, void 0, void 0, function* () {
3991
4157
  const addressValidation = utils.validateAddress(address);
3992
4158
  if (addressValidation !== utils.ValidationResult.VALID) {
3993
- throw new core.InvalidAddressError(address, utils.invalidDetail(addressValidation));
4159
+ throw new core.InvalidAddressError(address, addressValidation);
3994
4160
  }
3995
4161
  return this.context.readProvider.getSpendable(address, 'head');
3996
4162
  });
@@ -3999,7 +4165,7 @@
3999
4165
  return __awaiter(this, void 0, void 0, function* () {
4000
4166
  const addressValidation = utils.validateAddress(address);
4001
4167
  if (addressValidation !== utils.ValidationResult.VALID) {
4002
- throw new core.InvalidAddressError(address, utils.invalidDetail(addressValidation));
4168
+ throw new core.InvalidAddressError(address, addressValidation);
4003
4169
  }
4004
4170
  return this.context.readProvider.getDelegate(address, 'head');
4005
4171
  });
@@ -4008,7 +4174,7 @@
4008
4174
  return __awaiter(this, void 0, void 0, function* () {
4009
4175
  const pkhValidation = utils.validateKeyHash(pkh);
4010
4176
  if (pkhValidation !== utils.ValidationResult.VALID) {
4011
- throw new utils.InvalidKeyHashError(pkh, utils.invalidDetail(pkhValidation));
4177
+ throw new utils.InvalidKeyHashError(pkh, pkhValidation);
4012
4178
  }
4013
4179
  const prepared = yield this.prepare.activate({ pkh, secret });
4014
4180
  const forgedBytes = yield this.forge(prepared);
@@ -4162,7 +4328,8 @@
4162
4328
  class RPCEstimateProvider extends Provider {
4163
4329
  constructor() {
4164
4330
  super(...arguments);
4165
- this.OP_SIZE_REVEAL = 324; // injecting size tz1=320, tz2=322, tz3=322, tz4=420(not supported)
4331
+ this.REVEAL_LENGTH = 324; // injecting size tz1=320, tz2=322, tz3=322
4332
+ this.REVEAL_LENGTH_TZ4 = 622; // injecting size tz4=620
4166
4333
  this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
4167
4334
  this.STORAGE_BUFFER = 20; // according to octez-client
4168
4335
  this.prepare = new PrepareProvider(this.context);
@@ -4244,9 +4411,20 @@
4244
4411
  : op.opOb.contents.length;
4245
4412
  }
4246
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
+ }
4247
4425
  return this.getEstimationPropertiesFromOperationContent(x,
4248
4426
  // diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
4249
- x.kind === 'reveal' ? this.OP_SIZE_REVEAL / 2 : (opbytes.length + 130) / 2 / numberOfOps, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
4427
+ x.kind === 'reveal' ? revealSize : eachOpSize, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
4250
4428
  );
4251
4429
  });
4252
4430
  });
@@ -4265,8 +4443,11 @@
4265
4443
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4266
4444
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4267
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;
4268
4449
  estimateProperties.shift();
4269
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4450
+ estimateProperties[0].opSize -= revealSize;
4270
4451
  }
4271
4452
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4272
4453
  });
@@ -4285,11 +4466,11 @@
4285
4466
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4286
4467
  const toValidation = utils.validateAddress(rest.to);
4287
4468
  if (toValidation !== utils.ValidationResult.VALID) {
4288
- throw new core.InvalidAddressError(rest.to, utils.invalidDetail(toValidation));
4469
+ throw new core.InvalidAddressError(rest.to, toValidation);
4289
4470
  }
4290
4471
  const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4291
4472
  if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4292
- throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4473
+ throw new core.InvalidAddressError(rest.source, sourceValidation);
4293
4474
  }
4294
4475
  if (rest.amount < 0) {
4295
4476
  throw new core.InvalidAmountError(rest.amount.toString());
@@ -4300,8 +4481,11 @@
4300
4481
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4301
4482
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4302
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;
4303
4487
  estimateProperties.shift();
4304
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
4488
+ estimateProperties[0].opSize -= revealSize;
4305
4489
  }
4306
4490
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4307
4491
  });
@@ -4320,7 +4504,7 @@
4320
4504
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4321
4505
  const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4322
4506
  if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4323
- throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4507
+ throw new core.InvalidAddressError(rest.source, sourceValidation);
4324
4508
  }
4325
4509
  if (!rest.to) {
4326
4510
  rest.to = rest.source;
@@ -4338,7 +4522,10 @@
4338
4522
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4339
4523
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4340
4524
  estimateProperties.shift();
4341
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4342
4529
  }
4343
4530
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4344
4531
  });
@@ -4357,7 +4544,7 @@
4357
4544
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4358
4545
  const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4359
4546
  if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4360
- throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4547
+ throw new core.InvalidAddressError(rest.source, sourceValidation);
4361
4548
  }
4362
4549
  if (!rest.to) {
4363
4550
  rest.to = rest.source;
@@ -4375,7 +4562,10 @@
4375
4562
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4376
4563
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4377
4564
  estimateProperties.shift();
4378
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4379
4569
  }
4380
4570
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4381
4571
  });
@@ -4394,14 +4584,11 @@
4394
4584
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4395
4585
  const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4396
4586
  if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4397
- throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4587
+ throw new core.InvalidAddressError(rest.source, sourceValidation);
4398
4588
  }
4399
4589
  if (!rest.to) {
4400
4590
  rest.to = rest.source;
4401
4591
  }
4402
- if (rest.to && rest.to !== rest.source) {
4403
- throw new core.InvalidStakingAddressError(rest.to);
4404
- }
4405
4592
  if (!rest.amount) {
4406
4593
  rest.amount = 0;
4407
4594
  }
@@ -4415,7 +4602,10 @@
4415
4602
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4416
4603
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4417
4604
  estimateProperties.shift();
4418
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4419
4609
  }
4420
4610
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4421
4611
  });
@@ -4434,11 +4624,11 @@
4434
4624
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
4435
4625
  const destinationValidation = utils.validateAddress(rest.destination);
4436
4626
  if (destinationValidation !== utils.ValidationResult.VALID) {
4437
- throw new core.InvalidAddressError(rest.destination, utils.invalidDetail(destinationValidation));
4627
+ throw new core.InvalidAddressError(rest.destination, destinationValidation);
4438
4628
  }
4439
4629
  const sourceValidation = utils.validateAddress((_b = rest.source) !== null && _b !== void 0 ? _b : '');
4440
4630
  if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4441
- throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4631
+ throw new core.InvalidAddressError(rest.source, sourceValidation);
4442
4632
  }
4443
4633
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4444
4634
  const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
@@ -4447,7 +4637,10 @@
4447
4637
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4448
4638
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4449
4639
  estimateProperties.shift();
4450
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4451
4644
  }
4452
4645
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4453
4646
  });
@@ -4466,11 +4659,11 @@
4466
4659
  var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
4467
4660
  const sourceValidation = utils.validateAddress(rest.source);
4468
4661
  if (rest.source && sourceValidation !== utils.ValidationResult.VALID) {
4469
- throw new core.InvalidAddressError(rest.source, utils.invalidDetail(sourceValidation));
4662
+ throw new core.InvalidAddressError(rest.source, sourceValidation);
4470
4663
  }
4471
4664
  const delegateValidation = utils.validateAddress((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
4472
4665
  if (rest.delegate && delegateValidation !== utils.ValidationResult.VALID) {
4473
- throw new core.InvalidAddressError(rest.delegate, utils.invalidDetail(delegateValidation));
4666
+ throw new core.InvalidAddressError(rest.delegate, delegateValidation);
4474
4667
  }
4475
4668
  const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
4476
4669
  storageLimit,
@@ -4479,7 +4672,10 @@
4479
4672
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4480
4673
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4481
4674
  estimateProperties.shift();
4482
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4483
4679
  }
4484
4680
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4485
4681
  });
@@ -4516,7 +4712,10 @@
4516
4712
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4517
4713
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4518
4714
  estimateProperties.shift();
4519
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4520
4719
  }
4521
4720
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4522
4721
  });
@@ -4524,7 +4723,6 @@
4524
4723
  /**
4525
4724
  *
4526
4725
  * @description Estimate gasLimit, storageLimit and fees to reveal the current account
4527
- *
4528
4726
  * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
4529
4727
  *
4530
4728
  * @param Estimate
@@ -4536,6 +4734,21 @@
4536
4734
  throw new RevealEstimateError();
4537
4735
  }
4538
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
+ }
4539
4752
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4540
4753
  const preparedOperation = params
4541
4754
  ? yield this.prepare.reveal(params)
@@ -4563,7 +4776,10 @@
4563
4776
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4564
4777
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4565
4778
  estimateProperties.shift();
4566
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4567
4783
  }
4568
4784
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4569
4785
  });
@@ -4589,7 +4805,10 @@
4589
4805
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4590
4806
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4591
4807
  estimateProperties.shift();
4592
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4593
4812
  }
4594
4813
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4595
4814
  });
@@ -4597,19 +4816,59 @@
4597
4816
  /**
4598
4817
  *
4599
4818
  * @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
4600
- *
4601
4819
  * @returns An estimation of gasLimit, storageLimit and fees for the operation
4602
- *
4603
4820
  * @param Estimate
4604
4821
  */
4605
4822
  updateConsensusKey(params) {
4606
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
+ }
4607
4835
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
4608
4836
  const preparedOperation = yield this.prepare.updateConsensusKey(params);
4609
4837
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4610
4838
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4611
4839
  estimateProperties.shift();
4612
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4613
4872
  }
4614
4873
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4615
4874
  });
@@ -4629,7 +4888,10 @@
4629
4888
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4630
4889
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4631
4890
  estimateProperties.shift();
4632
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4633
4895
  }
4634
4896
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4635
4897
  });
@@ -4649,7 +4911,10 @@
4649
4911
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4650
4912
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4651
4913
  estimateProperties.shift();
4652
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4653
4918
  }
4654
4919
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4655
4920
  });
@@ -4688,7 +4953,10 @@
4688
4953
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
4689
4954
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
4690
4955
  estimateProperties.shift();
4691
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
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;
4692
4960
  }
4693
4961
  return Estimate.createEstimateInstanceFromProperties(estimateProperties);
4694
4962
  });
@@ -4906,6 +5174,14 @@
4906
5174
  get publicKey() {
4907
5175
  return this.params.public_key;
4908
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
+ }
4909
5185
  sumProp(arr, prop) {
4910
5186
  return arr.reduce((prev, current) => {
4911
5187
  return prop in current ? Number(current[prop]) + prev : prev;
@@ -5076,6 +5352,67 @@
5076
5352
  get pk() {
5077
5353
  return this.params.pk;
5078
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
+ }
5079
5416
  get consumedMilliGas() {
5080
5417
  var _a;
5081
5418
  return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
@@ -5373,7 +5710,7 @@
5373
5710
  return __awaiter(this, void 0, void 0, function* () {
5374
5711
  const contractValidation = utils.validateContractAddress(contract);
5375
5712
  if (contractValidation !== utils.ValidationResult.VALID) {
5376
- throw new core.InvalidContractAddressError(contract, utils.invalidDetail(contractValidation));
5713
+ throw new core.InvalidContractAddressError(contract, contractValidation);
5377
5714
  }
5378
5715
  const script = yield this.context.readProvider.getScript(contract, 'head');
5379
5716
  if (!schema) {
@@ -5405,7 +5742,7 @@
5405
5742
  return __awaiter(this, void 0, void 0, function* () {
5406
5743
  const contractValidation = utils.validateContractAddress(contract);
5407
5744
  if (contractValidation !== utils.ValidationResult.VALID) {
5408
- throw new core.InvalidContractAddressError(contract, utils.invalidDetail(contractValidation));
5745
+ throw new core.InvalidContractAddressError(contract, contractValidation);
5409
5746
  }
5410
5747
  if (!schema) {
5411
5748
  schema = (yield this.rpc.getContract(contract)).script;
@@ -5549,14 +5886,14 @@
5549
5886
  var _a;
5550
5887
  const sourceValidation = utils.validateAddress(params.source);
5551
5888
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5552
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
5889
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5553
5890
  }
5554
5891
  const delegateValidation = utils.validateAddress((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
5555
5892
  if (params.delegate && delegateValidation !== utils.ValidationResult.VALID) {
5556
- throw new core.InvalidAddressError(params.delegate, utils.invalidDetail(delegateValidation));
5893
+ throw new core.InvalidAddressError(params.delegate, delegateValidation);
5557
5894
  }
5558
5895
  // Since babylon delegation source cannot smart contract
5559
- if (/kt1/i.test(params.source)) {
5896
+ if (/^kt1/i.test(params.source)) {
5560
5897
  throw new InvalidDelegationSource(params.source);
5561
5898
  }
5562
5899
  const publicKeyHash = yield this.signer.publicKeyHash();
@@ -5601,11 +5938,11 @@
5601
5938
  var _a;
5602
5939
  const toValidation = utils.validateAddress(params.to);
5603
5940
  if (toValidation !== utils.ValidationResult.VALID) {
5604
- throw new core.InvalidAddressError(params.to, utils.invalidDetail(toValidation));
5941
+ throw new core.InvalidAddressError(params.to, toValidation);
5605
5942
  }
5606
5943
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5607
5944
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5608
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
5945
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5609
5946
  }
5610
5947
  if (params.amount < 0) {
5611
5948
  throw new core.InvalidAmountError(params.amount.toString());
@@ -5633,7 +5970,7 @@
5633
5970
  var _a;
5634
5971
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5635
5972
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5636
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
5973
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5637
5974
  }
5638
5975
  if (!params.to) {
5639
5976
  params.to = params.source;
@@ -5669,7 +6006,7 @@
5669
6006
  var _a;
5670
6007
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5671
6008
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5672
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
6009
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5673
6010
  }
5674
6011
  if (!params.to) {
5675
6012
  params.to = params.source;
@@ -5702,14 +6039,11 @@
5702
6039
  var _a;
5703
6040
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5704
6041
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5705
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
6042
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5706
6043
  }
5707
6044
  if (!params.to) {
5708
6045
  params.to = params.source;
5709
6046
  }
5710
- if (params.to && params.to !== params.source) {
5711
- throw new core.InvalidStakingAddressError(params.to);
5712
- }
5713
6047
  if (!params.amount) {
5714
6048
  params.amount = 0;
5715
6049
  }
@@ -5739,11 +6073,11 @@
5739
6073
  var _a, _b;
5740
6074
  const destinationValidation = utils.validateAddress(params.destination);
5741
6075
  if (destinationValidation !== utils.ValidationResult.VALID) {
5742
- throw new core.InvalidAddressError(params.destination, utils.invalidDetail(destinationValidation));
6076
+ throw new core.InvalidAddressError(params.destination, destinationValidation);
5743
6077
  }
5744
6078
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5745
6079
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5746
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
6080
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5747
6081
  }
5748
6082
  const publicKeyHash = yield this.signer.publicKeyHash();
5749
6083
  const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
@@ -5757,8 +6091,7 @@
5757
6091
  }
5758
6092
  /**
5759
6093
  *
5760
- * @description Reveal the current address. Will throw an error if the address is already revealed.
5761
- *
6094
+ * @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
5762
6095
  * @returns An operation handle with the result from the rpc node
5763
6096
  *
5764
6097
  * @param RevealParams operation parameter
@@ -5766,6 +6099,21 @@
5766
6099
  reveal(params) {
5767
6100
  return __awaiter(this, void 0, void 0, function* () {
5768
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
+ }
5769
6117
  const estimateReveal = yield this.estimator.reveal(params);
5770
6118
  if (estimateReveal) {
5771
6119
  const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
@@ -5852,7 +6200,7 @@
5852
6200
  const publicKeyHash = yield this.signer.publicKeyHash();
5853
6201
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5854
6202
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5855
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
6203
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5856
6204
  }
5857
6205
  const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
5858
6206
  const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
@@ -5876,7 +6224,7 @@
5876
6224
  const publicKeyHash = yield this.signer.publicKeyHash();
5877
6225
  const sourceValidation = utils.validateAddress((_a = params.source) !== null && _a !== void 0 ? _a : '');
5878
6226
  if (params.source && sourceValidation !== utils.ValidationResult.VALID) {
5879
- throw new core.InvalidAddressError(params.source, utils.invalidDetail(sourceValidation));
6227
+ throw new core.InvalidAddressError(params.source, sourceValidation);
5880
6228
  }
5881
6229
  const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
5882
6230
  const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
@@ -5888,8 +6236,7 @@
5888
6236
  }
5889
6237
  /**
5890
6238
  *
5891
- * @description Updates the consensus key of the baker to public_key starting from the current cycle plus PRESERVED_CYCLES + 1
5892
- *
6239
+ * @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
5893
6240
  * @returns An operation handle with the result from the rpc node
5894
6241
  *
5895
6242
  * @param UpdateConsensusKeyParams
@@ -5897,6 +6244,17 @@
5897
6244
  updateConsensusKey(params) {
5898
6245
  return __awaiter(this, void 0, void 0, function* () {
5899
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
+ }
5900
6258
  const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
5901
6259
  const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
5902
6260
  const content = prepared.opOb.contents.find((op) => op.kind === rpc.OpKind.UPDATE_CONSENSUS_KEY);
@@ -5905,6 +6263,31 @@
5905
6263
  return new UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
5906
6264
  });
5907
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
+ }
5908
6291
  /**
5909
6292
  * @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
5910
6293
  * @param SmartRollupAddMessagesParams
@@ -5999,7 +6382,7 @@
5999
6382
  return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
6000
6383
  const addressValidation = utils.validateContractAddress(address);
6001
6384
  if (addressValidation !== utils.ValidationResult.VALID) {
6002
- throw new core.InvalidContractAddressError(address, utils.invalidDetail(addressValidation));
6385
+ throw new core.InvalidContractAddressError(address, addressValidation);
6003
6386
  }
6004
6387
  const rpc = this.context.withExtensions().rpc;
6005
6388
  const readProvider = this.context.withExtensions().readProvider;
@@ -6636,7 +7019,7 @@
6636
7019
  constructor(context, config = {}) {
6637
7020
  this.context = context;
6638
7021
  this._config$ = new rxjs.BehaviorSubject(Object.assign(Object.assign({}, defaultConfigStreamer), config));
6639
- this.timer$ = this._config$.pipe(operators.pluck('pollingIntervalMilliseconds'), operators.switchMap((pollingIntervalMilliseconds) => {
7022
+ this.timer$ = this._config$.pipe(operators.map((x) => x === null || x === void 0 ? void 0 : x.pollingIntervalMilliseconds), operators.switchMap((pollingIntervalMilliseconds) => {
6640
7023
  if (!pollingIntervalMilliseconds) {
6641
7024
  return rxjs.from(this.getConfirmationPollingInterval()).pipe(operators.switchMap((interval) => {
6642
7025
  return rxjs.timer(0, interval);
@@ -6646,7 +7029,11 @@
6646
7029
  return rxjs.timer(0, pollingIntervalMilliseconds);
6647
7030
  }
6648
7031
  }));
6649
- this.newBlock$ = this.timer$.pipe(operators.switchMap(() => getLastBlock(this.context)), operators.distinctUntilKeyChanged('hash'), operators.publish(), operators.refCount());
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
+ }));
6650
7037
  }
6651
7038
  get config() {
6652
7039
  return this._config$.getValue();
@@ -6678,7 +7065,7 @@
6678
7065
  return new ObservableSubscription(this.newBlock$, this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
6679
7066
  }
6680
7067
  subscribe(_filter) {
6681
- return new ObservableSubscription(this.newBlock$.pipe(operators.pluck('hash')), this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
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);
6682
7069
  }
6683
7070
  subscribeOperation(filter) {
6684
7071
  return new ObservableSubscription(this.newBlock$.pipe(applyFilter(filter)), this.config.shouldObservableSubscriptionRetry, this.config.observableSubscriptionRetryFunction);
@@ -6864,8 +7251,8 @@
6864
7251
 
6865
7252
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
6866
7253
  const VERSION = {
6867
- "commitHash": "f0eb755ed1e0de4d1cd86623df4496f76efd0caf",
6868
- "version": "22.0.0-beta.0"
7254
+ "commitHash": "13639ef56845fbb7e93bcbd37d3f6d0457b0872b",
7255
+ "version": "23.0.0-RC.0"
6869
7256
  };
6870
7257
 
6871
7258
  /**
@@ -7339,7 +7726,10 @@
7339
7726
  exports.ContractMethod = ContractMethod;
7340
7727
  exports.ContractMethodObject = ContractMethodObject;
7341
7728
  exports.ContractView = ContractView;
7729
+ exports.DEFAULT_FEE = DEFAULT_FEE;
7730
+ exports.DEFAULT_GAS_LIMIT = DEFAULT_GAS_LIMIT;
7342
7731
  exports.DEFAULT_SMART_CONTRACT_METHOD_NAME = DEFAULT_SMART_CONTRACT_METHOD_NAME;
7732
+ exports.DEFAULT_STORAGE_LIMIT = DEFAULT_STORAGE_LIMIT;
7343
7733
  exports.DefaultGlobalConstantsProvider = DefaultGlobalConstantsProvider;
7344
7734
  exports.DelegateOperation = DelegateOperation;
7345
7735
  exports.DelegationWalletOperation = DelegationWalletOperation;
@@ -7391,6 +7781,7 @@
7391
7781
  exports.TransferTicketOperation = TransferTicketOperation;
7392
7782
  exports.TransferTicketWalletOperation = TransferTicketWalletOperation;
7393
7783
  exports.UnconfiguredGlobalConstantsProviderError = UnconfiguredGlobalConstantsProviderError;
7784
+ exports.UpdateCompanionKeyOperation = UpdateCompanionKeyOperation;
7394
7785
  exports.UpdateConsensusKeyOperation = UpdateConsensusKeyOperation;
7395
7786
  exports.VIEW_LAMBDA = VIEW_LAMBDA;
7396
7787
  exports.ViewSimulationError = ViewSimulationError;
@@ -7414,6 +7805,7 @@
7414
7805
  exports.createSmartRollupOriginateOperation = createSmartRollupOriginateOperation;
7415
7806
  exports.createTransferOperation = createTransferOperation;
7416
7807
  exports.createTransferTicketOperation = createTransferTicketOperation;
7808
+ exports.createUpdateCompanionKeyOperation = createUpdateCompanionKeyOperation;
7417
7809
  exports.createUpdateConsensusKeyOperation = createUpdateConsensusKeyOperation;
7418
7810
  exports.defaultConfigConfirmation = defaultConfigConfirmation;
7419
7811
  exports.findWithKind = findWithKind;