@tezos-x/octez.js-michel-codec 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 (41) hide show
  1. package/README.md +174 -0
  2. package/dist/lib/base58.js +255 -0
  3. package/dist/lib/binary.js +1272 -0
  4. package/dist/lib/errors.js +90 -0
  5. package/dist/lib/formatters.js +60 -0
  6. package/dist/lib/global-constants.js +12 -0
  7. package/dist/lib/macros.js +548 -0
  8. package/dist/lib/micheline-emitter.js +132 -0
  9. package/dist/lib/micheline-parser.js +403 -0
  10. package/dist/lib/micheline.js +5 -0
  11. package/dist/lib/michelson-contract.js +93 -0
  12. package/dist/lib/michelson-typecheck.js +1752 -0
  13. package/dist/lib/michelson-types.js +83 -0
  14. package/dist/lib/michelson-validator.js +835 -0
  15. package/dist/lib/octez.js-michel-codec.js +38 -0
  16. package/dist/lib/scan.js +128 -0
  17. package/dist/lib/utils.js +321 -0
  18. package/dist/lib/version.js +8 -0
  19. package/dist/octez.js-michel-codec.es6.js +5790 -0
  20. package/dist/octez.js-michel-codec.es6.js.map +1 -0
  21. package/dist/octez.js-michel-codec.umd.js +5854 -0
  22. package/dist/octez.js-michel-codec.umd.js.map +1 -0
  23. package/dist/types/base58.d.ts +13 -0
  24. package/dist/types/binary.d.ts +127 -0
  25. package/dist/types/errors.d.ts +57 -0
  26. package/dist/types/formatters.d.ts +6 -0
  27. package/dist/types/global-constants.d.ts +3 -0
  28. package/dist/types/macros.d.ts +13 -0
  29. package/dist/types/micheline-emitter.d.ts +17 -0
  30. package/dist/types/micheline-parser.d.ts +130 -0
  31. package/dist/types/micheline.d.ts +44 -0
  32. package/dist/types/michelson-contract.d.ts +24 -0
  33. package/dist/types/michelson-typecheck.d.ts +38 -0
  34. package/dist/types/michelson-types.d.ts +147 -0
  35. package/dist/types/michelson-validator.d.ts +66 -0
  36. package/dist/types/octez.js-michel-codec.d.ts +16 -0
  37. package/dist/types/scan.d.ts +26 -0
  38. package/dist/types/utils.d.ts +77 -0
  39. package/dist/types/version.d.ts +4 -0
  40. package/package.json +94 -0
  41. package/signature.json +315 -0
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HexParseError = exports.LongIntegerError = exports.TezosIdEncodeError = exports.InvalidEntrypointError = exports.InvalidDataExpressionError = exports.InvalidTypeExpressionError = exports.InvalidMichelsonError = void 0;
4
+ const octez_js_core_1 = require("@tezos-x/octez.js-core");
5
+ /**
6
+ * @category Error
7
+ * @description Error that indicates an invalid Michelson being passed or used
8
+ */
9
+ class InvalidMichelsonError extends octez_js_core_1.ParameterValidationError {
10
+ constructor(message) {
11
+ super();
12
+ this.message = message;
13
+ this.name = 'InvalidMichelsonError';
14
+ }
15
+ }
16
+ exports.InvalidMichelsonError = InvalidMichelsonError;
17
+ /**
18
+ * @category Error
19
+ * @description Error that indicates an invalid type expression being passed or used
20
+ */
21
+ class InvalidTypeExpressionError extends octez_js_core_1.ParameterValidationError {
22
+ constructor(message) {
23
+ super();
24
+ this.message = message;
25
+ this.name = 'InvalidTypeExpressionError';
26
+ }
27
+ }
28
+ exports.InvalidTypeExpressionError = InvalidTypeExpressionError;
29
+ /**
30
+ * @category Error
31
+ * @description Error that indicates an invalid data expression being passed or used
32
+ */
33
+ class InvalidDataExpressionError extends octez_js_core_1.ParameterValidationError {
34
+ constructor(message) {
35
+ super();
36
+ this.message = message;
37
+ this.name = 'InvalidDataExpressionError';
38
+ }
39
+ }
40
+ exports.InvalidDataExpressionError = InvalidDataExpressionError;
41
+ /**
42
+ * @category Error
43
+ * @description Error that indicates an invalid contract entrypoint being referenced or passed
44
+ */
45
+ class InvalidEntrypointError extends octez_js_core_1.ParameterValidationError {
46
+ constructor(entrypoint) {
47
+ super();
48
+ this.entrypoint = entrypoint;
49
+ this.name = 'InvalidEntrypointError';
50
+ this.message = `Contract has no entrypoint named: "${entrypoint}"`;
51
+ }
52
+ }
53
+ exports.InvalidEntrypointError = InvalidEntrypointError;
54
+ /**
55
+ * @category Error
56
+ * @description Error that indicates a failure happening when trying to encode Tezos ID
57
+ */
58
+ class TezosIdEncodeError extends octez_js_core_1.ParameterValidationError {
59
+ constructor(message) {
60
+ super();
61
+ this.message = message;
62
+ this.name = 'TezosIdEncodeError';
63
+ }
64
+ }
65
+ exports.TezosIdEncodeError = TezosIdEncodeError;
66
+ /**
67
+ * @category Error
68
+ * @description Error that indicates a general error happening when trying to create a LongInteger
69
+ */
70
+ class LongIntegerError extends octez_js_core_1.TaquitoError {
71
+ constructor(message) {
72
+ super();
73
+ this.message = message;
74
+ this.name = 'LongIntegerError';
75
+ }
76
+ }
77
+ exports.LongIntegerError = LongIntegerError;
78
+ /**
79
+ * @category Error
80
+ * @description Error that indicates a failure occurring when trying to parse a hex byte
81
+ */
82
+ class HexParseError extends octez_js_core_1.TaquitoError {
83
+ constructor(hexByte) {
84
+ super();
85
+ this.hexByte = hexByte;
86
+ this.name = 'HexParseError';
87
+ this.message = `Unable to parse hex byte "${hexByte}"`;
88
+ }
89
+ }
90
+ exports.HexParseError = HexParseError;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatStack = formatStack;
4
+ exports.traceDumpFunc = traceDumpFunc;
5
+ exports.formatError = formatError;
6
+ const micheline_1 = require("./micheline");
7
+ const michelson_typecheck_1 = require("./michelson-typecheck");
8
+ const micheline_emitter_1 = require("./micheline-emitter");
9
+ const utils_1 = require("./utils");
10
+ function formatStack(s) {
11
+ if ('failed' in s) {
12
+ return `[FAILED: ${(0, micheline_emitter_1.emitMicheline)(s.failed)}]`;
13
+ }
14
+ return s
15
+ .map((v, i) => {
16
+ const ann = (0, utils_1.unpackAnnotations)(v);
17
+ return `[${i}${ann.v ? '/' + ann.v[0] : ''}]: ${(0, micheline_emitter_1.emitMicheline)(v)}`;
18
+ })
19
+ .join('\n');
20
+ }
21
+ function traceDumpFunc(blocks, cb) {
22
+ return (v) => {
23
+ var _a;
24
+ if (Array.isArray(v) && !blocks) {
25
+ return;
26
+ }
27
+ const macro = (_a = v.op[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
28
+ const msg = `${macro ? 'Macro' : 'Op'}: ${macro ? (0, micheline_emitter_1.emitMicheline)(macro, undefined, true) + ' / ' : ''}${(0, micheline_emitter_1.emitMicheline)(v.op)}
29
+ Input:
30
+ ${formatStack(v.in)}
31
+ Output:
32
+ ${formatStack(v.out)}
33
+ `;
34
+ cb(msg);
35
+ };
36
+ }
37
+ function formatError(err) {
38
+ var _a;
39
+ if (err instanceof michelson_typecheck_1.MichelsonInstructionError) {
40
+ const macro = (_a = err.val[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
41
+ return `${macro ? 'Macro' : 'Op'}: ${macro ? (0, micheline_emitter_1.emitMicheline)(macro, undefined, true) + ' / ' : ''}${(0, micheline_emitter_1.emitMicheline)(err.val)}
42
+ Stack:
43
+ ${formatStack(err.stackState)}
44
+ `;
45
+ }
46
+ else if (err instanceof utils_1.MichelsonTypeError) {
47
+ const type = Array.isArray(err.val)
48
+ ? '[' + err.val.map((v, i) => `[${i}]: ${(0, micheline_emitter_1.emitMicheline)(v)}`).join('; ') + ']'
49
+ : (0, micheline_emitter_1.emitMicheline)(err.val);
50
+ return `Type: ${type}
51
+ ${err.data
52
+ ? `Data: ${(0, micheline_emitter_1.emitMicheline)(err.data)}
53
+ `
54
+ : ''}
55
+ `;
56
+ }
57
+ else {
58
+ return `Value: ${(0, micheline_emitter_1.emitMicheline)(err.val)}`;
59
+ }
60
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expandGlobalConstants = expandGlobalConstants;
4
+ function expandGlobalConstants(ex, hashAndValue) {
5
+ if (ex.args !== undefined &&
6
+ ex.args.length === 1 &&
7
+ 'string' in ex.args[0] &&
8
+ ex.args[0].string in hashAndValue) {
9
+ return hashAndValue[ex.args[0].string];
10
+ }
11
+ return ex;
12
+ }