@tezos-x/octez.js 0.9.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 (208) hide show
  1. package/README.md +154 -0
  2. package/dist/lib/batch/constants.js +16 -0
  3. package/dist/lib/batch/rpc-batch-provider.js +319 -0
  4. package/dist/lib/constants.js +133 -0
  5. package/dist/lib/context.js +182 -0
  6. package/dist/lib/contract/big-map.js +70 -0
  7. package/dist/lib/contract/compose.js +6 -0
  8. package/dist/lib/contract/constants.js +4 -0
  9. package/dist/lib/contract/contract-methods/contract-method-factory.js +18 -0
  10. package/dist/lib/contract/contract-methods/contract-method-interface.js +2 -0
  11. package/dist/lib/contract/contract-methods/contract-method-object-param.js +72 -0
  12. package/dist/lib/contract/contract-methods/contract-on-chain-view.js +124 -0
  13. package/dist/lib/contract/contract.js +169 -0
  14. package/dist/lib/contract/errors.js +140 -0
  15. package/dist/lib/contract/index.js +30 -0
  16. package/dist/lib/contract/interface.js +2 -0
  17. package/dist/lib/contract/manager-lambda.js +71 -0
  18. package/dist/lib/contract/prepare.js +240 -0
  19. package/dist/lib/contract/rpc-contract-provider.js +724 -0
  20. package/dist/lib/contract/sapling-state-abstraction.js +35 -0
  21. package/dist/lib/contract/semantic.js +40 -0
  22. package/dist/lib/contract/view_lambda.js +27 -0
  23. package/dist/lib/errors.js +42 -0
  24. package/dist/lib/estimate/errors.js +16 -0
  25. package/dist/lib/estimate/estimate-provider-interface.js +2 -0
  26. package/dist/lib/estimate/estimate.js +130 -0
  27. package/dist/lib/estimate/index.js +20 -0
  28. package/dist/lib/estimate/rpc-estimate-provider.js +673 -0
  29. package/dist/lib/extension/extension.js +2 -0
  30. package/dist/lib/forger/composite-forger.js +43 -0
  31. package/dist/lib/forger/errors.js +30 -0
  32. package/dist/lib/forger/octez.js-local-forger.js +34 -0
  33. package/dist/lib/forger/rpc-forger.js +12 -0
  34. package/dist/lib/global-constants/default-global-constants-provider.js +46 -0
  35. package/dist/lib/global-constants/errors.js +30 -0
  36. package/dist/lib/global-constants/interface-global-constants-provider.js +2 -0
  37. package/dist/lib/global-constants/noop-global-constants-provider.js +21 -0
  38. package/dist/lib/import-key.js +51 -0
  39. package/dist/lib/injector/helper.js +18 -0
  40. package/dist/lib/injector/interface.js +2 -0
  41. package/dist/lib/injector/rpc-injector.js +38 -0
  42. package/dist/lib/octez.js +404 -0
  43. package/dist/lib/operations/ballot-operation.js +33 -0
  44. package/dist/lib/operations/batch-operation.js +66 -0
  45. package/dist/lib/operations/delegate-operation.js +57 -0
  46. package/dist/lib/operations/drain-delegate-operation.js +31 -0
  47. package/dist/lib/operations/errors.js +130 -0
  48. package/dist/lib/operations/failing-noop-operation.js +2 -0
  49. package/dist/lib/operations/increase-paid-storage-operation.js +52 -0
  50. package/dist/lib/operations/index.js +54 -0
  51. package/dist/lib/operations/operations.js +123 -0
  52. package/dist/lib/operations/origination-operation.js +89 -0
  53. package/dist/lib/operations/proposals-operation.js +30 -0
  54. package/dist/lib/operations/register-global-constant-operation.js +55 -0
  55. package/dist/lib/operations/reveal-operation.js +74 -0
  56. package/dist/lib/operations/smart-rollup-add-messages-operation.js +47 -0
  57. package/dist/lib/operations/smart-rollup-execute-outbox-message-operation.js +56 -0
  58. package/dist/lib/operations/smart-rollup-originate-operation.js +53 -0
  59. package/dist/lib/operations/transaction-operation.js +70 -0
  60. package/dist/lib/operations/transfer-ticket-operation.js +49 -0
  61. package/dist/lib/operations/types.js +90 -0
  62. package/dist/lib/operations/update-companion-key-operation.js +58 -0
  63. package/dist/lib/operations/update-consensus-key-operation.js +58 -0
  64. package/dist/lib/packer/interface.js +2 -0
  65. package/dist/lib/packer/michel-codec-packer.js +22 -0
  66. package/dist/lib/packer/rpc-packer.js +23 -0
  67. package/dist/lib/parser/interface.js +2 -0
  68. package/dist/lib/parser/michel-codec-parser.js +135 -0
  69. package/dist/lib/parser/noop-parser.js +20 -0
  70. package/dist/lib/prepare/index.js +18 -0
  71. package/dist/lib/prepare/interface.js +2 -0
  72. package/dist/lib/prepare/prepare-provider.js +1010 -0
  73. package/dist/lib/provider.js +169 -0
  74. package/dist/lib/read-provider/interface.js +2 -0
  75. package/dist/lib/read-provider/rpc-read-adapter.js +228 -0
  76. package/dist/lib/signer/errors.js +17 -0
  77. package/dist/lib/signer/noop.js +40 -0
  78. package/dist/lib/subscribe/create-observable-from-subscription.js +20 -0
  79. package/dist/lib/subscribe/errors.js +30 -0
  80. package/dist/lib/subscribe/filters.js +96 -0
  81. package/dist/lib/subscribe/interface.js +2 -0
  82. package/dist/lib/subscribe/observable-subscription.js +79 -0
  83. package/dist/lib/subscribe/polling-subcribe-provider.js +118 -0
  84. package/dist/lib/tz/interface.js +2 -0
  85. package/dist/lib/tz/rpc-tz-provider.js +63 -0
  86. package/dist/lib/version.js +8 -0
  87. package/dist/lib/wallet/batch-operation.js +84 -0
  88. package/dist/lib/wallet/delegation-operation.js +57 -0
  89. package/dist/lib/wallet/errors.js +28 -0
  90. package/dist/lib/wallet/increase-paid-storage-operation.js +57 -0
  91. package/dist/lib/wallet/index.js +25 -0
  92. package/dist/lib/wallet/interface.js +2 -0
  93. package/dist/lib/wallet/legacy.js +86 -0
  94. package/dist/lib/wallet/operation-factory.js +117 -0
  95. package/dist/lib/wallet/operation.js +157 -0
  96. package/dist/lib/wallet/origination-operation.js +65 -0
  97. package/dist/lib/wallet/receipt.js +43 -0
  98. package/dist/lib/wallet/register-global-constant-operation.js +62 -0
  99. package/dist/lib/wallet/transaction-operation.js +53 -0
  100. package/dist/lib/wallet/transfer-ticket-operation.js +53 -0
  101. package/dist/lib/wallet/wallet.js +442 -0
  102. package/dist/octez.es6.js +7673 -0
  103. package/dist/octez.es6.js.map +1 -0
  104. package/dist/octez.umd.js +7787 -0
  105. package/dist/octez.umd.js.map +1 -0
  106. package/dist/types/batch/constants.d.ts +3 -0
  107. package/dist/types/batch/rpc-batch-provider.d.ts +139 -0
  108. package/dist/types/constants.d.ts +81 -0
  109. package/dist/types/context.d.ts +100 -0
  110. package/dist/types/contract/big-map.d.ts +35 -0
  111. package/dist/types/contract/compose.d.ts +5 -0
  112. package/dist/types/contract/constants.d.ts +1 -0
  113. package/dist/types/contract/contract-methods/contract-method-factory.d.ts +14 -0
  114. package/dist/types/contract/contract-methods/contract-method-interface.d.ts +28 -0
  115. package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +39 -0
  116. package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +43 -0
  117. package/dist/types/contract/contract.d.ts +75 -0
  118. package/dist/types/contract/errors.d.ts +83 -0
  119. package/dist/types/contract/index.d.ts +11 -0
  120. package/dist/types/contract/interface.d.ts +254 -0
  121. package/dist/types/contract/manager-lambda.d.ts +73 -0
  122. package/dist/types/contract/prepare.d.ts +18 -0
  123. package/dist/types/contract/rpc-contract-provider.d.ts +269 -0
  124. package/dist/types/contract/sapling-state-abstraction.d.ts +17 -0
  125. package/dist/types/contract/semantic.d.ts +7 -0
  126. package/dist/types/contract/view_lambda.d.ts +34 -0
  127. package/dist/types/errors.d.ts +26 -0
  128. package/dist/types/estimate/errors.d.ts +8 -0
  129. package/dist/types/estimate/estimate-provider-interface.d.ts +156 -0
  130. package/dist/types/estimate/estimate.d.ts +94 -0
  131. package/dist/types/estimate/index.d.ts +4 -0
  132. package/dist/types/estimate/rpc-estimate-provider.d.ts +170 -0
  133. package/dist/types/extension/extension.d.ts +4 -0
  134. package/dist/types/forger/composite-forger.d.ts +6 -0
  135. package/dist/types/forger/errors.d.ts +16 -0
  136. package/dist/types/forger/octez.js-local-forger.d.ts +8 -0
  137. package/dist/types/forger/rpc-forger.d.ts +7 -0
  138. package/dist/types/global-constants/default-global-constants-provider.d.ts +18 -0
  139. package/dist/types/global-constants/errors.d.ts +16 -0
  140. package/dist/types/global-constants/interface-global-constants-provider.d.ts +11 -0
  141. package/dist/types/global-constants/noop-global-constants-provider.d.ts +5 -0
  142. package/dist/types/import-key.d.ts +13 -0
  143. package/dist/types/injector/helper.d.ts +2 -0
  144. package/dist/types/injector/interface.d.ts +5 -0
  145. package/dist/types/injector/rpc-injector.d.ts +7 -0
  146. package/dist/types/octez.d.ts +248 -0
  147. package/dist/types/operations/ballot-operation.d.ts +18 -0
  148. package/dist/types/operations/batch-operation.d.ts +19 -0
  149. package/dist/types/operations/delegate-operation.d.ts +24 -0
  150. package/dist/types/operations/drain-delegate-operation.d.ts +17 -0
  151. package/dist/types/operations/errors.d.ts +50 -0
  152. package/dist/types/operations/failing-noop-operation.d.ts +17 -0
  153. package/dist/types/operations/increase-paid-storage-operation.d.ts +23 -0
  154. package/dist/types/operations/index.d.ts +18 -0
  155. package/dist/types/operations/operations.d.ts +35 -0
  156. package/dist/types/operations/origination-operation.d.ts +35 -0
  157. package/dist/types/operations/proposals-operation.d.ts +17 -0
  158. package/dist/types/operations/register-global-constant-operation.d.ts +25 -0
  159. package/dist/types/operations/reveal-operation.d.ts +25 -0
  160. package/dist/types/operations/smart-rollup-add-messages-operation.d.ts +20 -0
  161. package/dist/types/operations/smart-rollup-execute-outbox-message-operation.d.ts +24 -0
  162. package/dist/types/operations/smart-rollup-originate-operation.d.ts +23 -0
  163. package/dist/types/operations/transaction-operation.d.ts +28 -0
  164. package/dist/types/operations/transfer-ticket-operation.d.ts +22 -0
  165. package/dist/types/operations/types.d.ts +461 -0
  166. package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
  167. package/dist/types/operations/update-consensus-key-operation.d.ts +23 -0
  168. package/dist/types/packer/interface.d.ts +4 -0
  169. package/dist/types/packer/michel-codec-packer.d.ts +5 -0
  170. package/dist/types/packer/rpc-packer.d.ts +8 -0
  171. package/dist/types/parser/interface.d.ts +4 -0
  172. package/dist/types/parser/michel-codec-parser.d.ts +16 -0
  173. package/dist/types/parser/noop-parser.d.ts +5 -0
  174. package/dist/types/prepare/index.d.ts +2 -0
  175. package/dist/types/prepare/interface.d.ts +153 -0
  176. package/dist/types/prepare/prepare-provider.d.ts +213 -0
  177. package/dist/types/provider.d.ts +44 -0
  178. package/dist/types/read-provider/interface.d.ts +132 -0
  179. package/dist/types/read-provider/rpc-read-adapter.d.ts +130 -0
  180. package/dist/types/signer/errors.d.ts +8 -0
  181. package/dist/types/signer/noop.d.ts +11 -0
  182. package/dist/types/subscribe/create-observable-from-subscription.d.ts +4 -0
  183. package/dist/types/subscribe/errors.d.ts +18 -0
  184. package/dist/types/subscribe/filters.d.ts +6 -0
  185. package/dist/types/subscribe/interface.d.ts +48 -0
  186. package/dist/types/subscribe/observable-subscription.d.ts +21 -0
  187. package/dist/types/subscribe/polling-subcribe-provider.d.ts +23 -0
  188. package/dist/types/tz/interface.d.ts +20 -0
  189. package/dist/types/tz/rpc-tz-provider.d.ts +13 -0
  190. package/dist/types/version.d.ts +4 -0
  191. package/dist/types/wallet/batch-operation.d.ts +13 -0
  192. package/dist/types/wallet/delegation-operation.d.ts +12 -0
  193. package/dist/types/wallet/errors.d.ts +16 -0
  194. package/dist/types/wallet/increase-paid-storage-operation.d.ts +12 -0
  195. package/dist/types/wallet/index.d.ts +9 -0
  196. package/dist/types/wallet/interface.d.ts +66 -0
  197. package/dist/types/wallet/legacy.d.ts +21 -0
  198. package/dist/types/wallet/operation-factory.d.ts +32 -0
  199. package/dist/types/wallet/operation.d.ts +54 -0
  200. package/dist/types/wallet/origination-operation.d.ts +14 -0
  201. package/dist/types/wallet/receipt.d.ts +16 -0
  202. package/dist/types/wallet/register-global-constant-operation.d.ts +13 -0
  203. package/dist/types/wallet/transaction-operation.d.ts +12 -0
  204. package/dist/types/wallet/transfer-ticket-operation.d.ts +12 -0
  205. package/dist/types/wallet/wallet.d.ts +195 -0
  206. package/package.json +131 -0
  207. package/patch.js +20 -0
  208. package/signature.json +866 -0
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SaplingStateAbstraction = void 0;
13
+ class SaplingStateAbstraction {
14
+ constructor(id, provider) {
15
+ this.id = id;
16
+ this.provider = provider;
17
+ }
18
+ /**
19
+ *
20
+ * @description Fetch the sapling state
21
+ *
22
+ * @param block optional block level to fetch the values from (head will be use by default)
23
+ * @returns Return a json object of the sapling_state
24
+ *
25
+ */
26
+ getSaplingDiff(block) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ return this.provider.getSaplingDiffByID(this.id.toString(), block);
29
+ });
30
+ }
31
+ getId() {
32
+ return this.id.toString();
33
+ }
34
+ }
35
+ exports.SaplingStateAbstraction = SaplingStateAbstraction;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.smartContractAbstractionSemantic = void 0;
4
+ const octez_js_michelson_encoder_1 = require("@tezos-x/octez.js-michelson-encoder");
5
+ const big_map_1 = require("./big-map");
6
+ const bignumber_js_1 = require("bignumber.js");
7
+ const sapling_state_abstraction_1 = require("./sapling-state-abstraction");
8
+ /**
9
+ * @description Override the default michelson encoder semantic to provide richer abstraction over storage properties
10
+ * @param provider ContractProvider (contract API)
11
+ */
12
+ // Override the default michelson encoder semantic to provide richer abstraction over storage properties
13
+ const smartContractAbstractionSemantic = (provider) => ({
14
+ // Provide a specific abstraction for BigMaps
15
+ big_map: (val, code) => {
16
+ if (!val || !('int' in val) || val.int === undefined) {
17
+ // Return an empty object in case of missing big map ID
18
+ return {};
19
+ }
20
+ else {
21
+ const schema = new octez_js_michelson_encoder_1.Schema(code);
22
+ return new big_map_1.BigMapAbstraction(new bignumber_js_1.default(val.int), schema, provider);
23
+ }
24
+ },
25
+ sapling_state: (val) => {
26
+ if (!val || !('int' in val) || val.int === undefined) {
27
+ // Return an empty object in case of missing sapling state ID
28
+ return {};
29
+ }
30
+ else {
31
+ return new sapling_state_abstraction_1.SaplingStateAbstraction(new bignumber_js_1.default(val.int), provider);
32
+ }
33
+ },
34
+ /*
35
+ // TODO: embed useful other abstractions
36
+ 'contract': () => {},
37
+ 'address': () => {}
38
+ */
39
+ });
40
+ exports.smartContractAbstractionSemantic = smartContractAbstractionSemantic;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VIEW_LAMBDA = void 0;
4
+ const code = [
5
+ {
6
+ prim: 'parameter',
7
+ args: [
8
+ {
9
+ prim: 'lambda',
10
+ args: [
11
+ { prim: 'unit' },
12
+ {
13
+ prim: 'pair',
14
+ args: [{ prim: 'list', args: [{ prim: 'operation' }] }, { prim: 'unit' }],
15
+ },
16
+ ],
17
+ },
18
+ ],
19
+ },
20
+ { prim: 'storage', args: [{ prim: 'unit' }] },
21
+ { prim: 'code', args: [[{ prim: 'CAR' }, { prim: 'UNIT' }, { prim: 'EXEC' }]] },
22
+ ];
23
+ const storage = 'Unit';
24
+ exports.VIEW_LAMBDA = {
25
+ code,
26
+ storage
27
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RPCResponseError = exports.ConfirmationTimeoutError = exports.InvalidConfirmationCountError = void 0;
4
+ const octez_js_core_1 = require("@tezos-x/octez.js-core");
5
+ /**
6
+ * @category Error
7
+ * @description Error that indicates invalid confirmation count has been passed or configured
8
+ */
9
+ class InvalidConfirmationCountError extends octez_js_core_1.ParameterValidationError {
10
+ constructor(invalidConfirmations) {
11
+ super();
12
+ this.invalidConfirmations = invalidConfirmations;
13
+ this.name = 'InvalidConfirmationCountError';
14
+ this.message = `Invalid confirmation count ${invalidConfirmations} expecting at least 1`;
15
+ }
16
+ }
17
+ exports.InvalidConfirmationCountError = InvalidConfirmationCountError;
18
+ /**
19
+ * @category Error
20
+ * @description Error that indicates that confirmation polling timed out
21
+ */
22
+ class ConfirmationTimeoutError extends octez_js_core_1.NetworkError {
23
+ constructor(message) {
24
+ super();
25
+ this.message = message;
26
+ this.name = 'ConfirmationTimeoutError';
27
+ }
28
+ }
29
+ exports.ConfirmationTimeoutError = ConfirmationTimeoutError;
30
+ /**
31
+ * @category Error
32
+ * @description Error that indicates an error being returned from the RPC response
33
+ */
34
+ class RPCResponseError extends octez_js_core_1.RpcError {
35
+ constructor(message, cause) {
36
+ super();
37
+ this.message = message;
38
+ this.cause = cause;
39
+ this.name = 'RPCResponseError';
40
+ }
41
+ }
42
+ exports.RPCResponseError = RPCResponseError;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RevealEstimateError = void 0;
4
+ const octez_js_core_1 = require("@tezos-x/octez.js-core");
5
+ /**
6
+ * @category Error
7
+ * @description Error that indicates unable to get public key to estimate reveal operation in Wallet API
8
+ */
9
+ class RevealEstimateError extends octez_js_core_1.TaquitoError {
10
+ constructor() {
11
+ super();
12
+ this.name = 'RevealEstimateError';
13
+ this.message = 'Public key is unknown, unable to estimate the reveal operation in Wallet API.';
14
+ }
15
+ }
16
+ exports.RevealEstimateError = RevealEstimateError;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Estimate = void 0;
4
+ const MINIMAL_FEE_MUTEZ = 100;
5
+ const MINIMAL_FEE_PER_BYTE_MUTEZ = 1;
6
+ const MINIMAL_FEE_PER_GAS_MUTEZ = 0.1;
7
+ /**
8
+ * Examples of use :
9
+ *
10
+ * Estimate a transfer operation :
11
+ * ```
12
+ * // Assuming that provider and signer are already configured...
13
+ *
14
+ * const amount = 2;
15
+ * const address = 'tz1h3rQ8wBxFd8L9B3d7Jhaawu6Z568XU3xY';
16
+ *
17
+ * // Estimate gasLimit, storageLimit and fees for a transfer operation
18
+ * const est = await Tezos.estimate.transfer({ to: address, amount: amount })
19
+ * console.log(est.burnFeeMutez, est.gasLimit, est.minimalFeeMutez, est.storageLimit,
20
+ * est.suggestedFeeMutez, est.totalCost, est.usingBaseFeeMutez)
21
+ *
22
+ * ```
23
+ *
24
+ * Estimate a contract origination :
25
+ * ```
26
+ * // generic.json is referring to a Michelson Smart Contract
27
+ *
28
+ * const genericMultisigJSON = require('./generic.json')
29
+ * const est = await Tezos.estimate.originate({
30
+ * code: genericMultisigJSON,
31
+ * storage: {
32
+ * stored_counter: 0,
33
+ * threshold: 1,
34
+ * keys: ['edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t']
35
+ * }
36
+ * })
37
+ * console.log(est.burnFeeMutez, est.gasLimit, est.minimalFeeMutez, est.storageLimit,
38
+ * est.suggestedFeeMutez, est.totalCost, est.usingBaseFeeMutez)
39
+ *
40
+ * ```
41
+ */
42
+ class Estimate {
43
+ constructor(_milligasLimit, _storageLimit, opSize, minimalFeePerStorageByteMutez,
44
+ /**
45
+ * @description Base fee in mutez (1 mutez = 1e10−6 tez)
46
+ */
47
+ baseFeeMutez = MINIMAL_FEE_MUTEZ) {
48
+ this._milligasLimit = _milligasLimit;
49
+ this._storageLimit = _storageLimit;
50
+ this.opSize = opSize;
51
+ this.minimalFeePerStorageByteMutez = minimalFeePerStorageByteMutez;
52
+ this.baseFeeMutez = baseFeeMutez;
53
+ }
54
+ /**
55
+ * @description The number of Mutez that will be burned for the storage of the [operation](https://tezos.gitlab.io/user/glossary.html#operations). (Storage + Allocation fees)
56
+ */
57
+ get burnFeeMutez() {
58
+ return this.roundUp(Number(this.storageLimit) * Number(this.minimalFeePerStorageByteMutez));
59
+ }
60
+ /**
61
+ * @description The limit on the amount of storage an [operation](https://tezos.gitlab.io/user/glossary.html#operations) can use with 20 buffer.
62
+ */
63
+ get storageLimit() {
64
+ return Math.max(Number(this._storageLimit), 0);
65
+ }
66
+ /**
67
+ * @description The limit on the amount of [gas](https://tezos.gitlab.io/user/glossary.html#gas) a given operation can consume with 100 buffer depends on the operation.
68
+ */
69
+ get gasLimit() {
70
+ return this.roundUp(Number(this._milligasLimit) / 1000);
71
+ }
72
+ get operationFeeMutez() {
73
+ return (this.gasLimit * MINIMAL_FEE_PER_GAS_MUTEZ + Number(this.opSize) * MINIMAL_FEE_PER_BYTE_MUTEZ);
74
+ }
75
+ roundUp(nanotez) {
76
+ return Math.ceil(Number(nanotez));
77
+ }
78
+ /**
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.
80
+ */
81
+ get minimalFeeMutez() {
82
+ return this.roundUp(this.operationFeeMutez + MINIMAL_FEE_MUTEZ);
83
+ }
84
+ /**
85
+ * @description The suggested fee for the operation which includes minimal fees and a small buffer.
86
+ */
87
+ get suggestedFeeMutez() {
88
+ return this.roundUp(this.operationFeeMutez + MINIMAL_FEE_MUTEZ * 1.2);
89
+ }
90
+ /**
91
+ * @description Fees according to your specified base fee will ensure that at least minimum fees are used.
92
+ */
93
+ get usingBaseFeeMutez() {
94
+ return (Math.max(Number(this.baseFeeMutez), MINIMAL_FEE_MUTEZ) + this.roundUp(this.operationFeeMutez));
95
+ }
96
+ /**
97
+ * @description The sum of `minimalFeeMutez` + `burnFeeMutez`.
98
+ */
99
+ get totalCost() {
100
+ return this.minimalFeeMutez + this.burnFeeMutez;
101
+ }
102
+ /**
103
+ * @description Since Delphinet, consumed gas is provided in milligas for more precision.
104
+ * This function returns an estimation of the gas that operation will consume in milligas.
105
+ */
106
+ get consumedMilligas() {
107
+ return Number(this._milligasLimit);
108
+ }
109
+ static createEstimateInstanceFromProperties(estimateProperties) {
110
+ let milligasLimit = 0;
111
+ let storageLimit = 0;
112
+ let opSize = 0;
113
+ let minimalFeePerStorageByteMutez = 0;
114
+ let baseFeeMutez;
115
+ estimateProperties.forEach((estimate) => {
116
+ milligasLimit += estimate.milligasLimit;
117
+ storageLimit += estimate.storageLimit;
118
+ opSize += estimate.opSize;
119
+ minimalFeePerStorageByteMutez = Math.max(estimate.minimalFeePerStorageByteMutez, minimalFeePerStorageByteMutez);
120
+ if (estimate.baseFeeMutez) {
121
+ baseFeeMutez = baseFeeMutez ? baseFeeMutez + estimate.baseFeeMutez : estimate.baseFeeMutez;
122
+ }
123
+ });
124
+ return new Estimate(milligasLimit, storageLimit, opSize, minimalFeePerStorageByteMutez, baseFeeMutez);
125
+ }
126
+ static createArrayEstimateInstancesFromProperties(estimateProperties) {
127
+ return estimateProperties.map((x) => new Estimate(x.milligasLimit, x.storageLimit, x.opSize, x.minimalFeePerStorageByteMutez, x.baseFeeMutez));
128
+ }
129
+ }
130
+ exports.Estimate = Estimate;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./estimate"), exports);
18
+ __exportStar(require("./estimate-provider-interface"), exports);
19
+ __exportStar(require("./rpc-estimate-provider"), exports);
20
+ __exportStar(require("./errors"), exports);