@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
@@ -34,7 +34,8 @@ const STUB_SIGNATURE = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfL
34
34
  class RPCEstimateProvider extends provider_1.Provider {
35
35
  constructor() {
36
36
  super(...arguments);
37
- this.OP_SIZE_REVEAL = 324; // injecting size tz1=320, tz2=322, tz3=322, tz4=420(not supported)
37
+ this.REVEAL_LENGTH = 324; // injecting size tz1=320, tz2=322, tz3=322
38
+ this.REVEAL_LENGTH_TZ4 = 622; // injecting size tz4=620
38
39
  this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
39
40
  this.STORAGE_BUFFER = 20; // according to octez-client
40
41
  this.prepare = new prepare_provider_1.PrepareProvider(this.context);
@@ -116,9 +117,20 @@ class RPCEstimateProvider extends provider_1.Provider {
116
117
  : op.opOb.contents.length;
117
118
  }
118
119
  return opResponse.contents.map((x) => {
120
+ const content = x;
121
+ content.source = content.source || '';
122
+ let revealSize, eachOpSize;
123
+ if (content.source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)) {
124
+ revealSize = this.REVEAL_LENGTH_TZ4 / 2;
125
+ eachOpSize = (opbytes.length / 2 + utils_1.payloadLength[utils_1.PrefixV2.BLS12_381Signature]) / numberOfOps;
126
+ }
127
+ else {
128
+ revealSize = this.REVEAL_LENGTH / 2;
129
+ eachOpSize = (opbytes.length / 2 + utils_1.payloadLength[utils_1.PrefixV2.Ed25519Signature]) / numberOfOps;
130
+ }
119
131
  return this.getEstimationPropertiesFromOperationContent(x,
120
132
  // diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
121
- 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
133
+ x.kind === 'reveal' ? revealSize : eachOpSize, cost_per_byte, origination_size !== null && origination_size !== void 0 ? origination_size : 257 // protocol constants
122
134
  );
123
135
  });
124
136
  });
@@ -137,8 +149,11 @@ class RPCEstimateProvider extends provider_1.Provider {
137
149
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
138
150
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
139
151
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
152
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
153
+ ? this.REVEAL_LENGTH_TZ4 / 2
154
+ : this.REVEAL_LENGTH / 2;
140
155
  estimateProperties.shift();
141
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
156
+ estimateProperties[0].opSize -= revealSize;
142
157
  }
143
158
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
144
159
  });
@@ -157,11 +172,11 @@ class RPCEstimateProvider extends provider_1.Provider {
157
172
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
158
173
  const toValidation = (0, utils_1.validateAddress)(rest.to);
159
174
  if (toValidation !== utils_1.ValidationResult.VALID) {
160
- throw new core_1.InvalidAddressError(rest.to, (0, utils_1.invalidDetail)(toValidation));
175
+ throw new core_1.InvalidAddressError(rest.to, toValidation);
161
176
  }
162
177
  const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
163
178
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
164
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
179
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
165
180
  }
166
181
  if (rest.amount < 0) {
167
182
  throw new core_1.InvalidAmountError(rest.amount.toString());
@@ -172,8 +187,11 @@ class RPCEstimateProvider extends provider_1.Provider {
172
187
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
173
188
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
174
189
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
190
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
191
+ ? this.REVEAL_LENGTH_TZ4 / 2
192
+ : this.REVEAL_LENGTH / 2;
175
193
  estimateProperties.shift();
176
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
194
+ estimateProperties[0].opSize -= revealSize;
177
195
  }
178
196
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
179
197
  });
@@ -192,7 +210,7 @@ class RPCEstimateProvider extends provider_1.Provider {
192
210
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
193
211
  const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
194
212
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
195
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
213
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
196
214
  }
197
215
  if (!rest.to) {
198
216
  rest.to = rest.source;
@@ -210,7 +228,10 @@ class RPCEstimateProvider extends provider_1.Provider {
210
228
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
211
229
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
212
230
  estimateProperties.shift();
213
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
231
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
232
+ ? this.REVEAL_LENGTH_TZ4 / 2
233
+ : this.REVEAL_LENGTH / 2;
234
+ estimateProperties[0].opSize -= revealSize;
214
235
  }
215
236
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
216
237
  });
@@ -229,7 +250,7 @@ class RPCEstimateProvider extends provider_1.Provider {
229
250
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
230
251
  const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
231
252
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
232
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
253
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
233
254
  }
