@taquito/taquito 19.0.2 → 19.1.0-RC.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 (35) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/batch/rpc-batch-provider.js +15 -0
  3. package/dist/lib/constants.js +52 -12
  4. package/dist/lib/contract/contract.js +1 -1
  5. package/dist/lib/contract/prepare.js +20 -8
  6. package/dist/lib/contract/rpc-contract-provider.js +17 -0
  7. package/dist/lib/estimate/estimate.js +5 -8
  8. package/dist/lib/estimate/rpc-estimate-provider.js +60 -21
  9. package/dist/lib/operations/index.js +19 -3
  10. package/dist/lib/operations/operations.js +4 -3
  11. package/dist/lib/operations/smart-rollup-execute-outbox-message-operation.js +56 -0
  12. package/dist/lib/operations/types.js +22 -3
  13. package/dist/lib/prepare/prepare-provider.js +36 -4
  14. package/dist/lib/provider.js +2 -0
  15. package/dist/lib/version.js +2 -2
  16. package/dist/taquito.es6.js +389 -170
  17. package/dist/taquito.es6.js.map +1 -1
  18. package/dist/taquito.min.js +1 -1
  19. package/dist/taquito.umd.js +401 -169
  20. package/dist/taquito.umd.js.map +1 -1
  21. package/dist/types/batch/rpc-batch-provider.d.ts +9 -2
  22. package/dist/types/constants.d.ts +13 -0
  23. package/dist/types/contract/contract.d.ts +1 -1
  24. package/dist/types/contract/interface.d.ts +10 -1
  25. package/dist/types/contract/prepare.d.ts +4 -3
  26. package/dist/types/contract/rpc-contract-provider.d.ts +8 -1
  27. package/dist/types/estimate/estimate-provider-interface.d.ts +10 -1
  28. package/dist/types/estimate/rpc-estimate-provider.d.ts +11 -3
  29. package/dist/types/operations/index.d.ts +10 -2
  30. package/dist/types/operations/smart-rollup-execute-outbox-message-operation.d.ts +24 -0
  31. package/dist/types/operations/types.d.ts +35 -12
  32. package/dist/types/prepare/interface.d.ts +14 -2
  33. package/dist/types/prepare/prepare-provider.d.ts +9 -1
  34. package/dist/types/provider.d.ts +1 -1
  35. package/package.json +9 -9
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@19.0.2/dist/taquito.min.js"
10
+ <script src="https://unpkg.com/@taquito/taquito@19.1.0-RC.1/dist/taquito.min.js"
11
11
  crossorigin="anonymous" integrity="sha384-IxvP0ECHi5oqLyz94wF85pU9+ktcsL1HHtA42MITxZsGbsUMEu/g+0Vkjj5vqiMR"></script>
