@taquito/taquito 23.0.0-beta.0 → 23.0.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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/batch/rpc-batch-provider.js +47 -5
  3. package/dist/lib/constants.js +1 -2
  4. package/dist/lib/contract/contract.js +1 -1
  5. package/dist/lib/contract/prepare.js +17 -3
  6. package/dist/lib/contract/rpc-contract-provider.js +67 -17
  7. package/dist/lib/estimate/rpc-estimate-provider.js +133 -27
  8. package/dist/lib/operations/index.js +3 -1
  9. package/dist/lib/operations/reveal-operation.js +9 -0
  10. package/dist/lib/operations/types.js +5 -1
  11. package/dist/lib/operations/update-companion-key-operation.js +58 -0
  12. package/dist/lib/operations/update-consensus-key-operation.js +9 -0
  13. package/dist/lib/prepare/prepare-provider.js +76 -3
  14. package/dist/lib/provider.js +4 -0
  15. package/dist/lib/taquito.js +0 -1
  16. package/dist/lib/tz/rpc-tz-provider.js +4 -4
  17. package/dist/lib/version.js +2 -2
  18. package/dist/lib/wallet/wallet.js +9 -9
  19. package/dist/taquito.es6.js +434 -76
  20. package/dist/taquito.es6.js.map +1 -1
  21. package/dist/taquito.min.js +1 -1
  22. package/dist/taquito.min.js.LICENSE.txt +2 -0
  23. package/dist/taquito.umd.js +433 -73
  24. package/dist/taquito.umd.js.map +1 -1
  25. package/dist/types/batch/rpc-batch-provider.d.ts +16 -2
  26. package/dist/types/context.d.ts +1 -1
  27. package/dist/types/contract/interface.d.ts +10 -3
  28. package/dist/types/contract/prepare.d.ts +4 -3
  29. package/dist/types/contract/rpc-contract-provider.d.ts +11 -4
  30. package/dist/types/estimate/estimate-provider-interface.d.ts +9 -3
  31. package/dist/types/estimate/rpc-estimate-provider.d.ts +10 -4
  32. package/dist/types/operations/index.d.ts +1 -0
  33. package/dist/types/operations/reveal-operation.d.ts +1 -0
  34. package/dist/types/operations/types.d.ts +26 -5
  35. package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
  36. package/dist/types/operations/update-consensus-key-operation.d.ts +1 -0
  37. package/dist/types/prepare/interface.d.ts +8 -3
  38. package/dist/types/prepare/prepare-provider.d.ts +10 -4
  39. package/dist/types/provider.d.ts +2 -2
  40. package/dist/types/signer/noop.d.ts +1 -1
  41. package/dist/types/taquito.d.ts +2 -2
  42. package/package.json +9 -9
  43. package/dist/lib/signer/interface.js +0 -2
  44. package/dist/types/signer/interface.d.ts +0 -28
@@ -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,7 +290,7 @@ 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;
@@ -284,7 +308,10 @@ class RPCEstimateProvider extends provider_1.Provider {
284
308
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
285
309
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
286
310
  estimateProperties.shift();
287
- 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;
288
315
  }
289
316
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
290
317
  });
@@ -303,11 +330,11 @@ class RPCEstimateProvider extends provider_1.Provider {
303
330
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
304
331
  const destinationValidation = (0, utils_1.validateAddress)(rest.destination);
305
332
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
306
- throw new core_1.InvalidAddressError(rest.destination, (0, utils_1.invalidDetail)(destinationValidation));
333
+ throw new core_1.InvalidAddressError(rest.destination, destinationValidation);
307
334
  }
308
335
  const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
309
336
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
310
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
337
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
311
338
  }