234
255
  if (!rest.to) {
235
256
  rest.to = rest.source;
@@ -247,7 +268,10 @@ class RPCEstimateProvider extends provider_1.Provider {
247
268
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
248
269
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
249
270
  estimateProperties.shift();
250
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
271
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
272
+ ? this.REVEAL_LENGTH_TZ4 / 2
273
+ : this.REVEAL_LENGTH / 2;
274
+ estimateProperties[0].opSize -= revealSize;
251
275
  }
252
276
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
253
277
  });
@@ -266,14 +290,11 @@ class RPCEstimateProvider extends provider_1.Provider {
266
290
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
267
291
  const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
268
292
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
269
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
293
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
270
294
  }
271
295
  if (!rest.to) {
272
296
  rest.to = rest.source;
273
297
  }
274
- if (rest.to && rest.to !== rest.source) {
275
- throw new core_1.InvalidStakingAddressError(rest.to);
276
- }
277
298
  if (!rest.amount) {
278
299
  rest.amount = 0;
279
300
  }
@@ -287,7 +308,10 @@ class RPCEstimateProvider extends provider_1.Provider {
287
308
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
288
309
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
289
310
  estimateProperties.shift();
290
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
311
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
312
+ ? this.REVEAL_LENGTH_TZ4 / 2
313
+ : this.REVEAL_LENGTH / 2;
314
+ estimateProperties[0].opSize -= revealSize;
291
315
  }
292
316
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
293
317
  });
@@ -306,11 +330,11 @@ class RPCEstimateProvider extends provider_1.Provider {
306
330
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
307
331
  const destinationValidation = (0, utils_1.validateAddress)(rest.destination);
308
332
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
309
- throw new core_1.InvalidAddressError(rest.destination, (0, utils_1.invalidDetail)(destinationValidation));
333
+ throw new core_1.InvalidAddressError(rest.destination, destinationValidation);
310
334
  }
311
335
  const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
312
336
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
313
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
337
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
314
338
  }
315
339
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
316
340
  const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
@@ -319,7 +343,10 @@ class RPCEstimateProvider extends provider_1.Provider {
319
343
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
320
344
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
321
345
  estimateProperties.shift();
322
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
346
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
347
+ ? this.REVEAL_LENGTH_TZ4 / 2
348
+ : this.REVEAL_LENGTH / 2;
349
+ estimateProperties[0].opSize -= revealSize;
323
350
  }
324
351
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
325
352
  });
@@ -338,11 +365,11 @@ class RPCEstimateProvider extends provider_1.Provider {
338
365
  var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
339
366
  const sourceValidation = (0, utils_1.validateAddress)(rest.source);
340
367
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
341
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
368
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
342
369
  }
343
370
  const delegateValidation = (0, utils_1.validateAddress)((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
344
371
  if (rest.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
345
- throw new core_1.InvalidAddressError(rest.delegate, (0, utils_1.invalidDetail)(delegateValidation));
372
+ throw new core_1.InvalidAddressError(rest.delegate, delegateValidation);
346
373
  }
347
374
  const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
348
375
  storageLimit,
@@ -351,7 +378,10 @@ class RPCEstimateProvider extends provider_1.Provider {
351
378
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
352
379
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
353
380
  estimateProperties.shift();
354
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
381
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
382
+ ? this.REVEAL_LENGTH_TZ4 / 2
383
+ : this.REVEAL_LENGTH / 2;
384
+ estimateProperties[0].opSize -= revealSize;
355
385
  }
356
386
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
357
387
  });
@@ -388,7 +418,10 @@ class RPCEstimateProvider extends provider_1.Provider {
388
418
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
389
419
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
390
420
  estimateProperties.shift();
391
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
421
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
422
+ ? this.REVEAL_LENGTH_TZ4 / 2
423
+ : this.REVEAL_LENGTH / 2;
424
+ estimateProperties[0].opSize -= revealSize;
392
425
  }
393
426
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
394
427
  });
