@taquito/taquito 23.0.0-beta.0 → 23.0.0-beta.1

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 (39) 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/tz/rpc-tz-provider.js +4 -4
  16. package/dist/lib/version.js +2 -2
  17. package/dist/lib/wallet/wallet.js +9 -9
  18. package/dist/taquito.es6.js +434 -76
  19. package/dist/taquito.es6.js.map +1 -1
  20. package/dist/taquito.min.js +1 -1
  21. package/dist/taquito.min.js.LICENSE.txt +2 -0
  22. package/dist/taquito.umd.js +433 -73
  23. package/dist/taquito.umd.js.map +1 -1
  24. package/dist/types/batch/rpc-batch-provider.d.ts +16 -2
  25. package/dist/types/contract/interface.d.ts +10 -3
  26. package/dist/types/contract/prepare.d.ts +4 -3
  27. package/dist/types/contract/rpc-contract-provider.d.ts +11 -4
  28. package/dist/types/estimate/estimate-provider-interface.d.ts +9 -3
  29. package/dist/types/estimate/rpc-estimate-provider.d.ts +10 -4
  30. package/dist/types/operations/index.d.ts +1 -0
  31. package/dist/types/operations/reveal-operation.d.ts +1 -0
  32. package/dist/types/operations/types.d.ts +26 -5
  33. package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
  34. package/dist/types/operations/update-consensus-key-operation.d.ts +1 -0
  35. package/dist/types/prepare/interface.d.ts +8 -3
  36. package/dist/types/prepare/prepare-provider.d.ts +10 -4
  37. package/dist/types/provider.d.ts +1 -1
  38. package/dist/types/signer/interface.d.ts +18 -8
  39. package/package.json +9 -9
@@ -41,6 +41,7 @@ const core_1 = require("@taquito/core");
41
41
  const contract_1 = require("../contract");
42
42
  const provider_1 = require("../provider");
43
43
  const bignumber_js_1 = require("bignumber.js");
