@tezos-x/octez.js-michel-codec 0.9.0 → 25.0.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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,24 @@
1
+ octez.js - A TypeScript library for Tezos
2
+
3
+ Copyright 2026 Nomadic Labs
4
+ Copyright 2023 ECAD Labs Inc.
5
+
6
+ This project is a fork of Taquito (https://github.com/ecadlabs/taquito).
7
+
8
+ In accordance with Section 4(b) of the Apache License, Version 2.0, this
9
+ notice states that files in this repository have been modified from the
10
+ original Taquito source as part of this fork. This notice applies to the
11
+ repository as a whole; the complete, file-by-file record of every change is
12
+ preserved in this repository's public git commit history.
13
+
14
+ Licensed under the Apache License, Version 2.0 (the "License");
15
+ you may not use this file except in compliance with the License.
16
+ You may obtain a copy of the License at
17
+
18
+ https://www.apache.org/licenses/LICENSE-2.0
19
+
20
+ Unless required by applicable law or agreed to in writing, software
21
+ distributed under the License is distributed on an "AS IS" BASIS,
22
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ See the License for the specific language governing permissions and
24
+ limitations under the License.
package/README.md CHANGED
@@ -17,7 +17,7 @@ See the top-level project [https://github.com/trilitech/octez.js](https://github
17
17
  ### Michelson expression to JSON
18
18
 
19
19
  ```js
20
- const code = `(Pair
20
+ const code = `(Pair
21
21
  (Pair { Elt 1 (Pair (Pair "tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") 0x0501000000026869)}
22
22
  10000000)
23
23
  (Pair 2 333)
@@ -85,7 +85,7 @@ Type definition allows some types like `timestamp` and `address` and other base5
85
85
 
86
86
  ```js
87
87
  const data: MichelsonData = {
88
- string: 'KT1RvkwF4F7pz1gCoxkyZrG1RkrxQy3gmFTv%foo',
88
+ string: 'KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main',
89
89
  };
90
90
 
91
91
  const typ: MichelsonType = {
@@ -93,27 +93,27 @@ const typ: MichelsonType = {
93
93
  };
94
94
 
95
95
  const packed = packData(data, typ);
96
- // 050a0000001901be41ee922ddd2cf33201e49d32da0afec571dce300666f6f
96
+ // 050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e
97
97
 
98
98
  // alternatively
99
99
  const packedBytes = packDataBytes(data, typ);
100
- // { bytes: "050a0000001901be41ee922ddd2cf33201e49d32da0afec571dce300666f6f" }
100
+ // { bytes: "050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e" }
101
101
  ```
102
102
 
103
103
  Without a type definition the base58 encoded address will be treated as a string
104
104
 
105
105
  ```js
106
106
  const data: MichelsonData = {
107
- string: 'KT1RvkwF4F7pz1gCoxkyZrG1RkrxQy3gmFTv%foo',
107
+ string: 'KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main',
108
108
  };
109
109
 
110
110
  const packed = packData(data);
111
- // 0501000000284b543152766b7746344637707a3167436f786b795a724731526b7278517933676d46547625666f6f
111
+ // 0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e
112
112
 
113
113
  // alternatively
114
114
  const packedBytes = packDataBytes(data);
115
115
  // {
116
- // bytes: "0501000000284b543152766b7746344637707a3167436f786b795a724731526b7278517933676d46547625666f6f"
116
+ // bytes: "0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e"
117
117
  // }
118
118
  ```
119
119
 
@@ -167,7 +167,7 @@ const data = unpackDataBytes(src);
167
167
 
168
168
  ## API Documentation
169
169
 
170
- TypeDoc style documentation is available on-line [here](https://octez.js.io/typedoc/modules/_octez.js_michel_codec.html)
170
+ TypeDoc style documentation is available on-line [here](https://octez.js.io/typedoc/)
171
171
 
172
172
  ## Disclaimer
173
173
 
@@ -84,9 +84,9 @@ const K = [
84
84
  ];
85
85
  /**
86
86
  * @category Error
87
- * @description Error that indicates a failure when decoding a base58 encoding
87
+ * Error that indicates a failure when decoding a base58 encoding
88
88
  */
89
- class Base58DecodingError extends octez_js_core_1.TaquitoError {
89
+ class Base58DecodingError extends octez_js_core_1.OctezJsError {
90
90
  constructor(message) {
91
91
  super();
92
92
  this.message = message;
@@ -439,7 +439,6 @@ function writePublicKey(pk, w) {
439
439
  w.writeBytes(Array.from(pk.publicKey));
440
440
  }
441
441
  function writeExpr(expr, wr, tf) {
442
- var _a, _b;
443
442
  const [e, args] = tf(expr);
444
443
  if (Array.isArray(e)) {
445
444
  const w = new Writer();
@@ -497,9 +496,9 @@ function writeExpr(expr, wr, tf) {
497
496
  if (prim === undefined) {
498
497
  throw new TypeError(`Can't encode primary: ${e.prim}`);
499
498
  }
500
- const tag = (((_a = e.args) === null || _a === void 0 ? void 0 : _a.length) || 0) < 3
499
+ const tag = (e.args?.length || 0) < 3
501
500
  ? Tag.Prim0 +
502
- (((_b = e.args) === null || _b === void 0 ? void 0 : _b.length) || 0) * 2 +
501
+ (e.args?.length || 0) * 2 +
503
502
  (e.annots === undefined || e.annots.length === 0 ? 0 : 1)
504
503
  : Tag.Prim;
505
504
  wr.writeUint8(tag);
@@ -902,7 +901,7 @@ const writePassThrough = (e) => {
902
901
  *
903
902
  * ```typescript
904
903
  * const data: MichelsonData = {
905
- * string: "KT1RvkwF4F7pz1gCoxkyZrG1RkrxQy3gmFTv%foo"
904
+ * string: "KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main"
906
905
  * };
907
906
  *
908
907
  * const typ: MichelsonType = {
@@ -911,18 +910,18 @@ const writePassThrough = (e) => {
911
910
  *
912
911
  * const packed = packData(data, typ);
913
912
  *
914
- * // 050a0000001901be41ee922ddd2cf33201e49d32da0afec571dce300666f6f
913
+ * // 050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e
915
914
  * ```
916
915
  *
917
916
  * Without a type definition the base58 encoded address will be treated as a string
918
917
  * ```typescript
919
918
  * const data: MichelsonData = {
920
- * string: "KT1RvkwF4F7pz1gCoxkyZrG1RkrxQy3gmFTv%foo"
919
+ * string: "KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main"
921
920
  * };
922
921
  *
923
922
  * const packed = packData(data);
924
923
  *
925
- * // 0501000000284b543152766b7746344637707a3167436f786b795a724731526b7278517933676d46547625666f6f
924
+ * // 0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e
926
925
  * ```
927
926
  * @param d Data object
928
927
  * @param t Optional type definition
@@ -4,7 +4,7 @@ exports.HexParseError = exports.LongIntegerError = exports.TezosIdEncodeError =
4
4
  const octez_js_core_1 = require("@tezos-x/octez.js-core");
5
5
  /**
6
6
  * @category Error
7
- * @description Error that indicates an invalid Michelson being passed or used
7
+ * Error that indicates an invalid Michelson being passed or used
8
8
  */
9
9
  class InvalidMichelsonError extends octez_js_core_1.ParameterValidationError {
10
10
  constructor(message) {
@@ -16,7 +16,7 @@ class InvalidMichelsonError extends octez_js_core_1.ParameterValidationError {
16
16
  exports.InvalidMichelsonError = InvalidMichelsonError;
17
17
  /**
18
18
  * @category Error
19
- * @description Error that indicates an invalid type expression being passed or used
19
+ * Error that indicates an invalid type expression being passed or used
20
20
  */
21
21
  class InvalidTypeExpressionError extends octez_js_core_1.ParameterValidationError {
22
22
  constructor(message) {
@@ -28,7 +28,7 @@ class InvalidTypeExpressionError extends octez_js_core_1.ParameterValidationErro
28
28
  exports.InvalidTypeExpressionError = InvalidTypeExpressionError;
29
29
  /**
30
30
  * @category Error
31
- * @description Error that indicates an invalid data expression being passed or used
31
+ * Error that indicates an invalid data expression being passed or used
32
32
  */
33
33
  class InvalidDataExpressionError extends octez_js_core_1.ParameterValidationError {
34
34
  constructor(message) {
@@ -40,7 +40,7 @@ class InvalidDataExpressionError extends octez_js_core_1.ParameterValidationErro
40
40
  exports.InvalidDataExpressionError = InvalidDataExpressionError;
41
41
  /**
42
42
  * @category Error
43
- * @description Error that indicates an invalid contract entrypoint being referenced or passed
43
+ * Error that indicates an invalid contract entrypoint being referenced or passed
44
44
  */
45
45
  class InvalidEntrypointError extends octez_js_core_1.ParameterValidationError {
46
46
  constructor(entrypoint) {
@@ -53,7 +53,7 @@ class InvalidEntrypointError extends octez_js_core_1.ParameterValidationError {
53
53
  exports.InvalidEntrypointError = InvalidEntrypointError;
54
54
  /**
55
55
  * @category Error
56
- * @description Error that indicates a failure happening when trying to encode Tezos ID
56
+ * Error that indicates a failure happening when trying to encode Tezos ID
57
57
  */
58
58
  class TezosIdEncodeError extends octez_js_core_1.ParameterValidationError {
59
59
  constructor(message) {
@@ -65,9 +65,9 @@ class TezosIdEncodeError extends octez_js_core_1.ParameterValidationError {
65
65
  exports.TezosIdEncodeError = TezosIdEncodeError;
66
66
  /**
67
67
  * @category Error
68
- * @description Error that indicates a general error happening when trying to create a LongInteger
68
+ * Error that indicates a general error happening when trying to create a LongInteger
69
69
  */
70
- class LongIntegerError extends octez_js_core_1.TaquitoError {
70
+ class LongIntegerError extends octez_js_core_1.OctezJsError {
71
71
  constructor(message) {
72
72
  super();
73
73
  this.message = message;
@@ -77,9 +77,9 @@ class LongIntegerError extends octez_js_core_1.TaquitoError {
77
77
  exports.LongIntegerError = LongIntegerError;
78
78
  /**
79
79
  * @category Error
80
- * @description Error that indicates a failure occurring when trying to parse a hex byte
80
+ * Error that indicates a failure occurring when trying to parse a hex byte
81
81
  */
82
- class HexParseError extends octez_js_core_1.TaquitoError {
82
+ class HexParseError extends octez_js_core_1.OctezJsError {
83
83
  constructor(hexByte) {
84
84
  super();
85
85
  this.hexByte = hexByte;
@@ -20,11 +20,10 @@ function formatStack(s) {
20
20
  }
21
21
  function traceDumpFunc(blocks, cb) {
22
22
  return (v) => {
23
- var _a;
24
23
  if (Array.isArray(v) && !blocks) {
25
24
  return;
26
25
  }
27
- const macro = (_a = v.op[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
26
+ const macro = v.op[micheline_1.sourceReference]?.macro;
28
27
  const msg = `${macro ? 'Macro' : 'Op'}: ${macro ? (0, micheline_emitter_1.emitMicheline)(macro, undefined, true) + ' / ' : ''}${(0, micheline_emitter_1.emitMicheline)(v.op)}
29
28
  Input:
30
29
  ${formatStack(v.in)}
@@ -35,9 +34,8 @@ ${formatStack(v.out)}
35
34
  };
36
35
  }
37
36
  function formatError(err) {
38
- var _a;
39
37
  if (err instanceof michelson_typecheck_1.MichelsonInstructionError) {
40
- const macro = (_a = err.val[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
38
+ const macro = err.val[micheline_1.sourceReference]?.macro;
41
39
  return `${macro ? 'Macro' : 'Op'}: ${macro ? (0, micheline_emitter_1.emitMicheline)(macro, undefined, true) + ' / ' : ''}${(0, micheline_emitter_1.emitMicheline)(err.val)}
42
40
  Stack:
43
41
  ${formatStack(err.stackState)}
@@ -6,9 +6,9 @@ const octez_js_core_1 = require("@tezos-x/octez.js-core");
6
6
  const michelson_types_1 = require("./michelson-types");
7
7
  /**
8
8
  * @category Error
9
- * @description Error that indicates macros failed to be expanded
9
+ * Error that indicates macros failed to be expanded
10
10
  */
11
- class MacroError extends octez_js_core_1.TaquitoError {
11
+ class MacroError extends octez_js_core_1.OctezJsError {
12
12
  constructor(prim, message) {
13
13
  super();
14
14
  this.prim = prim;
@@ -18,11 +18,10 @@ class MacroError extends octez_js_core_1.TaquitoError {
18
18
  }
19
19
  exports.MacroError = MacroError;
20
20
  function assertArgs(ex, n) {
21
- var _a, _b;
22
- if ((n === 0 && ex.args === undefined) || ((_a = ex.args) === null || _a === void 0 ? void 0 : _a.length) === n) {
21
+ if ((n === 0 && ex.args === undefined) || ex.args?.length === n) {
23
22
  return true;
24
23
  }
25
- throw new MacroError(ex, `macro ${ex.prim} expects ${n} arguments, was given ${(_b = ex.args) === null || _b === void 0 ? void 0 : _b.length}`);
24
+ throw new MacroError(ex, `macro ${ex.prim} expects ${n} arguments, was given ${ex.args?.length}`);
26
25
  }
27
26
  function assertNoAnnots(ex) {
28
27
  if (ex.annots === undefined) {
@@ -140,7 +139,11 @@ function filterAnnotations(a) {
140
139
  return { fields, rest };
141
140
  }
142
141
  function mkPrim({ prim, annots, args }) {
143
- return Object.assign(Object.assign({ prim }, (annots && { annots })), (args && { args }));
142
+ return {
143
+ prim,
144
+ ...(annots && { annots }),
145
+ ...(args && { args }),
146
+ };
144
147
  }
145
148
  const pairRe = /^P[PAI]{3,}R$/;
146
149
  const unpairRe = /^UNP[PAI]{2,}R$/;
@@ -150,7 +153,7 @@ const mapCadrRe = /^MAP_C[AD]+R$/;
150
153
  const diipRe = /^DI{2,}P$/;
151
154
  const duupRe = /^DU+P$/;
152
155
  function expandMacros(ex, opt) {
153
- const proto = (opt === null || opt === void 0 ? void 0 : opt.protocol) || michelson_types_1.DefaultProtocol;
156
+ const proto = opt?.protocol || michelson_types_1.DefaultProtocol;
154
157
  function mayRename(annots) {
155
158
  return annots !== undefined ? [{ prim: 'RENAME', annots }] : [];
156
159
  }
@@ -8,9 +8,8 @@ class Formatter {
8
8
  this.lev = lev;
9
9
  }
10
10
  indent(n = 0) {
11
- var _a;
12
11
  let ret = '';
13
- if (((_a = this.opt) === null || _a === void 0 ? void 0 : _a.indent) !== undefined) {
12
+ if (this.opt?.indent !== undefined) {
14
13
  for (let i = this.lev + n; i > 0; i--) {
15
14
  ret += this.opt.indent;
16
15
  }
@@ -18,12 +17,10 @@ class Formatter {
18
17
  return ret;
19
18
  }
20
19
  get lf() {
21
- var _a;
22
- return ((_a = this.opt) === null || _a === void 0 ? void 0 : _a.newline) || '';
20
+ return this.opt?.newline || '';
23
21
  }
24
22
  get lfsp() {
25
- var _a;
26
- return ((_a = this.opt) === null || _a === void 0 ? void 0 : _a.newline) || ' ';
23
+ return this.opt?.newline || ' ';
27
24
  }
28
25
  down(n) {
29
26
  return new Formatter(this.opt, this.lev + n);
@@ -45,8 +42,7 @@ function isMultiline(node) {
45
42
  return false;
46
43
  }
47
44
  function emitExpr(node, f, foldMacros) {
48
- var _a;
49
- const macro = (_a = node[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
45
+ const macro = node[micheline_1.sourceReference]?.macro;
50
46
  if (foldMacros && macro) {
51
47
  return emitExpr(macro, f, foldMacros);
52
48
  }
@@ -8,9 +8,9 @@ const global_constants_1 = require("./global-constants");
8
8
  const octez_js_core_1 = require("@tezos-x/octez.js-core");
9
9
  /**
10
10
  * @category Error
11
- * @description Error that indicates a failure when parsing Micheline expressions
11
+ * Error that indicates a failure when parsing Micheline expressions
12
12
  */
13
- class MichelineParseError extends octez_js_core_1.TaquitoError {
13
+ class MichelineParseError extends octez_js_core_1.OctezJsError {
14
14
  /**
15
15
  * @param token A token caused the error
16
16
  * @param message An error message
@@ -25,9 +25,9 @@ class MichelineParseError extends octez_js_core_1.TaquitoError {
25
25
  exports.MichelineParseError = MichelineParseError;
26
26
  /**
27
27
  * @category Error
28
- * @description Error indicates a failure when parsing Micheline JSON
28
+ * Error indicates a failure when parsing Micheline JSON
29
29
  */
30
- class JSONParseError extends octez_js_core_1.TaquitoError {
30
+ class JSONParseError extends octez_js_core_1.OctezJsError {
31
31
  /**
32
32
  * @param node A node caused the error
33
33
  * @param message An error message
@@ -83,18 +83,20 @@ class Parser {
83
83
  this.opt = opt;
84
84
  }
85
85
  expand(ex) {
86
- var _a, _b, _c;
87
- if (((_a = this.opt) === null || _a === void 0 ? void 0 : _a.expandGlobalConstant) !== undefined && ex.prim === 'constant') {
86
+ if (this.opt?.expandGlobalConstant !== undefined && ex.prim === 'constant') {
88
87
  const ret = (0, global_constants_1.expandGlobalConstants)(ex, this.opt.expandGlobalConstant);
89
88
  if (ret !== ex) {
90
- ret[micheline_1.sourceReference] = Object.assign(Object.assign({}, (ex[micheline_1.sourceReference] || { first: 0, last: 0 })), { globalConstant: ex });
89
+ ret[micheline_1.sourceReference] = {
90
+ ...(ex[micheline_1.sourceReference] || { first: 0, last: 0 }),
91
+ globalConstant: ex,
92
+ };
91
93
  }
92
94
  return ret;
93
95
  }
94
- if (((_b = this.opt) === null || _b === void 0 ? void 0 : _b.expandMacros) !== undefined ? (_c = this.opt) === null || _c === void 0 ? void 0 : _c.expandMacros : true) {
96
+ if (this.opt?.expandMacros !== undefined ? this.opt?.expandMacros : true) {
95
97
  const ret = (0, macros_1.expandMacros)(ex, this.opt);
96
98
  if (ret !== ex) {
97
- ret[micheline_1.sourceReference] = Object.assign(Object.assign({}, (ex[micheline_1.sourceReference] || { first: 0, last: 0 })), { macro: ex });
99
+ ret[micheline_1.sourceReference] = { ...(ex[micheline_1.sourceReference] || { first: 0, last: 0 }), macro: ex };
98
100
  }
99
101
  return ret;
100
102
  }
@@ -103,7 +105,6 @@ class Parser {
103
105
  }
104
106
  }
105
107
  parseListExpr(scanner, start) {
106
- var _a;
107
108
  const ref = {
108
109
  first: start.first,
109
110
  last: start.last,
@@ -150,14 +151,13 @@ class Parser {
150
151
  else {
151
152
  ret.args = ret.args || [];
152
153
  const arg = this.parseExpr(scanner, tok.value);
153
- ref.last = ((_a = arg[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.last) || ref.last;
154
+ ref.last = arg[micheline_1.sourceReference]?.last || ref.last;
154
155
  ret.args.push(arg);
155
156
  }
156
157
  }
157
158
  return this.expand(ret);
158
159
  }
159
160
  parseArgs(scanner, start) {
160
- var _a;
161
161
  // Identifier with arguments
162
162
  const ref = {
163
163
  first: start.first,
@@ -179,14 +179,13 @@ class Parser {
179
179
  }
180
180
  else {
181
181
  const arg = this.parseExpr(scanner, t.value);
182
- ref.last = ((_a = arg[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.last) || ref.last;
182
+ ref.last = arg[micheline_1.sourceReference]?.last || ref.last;
183
183
  p.args = p.args || [];
184
184
  p.args.push(arg);
185
185
  }
186
186
  }
187
187
  }
188
188
  parseSequenceExpr(scanner, start) {
189
- var _a, _b;
190
189
  const ref = {
191
190
  first: start.first,
192
191
  last: start.last,
@@ -221,14 +220,14 @@ class Parser {
221
220
  else if (tok.value.t === scan_1.Literal.Ident) {
222
221
  // Identifier with arguments
223
222
  const [itm, n] = this.parseArgs(scanner, tok.value);
224
- ref.last = ((_a = itm[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.last) || ref.last;
223
+ ref.last = itm[micheline_1.sourceReference]?.last || ref.last;
225
224
  seq.push(this.expand(itm));
226
225
  tok = n;
227
226
  }
228
227
  else {
229
228
  // Other
230
229
  const ex = this.parseExpr(scanner, tok.value);
231
- ref.last = ((_b = ex[micheline_1.sourceReference]) === null || _b === void 0 ? void 0 : _b.last) || ref.last;
230
+ ref.last = ex[micheline_1.sourceReference]?.last || ref.last;
232
231
  seq.push(ex);
233
232
  tok = null;
234
233
  }
@@ -8,7 +8,7 @@ const errors_1 = require("./errors");
8
8
  class Contract {
9
9
  constructor(contract, opt) {
10
10
  this.contract = contract;
11
- this.ctx = Object.assign({ contract }, opt);
11
+ this.ctx = { contract, ...opt };
12
12
  this.output = (0, michelson_typecheck_1.assertContractValid)(contract, this.ctx);
13
13
  }
14
14
  static parse(src, opt) {
@@ -64,7 +64,7 @@ class Contract {
64
64
  assertParameterValid(ep, d) {
65
65
  const t = this.entryPoint(ep || undefined);
66
66
  if (t === null) {
67
- throw new errors_1.InvalidEntrypointError(ep === null || ep === void 0 ? void 0 : ep.toString());
67
+ throw new errors_1.InvalidEntrypointError(ep?.toString());
68
68
  }
69
69
  this.assertDataValid(d, t);
70
70
  }
@@ -73,7 +73,7 @@ class Contract {
73
73
  this.assertParameterValid(ep, d);
74
74
  return true;
75
75
  }
76
- catch (_a) {
76
+ catch {
77
77
  return false;
78
78
  }
79
79
  }