@@ -396,7 +429,6 @@ class RPCEstimateProvider extends provider_1.Provider {
396
429
  /**
397
430
  *
398
431
  * @description Estimate gasLimit, storageLimit and fees to reveal the current account
399
- *
400
432
  * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
401
433
  *
402
434
  * @param Estimate
@@ -408,6 +440,21 @@ class RPCEstimateProvider extends provider_1.Provider {
408
440
  throw new errors_2.RevealEstimateError();
409
441
  }
410
442
  if (yield this.isAccountRevealRequired(publicKeyHash)) {
443
+ const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(publicKeyHash, utils_1.publicKeyHashPrefixes);
444
+ if (pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash) {
445
+ if (params && params.proof) {
446
+ (0, utils_1.b58DecodeAndCheckPrefix)(params.proof, [utils_1.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
447
+ }
448
+ else {
449
+ const { prefixSig } = yield this.signer.provePossession();
450
+ params = Object.assign(Object.assign({}, params), { proof: prefixSig });
451
+ }
452
+ }
453
+ else {
454
+ if (params && params.proof) {
455
+ throw new core_1.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
456
+ }
457
+ }
411
458
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
412
459
  const preparedOperation = params
413
460
  ? yield this.prepare.reveal(params)
@@ -435,7 +482,10 @@ class RPCEstimateProvider extends provider_1.Provider {
435
482
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
436
483
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
437
484
  estimateProperties.shift();
438
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
485
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
486
+ ? this.REVEAL_LENGTH_TZ4 / 2
487
+ : this.REVEAL_LENGTH / 2;
488
+ estimateProperties[0].opSize -= revealSize;
439
489
  }
440
490
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
441
491
  });
@@ -461,7 +511,10 @@ class RPCEstimateProvider extends provider_1.Provider {
461
511
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
462
512
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
463
513
  estimateProperties.shift();
464
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
514
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
515
+ ? this.REVEAL_LENGTH_TZ4 / 2
516
+ : this.REVEAL_LENGTH / 2;
517
+ estimateProperties[0].opSize -= revealSize;
465
518
  }
466
519
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
467
520
  });
@@ -469,19 +522,59 @@ class RPCEstimateProvider extends provider_1.Provider {
469
522
  /**
470
523
  *
471
524
  * @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
472
- *
473
525
  * @returns An estimation of gasLimit, storageLimit and fees for the operation
474
- *
475
526
  * @param Estimate
476
527
  */
477
528
  updateConsensusKey(params) {
478
529
  return __awaiter(this, void 0, void 0, function* () {
530
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
531
+ if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
532
+ if (!params.proof) {
533
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
534
+ }
535
+ }
536
+ else {
537
+ if (params.proof) {
538
+ throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
539
+ }
540
+ }
479
541
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
480
542
  const preparedOperation = yield this.prepare.updateConsensusKey(params);
481
543
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
482
544
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
483
545
  estimateProperties.shift();
484
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
546
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
547
+ ? this.REVEAL_LENGTH_TZ4 / 2
548
+ : this.REVEAL_LENGTH / 2;
549
+ estimateProperties[0].opSize -= revealSize;
550
+ }
551
+ return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
552
+ });
553
+ }
554
+ /**
555
+ *
556
+ * @description Estimate gasLimit, storageLimit and fees for an Update Companion Key operation
557
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
558
+ * @param Estimate
559
+ */
560
+ updateCompanionKey(params) {
561
+ return __awaiter(this, void 0, void 0, function* () {
562
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
563
+ if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
564
+ throw new core_1.ProhibitedActionError('companion key must be a bls account');
565
+ }
566
+ if (!params.proof) {
567
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
568
+ }
569
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
570
+ const preparedOperation = yield this.prepare.updateCompanionKey(params);
571
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
572
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
573
+ estimateProperties.shift();
574
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
575
+ ? this.REVEAL_LENGTH_TZ4 / 2
576
+ : this.REVEAL_LENGTH / 2;
577
+ estimateProperties[0].opSize -= revealSize;
485
578
  }
486
579
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
487
580
  });
@@ -501,7 +594,10 @@ class RPCEstimateProvider extends provider_1.Provider {
501
594
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
502
595
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
503
596
  estimateProperties.shift();
504
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
597
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
598
+ ? this.REVEAL_LENGTH_TZ4 / 2
599
+ : this.REVEAL_LENGTH / 2;
600
+ estimateProperties[0].opSize -= revealSize;
505
601
  }
506
602
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
507
603
  });
@@ -521,7 +617,10 @@ class RPCEstimateProvider extends provider_1.Provider {
521
617
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
522
618
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
523
619
  estimateProperties.shift();
524
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
620
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
621
+ ? this.REVEAL_LENGTH_TZ4 / 2
622
+ : this.REVEAL_LENGTH / 2;
623
+ estimateProperties[0].opSize -= revealSize;
525
624
  }