44
+ const utils_1 = require("@taquito/utils");
44
45
  const mergeLimits = (userDefinedLimit, defaultLimits) => {
45
46
  var _a, _b, _c;
46
47
  return {
@@ -114,10 +115,14 @@ class PrepareProvider extends provider_1.Provider {
114
115
  if (!publicKey) {
115
116
  throw new core_1.PublicKeyNotFoundError(pkh);
116
117
  }
118
+ const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
117
119
  ops.unshift(yield (0, contract_1.createRevealOperation)({
118
120
  fee: (0, constants_1.getRevealFee)(pkh),
119
121
  storageLimit: constants_1.REVEAL_STORAGE_LIMIT,
120
122
  gasLimit: (0, constants_1.getRevealGasLimit)(pkh),
123
+ proof: pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash
124
+ ? (yield this.signer.provePossession()).prefixSig
125
+ : undefined,
121
126
  }, publicKeyHash, publicKey));
122
127
  return ops;
123
128
  }
@@ -163,6 +168,7 @@ class PrepareProvider extends provider_1.Provider {
163
168
  case rpc_1.OpKind.DELEGATION:
164
169
  case rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT:
165
170
  case rpc_1.OpKind.UPDATE_CONSENSUS_KEY:
171
+ case rpc_1.OpKind.UPDATE_COMPANION_KEY:
166
172
  case rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
167
173
  case rpc_1.OpKind.SMART_ROLLUP_ORIGINATE:
168
174
  case rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
@@ -218,17 +224,31 @@ class PrepareProvider extends provider_1.Provider {
218
224
  /**
219
225
  *
220
226
  * @description Method to prepare a reveal operation
221
- * @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
222
227
  * @param operation RPCOperation object or RPCOperation array
223
228
  * @param source string or undefined source pkh
224
229
  * @returns a PreparedOperation object
225
230
  */
226
231
  reveal(_a) {
227
- return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit }) {
232
+ return __awaiter(this, arguments, void 0, function* ({ fee, gasLimit, storageLimit, proof }) {
228
233
  const { pkh, publicKey } = yield this.getKeys();
229
234
  if (!publicKey) {
230
235
  throw new core_1.PublicKeyNotFoundError(pkh);
231
236
  }
237
+ const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
238
+ if (pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash) {
239
+ if (proof) {
240
+ (0, utils_1.b58DecodeAndCheckPrefix)(proof, [utils_1.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
241
+ }
242
+ else {
243
+ const { prefixSig } = yield this.signer.provePossession();
244
+ proof = prefixSig;
245
+ }
246
+ }
247
+ else {
248
+ if (proof) {
249
+ throw new core_1.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
250
+ }
251
+ }
232
252
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
233
253
  const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
234
254
  const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
@@ -236,6 +256,7 @@ class PrepareProvider extends provider_1.Provider {
236
256
  fee: mergedEstimates.fee,
237
257
  gasLimit: mergedEstimates.gasLimit,
238
258
  storageLimit: mergedEstimates.storageLimit,
259
+ proof,
239
260
  }, pkh, publicKey);
240
261
  const ops = this.convertIntoArray(op);
241
262
  const hash = yield this.getBlockHash();
@@ -519,7 +540,6 @@ class PrepareProvider extends provider_1.Provider {
519
540
  /**
520
541
  *
521
542
  * @description Method to prepare an update_consensus_key operation
522
- * @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
523
543
  * @param operation RPCOperation object or RPCOperation array
524
544
  * @param source string or undefined source pkh
525
545
  * @returns a PreparedOperation object
@@ -528,6 +548,17 @@ class PrepareProvider extends provider_1.Provider {
528
548
  return __awaiter(this, void 0, void 0, function* () {
529
549
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
530
550
  const { pkh } = yield this.getKeys();
551
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(rest.pk, utils_1.publicKeyPrefixes);
552
+ if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
553
+ if (!rest.proof) {
554
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
555
+ }
556
+ }
557
+ else {
558
+ if (rest.proof) {
559
+ throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
560
+ }
561
+ }
531
562
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
532
563
  const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
533
564
  const op = yield (0, contract_1.createUpdateConsensusKeyOperation)(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
@@ -548,6 +579,44 @@ class PrepareProvider extends provider_1.Provider {
548
579
  };
549
580
  });
550
581
  }
582
+ /**
583
+ *
584
+ * @description Method to prepare an update_companion_key operation
585
+ * @param operation RPCOperation object or RPCOperation array
586
+ * @param source string or undefined source pkh
587
+ * @returns a PreparedOperation object
588
+ */
589
+ updateCompanionKey(_a, source) {
590
+ return __awaiter(this, void 0, void 0, function* () {
591
+ var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
592
+ const { pkh } = yield this.getKeys();
593
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(rest.pk, utils_1.publicKeyPrefixes);
594
+ if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
595
+ throw new core_1.ProhibitedActionError('companion key must be a bls account');
596
+ }
597
+ if (!rest.proof) {
598
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
599
+ }
600
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
601
+ const DEFAULT_PARAMS = yield this.getOperationLimits(protocolConstants);
602
+ const op = yield (0, contract_1.createUpdateCompanionKeyOperation)(Object.assign(Object.assign({}, rest), mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS)));
603
+ const operation = yield this.addRevealOperationIfNeeded(op, pkh);
604
+ const ops = this.convertIntoArray(operation);
605
+ const hash = yield this.getBlockHash();
606
+ const protocol = yield this.getProtocolHash();
607
+ __classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
608
+ const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
609
+ const contents = this.constructOpContents(ops, headCounter, pkh, source);
610
+ return {
611
+ opOb: {
612
+ branch: hash,
613
+ contents,
614
+ protocol,
615
+ },
616
+ counter: headCounter,
617
+ };
618
+ });
619
+ }
551
620
  /**
552
621
  *
553
622
  * @description Method to prepare an increase_paid_storage operation
@@ -838,10 +907,14 @@ class PrepareProvider extends provider_1.Provider {
838
907
  if (!publicKey) {
839
908
  throw new core_1.PublicKeyNotFoundError(pkh);
840
909
  }
910
+ const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
841
911
  ops.unshift(yield (0, contract_1.createRevealOperation)({
842
912
  fee: (0, constants_1.getRevealFee)(pkh),
843
913
  storageLimit: constants_1.REVEAL_STORAGE_LIMIT,
844
914
  gasLimit: (0, constants_1.getRevealGasLimit)(pkh),
915
+ proof: pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash
916
+ ? (yield this.signer.provePossession()).prefixSig
917
+ : undefined,
845
918
  }, pkh, publicKey));
846
919
  }
847
920
  const hash = yield this.getBlockHash();
@@ -91,6 +91,10 @@ class Provider {
91
91
  return (0, prepare_1.createRegisterGlobalConstantOperation)(Object.assign({}, param));
92
92
  case rpc_1.OpKind.INCREASE_PAID_STORAGE:
93
93
  return (0, prepare_1.createIncreasePaidStorageOperation)(Object.assign({}, param));
94
+ case rpc_1.OpKind.UPDATE_CONSENSUS_KEY:
95
+ return (0, prepare_1.createUpdateConsensusKeyOperation)(Object.assign({}, param));
96
+ case rpc_1.OpKind.UPDATE_COMPANION_KEY:
97
+ return (0, prepare_1.createUpdateCompanionKeyOperation)(Object.assign({}, param));
94
98
  case rpc_1.OpKind.TRANSFER_TICKET:
95
99
  return (0, prepare_1.createTransferTicketOperation)(Object.assign({}, param));
96
100
  case rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
@@ -24,7 +24,7 @@ class RpcTzProvider extends provider_1.Provider {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const addressValidation = (0, utils_1.validateAddress)(address);
26
26
  if (addressValidation !== utils_1.ValidationResult.VALID) {
27
- throw new core_1.InvalidAddressError(address, (0, utils_1.invalidDetail)(addressValidation));
27
+ throw new core_1.InvalidAddressError(address, addressValidation);
28
28
  }
29
29
  return this.context.readProvider.getBalance(address, 'head');
30
30
  });
@@ -33,7 +33,7 @@ class RpcTzProvider extends provider_1.Provider {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  const addressValidation = (0, utils_1.validateAddress)(address);
35
35
  if (addressValidation !== utils_1.ValidationResult.VALID) {
36
- throw new core_1.InvalidAddressError(address, (0, utils_1.invalidDetail)(addressValidation));
36
+ throw new core_1.InvalidAddressError(address, addressValidation);
37
37
  }
38
38
  return this.context.readProvider.getSpendable(address, 'head');
39
39
  });
@@ -42,7 +42,7 @@ class RpcTzProvider extends provider_1.Provider {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  const addressValidation = (0, utils_1.validateAddress)(address);
44
44
  if (addressValidation !== utils_1.ValidationResult.VALID) {
45
- throw new core_1.InvalidAddressError(address, (0, utils_1.invalidDetail)(addressValidation));
45
+ throw new core_1.InvalidAddressError(address, addressValidation);
46
46
  }
47
47
  return this.context.readProvider.getDelegate(address, 'head');
48
48
  });
@@ -51,7 +51,7 @@ class RpcTzProvider extends provider_1.Provider {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
52
  const pkhValidation = (0, utils_1.validateKeyHash)(pkh);
53
53
  if (pkhValidation !== utils_1.ValidationResult.VALID) {
54
- throw new utils_1.InvalidKeyHashError(pkh, (0, utils_1.invalidDetail)(pkhValidation));
54
+ throw new utils_1.InvalidKeyHashError(pkh, pkhValidation);
55
55
  }
56
56
  const prepared = yield this.prepare.activate({ pkh, secret });
57
57
  const forgedBytes = yield this.forge(prepared);
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "7af2138a9e5c5b230c4b4c726f35c2f2e67b721c",
7
- "version": "23.0.0-beta.0"
6
+ "commitHash": "10b3de10de15ae68d47b1fca922d3129d2f79641",
7
+ "version": "23.0.0-beta.1"
8
8
  };
@@ -27,7 +27,7 @@ class WalletOperationBatch {
27
27
  withTransfer(params) {
28
28
  const toValidation = (0, utils_1.validateAddress)(params.to);
29
29
  if (toValidation !== utils_1.ValidationResult.VALID) {
30
- throw new core_1.InvalidAddressError(params.to, (0, utils_1.invalidDetail)(toValidation));
30
+ throw new core_1.InvalidAddressError(params.to, toValidation);
31
31
  }
32
32
  this.operations.push(Object.assign({ kind: types_1.OpKind.TRANSACTION }, params));
33
33
  return this;
@@ -48,7 +48,7 @@ class WalletOperationBatch {
48
48
  var _a;
49
49
  const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
50
50
  if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
51
- throw new core_1.InvalidAddressError(params.delegate, (0, utils_1.invalidDetail)(delegateValidation));
51
+ throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
52
52
  }
53
53
  this.operations.push(Object.assign({ kind: types_1.OpKind.DELEGATION }, params));
54
54
  return this;
@@ -68,7 +68,7 @@ class WalletOperationBatch {
68
68
  withIncreasePaidStorage(params) {
69
69
  const destinationValidation = (0, utils_1.validateAddress)(params.destination);
70
70
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
71
- throw new core_1.InvalidAddressError(params.destination, (0, utils_1.invalidDetail)(destinationValidation));
71
+ throw new core_1.InvalidAddressError(params.destination, destinationValidation);
72
72
  }
73
73
  this.operations.push(Object.assign({ kind: types_1.OpKind.INCREASE_PAID_STORAGE }, params));
74
74
  return this;
@@ -80,7 +80,7 @@ class WalletOperationBatch {
80
80
  withTransferTicket(params) {
81
81
  const destinationValidation = (0, utils_1.validateAddress)(params.destination);
82
82
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
83
- throw new core_1.InvalidAddressError(params.destination, (0, utils_1.invalidDetail)(destinationValidation));
83
+ throw new core_1.InvalidAddressError(params.destination, destinationValidation);
84
84
  }
85
85
  this.operations.push(Object.assign({ kind: types_1.OpKind.TRANSFER_TICKET }, params));
86
86
  return this;
@@ -203,7 +203,7 @@ class Wallet {
203
203
  var _a;
204
204
  const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
205
205
  if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
206
- throw new core_1.InvalidAddressError(params.delegate, (0, utils_1.invalidDetail)(delegateValidation));
206
+ throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
207
207
  }
208
208
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
209
209
  const mappedParams = yield this.walletProvider.mapDelegateParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -265,7 +265,7 @@ class Wallet {
265
265
  transfer(params) {
266
266
  const toValidation = (0, utils_1.validateAddress)(params.to);
267
267
  if (toValidation !== utils_1.ValidationResult.VALID) {
268
- throw new core_1.InvalidAddressError(params.to, (0, utils_1.invalidDetail)(toValidation));
268
+ throw new core_1.InvalidAddressError(params.to, toValidation);
269
269
  }
270
270
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
271
271
  const mappedParams = yield this.walletProvider.mapTransferParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -281,7 +281,7 @@ class Wallet {
281
281
  transferTicket(params) {
282
282
  const toValidation = (0, utils_1.validateAddress)(params.destination);
283
283
  if (toValidation !== utils_1.ValidationResult.VALID) {
284
- throw new core_1.InvalidAddressError(params.destination, (0, utils_1.invalidDetail)(toValidation));
284
+ throw new core_1.InvalidAddressError(params.destination, toValidation);
285
285
  }
286
286
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
287
287
  const mappedParams = yield this.walletProvider.mapTransferTicketParamsToWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -368,7 +368,7 @@ class Wallet {
368
368
  increasePaidStorage(params) {
369
369
  const destinationValidation = (0, utils_1.validateAddress)(params.destination);
370
370
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
371
- throw new core_1.InvalidAddressError(params.destination, (0, utils_1.invalidDetail)(destinationValidation));
371
+ throw new core_1.InvalidAddressError(params.destination, destinationValidation);
372
372
  }
373
373
  return this.walletCommand(() => __awaiter(this, void 0, void 0, function* () {
374
374
  const mappedParams = yield this.walletProvider.mapIncreasePaidStorageWalletParams(() => __awaiter(this, void 0, void 0, function* () { return params; }));
@@ -398,7 +398,7 @@ class Wallet {
398
398
  return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
399
399
  const addressValidation = (0, utils_1.validateContractAddress)(address);
400
400
  if (addressValidation !== utils_1.ValidationResult.VALID) {
401
- throw new core_1.InvalidContractAddressError(address, (0, utils_1.invalidDetail)(addressValidation));
401
+ throw new core_1.InvalidContractAddressError(address, addressValidation);
402
402
  }
403
403
  const rpc = this.context.withExtensions().rpc;
404
404
  const readProvider = this.context.withExtensions().readProvider;