312
339
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
313
340
  const preparedOperation = yield this.prepare.transferTicket(Object.assign({ fee,
@@ -316,7 +343,10 @@ class RPCEstimateProvider extends provider_1.Provider {
316
343
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
317
344
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
318
345
  estimateProperties.shift();
319
- 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;
320
350
  }
321
351
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
322
352
  });
@@ -335,11 +365,11 @@ class RPCEstimateProvider extends provider_1.Provider {
335
365
  var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
336
366
  const sourceValidation = (0, utils_1.validateAddress)(rest.source);
337
367
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
338
- throw new core_1.InvalidAddressError(rest.source, (0, utils_1.invalidDetail)(sourceValidation));
368
+ throw new core_1.InvalidAddressError(rest.source, sourceValidation);
339
369
  }
340
370
  const delegateValidation = (0, utils_1.validateAddress)((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
341
371
  if (rest.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
342
- throw new core_1.InvalidAddressError(rest.delegate, (0, utils_1.invalidDetail)(delegateValidation));
372
+ throw new core_1.InvalidAddressError(rest.delegate, delegateValidation);
343
373
  }
344
374
  const preparedOperation = yield this.prepare.delegation(Object.assign({ fee,
345
375
  storageLimit,
@@ -348,7 +378,10 @@ class RPCEstimateProvider extends provider_1.Provider {
348
378
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
349
379
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
350
380
  estimateProperties.shift();
351
- 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;
352
385
  }
353
386
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
354
387
  });
@@ -385,7 +418,10 @@ class RPCEstimateProvider extends provider_1.Provider {
385
418
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
386
419
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
387
420
  estimateProperties.shift();
388
- 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;
389
425
  }
390
426
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
391
427
  });
@@ -393,7 +429,6 @@ class RPCEstimateProvider extends provider_1.Provider {
393
429
  /**
394
430
  *
395
431
  * @description Estimate gasLimit, storageLimit and fees to reveal the current account
396
- * @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
397
432
  * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
398
433
  *
399
434
  * @param Estimate
@@ -405,6 +440,21 @@ class RPCEstimateProvider extends provider_1.Provider {
405
440
  throw new errors_2.RevealEstimateError();
406
441
  }
407
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
+ }
408
458
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
409
459
  const preparedOperation = params
410
460
  ? yield this.prepare.reveal(params)
@@ -432,7 +482,10 @@ class RPCEstimateProvider extends provider_1.Provider {
432
482
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
433
483
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
434
484
  estimateProperties.shift();
435
- 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;
436
489
  }
437
490
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
438
491
  });
@@ -458,7 +511,10 @@ class RPCEstimateProvider extends provider_1.Provider {
458
511
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
459
512
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
460
513
  estimateProperties.shift();
461
- 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;
462
518
  }
463
519
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
464
520
  });
@@ -466,18 +522,59 @@ class RPCEstimateProvider extends provider_1.Provider {
466
522
  /**
467
523
  *
468
524
  * @description Estimate gasLimit, storageLimit and fees for an Update Consensus Key operation
469
- * @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
470
525
  * @returns An estimation of gasLimit, storageLimit and fees for the operation
471
526
  * @param Estimate
472
527
  */
473
528
  updateConsensusKey(params) {
474
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
+ }
475
541
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
476
542
  const preparedOperation = yield this.prepare.updateConsensusKey(params);
477
543
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
478
544
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
479
545
  estimateProperties.shift();
480
- 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;
481
578
  }
482
579
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
483
580
  });
@@ -497,7 +594,10 @@ class RPCEstimateProvider extends provider_1.Provider {
497
594
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
498
595
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
499
596
  estimateProperties.shift();
500
- 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;
501
601
  }
502
602
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
503
603
  });
@@ -517,7 +617,10 @@ class RPCEstimateProvider extends provider_1.Provider {
517
617
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
518
618
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
519
619
  estimateProperties.shift();
520
- 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;
521
624
  }
522
625
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
523
626
  });
@@ -556,7 +659,10 @@ class RPCEstimateProvider extends provider_1.Provider {
556
659
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
557
660
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
558
661
  estimateProperties.shift();
559
- 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;
560
666
  }
561
667
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
562
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;