526
625
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
527
626
  });
@@ -560,7 +659,10 @@ class RPCEstimateProvider extends provider_1.Provider {
560
659
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
561
660
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
562
661
  estimateProperties.shift();
563
- estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
662
+ const revealSize = preparedOperation.opOb.contents[0].source.startsWith(utils_1.PrefixV2.BLS12_381PublicKeyHash)
663
+ ? this.REVEAL_LENGTH_TZ4 / 2
664
+ : this.REVEAL_LENGTH / 2;
665
+ estimateProperties[0].opSize -= revealSize;
564
666
  }
565
667
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
566
668
  });
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Operation = exports.RevealOperation = exports.ProposalsOperation = exports.DrainDelegateOperation = exports.BallotOperation = exports.SmartRollupOriginateOperation = exports.SmartRollupAddMessagesOperation = exports.UpdateConsensusKeyOperation = exports.TransferTicketOperation = exports.IncreasePaidStorageOperation = exports.RegisterGlobalConstantOperation = exports.TransactionOperation = exports.DelegateOperation = exports.OriginationOperation = exports.BatchOperation = exports.InvalidEstimateValueError = exports.TezosPreapplyFailureError = exports.TezosOperationError = void 0;
17
+ exports.Operation = exports.RevealOperation = exports.ProposalsOperation = exports.DrainDelegateOperation = exports.BallotOperation = exports.SmartRollupOriginateOperation = exports.SmartRollupAddMessagesOperation = exports.UpdateCompanionKeyOperation = exports.UpdateConsensusKeyOperation = exports.TransferTicketOperation = exports.IncreasePaidStorageOperation = exports.RegisterGlobalConstantOperation = exports.TransactionOperation = exports.DelegateOperation = exports.OriginationOperation = exports.BatchOperation = exports.InvalidEstimateValueError = exports.TezosPreapplyFailureError = exports.TezosOperationError = void 0;
18
18
  __exportStar(require("./types"), exports);
19
19
  var errors_1 = require("./errors");
20
20
  Object.defineProperty(exports, "TezosOperationError", { enumerable: true, get: function () { return errors_1.TezosOperationError; } });
@@ -36,6 +36,8 @@ var transfer_ticket_operation_1 = require("./transfer-ticket-operation");
36
36
  Object.defineProperty(exports, "TransferTicketOperation", { enumerable: true, get: function () { return transfer_ticket_operation_1.TransferTicketOperation; } });
37
37
  var update_consensus_key_operation_1 = require("./update-consensus-key-operation");
38
38
  Object.defineProperty(exports, "UpdateConsensusKeyOperation", { enumerable: true, get: function () { return update_consensus_key_operation_1.UpdateConsensusKeyOperation; } });
39
+ var update_companion_key_operation_1 = require("./update-companion-key-operation");
40
+ Object.defineProperty(exports, "UpdateCompanionKeyOperation", { enumerable: true, get: function () { return update_companion_key_operation_1.UpdateCompanionKeyOperation; } });
39
41
  var smart_rollup_add_messages_operation_1 = require("./smart-rollup-add-messages-operation");
40
42
  Object.defineProperty(exports, "SmartRollupAddMessagesOperation", { enumerable: true, get: function () { return smart_rollup_add_messages_operation_1.SmartRollupAddMessagesOperation; } });
41
43
  var smart_rollup_originate_operation_1 = require("./smart-rollup-originate-operation");
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RevealOperation = void 0;
4
+ const core_1 = require("@taquito/core");
4
5
  const bignumber_js_1 = require("bignumber.js");
5
6
  const errors_1 = require("./errors");
6
7
  const operations_1 = require("./operations");