12
12
  ```
13
13
 
@@ -155,6 +155,16 @@ class OperationBatch extends provider_1.Provider {
155
155
  this.operations.push(Object.assign({ kind: rpc_1.OpKind.SMART_ROLLUP_ORIGINATE }, params));
156
156
  return this;
157
157
  }
158
+ /**
159
+ *
160
+ * @description Add a smart rollup execute outbox message to the batch
161
+ *
162
+ * @param params Smart Rollup Execute Outbox Message operation parameter
163
+ */
164
+ withSmartRollupExecuteOutboxMessage(params) {
165
+ this.operations.push(Object.assign({ kind: rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE }, params));
166
+ return this;
167
+ }
158
168
  getRPCOp(param) {
159
169
  return __awaiter(this, void 0, void 0, function* () {
160
170
  switch (param.kind) {
@@ -174,6 +184,8 @@ class OperationBatch extends provider_1.Provider {
174
184
  return (0, prepare_1.createSmartRollupAddMessagesOperation)(Object.assign({}, param));
175
185
  case rpc_1.OpKind.SMART_ROLLUP_ORIGINATE:
176
186
  return (0, prepare_1.createSmartRollupOriginateOperation)(Object.assign({}, param));
187
+ case rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
188
+ return (0, prepare_1.createSmartRollupExecuteOutboxMessageOperation)(Object.assign({}, param));
177
189
  default:
178
190
  throw new core_1.InvalidOperationKindError(JSON.stringify(param.kind));
179
191
  }
@@ -216,6 +228,9 @@ class OperationBatch extends provider_1.Provider {
216
228
  case rpc_1.OpKind.SMART_ROLLUP_ORIGINATE:
217
229
  this.withSmartRollupOriginate(param);
218
230
  break;
231
+ case rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
232
+ this.withSmartRollupExecuteOutboxMessage(param);
233
+ break;
219
234
  default:
220
235
  throw new core_1.InvalidOperationKindError(JSON.stringify(param.kind));
221
236
  }
@@ -1,33 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRevealGasLimit = exports.ChainIds = exports.protocols = exports.Protocols = exports.COST_PER_BYTE = exports.DEFAULT_STORAGE_LIMIT = exports.DEFAULT_FEE = exports.DEFAULT_GAS_LIMIT = void 0;
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
+ */
4
7
  exports.DEFAULT_GAS_LIMIT = {
5
8
  DELEGATION: 10600,
6
9
  ORIGINATION: 10600,
7
10
  TRANSFER: 10600,
8
- /* This is used for gas_limit. There is no harm in setting a higher limit.
9
- Only if an account has a balance that is very close to the total gas consumption,
10
- then this margin can fail the operation.
11
- Another benefit of this higher value is that then Dapps build with Taquito 17 can
12
- still work with Mumbainet, as this value is higher than the reveal cost in Mumbai.
13
- */
14
11
  REVEAL_TZ1: 1000,
15
12
  REVEAL_TZ2: 1000,
16
13
  REVEAL_TZ3: 2000,
17
14
  REVEAL_TZ4: 2000,
18
15
  };
16
+ /**
17
+ * @deprecated default reveal fee please use getRevealFee(address) instead, removing hardcoded fee of delegation, origination and transfer
18
+ */
19
19
  exports.DEFAULT_FEE = {
20
20
  DELEGATION: 1257,
21
21
  ORIGINATION: 10000,
22
22
  TRANSFER: 10000,
23
23
  REVEAL: 374,
24
24
  };
25
+ /**
26
+ * @deprecated default reveal storageLimit please use REVEAL_STORAGE_LIMIT instead, removing hardcoded storageLimit of delegation, origination and transfer
27
+ */
25
28
  exports.DEFAULT_STORAGE_LIMIT = {
26
29
  DELEGATION: 0,
27
30
  ORIGINATION: 257,
28
31
  TRANSFER: 257,
29
32
  REVEAL: 0,
30
33
  };
34
+ // value is based on octez-client reveal operation gasLimit of each address type
35
+ const REVEAL_GAS_LIMIT = {
36
+ TZ1: 169,
37
+ TZ2: 155,
38
+ TZ3: 445,
39
+ TZ4: 1674,
40
+ };
41
+ // value is based on octez-client reveal operation fee of each address type
42
+ const REVEAL_FEE = {
43
+ TZ1: 276,
44
+ TZ2: 276,
45
+ TZ3: 305,
46
+ TZ4: 477,
47
+ };
48
+ // value is based on octez-client reveal operation storageLimit of all address type
49
+ exports.REVEAL_STORAGE_LIMIT = 0;
50
+ // protocol constants
51
+ exports.ORIGINATION_SIZE = 257;
52
+ // protocol constants
31
53
  exports.COST_PER_BYTE = 250;
32
54
  var Protocols;
33
55
  (function (Protocols) {
@@ -88,19 +110,37 @@ var ChainIds;
88
110
  ChainIds["NAIROBINET"] = "NetXyuzvDo2Ugzb";
89
111
  ChainIds["OXFORDNET2"] = "NetXxWsskGahzQB";
90
112
  })(ChainIds || (exports.ChainIds = ChainIds = {}));
91
- const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 11) / 10);
113
+ // 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)
114
+ const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
92
115
  exports.getRevealGasLimit = getRevealGasLimit;
93
116
  const getRevealGasLimitInternal = (address) => {
94
117
  switch (address.substring(0, 3)) {
95
118
  case 'tz1':
96
- return exports.DEFAULT_GAS_LIMIT.REVEAL_TZ1;
119
+ return REVEAL_GAS_LIMIT.TZ1;
97
120
  case 'tz2':
98
- return exports.DEFAULT_GAS_LIMIT.REVEAL_TZ2;
121
+ return REVEAL_GAS_LIMIT.TZ2;
99
122
  case 'tz3':
100
- return exports.DEFAULT_GAS_LIMIT.REVEAL_TZ3;
123
+ return REVEAL_GAS_LIMIT.TZ3;
101
124
  case 'tz4':
102
- return exports.DEFAULT_GAS_LIMIT.REVEAL_TZ4;
125
+ return REVEAL_GAS_LIMIT.TZ4;
103
126
  default:
104
127
  throw new Error(`Cannot estimate reveal gas limit for ${address}`);
105
128
  }
106
129
  };
130
+ const getRevealFee = (address) => Math.round(((0, exports.getRevealFeeInternal)(address) * 12) / 10);
131
+ exports.getRevealFee = getRevealFee;
132
+ const getRevealFeeInternal = (address) => {
133
+ switch (address.substring(0, 3)) {
134
+ case 'tz1':
135
+ return REVEAL_FEE.TZ1;
136
+ case 'tz2':
137
+ return REVEAL_FEE.TZ2;
138
+ case 'tz3':
139
+ return REVEAL_FEE.TZ3;
140
+ case 'tz4':
141
+ return REVEAL_FEE.TZ4;
142
+ default:
143
+ throw new Error(`Cannot estimate reveal fee for ${address}`);
144
+ }
145
+ };
146
+ exports.getRevealFeeInternal = getRevealFeeInternal;
@@ -79,9 +79,9 @@ class ContractAbstraction {
79
79
  this.rpc = rpc;
80
80
  this.readProvider = readProvider;
81
81
  /**
82
+ * @deprecated use methodsObject instead, flat params of methods can't sufficiently represent all Michelson values
82
83
  * @description Contains methods that are implemented by the target Tezos Smart Contract, and offers the user to call the Smart Contract methods as if they were native TS/JS methods.
83
84
  * NB: if the contract contains annotation it will include named properties; if not it will be indexed by a number.
84
- *
85
85
  */
86
86
  this.methods = {};
87
87
  /**
@@ -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.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.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");
@@ -23,7 +23,7 @@ const createActivationOperation = ({ pkh, secret }) => __awaiter(void 0, void 0,
23
23
  };
24
24
  });
25
25
  exports.createActivationOperation = createActivationOperation;
26
- const createOriginationOperation = ({ code, init, balance = '0', delegate, storage, fee = constants_1.DEFAULT_FEE.ORIGINATION, gasLimit = constants_1.DEFAULT_GAS_LIMIT.ORIGINATION, storageLimit = constants_1.DEFAULT_STORAGE_LIMIT.ORIGINATION, mutez = false, }) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const createOriginationOperation = ({ code, init, balance = '0', delegate, storage, fee, gasLimit, storageLimit, mutez = false, }) => __awaiter(void 0, void 0, void 0, function* () {
27
27
  if (storage !== undefined && init !== undefined) {
28
28
  throw new errors_1.OriginationParameterError('Storage and Init cannot be set a the same time. Please either use storage or init but not both.');
29
29
  }
@@ -66,8 +66,8 @@ const createOriginationOperation = ({ code, init, balance = '0', delegate, stora
66
66
  return operation;
67
67
  });
68
68
  exports.createOriginationOperation = createOriginationOperation;
69
- const createTransferOperation = ({ to, amount, parameter, fee = constants_1.DEFAULT_FEE.TRANSFER, gasLimit = constants_1.DEFAULT_GAS_LIMIT.TRANSFER, storageLimit = constants_1.DEFAULT_STORAGE_LIMIT.TRANSFER, mutez = false, }) => __awaiter(void 0, void 0, void 0, function* () {
70
- const operation = {
69
+ const createTransferOperation = ({ to, amount, parameter, fee, gasLimit, storageLimit, mutez = false, }) => __awaiter(void 0, void 0, void 0, function* () {
70
+ return {
71
71
  kind: rpc_1.OpKind.TRANSACTION,
72
72
  fee,
73
73
  gas_limit: gasLimit,
@@ -76,10 +76,9 @@ const createTransferOperation = ({ to, amount, parameter, fee = constants_1.DEFA
76
76
  destination: to,
77
77
  parameters: parameter,
78
78
  };
79
- return operation;
80
79
  });
81
80
  exports.createTransferOperation = createTransferOperation;
82
- const createSetDelegateOperation = ({ delegate, source, fee = constants_1.DEFAULT_FEE.DELEGATION, gasLimit = constants_1.DEFAULT_GAS_LIMIT.DELEGATION, storageLimit = constants_1.DEFAULT_STORAGE_LIMIT.DELEGATION, }) => __awaiter(void 0, void 0, void 0, function* () {
81
+ const createSetDelegateOperation = ({ delegate, source, fee, gasLimit, storageLimit, }) => __awaiter(void 0, void 0, void 0, function* () {
83
82
  const operation = {
84
83
  kind: rpc_1.OpKind.DELEGATION,
85
84
  source,
@@ -91,7 +90,7 @@ const createSetDelegateOperation = ({ delegate, source, fee = constants_1.DEFAUL
91
90
  return operation;
92
91
  });
93
92
  exports.createSetDelegateOperation = createSetDelegateOperation;
94
- const createRegisterDelegateOperation = ({ fee = constants_1.DEFAULT_FEE.DELEGATION, gasLimit = constants_1.DEFAULT_GAS_LIMIT.DELEGATION, storageLimit = constants_1.DEFAULT_STORAGE_LIMIT.DELEGATION, }, source) => __awaiter(void 0, void 0, void 0, function* () {
93
+ const createRegisterDelegateOperation = ({ fee, gasLimit, storageLimit }, source) => __awaiter(void 0, void 0, void 0, function* () {
95
94
  return {
96
95
  kind: rpc_1.OpKind.DELEGATION,
97
96
  fee,
@@ -101,7 +100,7 @@ const createRegisterDelegateOperation = ({ fee = constants_1.DEFAULT_FEE.DELEGAT
101
100
  };
102
101
  });
103
102
  exports.createRegisterDelegateOperation = createRegisterDelegateOperation;
104
- const createRevealOperation = ({ fee = constants_1.DEFAULT_FEE.REVEAL, gasLimit = undefined, storageLimit = constants_1.DEFAULT_STORAGE_LIMIT.REVEAL, }, source, publicKey) => __awaiter(void 0, void 0, void 0, function* () {
103
+ const createRevealOperation = ({ fee, gasLimit, storageLimit }, source, publicKey) => __awaiter(void 0, void 0, void 0, function* () {
105
104
  return {
106
105
  kind: rpc_1.OpKind.REVEAL,
107
106
  fee,
@@ -212,3 +211,16 @@ const createSmartRollupOriginateOperation = ({ source, fee, gasLimit, storageLim
212
211
  };
213
212
  });
214
213
  exports.createSmartRollupOriginateOperation = createSmartRollupOriginateOperation;
214
+ const createSmartRollupExecuteOutboxMessageOperation = ({ source, fee, gasLimit, storageLimit, rollup, cementedCommitment, outputProof, }) => __awaiter(void 0, void 0, void 0, function* () {
215
+ return {
216
+ kind: rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,
217
+ source,
218
+ fee,
219
+ gas_limit: gasLimit,
220
+ storage_limit: storageLimit,
221
+ rollup,
222
+ cemented_commitment: cementedCommitment,
223
+ output_proof: outputProof,
224
+ };
225
+ });
226
+ exports.createSmartRollupExecuteOutboxMessageOperation = createSmartRollupExecuteOutboxMessageOperation;
@@ -32,6 +32,7 @@ const proposals_operation_1 = require("../operations/proposals-operation");
32
32
  const update_consensus_key_operation_1 = require("../operations/update-consensus-key-operation");
33
33
  const smart_rollup_add_messages_operation_1 = require("../operations/smart-rollup-add-messages-operation");
34
34
  const smart_rollup_originate_operation_1 = require("../operations/smart-rollup-originate-operation");
35
+ const smart_rollup_execute_outbox_message_operation_1 = require("../operations/smart-rollup-execute-outbox-message-operation");
35
36
  const provider_1 = require("../provider");
36
37
  const prepare_1 = require("../prepare");
37
38
  class RpcContractProvider extends provider_1.Provider {
@@ -512,6 +513,22 @@ class RpcContractProvider extends provider_1.Provider {
512
513
  return new smart_rollup_originate_operation_1.SmartRollupOriginateOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
513
514
  });
514
515
  }
516
+ /**
517
+ * @description Execute a message from a smart rollup's outbox of a cemented commitment
518
+ * @param SmartRollupExecuteOutboxMessageParams
519
+ * @returns An operation handle with results from the RPC node
520
+ */
521
+ smartRollupExecuteOutboxMessage(params) {
522
+ return __awaiter(this, void 0, void 0, function* () {
523
+ const publicKeyHash = yield this.signer.publicKeyHash();
524
+ const estimate = yield this.estimate(params, this.estimator.smartRollupExecuteOutboxMessage.bind(this.estimator));
525
+ const prepared = yield this.prepare.smartRollupExecuteOutboxMessage(Object.assign(Object.assign({}, params), estimate));
526
+ const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE);
527
+ const opBytes = yield this.forge(prepared);
528
+ const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
529
+ return new smart_rollup_execute_outbox_message_operation_1.SmartRollupExecuteOutboxMessageOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
530
+ });
531
+ }
515
532
  /**
516
533
  *
517
534
  * @description A failing_noop operation that is guaranteed to fail.
@@ -4,7 +4,6 @@ exports.Estimate = void 0;
4
4
  const MINIMAL_FEE_MUTEZ = 100;
5
5
  const MINIMAL_FEE_PER_BYTE_MUTEZ = 1;
6
6
  const MINIMAL_FEE_PER_GAS_MUTEZ = 0.1;
7
- const GAS_BUFFER = 100;
8
7
  /**
9
8
  * Examples of use :
10
9
  *
@@ -62,18 +61,16 @@ class Estimate {
62
61
  * @description The limit on the amount of storage an [operation](https://tezos.gitlab.io/user/glossary.html#operations) can use.
63
62
  */
64
63
  get storageLimit() {
65
- const limit = Math.max(Number(this._storageLimit), 0);
66
- return limit > 0 ? limit : 0;
64
+ return Math.max(Number(this._storageLimit), 0);
67
65
  }
68
66
  /**
69
67
  * @description The limit on the amount of [gas](https://tezos.gitlab.io/user/glossary.html#gas) a given operation can consume.
70
68
  */
71
69
  get gasLimit() {
72
- return this.roundUp(Number(this._milligasLimit) / 1000 + GAS_BUFFER);
70
+ return this.roundUp(Number(this._milligasLimit) / 1000);
73
71
  }
74
72
  get operationFeeMutez() {
75
- return ((Number(this._milligasLimit) / 1000 + GAS_BUFFER) * MINIMAL_FEE_PER_GAS_MUTEZ +
76
- Number(this.opSize) * MINIMAL_FEE_PER_BYTE_MUTEZ);
73
+ return (this.gasLimit * MINIMAL_FEE_PER_GAS_MUTEZ + Number(this.opSize) * MINIMAL_FEE_PER_BYTE_MUTEZ);
77
74
  }
78
75
  roundUp(nanotez) {
79
76
  return Math.ceil(Number(nanotez));
@@ -82,13 +79,13 @@ class Estimate {
82
79
  * @description Minimum fees for the [operation](https://tezos.gitlab.io/user/glossary.html#operations) according to [baker](https://tezos.gitlab.io/user/glossary.html#baker) defaults.
83
80
  */
84
81
  get minimalFeeMutez() {
85
- return this.roundUp(MINIMAL_FEE_MUTEZ + this.operationFeeMutez);
82
+ return this.roundUp(this.operationFeeMutez + MINIMAL_FEE_MUTEZ);
86
83
  }
87
84
  /**
88
85
  * @description The suggested fee for the operation which includes minimal fees and a small buffer.
89
86
  */
90
87
  get suggestedFeeMutez() {
91
- return this.roundUp(this.operationFeeMutez + MINIMAL_FEE_MUTEZ * 2);
88
+ return this.roundUp(this.operationFeeMutez + MINIMAL_FEE_MUTEZ * 1.2);
92
89
  }
93
90
  /**
94
91
  * @description Fees according to your specified base fee will ensure that at least minimum fees are used.
@@ -29,12 +29,13 @@ const errors_2 = require("./errors");
29
29
  const provider_1 = require("../provider");
30
30
  const prepare_provider_1 = require("../prepare/prepare-provider");
31
31
  const core_1 = require("@taquito/core");
32
+ // stub signature that won't be verified by tezos rpc simulate_operation
33
+ const STUB_SIGNATURE = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg';
32
34
  class RPCEstimateProvider extends provider_1.Provider {
33
35
  constructor() {
34
36
  super(...arguments);
35
- this.ALLOCATION_STORAGE = 257;
36
- this.ORIGINATION_STORAGE = 257;
37
- this.OP_SIZE_REVEAL = 128;
37
+ this.OP_SIZE_REVEAL = 324; // injecting size tz1=320, tz2=322, tz3=322, tz4=420(not supported)
38
+ this.MILLIGAS_BUFFER = 100 * 1000; // 100 buffer depends on operation kind
38
39
  this.prepare = new prepare_provider_1.PrepareProvider(this.context);
39
40
  }
40
41
  getKeys() {
@@ -48,29 +49,36 @@ class RPCEstimateProvider extends provider_1.Provider {
48
49
  };
49
50
  });
50
51
  }
51
- getEstimationPropertiesFromOperationContent(content, size, costPerByte) {
52
+ getEstimationPropertiesFromOperationContent(content, size, costPerByte, originationSize) {
52
53
  const operationResults = (0, errors_1.flattenOperationResult)({ contents: [content] });
53
- let totalMilligas = 0;
54
- let totalStorage = 0;
54
+ let consumedMilligas = 0;
55
+ let accumulatedStorage = 0;
55
56
  operationResults.forEach((result) => {
56
- totalStorage +=
57
- 'originated_contracts' in result && typeof result.originated_contracts !== 'undefined'
58
- ? result.originated_contracts.length * this.ORIGINATION_STORAGE
57
+ consumedMilligas += Number(result.consumed_milligas) || 0;
58
+ // transfer to unrevealed implicit
59
+ accumulatedStorage += 'allocated_destination_contract' in result ? originationSize : 0;
60
+ // originate
61
+ accumulatedStorage +=
62
+ 'originated_contracts' in result && Array.isArray(result.originated_contracts)
63
+ ? result.originated_contracts.length * originationSize
59
64
  : 0;
60
- totalStorage += 'allocated_destination_contract' in result ? this.ALLOCATION_STORAGE : 0;
61
- totalMilligas += Number(result.consumed_milligas) || 0;
62
- totalStorage +=
63
- 'paid_storage_size_diff' in result ? Number(result.paid_storage_size_diff) || 0 : 0;
64
- totalStorage +=
65
+ // register_global_constants
66
+ accumulatedStorage +=
65
67
  'storage_size' in result && 'global_address' in result
66
68
  ? Number(result.storage_size) || 0
67
69
  : 0;
68
- totalStorage += 'genesis_commitment_hash' in result ? Number(result.size) : 0;
70
+ // transfer_ticket, originate, contract_call
71
+ accumulatedStorage +=
72
+ 'paid_storage_size_diff' in result ? Number(result.paid_storage_size_diff) || 0 : 0;
73
+ //smart_rollup_originate
74
+ accumulatedStorage += 'genesis_commitment_hash' in result ? Number(result.size) || 0 : 0;
69
75
  });
70
76
  if ((0, types_1.isOpWithFee)(content)) {
71
77
  return {
72
- milligasLimit: totalMilligas || 0,
73
- storageLimit: Number(totalStorage || 0),
78
+ milligasLimit: (0, types_1.isOpWithGasBuffer)(content)
79
+ ? consumedMilligas + Number(this.MILLIGAS_BUFFER)
80
+ : consumedMilligas,
81
+ storageLimit: accumulatedStorage || 0,
74
82
  opSize: size,
75
83
  minimalFeePerStorageByteMutez: costPerByte.toNumber(),
76
84
  };
@@ -89,11 +97,11 @@ class RPCEstimateProvider extends provider_1.Provider {
89
97
  return __awaiter(this, void 0, void 0, function* () {
90
98
  const { opbytes, opOb: { branch, contents }, } = yield this.forge(op);
91
99
  const operation = {
92
- operation: { branch, contents },
100
+ operation: { branch, contents, signature: STUB_SIGNATURE },
93
101
  chain_id: yield this.context.readProvider.getChainId(),
94
102
  };
95
103
  const { opResponse } = yield this.simulate(operation);
96
- const { cost_per_byte } = constants;
104
+ const { cost_per_byte, origination_size } = constants;
97
105
  const errors = [...(0, errors_1.flattenErrors)(opResponse, 'backtracked'), ...(0, errors_1.flattenErrors)(opResponse)];
98
106
  // Fail early in case of errors
99
107
  if (errors.length) {
@@ -108,8 +116,9 @@ class RPCEstimateProvider extends provider_1.Provider {
108
116
  }
109
117
  return opResponse.contents.map((x) => {
110
118
  return this.getEstimationPropertiesFromOperationContent(x,
111
- // TODO: Calculate a specific opSize for each operation.
112
- x.kind === 'reveal' ? this.OP_SIZE_REVEAL / 2 : opbytes.length / 2 / numberOfOps, cost_per_byte);
119
+ // diff between estimated and injecting OP_SIZE is 124-126, we added buffer to use 130
120
+ 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
121
+ );
113
122
  });
114
123
  });
115
124
  }
@@ -128,6 +137,7 @@ class RPCEstimateProvider extends provider_1.Provider {
128
137
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
129
138
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
130
139
  estimateProperties.shift();
140
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
131
141
  }
132
142
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
133
143
  });
@@ -162,6 +172,7 @@ class RPCEstimateProvider extends provider_1.Provider {
162
172
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
163
173
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
164
174
  estimateProperties.shift();
175
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
165
176
  }
166
177
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
167
178
  });
@@ -193,6 +204,7 @@ class RPCEstimateProvider extends provider_1.Provider {
193
204
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
194
205
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
195
206
  estimateProperties.shift();
207
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
196
208
  }
197
209
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
198
210
  });
@@ -224,6 +236,7 @@ class RPCEstimateProvider extends provider_1.Provider {
224
236
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
225
237
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
226
238
  estimateProperties.shift();
239
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
227
240
  }
228
241
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
229
242
  });
@@ -260,6 +273,7 @@ class RPCEstimateProvider extends provider_1.Provider {
260
273
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
261
274
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
262
275
  estimateProperties.shift();
276
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
263
277
  }
264
278
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
265
279
  });
@@ -306,6 +320,7 @@ class RPCEstimateProvider extends provider_1.Provider {
306
320
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
307
321
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
308
322
  estimateProperties.shift();
323
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
309
324
  }
310
325
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
311
326
  });
@@ -331,6 +346,7 @@ class RPCEstimateProvider extends provider_1.Provider {
331
346
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
332
347
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
333
348
  estimateProperties.shift();
349
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
334
350
  }
335
351
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
336
352
  });
@@ -350,6 +366,7 @@ class RPCEstimateProvider extends provider_1.Provider {
350
366
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
351
367
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
352
368
  estimateProperties.shift();
369
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
353
370
  }
354
371
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
355
372
  });
@@ -369,6 +386,7 @@ class RPCEstimateProvider extends provider_1.Provider {
369
386
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
370
387
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
371
388
  estimateProperties.shift();
389
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
372
390
  }
373
391
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
374
392
  });
@@ -386,6 +404,26 @@ class RPCEstimateProvider extends provider_1.Provider {
386
404
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
387
405
  const preparedOperation = yield this.prepare.smartRollupOriginate(params);
388
406
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
407
+ if (preparedOperation.opOb.contents[0].kind === 'reveal') {
408
+ estimateProperties.shift();
409
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
410
+ }
411
+ return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
412
+ });
413
+ }
414
+ /**
415
+ *
416
+ * @description Estimate gasLimit, storageLimit and fees for a smart_rollup_execute_outbox_message operation
417
+ *
418
+ * @returns An estimation of gasLimit, storageLimit and fees for the operation
419
+ *
420
+ * @param Estimate
421
+ */
422
+ smartRollupExecuteOutboxMessage(params) {
423
+ return __awaiter(this, void 0, void 0, function* () {
424
+ const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
425
+ const preparedOperation = yield this.prepare.smartRollupExecuteOutboxMessage(params);
426
+ const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
389
427
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
390
428
  estimateProperties.shift();
391
429
  }
@@ -407,6 +445,7 @@ class RPCEstimateProvider extends provider_1.Provider {
407
445
  const estimateProperties = yield this.calculateEstimates(preparedOperation, protocolConstants);
408
446
  if (preparedOperation.opOb.contents[0].kind === 'reveal') {
409
447
  estimateProperties.shift();
448
+ estimateProperties[0].opSize -= this.OP_SIZE_REVEAL / 2;
410
449
  }
411
450
  return estimate_1.Estimate.createEstimateInstanceFromProperties(estimateProperties);
412
451
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Operation = exports.DrainDelegateOperation = exports.BallotOperation = exports.TransactionOperation = exports.OriginationOperation = exports.DelegateOperation = exports.BatchOperation = exports.InvalidEstimateValueError = exports.TezosPreapplyFailureError = exports.TezosOperationError = exports.OpKind = void 0;
3
+ 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 = exports.OpKind = void 0;
4
4
  var types_1 = require("./types");
5
5
  Object.defineProperty(exports, "OpKind", { enumerable: true, get: function () { return types_1.OpKind; } });
6
6
  var errors_1 = require("./errors");
@@ -9,15 +9,31 @@ Object.defineProperty(exports, "TezosPreapplyFailureError", { enumerable: true,
9
9
  Object.defineProperty(exports, "InvalidEstimateValueError", { enumerable: true, get: function () { return errors_1.InvalidEstimateValueError; } });
10
10
  var batch_operation_1 = require("./batch-operation");
11
11
  Object.defineProperty(exports, "BatchOperation", { enumerable: true, get: function () { return batch_operation_1.BatchOperation; } });
12
- var delegate_operation_1 = require("./delegate-operation");
13
- Object.defineProperty(exports, "DelegateOperation", { enumerable: true, get: function () { return delegate_operation_1.DelegateOperation; } });
14
12
  var origination_operation_1 = require("./origination-operation");
15
13
  Object.defineProperty(exports, "OriginationOperation", { enumerable: true, get: function () { return origination_operation_1.OriginationOperation; } });
14
+ var delegate_operation_1 = require("./delegate-operation");
15
+ Object.defineProperty(exports, "DelegateOperation", { enumerable: true, get: function () { return delegate_operation_1.DelegateOperation; } });
16
16
  var transaction_operation_1 = require("./transaction-operation");
17
17
  Object.defineProperty(exports, "TransactionOperation", { enumerable: true, get: function () { return transaction_operation_1.TransactionOperation; } });
18
+ var register_global_constant_operation_1 = require("./register-global-constant-operation");
19
+ Object.defineProperty(exports, "RegisterGlobalConstantOperation", { enumerable: true, get: function () { return register_global_constant_operation_1.RegisterGlobalConstantOperation; } });
20
+ var increase_paid_storage_operation_1 = require("./increase-paid-storage-operation");
21
+ Object.defineProperty(exports, "IncreasePaidStorageOperation", { enumerable: true, get: function () { return increase_paid_storage_operation_1.IncreasePaidStorageOperation; } });
22
+ var transfer_ticket_operation_1 = require("./transfer-ticket-operation");
23
+ Object.defineProperty(exports, "TransferTicketOperation", { enumerable: true, get: function () { return transfer_ticket_operation_1.TransferTicketOperation; } });
24
+ var update_consensus_key_operation_1 = require("./update-consensus-key-operation");
25
+ Object.defineProperty(exports, "UpdateConsensusKeyOperation", { enumerable: true, get: function () { return update_consensus_key_operation_1.UpdateConsensusKeyOperation; } });
26
+ var smart_rollup_add_messages_operation_1 = require("./smart-rollup-add-messages-operation");
27
+ Object.defineProperty(exports, "SmartRollupAddMessagesOperation", { enumerable: true, get: function () { return smart_rollup_add_messages_operation_1.SmartRollupAddMessagesOperation; } });
28
+ var smart_rollup_originate_operation_1 = require("./smart-rollup-originate-operation");
29
+ Object.defineProperty(exports, "SmartRollupOriginateOperation", { enumerable: true, get: function () { return smart_rollup_originate_operation_1.SmartRollupOriginateOperation; } });
18
30
  var ballot_operation_1 = require("./ballot-operation");
19
31
  Object.defineProperty(exports, "BallotOperation", { enumerable: true, get: function () { return ballot_operation_1.BallotOperation; } });
20
32
  var drain_delegate_operation_1 = require("./drain-delegate-operation");
21
33
  Object.defineProperty(exports, "DrainDelegateOperation", { enumerable: true, get: function () { return drain_delegate_operation_1.DrainDelegateOperation; } });
34
+ var proposals_operation_1 = require("./proposals-operation");
35
+ Object.defineProperty(exports, "ProposalsOperation", { enumerable: true, get: function () { return proposals_operation_1.ProposalsOperation; } });
36
+ var reveal_operation_1 = require("./reveal-operation");
37
+ Object.defineProperty(exports, "RevealOperation", { enumerable: true, get: function () { return reveal_operation_1.RevealOperation; } });
22
38
  var operations_1 = require("./operations");
23
39
  Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return operations_1.Operation; } });
@@ -112,9 +112,10 @@ class Operation {
112
112
  return new Promise((resolve, reject) => {
113
113
  this.confirmed$
114
114
  .pipe((0, operators_1.switchMap)(() => this.currentHead$), (0, operators_1.filter)((head) => head.header.level - this._foundAt >= conf - 1), (0, operators_1.first)())
115
- .subscribe((_) => {
116
- resolve(this._foundAt + (conf - 1));
117
- }, reject);
115
+ .subscribe({
116
+ error: (e) => reject(e),
117
+ complete: () => resolve(this._foundAt + (conf - 1)),
118
+ });
118
119
  });
119
120
  });
120
121
  }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartRollupExecuteOutboxMessageOperation = void 0;
4
+ const rpc_1 = require("@taquito/rpc");
5
+ const operations_1 = require("./operations");
6
+ /**
7
+ *
8
+ * @description SmartRollupExecuteOutboxMessage Operation provides utility to fetch properties for Operation of kind SmartRollupExecuteOutboxMessage
9
+ *
10
+ */
11
+ class SmartRollupExecuteOutboxMessageOperation 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 smartRollupExecuteOutboxMessageOp = Array.isArray(this.results) &&
19
+ this.results.find((op) => op.kind === rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE);
20
+ const result = smartRollupExecuteOutboxMessageOp &&
21
+ smartRollupExecuteOutboxMessageOp.metadata &&
22
+ smartRollupExecuteOutboxMessageOp.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 rollup() {
30
+ return this.params.rollup;
31
+ }
32
+ get cementedCommitment() {
33
+ return this.params.cemented_commitment;
34
+ }
35
+ get outputProof() {
36
+ return this.params.output_proof;
37
+ }
38
+ get fee() {
39
+ return Number(this.params.fee);
40
+ }
41
+ get gasLimit() {
42
+ return Number(this.params.gas_limit);
43
+ }
44
+ get storageLimit() {
45
+ return Number(this.params.storage_limit);
46
+ }
47
+ get consumedMilliGas() {
48
+ var _a;
49
+ return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas;
50
+ }
51
+ get errors() {
52
+ var _a;
53
+ return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.errors;
54
+ }
55
+ }
56
+ exports.SmartRollupExecuteOutboxMessageOperation = SmartRollupExecuteOutboxMessageOperation;