@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
package/README.md CHANGED
@@ -7,7 +7,7 @@ The `@taquito/taquito` package contains higher-level functionality that builds u
7
7
  ## CDN Bundle
8
8
 
9
9
  ```html
10
- <script src="https://unpkg.com/@taquito/taquito@22.0.0-beta.0/dist/taquito.min.js"
10
+ <script src="https://unpkg.com/@taquito/taquito@23.0.0-RC.0/dist/taquito.min.js"
11
11
  crossorigin="anonymous" integrity="sha384-IxvP0ECHi5oqLyz94wF85pU9+ktcsL1HHtA42MITxZsGbsUMEu/g+0Vkjj5vqiMR"></script>
12
12
  ```
13
13
 
@@ -0,0 +1 @@
1
+ (self.webpackChunktaquito=self.webpackChunktaquito||[]).push([[400],{6400:()=>{}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunktaquito=self.webpackChunktaquito||[]).push([[993],{5993:()=>{}}]);
@@ -42,7 +42,7 @@ class OperationBatch extends provider_1.Provider {
42
42
  throw new core_1.InvalidAmountError(params.amount.toString());
43
43
  }
44
44
  if (toValidation !== utils_1.ValidationResult.VALID) {
45
- throw new core_1.InvalidAddressError(params.to, (0, utils_1.invalidDetail)(toValidation));
45
+ throw new core_1.InvalidAddressError(params.to, toValidation);
46
46
  }
47
47
  this.operations.push(Object.assign({ kind: rpc_1.OpKind.TRANSACTION }, params));
48
48
  return this;
@@ -56,7 +56,7 @@ class OperationBatch extends provider_1.Provider {
56
56
  withTransferTicket(params) {
57
57
  const destinationValidation = (0, utils_1.validateAddress)(params.destination);
58
58
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
59
- throw new core_1.InvalidAddressError(params.destination, (0, utils_1.invalidDetail)(destinationValidation));
59
+ throw new core_1.InvalidAddressError(params.destination, destinationValidation);
60
60
  }
61
61
  this.operations.push(Object.assign({ kind: rpc_1.OpKind.TRANSFER_TICKET }, params));
62
62
  return this;
@@ -81,11 +81,11 @@ class OperationBatch extends provider_1.Provider {
81
81
  var _a;
82
82
  const sourceValidation = (0, utils_1.validateAddress)(params.source);
83
83
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
84
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
84
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
85
85
  }
86
86
  const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
87
87
  if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
88
- throw new core_1.InvalidAddressError(params.delegate, (0, utils_1.invalidDetail)(delegateValidation));
88
+ throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
89
89
  }
90
90
  this.operations.push(Object.assign({ kind: rpc_1.OpKind.DELEGATION }, params));
91
91
  return this;
@@ -100,7 +100,7 @@ class OperationBatch extends provider_1.Provider {
100
100
  withActivation({ pkh, secret }) {
101
101
  const pkhValidation = (0, utils_1.validateKeyHash)(pkh);
102
102
  if (pkhValidation !== utils_1.ValidationResult.VALID) {
103
- throw new core_1.InvalidKeyHashError(pkh, (0, utils_1.invalidDetail)(pkhValidation));
103
+ throw new core_1.InvalidKeyHashError(pkh, pkhValidation);
104
104
  }
105
105
  this.operations.push({ kind: rpc_1.OpKind.ACTIVATION, pkh, secret });
106
106
  return this;
@@ -135,6 +135,44 @@ class OperationBatch extends provider_1.Provider {
135
135
  this.operations.push(Object.assign({ kind: rpc_1.OpKind.INCREASE_PAID_STORAGE }, params));
136
136
  return this;
137
137
  }
138
+ /**
139
+ *
140
+ * @description Add a update consensus key operation to the batch
141
+ *
142
+ * @param params UpdateConsensusKey operation parameter
143
+ */
144
+ withUpdateConsensusKey(params) {
145
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
146
+ if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
147
+ if (!params.proof) {
148
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
149
+ }
150
+ }
151
+ else {
152
+ if (params.proof) {
153
+ throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
154
+ }
155
+ }
156
+ this.operations.push(Object.assign({ kind: rpc_1.OpKind.UPDATE_CONSENSUS_KEY }, params));
157
+ return this;
158
+ }
159
+ /**
160
+ *
161
+ * @description Add a update companion key operation to the batch
162
+ *
163
+ * @param params UpdateCompanionKey operation parameter
164
+ */
165
+ withUpdateCompanionKey(params) {
166
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
167
+ if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
168
+ throw new core_1.ProhibitedActionError('companion key must be a bls account');
169
+ }
170
+ if (!params.proof) {
171
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
172
+ }
173
+ this.operations.push(Object.assign({ kind: rpc_1.OpKind.UPDATE_COMPANION_KEY }, params));
174
+ return this;
175
+ }
138
176
  /**
139
177
  *
140
178
  * @description Add a smart rollup add messages operation to the batch
@@ -178,6 +216,10 @@ class OperationBatch extends provider_1.Provider {
178
216
  return (0, prepare_1.createRegisterGlobalConstantOperation)(Object.assign({}, param));
179
217
  case rpc_1.OpKind.INCREASE_PAID_STORAGE:
180
218
  return (0, prepare_1.createIncreasePaidStorageOperation)(Object.assign({}, param));
219
+ case rpc_1.OpKind.UPDATE_CONSENSUS_KEY:
220
+ return (0, prepare_1.createUpdateConsensusKeyOperation)(Object.assign({}, param));
221
+ case rpc_1.OpKind.UPDATE_COMPANION_KEY:
222
+ return (0, prepare_1.createUpdateCompanionKeyOperation)(Object.assign({}, param));
181
223
  case rpc_1.OpKind.TRANSFER_TICKET:
182
224
  return (0, prepare_1.createTransferTicketOperation)(Object.assign({}, param));
183
225
  case rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
@@ -1,25 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRevealFeeInternal = exports.getRevealFee = exports.getRevealGasLimit = exports.ChainIds = exports.protocols = exports.Protocols = exports.COST_PER_BYTE = exports.ORIGINATION_SIZE = exports.REVEAL_STORAGE_LIMIT = void 0;
4
- // value is based on octez-client reveal operation gasLimit of each address type in Rio Protocol
3
+ exports.getRevealFeeInternal = exports.getRevealFee = exports.getRevealGasLimit = exports.ChainIds = exports.protocols = exports.Protocols = exports.COST_PER_BYTE = exports.ORIGINATION_SIZE = exports.REVEAL_STORAGE_LIMIT = exports.DEFAULT_STORAGE_LIMIT = exports.DEFAULT_FEE = exports.DEFAULT_GAS_LIMIT = void 0;
4
+ /**
5
+ * @deprecated default reveal gasLimit please use getRevealGasLimit(address) instead, removing hardcoded gasLimit of delegation, origination and transfer
6
+ */
7
+ exports.DEFAULT_GAS_LIMIT = {
8
+ DELEGATION: 10600,
9
+ ORIGINATION: 10600,
10
+ TRANSFER: 10600,
11
+ REVEAL_TZ1: 1000,
12
+ REVEAL_TZ2: 1000,
13
+ REVEAL_TZ3: 2000,
14
+ REVEAL_TZ4: 2000,
15
+ };
16
+ /**
17
+ * @deprecated default reveal fee please use getRevealFee(address) instead, removing hardcoded fee of delegation, origination and transfer
18
+ */
19
+ exports.DEFAULT_FEE = {
20
+ DELEGATION: 1257,
21
+ ORIGINATION: 10000,
22
+ TRANSFER: 10000,
23
+ REVEAL: 374,
24
+ };
25
+ /**
26
+ * @deprecated default reveal storageLimit please use REVEAL_STORAGE_LIMIT instead, removing hardcoded storageLimit of delegation, origination and transfer
27
+ */
28
+ exports.DEFAULT_STORAGE_LIMIT = {
29
+ DELEGATION: 0,
30
+ ORIGINATION: 257,
31
+ TRANSFER: 257,
32
+ REVEAL: 0,
33
+ };
34
+ // value is based on octez-client reveal operation gasLimit of each address type in Seoul Protocol
5
35
  const REVEAL_GAS_LIMIT = {
6
- TZ1: 169,
7
- TZ2: 155,
8
- TZ3: 445,
9
- TZ4: 1674,
36
+ TZ1: 171,
37
+ TZ2: 157,
38
+ TZ3: 447,
39
+ TZ4: 3252,
10
40
  };
11
- // value is based on octez-client reveal operation fee of each address type in Rio Protocol
41
+ // value is based on octez-client reveal operation fee of each address type in Seoul Protocol
12
42
  const REVEAL_FEE = {
13
- TZ1: 276,
14
- TZ2: 276,
15
- TZ3: 305,
16
- TZ4: 477,
43
+ TZ1: 278,
44
+ TZ2: 277,
45
+ TZ3: 306,
46
+ TZ4: 736,
17
47
  };
18
- // value is based on octez-client reveal operation storageLimit of all address type in Rio Protocol
48
+ // value is based on octez-client reveal operation storageLimit of all address type in Seoul Protocol
19
49
  exports.REVEAL_STORAGE_LIMIT = 0;
20
- // protocol constants in Rio Protocol
50
+ // protocol constants in Seoul Protocol
21
51
  exports.ORIGINATION_SIZE = 257;
22
- // protocol constants in Rio Protocol
52
+ // protocol constants in Seoul Protocol
23
53
  exports.COST_PER_BYTE = 250;
24
54
  var Protocols;
25
55
  (function (Protocols) {
@@ -45,6 +75,7 @@ var Protocols;
45
75
  Protocols["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
46
76
  Protocols["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
47
77
  Protocols["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
78
+ Protocols["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
48
79
  Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
49
80
  })(Protocols || (exports.Protocols = Protocols = {}));
50
81
  exports.protocols = {
@@ -66,7 +97,8 @@ exports.protocols = {
66
97
  '020': [Protocols.PtParisBx, Protocols.PsParisCZ],
67
98
  '021': [Protocols.PsQuebecn],
68
99
  '022': [Protocols.PsRiotuma],
69
- '023': [Protocols.ProtoALpha],
100
+ '023': [Protocols.PtSeouLou],
101
+ '024': [Protocols.ProtoALpha],
70
102
  };
71
103
  var ChainIds;
72
104
  (function (ChainIds) {
@@ -88,10 +120,10 @@ var ChainIds;
88
120
  ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
89
121
  ChainIds["PARISBNET"] = "NetXo8SqH1c38SS";
90
122
  ChainIds["PARISCNET"] = "NetXXWAHLEvre9b";
91
- ChainIds["QUEBECN"] = "NetXuTeGinLEqxp";
92
- ChainIds["RIOTUMANET"] = "NetXPdgaoabtBth";
123
+ ChainIds["QUEBECNET"] = "NetXuTeGinLEqxp";
124
+ ChainIds["RIONET"] = "NetXPdgaoabtBth";
125
+ ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
93
126
  })(ChainIds || (exports.ChainIds = ChainIds = {}));
94
- // 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)
95
127
  const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
96
128
  exports.getRevealGasLimit = getRevealGasLimit;
97
129
  const getRevealGasLimitInternal = (address) => {
@@ -119,7 +151,7 @@ const getRevealFeeInternal = (address) => {
119
151
  case 'tz3':
120
152
  return REVEAL_FEE.TZ3;
121
153
  case 'tz4':
122
- return REVEAL_FEE.TZ4;
154
+ return REVEAL_FEE.TZ4 * 1.7;
123
155
  default:
124
156
  throw new Error(`Cannot estimate reveal fee for ${address}`);
125
157
  }
@@ -36,7 +36,7 @@ class ContractView {
36
36
  throw new core_1.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.`);
37
37
  }
38
38
  else if (chainId && chainIdValidation !== utils_1.ValidationResult.VALID) {
39
- throw new core_1.InvalidChainIdError(chainId, (0, utils_1.invalidDetail)(chainIdValidation));
39
+ throw new core_1.InvalidChainIdError(chainId, chainIdValidation);
40
40
  }
41
41
  const arg = this.parameterSchema.Encode(...this.args);
42
42
  const result = yield this.rpc.runView({
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createSmartRollupExecuteOutboxMessageOperation = exports.createSmartRollupOriginateOperation = exports.createSmartRollupAddMessagesOperation = exports.createUpdateConsensusKeyOperation = exports.createProposalsOperation = exports.createBallotOperation = exports.createDrainDelegateOperation = exports.createIncreasePaidStorageOperation = exports.createTransferTicketOperation = exports.createRegisterGlobalConstantOperation = exports.createRevealOperation = exports.createRegisterDelegateOperation = exports.createSetDelegateOperation = exports.createTransferOperation = exports.createOriginationOperation = exports.createActivationOperation = void 0;
12
+ exports.createSmartRollupExecuteOutboxMessageOperation = exports.createSmartRollupOriginateOperation = exports.createSmartRollupAddMessagesOperation = exports.createUpdateCompanionKeyOperation = exports.createUpdateConsensusKeyOperation = exports.createProposalsOperation = exports.createBallotOperation = exports.createDrainDelegateOperation = exports.createIncreasePaidStorageOperation = exports.createTransferTicketOperation = exports.createRegisterGlobalConstantOperation = exports.createRevealOperation = exports.createRegisterDelegateOperation = exports.createSetDelegateOperation = exports.createTransferOperation = exports.createOriginationOperation = exports.createActivationOperation = void 0;
13
13
  const michelson_encoder_1 = require("@taquito/michelson-encoder");
14
14
  const rpc_1 = require("@taquito/rpc");
15
15
  const constants_1 = require("../constants");
@@ -100,7 +100,7 @@ const createRegisterDelegateOperation = (_a, source_1) => __awaiter(void 0, [_a,
100
100
  };
101
101
  });
102
102
  exports.createRegisterDelegateOperation = createRegisterDelegateOperation;
103
- const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit }, source, publicKey) {
103
+ const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit, proof }, source, publicKey) {
104
104
  return {
105
105
  kind: rpc_1.OpKind.REVEAL,
106
106
  fee,
@@ -108,6 +108,7 @@ const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [
108
108
  source,
109
109
  gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : (0, constants_1.getRevealGasLimit)(source),
110
110
  storage_limit: storageLimit,
111
+ proof,
111
112
  };
112
113
  });
113
114
  exports.createRevealOperation = createRevealOperation;
@@ -176,7 +177,7 @@ const createProposalsOperation = (_a) => __awaiter(void 0, [_a], void 0, functio
176
177
  };
177
178
  });
178
179
  exports.createProposalsOperation = createProposalsOperation;
179
- const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, }) {
180
+ const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
180
181
  return {
181
182
  kind: rpc_1.OpKind.UPDATE_CONSENSUS_KEY,
182
183
  source,
@@ -184,9 +185,22 @@ const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0
184
185
  gas_limit: gasLimit,
185
186
  storage_limit: storageLimit,
186
187
  pk,
188
+ proof,
187
189
  };
188
190
  });
189
191
  exports.createUpdateConsensusKeyOperation = createUpdateConsensusKeyOperation;
192
+ const createUpdateCompanionKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
193
+ return {
194
+ kind: rpc_1.OpKind.UPDATE_COMPANION_KEY,
195
+ source,
196
+ fee,
197
+ gas_limit: gasLimit,
198
+ storage_limit: storageLimit,
199
+ pk,
200
+ proof,
201
+ };
202
+ });
203
+ exports.createUpdateCompanionKeyOperation = createUpdateCompanionKeyOperation;
190
204
  const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
191
205
  return {
192
206
  kind: rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES,
@@ -30,6 +30,7 @@ const ballot_operation_1 = require("../operations/ballot-operation");
30
30
  const drain_delegate_operation_1 = require("../operations/drain-delegate-operation");
31
31
  const proposals_operation_1 = require("../operations/proposals-operation");
32
32
  const update_consensus_key_operation_1 = require("../operations/update-consensus-key-operation");
33
+ const update_companion_key_operation_1 = require("../operations/update-companion-key-operation");
33
34
  const smart_rollup_add_messages_operation_1 = require("../operations/smart-rollup-add-messages-operation");
34
35
  const smart_rollup_originate_operation_1 = require("../operations/smart-rollup-originate-operation");
35
36
  const smart_rollup_execute_outbox_message_operation_1 = require("../operations/smart-rollup-execute-outbox-message-operation");
@@ -55,7 +56,7 @@ class RpcContractProvider extends provider_1.Provider {
55
56
  return __awaiter(this, void 0, void 0, function* () {
56
57
  const contractValidation = (0, utils_1.validateContractAddress)(contract);
57
58
  if (contractValidation !== utils_1.ValidationResult.VALID) {
58
- throw new core_1.InvalidContractAddressError(contract, (0, utils_1.invalidDetail)(contractValidation));
59
+ throw new core_1.InvalidContractAddressError(contract, contractValidation);
59
60
  }
60
61
  const script = yield this.context.readProvider.getScript(contract, 'head');
61
62
  if (!schema) {
@@ -87,7 +88,7 @@ class RpcContractProvider extends provider_1.Provider {
87
88
  return __awaiter(this, void 0, void 0, function* () {
88
89
  const contractValidation = (0, utils_1.validateContractAddress)(contract);
89
90
  if (contractValidation !== utils_1.ValidationResult.VALID) {
90
- throw new core_1.InvalidContractAddressError(contract, (0, utils_1.invalidDetail)(contractValidation));
91
+ throw new core_1.InvalidContractAddressError(contract, contractValidation);
91
92
  }
92
93
  if (!schema) {
93
94
  schema = (yield this.rpc.getContract(contract)).script;
@@ -231,14 +232,14 @@ class RpcContractProvider extends provider_1.Provider {
231
232
  var _a;
232
233
  const sourceValidation = (0, utils_1.validateAddress)(params.source);
233
234
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
234
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
235
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
235
236
  }
236
237
  const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
237
238
  if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
238
- throw new core_1.InvalidAddressError(params.delegate, (0, utils_1.invalidDetail)(delegateValidation));
239
+ throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
239
240
  }
240
241
  // Since babylon delegation source cannot smart contract
241
- if (/kt1/i.test(params.source)) {
242
+ if (/^kt1/i.test(params.source)) {
242
243
  throw new errors_1.InvalidDelegationSource(params.source);
243
244
  }
244
245
  const publicKeyHash = yield this.signer.publicKeyHash();
@@ -283,11 +284,11 @@ class RpcContractProvider extends provider_1.Provider {
283
284
  var _a;
284
285
  const toValidation = (0, utils_1.validateAddress)(params.to);
285
286
  if (toValidation !== utils_1.ValidationResult.VALID) {
286
- throw new core_1.InvalidAddressError(params.to, (0, utils_1.invalidDetail)(toValidation));
287
+ throw new core_1.InvalidAddressError(params.to, toValidation);
287
288
  }
288
289
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
289
290
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
290
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
291
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
291
292
  }
292
293
  if (params.amount < 0) {
293
294
  throw new core_1.InvalidAmountError(params.amount.toString());
@@ -315,7 +316,7 @@ class RpcContractProvider extends provider_1.Provider {
315
316
  var _a;
316
317
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
317
318
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
318
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
319
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
319
320
  }
320
321
  if (!params.to) {
321
322
  params.to = params.source;
@@ -351,7 +352,7 @@ class RpcContractProvider extends provider_1.Provider {
351
352
  var _a;
352
353
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
353
354
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
354
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
355
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
355
356
  }
356
357
  if (!params.to) {
357
358
  params.to = params.source;
@@ -384,14 +385,11 @@ class RpcContractProvider extends provider_1.Provider {
384
385
  var _a;
385
386
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
386
387
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
387
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
388
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
388
389
  }
389
390
  if (!params.to) {
390
391
  params.to = params.source;
391
392
  }
392
- if (params.to && params.to !== params.source) {
393
- throw new core_1.InvalidStakingAddressError(params.to);
394
- }
395
393
  if (!params.amount) {
396
394
  params.amount = 0;
397
395
  }
@@ -421,11 +419,11 @@ class RpcContractProvider extends provider_1.Provider {
421
419
  var _a, _b;
422
420
  const destinationValidation = (0, utils_1.validateAddress)(params.destination);
423
421
  if (destinationValidation !== utils_1.ValidationResult.VALID) {
424
- throw new core_1.InvalidAddressError(params.destination, (0, utils_1.invalidDetail)(destinationValidation));
422
+ throw new core_1.InvalidAddressError(params.destination, destinationValidation);
425
423
  }
426
424
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
427
425
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
428
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
426
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
429
427
  }
430
428
  const publicKeyHash = yield this.signer.publicKeyHash();
431
429
  const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
@@ -439,8 +437,7 @@ class RpcContractProvider extends provider_1.Provider {
439
437
  }
440
438
  /**
441
439
  *
442
- * @description Reveal the current address. Will throw an error if the address is already revealed.
443
- *
440
+ * @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
444
441
  * @returns An operation handle with the result from the rpc node
445
442
  *
446
443
  * @param RevealParams operation parameter
@@ -448,6 +445,21 @@ class RpcContractProvider extends provider_1.Provider {
448
445
  reveal(params) {
449
446
  return __awaiter(this, void 0, void 0, function* () {
450
447
  const publicKeyHash = yield this.signer.publicKeyHash();
448
+ const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(publicKeyHash, utils_1.publicKeyHashPrefixes);
449
+ if (pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash) {
450
+ if (params.proof) {
451
+ (0, utils_1.b58DecodeAndCheckPrefix)(params.proof, [utils_1.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
452
+ }
453
+ else {
454
+ const { prefixSig } = yield this.signer.provePossession();
455
+ params.proof = prefixSig;
456
+ }
457
+ }
458
+ else {
459
+ if (params.proof) {
460
+ throw new core_1.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
461
+ }
462
+ }
451
463
  const estimateReveal = yield this.estimator.reveal(params);
452
464
  if (estimateReveal) {
453
465
  const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
@@ -534,7 +546,7 @@ class RpcContractProvider extends provider_1.Provider {
534
546
  const publicKeyHash = yield this.signer.publicKeyHash();
535
547
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
536
548
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
537
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
549
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
538
550
  }
539
551
  const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
540
552
  const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
@@ -558,7 +570,7 @@ class RpcContractProvider extends provider_1.Provider {
558
570
  const publicKeyHash = yield this.signer.publicKeyHash();
559
571
  const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
560
572
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
561
- throw new core_1.InvalidAddressError(params.source, (0, utils_1.invalidDetail)(sourceValidation));
573
+ throw new core_1.InvalidAddressError(params.source, sourceValidation);
562
574
  }
563
575
  const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
564
576
  const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
@@ -570,8 +582,7 @@ class RpcContractProvider extends provider_1.Provider {
570
582
  }
571
583
  /**
572
584
  *
573
- * @description Updates the consensus key of the baker to public_key starting from the current cycle plus PRESERVED_CYCLES + 1
574
- *
585
+ * @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
575
586
  * @returns An operation handle with the result from the rpc node
576
587
  *
577
588
  * @param UpdateConsensusKeyParams
@@ -579,6 +590,17 @@ class RpcContractProvider extends provider_1.Provider {
579
590
  updateConsensusKey(params) {
580
591
  return __awaiter(this, void 0, void 0, function* () {
581
592
  const publicKeyHash = yield this.signer.publicKeyHash();
593
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
594
+ if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
595
+ if (!params.proof) {
596
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
597
+ }
598
+ }
599
+ else {
600
+ if (params.proof) {
601
+ throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
602
+ }
603
+ }
582
604
  const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
583
605
  const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
584
606
  const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.UPDATE_CONSENSUS_KEY);
@@ -587,6 +609,31 @@ class RpcContractProvider extends provider_1.Provider {
587
609
  return new update_consensus_key_operation_1.UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
588
610
  });
589
611
  }
612
+ /**
613
+ *
614
+ * @description Updates the companion key of the delegate starting from the current cycle plus CONSENSUS_KEY_ACTIVATION_DELAY + 1
615
+ * @returns An operation handle with the result from the rpc node
616
+ *
617
+ * @param UpdateCompanionKeyParams
618
+ */
619
+ updateCompanionKey(params) {
620
+ return __awaiter(this, void 0, void 0, function* () {
621
+ const publicKeyHash = yield this.signer.publicKeyHash();
622
+ const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
623
+ if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
624
+ throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as companion key');
625
+ }
626
+ if (!params.proof) {
627
+ throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
628
+ }
629
+ const estimate = yield this.estimate(params, this.estimator.updateCompanionKey.bind(this.estimator));
630
+ const prepared = yield this.prepare.updateCompanionKey(Object.assign(Object.assign({}, params), estimate));
631
+ const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.UPDATE_COMPANION_KEY);
632
+ const opBytes = yield this.forge(prepared);
633
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
634
+ return new update_companion_key_operation_1.UpdateCompanionKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
635
+ });
636
+ }
590
637
  /**
591
638
  * @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
592
639
  * @param SmartRollupAddMessagesParams
@@ -681,7 +728,7 @@ class RpcContractProvider extends provider_1.Provider {
681
728
  return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
682
729
  const addressValidation = (0, utils_1.validateContractAddress)(address);
683
730
  if (addressValidation !== utils_1.ValidationResult.VALID) {
684
- throw new core_1.InvalidContractAddressError(address, (0, utils_1.invalidDetail)(addressValidation));
731
+ throw new core_1.InvalidContractAddressError(address, addressValidation);
685
732
  }
686
733
  const rpc = this.context.withExtensions().rpc;
687
734
  const readProvider = this.context.withExtensions().readProvider;