@@ -40,6 +41,14 @@ class RevealOperation extends operations_1.Operation {
40
41
  get publicKey() {
41
42
  return this.params.public_key;
42
43
  }
44
+ get proof() {
45
+ if (this.params.proof) {
46
+ return this.params.proof;
47
+ }
48
+ else {
49
+ throw new core_1.ProhibitedActionError('Only BLS key has proof');
50
+ }
51
+ }
43
52
  sumProp(arr, prop) {
44
53
  return arr.reduce((prev, current) => {
45
54
  return prop in current ? Number(current[prop]) + prev : prev;
@@ -22,7 +22,8 @@ const isKind = (op, kind) => {
22
22
  };
23
23
  exports.isKind = isKind;
24
24
  const isOpWithGasBuffer = (op) => {
25
- if (op.kind === rpc_1.OpKind.TRANSACTION && op.parameters) {
25
+ var _a;
26
+ if (op.kind === rpc_1.OpKind.TRANSACTION && ((_a = op.destination) === null || _a === void 0 ? void 0 : _a.startsWith('KT1'))) {
26
27
  return true;
27
28
  }
28
29
  else {
@@ -31,6 +32,7 @@ const isOpWithGasBuffer = (op) => {
31
32
  'register_global_constant',
32
33
  'transfer_ticket',
33
34
  'update_consensus_key',
35
+ 'update_companion_key',
34
36
  'smart_rollup_add_messages',
35
37
  'smart_rollup_originate',
36
38
  ].indexOf(op.kind) !== -1);
@@ -47,6 +49,7 @@ const isOpWithFee = (op) => {
47
49
  'increase_paid_storage',
48
50
  'transfer_ticket',
49
51
  'update_consensus_key',
52
+ 'update_companion_key',
50
53
  'smart_rollup_add_messages',
51
54
  'smart_rollup_originate',
52
55
  'smart_rollup_execute_outbox_message',
@@ -62,6 +65,7 @@ const isOpRequireReveal = (op) => {
62
65
  'increase_paid_storage',
63
66
  'transfer_ticket',
64
67
  'update_consensus_key',
68
+ 'update_companion_key',
65
69
  'smart_rollup_add_messages',
66
70
  'smart_rollup_originate',
67
71
  'smart_rollup_execute_outbox_message',
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateCompanionKeyOperation = void 0;
4
+ const core_1 = require("@taquito/core");
5
+ const operations_1 = require("./operations");
6
+ /**
7
+ *
8
+ * @description UpdateCompanionKeyOperation provides utility to fetch properties for Operation of kind UpdateCompanionKey
9
+ *
10
+ */
11
+ class UpdateCompanionKeyOperation extends operations_1.Operation {
12
+ constructor(hash, params, source, raw, results, context) {
13
+ super(hash, raw, results, context);
14
+ this.params = params;
15
+ this.source = source;
16
+ }
17
+ get operationResults() {
18
+ const updateCompanionKeyOp = Array.isArray(this.results) &&
19
+ this.results.find((op) => op.kind === 'update_companion_key');
20
+ const result = updateCompanionKeyOp &&
21
+ updateCompanionKeyOp.metadata &&
22
+ updateCompanionKeyOp.metadata.operation_result;
23
+ return result ? result : undefined;
24
+ }
25
+ get status() {
26
+ var _a, _b;
27
+ return (_b = (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'unknown';
28
+ }
29
+ get fee() {
30
+ return Number(this.params.fee);
31
+ }
32
+ get gasLimit() {
33
+ return Number(this.params.gas_limit);
34
+ }
35
+ get storageLimit() {
36
+ return Number(this.params.storage_limit);
37
+ }
38
+ get pk() {
39
+ return this.params.pk;
40
+ }
41
+ get proof() {
42
+ if (this.params.proof) {
43
+ return this.params.proof;
44
+ }
45
+ else {
46
+ throw new core_1.ProhibitedActionError('Only updating companion key to a BLS account has proof');
47
+ }
48
+ }
49
+ get consumedMilliGas() {
50
+ var _a;
51
+ return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
52
+ }
53
+ get errors() {
54
+ var _a;
55
+ return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.errors;
56
+ }
57
+ }
58
+ exports.UpdateCompanionKeyOperation = UpdateCompanionKeyOperation;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UpdateConsensusKeyOperation = void 0;
4
+ const core_1 = require("@taquito/core");
4
5
  const operations_1 = require("./operations");
5
6
  /**
6
7
  *
@@ -37,6 +38,14 @@ class UpdateConsensusKeyOperation extends operations_1.Operation {
37
38
  get pk() {
38
39
  return this.params.pk;
39
40
  }
41
+ get proof() {
42
+ if (this.params.proof) {
43
+ return this.params.proof;
44
+ }
45
+ else {
46
+ throw new core_1.ProhibitedActionError('Only updating consensus key to a BLS account has proof');
47
+ }
48
+ }
40
49
  get consumedMilliGas() {
41
50
  var _a;
42
51
  return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;