@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.
- package/README.md +174 -0
- package/dist/lib/base58.js +255 -0
- package/dist/lib/binary.js +1272 -0
- package/dist/lib/errors.js +90 -0
- package/dist/lib/formatters.js +60 -0
- package/dist/lib/global-constants.js +12 -0
- package/dist/lib/macros.js +548 -0
- package/dist/lib/micheline-emitter.js +132 -0
- package/dist/lib/micheline-parser.js +403 -0
- package/dist/lib/micheline.js +5 -0
- package/dist/lib/michelson-contract.js +93 -0
- package/dist/lib/michelson-typecheck.js +1752 -0
- package/dist/lib/michelson-types.js +83 -0
- package/dist/lib/michelson-validator.js +835 -0
- package/dist/lib/octez.js-michel-codec.js +38 -0
- package/dist/lib/scan.js +128 -0
- package/dist/lib/utils.js +321 -0
- package/dist/lib/version.js +8 -0
- package/dist/octez.js-michel-codec.es6.js +5790 -0
- package/dist/octez.js-michel-codec.es6.js.map +1 -0
- package/dist/octez.js-michel-codec.umd.js +5854 -0
- package/dist/octez.js-michel-codec.umd.js.map +1 -0
- package/dist/types/base58.d.ts +13 -0
- package/dist/types/binary.d.ts +127 -0
- package/dist/types/errors.d.ts +57 -0
- package/dist/types/formatters.d.ts +6 -0
- package/dist/types/global-constants.d.ts +3 -0
- package/dist/types/macros.d.ts +13 -0
- package/dist/types/micheline-emitter.d.ts +17 -0
- package/dist/types/micheline-parser.d.ts +130 -0
- package/dist/types/micheline.d.ts +44 -0
- package/dist/types/michelson-contract.d.ts +24 -0
- package/dist/types/michelson-typecheck.d.ts +38 -0
- package/dist/types/michelson-types.d.ts +147 -0
- package/dist/types/michelson-validator.d.ts +66 -0
- package/dist/types/octez.js-michel-codec.d.ts +16 -0
- package/dist/types/scan.d.ts +26 -0
- package/dist/types/utils.d.ts +77 -0
- package/dist/types/version.d.ts +4 -0
- package/package.json +94 -0
- package/signature.json +315 -0
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
exports.VERSION = exports.MacroError = exports.MichelsonTypeError = exports.isMichelsonError = exports.MichelsonError = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
* @module @tezos-x/octez.js-michel-codec
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./micheline"), exports);
|
|
23
|
+
__exportStar(require("./micheline-parser"), exports);
|
|
24
|
+
__exportStar(require("./micheline-emitter"), exports);
|
|
25
|
+
__exportStar(require("./michelson-validator"), exports);
|
|
26
|
+
__exportStar(require("./michelson-types"), exports);
|
|
27
|
+
__exportStar(require("./michelson-typecheck"), exports);
|
|
28
|
+
__exportStar(require("./michelson-contract"), exports);
|
|
29
|
+
__exportStar(require("./formatters"), exports);
|
|
30
|
+
__exportStar(require("./binary"), exports);
|
|
31
|
+
var utils_1 = require("./utils");
|
|
32
|
+
Object.defineProperty(exports, "MichelsonError", { enumerable: true, get: function () { return utils_1.MichelsonError; } });
|
|
33
|
+
Object.defineProperty(exports, "isMichelsonError", { enumerable: true, get: function () { return utils_1.isMichelsonError; } });
|
|
34
|
+
Object.defineProperty(exports, "MichelsonTypeError", { enumerable: true, get: function () { return utils_1.MichelsonTypeError; } });
|
|
35
|
+
var macros_1 = require("./macros");
|
|
36
|
+
Object.defineProperty(exports, "MacroError", { enumerable: true, get: function () { return macros_1.MacroError; } });
|
|
37
|
+
var version_1 = require("./version");
|
|
38
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
package/dist/lib/scan.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Literal = exports.ScanError = void 0;
|
|
4
|
+
exports.scan = scan;
|
|
5
|
+
const octez_js_core_1 = require("@tezos-x/octez.js-core");
|
|
6
|
+
/**
|
|
7
|
+
* @category Error
|
|
8
|
+
* @description Error that indicates a failure when performing the scan step when parsing Michelson
|
|
9
|
+
*/
|
|
10
|
+
class ScanError extends octez_js_core_1.TaquitoError {
|
|
11
|
+
constructor(src, idx, message) {
|
|
12
|
+
super();
|
|
13
|
+
this.src = src;
|
|
14
|
+
this.idx = idx;
|
|
15
|
+
this.message = message;
|
|
16
|
+
this.name = 'ScanError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ScanError = ScanError;
|
|
20
|
+
var Literal;
|
|
21
|
+
(function (Literal) {
|
|
22
|
+
Literal[Literal["Comment"] = 0] = "Comment";
|
|
23
|
+
Literal[Literal["Number"] = 1] = "Number";
|
|
24
|
+
Literal[Literal["String"] = 2] = "String";
|
|
25
|
+
Literal[Literal["Bytes"] = 3] = "Bytes";
|
|
26
|
+
Literal[Literal["Ident"] = 4] = "Ident";
|
|
27
|
+
})(Literal || (exports.Literal = Literal = {}));
|
|
28
|
+
const isSpace = new RegExp('\\s');
|
|
29
|
+
const isIdentStart = new RegExp('[:@%_A-Za-z]');
|
|
30
|
+
const isIdent = new RegExp('[@%_\\.A-Za-z0-9]');
|
|
31
|
+
const isDigit = new RegExp('[0-9]');
|
|
32
|
+
const isHex = new RegExp('[0-9a-fA-F]');
|
|
33
|
+
function* scan(src, scanComments = false) {
|
|
34
|
+
let i = 0;
|
|
35
|
+
while (i < src.length) {
|
|
36
|
+
// Skip space
|
|
37
|
+
while (i < src.length && isSpace.test(src[i])) {
|
|
38
|
+
i++;
|
|
39
|
+
}
|
|
40
|
+
if (i === src.length) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const s = src[i];
|
|
44
|
+
const start = i;
|
|
45
|
+
if (isIdentStart.test(s)) {
|
|
46
|
+
// Identifier
|
|
47
|
+
i++;
|
|
48
|
+
while (i < src.length && isIdent.test(src[i])) {
|
|
49
|
+
i++;
|
|
50
|
+
}
|
|
51
|
+
yield { t: Literal.Ident, v: src.slice(start, i), first: start, last: i };
|
|
52
|
+
}
|
|
53
|
+
else if (src.length - i > 1 && src.substring(i, i + 2) === '0x') {
|
|
54
|
+
// Bytes
|
|
55
|
+
i += 2;
|
|
56
|
+
while (i < src.length && isHex.test(src[i])) {
|
|
57
|
+
i++;
|
|
58
|
+
}
|
|
59
|
+
if (((i - start) & 1) !== 0) {
|
|
60
|
+
throw new ScanError(src, i, 'Bytes literal length is expected to be power of two');
|
|
61
|
+
}
|
|
62
|
+
yield { t: Literal.Bytes, v: src.slice(start, i), first: start, last: i };
|
|
63
|
+
}
|
|
64
|
+
else if (isDigit.test(s) || s === '-') {
|
|
65
|
+
// Number
|
|
66
|
+
if (s === '-') {
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
const ii = i;
|
|
70
|
+
while (i < src.length && isDigit.test(src[i])) {
|
|
71
|
+
i++;
|
|
72
|
+
}
|
|
73
|
+
if (ii === i) {
|
|
74
|
+
throw new ScanError(src, i, 'Number literal is too short');
|
|
75
|
+
}
|
|
76
|
+
yield { t: Literal.Number, v: src.slice(start, i), first: start, last: i };
|
|
77
|
+
}
|
|
78
|
+
else if (s === '"') {
|
|
79
|
+
// String
|
|
80
|
+
i++;
|
|
81
|
+
let esc = false;
|
|
82
|
+
for (; i < src.length && (esc || src[i] !== '"'); i++) {
|
|
83
|
+
if (!esc && src[i] === '\\') {
|
|
84
|
+
esc = true;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
esc = false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (i === src.length) {
|
|
91
|
+
throw new ScanError(src, i, 'Unterminated string literal');
|
|
92
|
+
}
|
|
93
|
+
i++;
|
|
94
|
+
yield { t: Literal.String, v: src.slice(start, i), first: start, last: i };
|
|
95
|
+
}
|
|
96
|
+
else if (s === '#') {
|
|
97
|
+
// Comment
|
|
98
|
+
i++;
|
|
99
|
+
while (i < src.length && src[i] !== '\n') {
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
if (scanComments) {
|
|
103
|
+
yield { t: Literal.Comment, v: src.slice(start, i), first: start, last: i };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (src.length - i > 1 && src.substring(i, i + 2) === '/*') {
|
|
107
|
+
// C style comment
|
|
108
|
+
i += 2;
|
|
109
|
+
while (i < src.length && !(src.length - i > 1 && src.substring(i, i + 2) === '*/')) {
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
if (i === src.length) {
|
|
113
|
+
throw new ScanError(src, i, 'Unterminated C style comment');
|
|
114
|
+
}
|
|
115
|
+
i += 2;
|
|
116
|
+
if (scanComments) {
|
|
117
|
+
yield { t: Literal.Comment, v: src.slice(start, i), first: start, last: i };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (s === '(' || s === ')' || s === '{' || s === '}' || s === ';') {
|
|
121
|
+
i++;
|
|
122
|
+
yield { t: s, v: s, first: start, last: i };
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new ScanError(src, i, `Invalid character at offset ${i}: \`${s}'`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tezosPrefix = exports.LongInteger = exports.MichelsonTypeError = exports.MichelsonError = void 0;
|
|
4
|
+
exports.isMichelsonError = isMichelsonError;
|
|
5
|
+
exports.parseBytes = parseBytes;
|
|
6
|
+
exports.compareBytes = compareBytes;
|
|
7
|
+
exports.isDecimal = isDecimal;
|
|
8
|
+
exports.isNatural = isNatural;
|
|
9
|
+
exports.unpackAnnotations = unpackAnnotations;
|
|
10
|
+
exports.checkDecodeTezosID = checkDecodeTezosID;
|
|
11
|
+
exports.encodeTezosID = encodeTezosID;
|
|
12
|
+
exports.unpackComb = unpackComb;
|
|
13
|
+
exports.isPairType = isPairType;
|
|
14
|
+
exports.isPairData = isPairData;
|
|
15
|
+
exports.parseDate = parseDate;
|
|
16
|
+
exports.parseHex = parseHex;
|
|
17
|
+
exports.hexBytes = hexBytes;
|
|
18
|
+
const base58_1 = require("./base58");
|
|
19
|
+
const errors_1 = require("./errors");
|
|
20
|
+
const octez_js_core_1 = require("@tezos-x/octez.js-core");
|
|
21
|
+
/**
|
|
22
|
+
* @category Error
|
|
23
|
+
* @description Error that indicates a Michelson failure occurring
|
|
24
|
+
*/
|
|
25
|
+
class MichelsonError extends octez_js_core_1.TaquitoError {
|
|
26
|
+
/**
|
|
27
|
+
* @param val Value of a AST node caused the error
|
|
28
|
+
* @param path Path to a node caused the error
|
|
29
|
+
* @param message An error message
|
|
30
|
+
*/
|
|
31
|
+
constructor(val, message) {
|
|
32
|
+
super();
|
|
33
|
+
this.val = val;
|
|
34
|
+
this.message = message;
|
|
35
|
+
this.name = 'MichelsonError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MichelsonError = MichelsonError;
|
|
39
|
+
function isMichelsonError(err) {
|
|
40
|
+
return err instanceof MichelsonError;
|
|
41
|
+
}
|
|
42
|
+
class MichelsonTypeError extends MichelsonError {
|
|
43
|
+
/**
|
|
44
|
+
* @param val Value of a type node caused the error
|
|
45
|
+
* @param data Value of a data node caused the error
|
|
46
|
+
* @param message An error message
|
|
47
|
+
*/
|
|
48
|
+
constructor(val, message, data) {
|
|
49
|
+
super(val, message);
|
|
50
|
+
this.val = val;
|
|
51
|
+
this.message = message;
|
|
52
|
+
this.name = 'MichelsonTypeError';
|
|
53
|
+
if (data !== undefined) {
|
|
54
|
+
this.data = data;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.MichelsonTypeError = MichelsonTypeError;
|
|
59
|
+
// Ad hoc big integer parser
|
|
60
|
+
class LongInteger {
|
|
61
|
+
append(c) {
|
|
62
|
+
let i = 0;
|
|
63
|
+
while (c !== 0 || i < this.buf.length) {
|
|
64
|
+
const m = (this.buf[i] || 0) * 10 + c;
|
|
65
|
+
this.buf[i++] = m % 256;
|
|
66
|
+
c = Math.floor(m / 256);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
constructor(arg) {
|
|
70
|
+
this.neg = false;
|
|
71
|
+
this.buf = [];
|
|
72
|
+
if (arg === undefined) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (typeof arg === 'string') {
|
|
76
|
+
for (let i = 0; i < arg.length; i++) {
|
|
77
|
+
const c = arg.charCodeAt(i);
|
|
78
|
+
if (i === 0 && c === 0x2d) {
|
|
79
|
+
this.neg = true;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (c < 0x30 || c > 0x39) {
|
|
83
|
+
throw new errors_1.LongIntegerError(`unexpected character in integer constant "${arg[i]}"`);
|
|
84
|
+
}
|
|
85
|
+
this.append(c - 0x30);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (arg < 0) {
|
|
90
|
+
this.neg = true;
|
|
91
|
+
this.append(-arg);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.append(arg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
cmp(arg) {
|
|
98
|
+
if (this.neg !== arg.neg) {
|
|
99
|
+
return (arg.neg ? 1 : 0) - (this.neg ? 1 : 0);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
let ret = 0;
|
|
103
|
+
if (this.buf.length !== arg.buf.length) {
|
|
104
|
+
ret = this.buf.length < arg.buf.length ? -1 : 1;
|
|
105
|
+
}
|
|
106
|
+
else if (this.buf.length !== 0) {
|
|
107
|
+
let i = arg.buf.length - 1;
|
|
108
|
+
while (i >= 0 && this.buf[i] === arg.buf[i]) {
|
|
109
|
+
i--;
|
|
110
|
+
}
|
|
111
|
+
ret = i < 0 ? 0 : this.buf[i] < arg.buf[i] ? -1 : 1;
|
|
112
|
+
}
|
|
113
|
+
return !this.neg ? ret : ret === 0 ? 0 : -ret;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
get sign() {
|
|
117
|
+
return this.buf.length === 0 ? 0 : this.neg ? -1 : 1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.LongInteger = LongInteger;
|
|
121
|
+
function parseBytes(s) {
|
|
122
|
+
const ret = [];
|
|
123
|
+
for (let i = 0; i < s.length; i += 2) {
|
|
124
|
+
const x = parseInt(s.slice(i, i + 2), 16);
|
|
125
|
+
if (Number.isNaN(x)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
ret.push(x);
|
|
129
|
+
}
|
|
130
|
+
return ret;
|
|
131
|
+
}
|
|
132
|
+
function compareBytes(a, b) {
|
|
133
|
+
if (a.length !== b.length) {
|
|
134
|
+
return a.length < b.length ? -1 : 1;
|
|
135
|
+
}
|
|
136
|
+
else if (a.length !== 0) {
|
|
137
|
+
let i = 0;
|
|
138
|
+
while (i < a.length && a[i] === b[i]) {
|
|
139
|
+
i++;
|
|
140
|
+
}
|
|
141
|
+
return i === a.length ? 0 : a[i] < b[i] ? -1 : 1;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function isDecimal(x) {
|
|
148
|
+
try {
|
|
149
|
+
new LongInteger(x);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
catch (_a) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function isNatural(x) {
|
|
157
|
+
try {
|
|
158
|
+
return new LongInteger(x).sign >= 0;
|
|
159
|
+
}
|
|
160
|
+
catch (_a) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const annRe = /^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z.%@]*)?)$/;
|
|
165
|
+
function unpackAnnotations(p, opt) {
|
|
166
|
+
if (Array.isArray(p)) {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
let field;
|
|
170
|
+
let type;
|
|
171
|
+
let vars;
|
|
172
|
+
if (p.annots !== undefined) {
|
|
173
|
+
for (const v of p.annots) {
|
|
174
|
+
if (v.length !== 0) {
|
|
175
|
+
if (!annRe.test(v) ||
|
|
176
|
+
(!(opt === null || opt === void 0 ? void 0 : opt.specialVar) && (v === '@%' || v === '@%%')) ||
|
|
177
|
+
(!(opt === null || opt === void 0 ? void 0 : opt.specialFields) && v === '%@')) {
|
|
178
|
+
throw new MichelsonError(p, `${p.prim}: unexpected annotation: ${v}`);
|
|
179
|
+
}
|
|
180
|
+
switch (v[0]) {
|
|
181
|
+
case '%':
|
|
182
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.emptyFields) || v.length > 1) {
|
|
183
|
+
field = field || [];
|
|
184
|
+
field.push(v);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case ':':
|
|
188
|
+
if (v.length > 1) {
|
|
189
|
+
type = type || [];
|
|
190
|
+
type.push(v);
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case '@':
|
|
194
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.emptyVar) || v.length > 1) {
|
|
195
|
+
vars = vars || [];
|
|
196
|
+
vars.push(v);
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { f: field, t: type, v: vars };
|
|
204
|
+
}
|
|
205
|
+
exports.tezosPrefix = {
|
|
206
|
+
BlockHash: [32, [1, 52]], // B(51)
|
|
207
|
+
OperationHash: [32, [5, 116]], // o(51)
|
|
208
|
+
OperationListHash: [32, [133, 233]], // Lo(52)
|
|
209
|
+
OperationListListHash: [32, [29, 159, 109]], // LLo(53)
|
|
210
|
+
ProtocolHash: [32, [2, 170]], // P(51)
|
|
211
|
+
ContextHash: [32, [79, 199]], // Co(52)
|
|
212
|
+
ED25519PublicKeyHash: [20, [6, 161, 159]], // tz1(36)
|
|
213
|
+
SECP256K1PublicKeyHash: [20, [6, 161, 161]], // tz2(36)
|
|
214
|
+
P256PublicKeyHash: [20, [6, 161, 164]], // tz3(36)
|
|
215
|
+
ContractHash: [20, [2, 90, 121]], // KT1(36)
|
|
216
|
+
CryptoboxPublicKeyHash: [16, [153, 103]], // id(30)
|
|
217
|
+
ED25519Seed: [32, [13, 15, 58, 7]], // edsk(54)
|
|
218
|
+
ED25519PublicKey: [32, [13, 15, 37, 217]], // edpk(54)
|
|
219
|
+
SECP256K1SecretKey: [32, [17, 162, 224, 201]], // spsk(54)
|
|
220
|
+
P256SecretKey: [32, [16, 81, 238, 189]], // p2sk(54)
|
|
221
|
+
ED25519EncryptedSeed: [56, [7, 90, 60, 179, 41]], // edesk(88)
|
|
222
|
+
SECP256K1EncryptedSecretKey: [56, [9, 237, 241, 174, 150]], // spesk(88)
|
|
223
|
+
P256EncryptedSecretKey: [56, [9, 48, 57, 115, 171]], // p2esk(88)
|
|
224
|
+
SECP256K1PublicKey: [33, [3, 254, 226, 86]], // sppk(55)
|
|
225
|
+
P256PublicKey: [33, [3, 178, 139, 127]], // p2pk(55)
|
|
226
|
+
SECP256K1Scalar: [33, [38, 248, 136]], // SSp(53)
|
|
227
|
+
SECP256K1Element: [33, [5, 92, 0]], // GSp(54)
|
|
228
|
+
ED25519SecretKey: [64, [43, 246, 78, 7]], // edsk(98)
|
|
229
|
+
ED25519Signature: [64, [9, 245, 205, 134, 18]], // edsig(99)
|
|
230
|
+
SECP256K1Signature: [64, [13, 115, 101, 19, 63]], // spsig1(99)
|
|
231
|
+
P256Signature: [64, [54, 240, 44, 52]], // p2sig(98)
|
|
232
|
+
GenericSignature: [64, [4, 130, 43]], // sig(96)
|
|
233
|
+
ChainID: [4, [87, 82, 0]],
|
|
234
|
+
RollupAddress: [20, [1, 128, 120, 31]],
|
|
235
|
+
};
|
|
236
|
+
function checkDecodeTezosID(id, ...types) {
|
|
237
|
+
const buf = (0, base58_1.decodeBase58Check)(id);
|
|
238
|
+
for (const t of types) {
|
|
239
|
+
const [plen, p] = exports.tezosPrefix[t];
|
|
240
|
+
if (buf.length === plen + p.length) {
|
|
241
|
+
let i = 0;
|
|
242
|
+
while (i < p.length && buf[i] === p[i]) {
|
|
243
|
+
i++;
|
|
244
|
+
}
|
|
245
|
+
if (i === p.length) {
|
|
246
|
+
return [t, buf.slice(p.length)];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
function encodeTezosID(id, data) {
|
|
253
|
+
const [plen, p] = exports.tezosPrefix[id];
|
|
254
|
+
if (data.length !== plen) {
|
|
255
|
+
throw new errors_1.TezosIdEncodeError(`Incorrect data length for ${id}: ${data.length}`);
|
|
256
|
+
}
|
|
257
|
+
return (0, base58_1.encodeBase58Check)([...p, ...data]);
|
|
258
|
+
}
|
|
259
|
+
function unpackComb(id, v) {
|
|
260
|
+
const vv = v;
|
|
261
|
+
const args = Array.isArray(vv) ? vv : vv.args;
|
|
262
|
+
if (args.length === 2) {
|
|
263
|
+
// it's a way to make a union of two interfaces not an interface with two independent properties of union types
|
|
264
|
+
const ret = id === 'pair'
|
|
265
|
+
? {
|
|
266
|
+
prim: 'pair',
|
|
267
|
+
args,
|
|
268
|
+
}
|
|
269
|
+
: {
|
|
270
|
+
prim: 'Pair',
|
|
271
|
+
args,
|
|
272
|
+
};
|
|
273
|
+
return ret;
|
|
274
|
+
}
|
|
275
|
+
return Object.assign(Object.assign({}, (Array.isArray(vv) ? { prim: id } : vv)), { args: [
|
|
276
|
+
args[0],
|
|
277
|
+
{
|
|
278
|
+
prim: id,
|
|
279
|
+
args: args.slice(1),
|
|
280
|
+
},
|
|
281
|
+
] });
|
|
282
|
+
}
|
|
283
|
+
function isPairType(t) {
|
|
284
|
+
return Array.isArray(t) || t.prim === 'pair';
|
|
285
|
+
}
|
|
286
|
+
function isPairData(d) {
|
|
287
|
+
return Array.isArray(d) || ('prim' in d && d.prim === 'Pair');
|
|
288
|
+
}
|
|
289
|
+
const rfc3339Re = /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[T ]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):([0-5][0-9]))$/;
|
|
290
|
+
function parseDate(a) {
|
|
291
|
+
if ('string' in a) {
|
|
292
|
+
if (isNatural(a.string)) {
|
|
293
|
+
return new Date(parseInt(a.string, 10));
|
|
294
|
+
}
|
|
295
|
+
else if (rfc3339Re.test(a.string)) {
|
|
296
|
+
const x = new Date(a.string);
|
|
297
|
+
if (!Number.isNaN(x.valueOf)) {
|
|
298
|
+
return x;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else if (isDecimal(a.int)) {
|
|
303
|
+
return new Date(parseInt(a.int, 10));
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
function parseHex(s) {
|
|
308
|
+
const res = [];
|
|
309
|
+
for (let i = 0; i < s.length; i += 2) {
|
|
310
|
+
const ss = s.slice(i, i + 2);
|
|
311
|
+
const x = parseInt(ss, 16);
|
|
312
|
+
if (Number.isNaN(x)) {
|
|
313
|
+
throw new errors_1.HexParseError(ss);
|
|
314
|
+
}
|
|
315
|
+
res.push(x);
|
|
316
|
+
}
|
|
317
|
+
return res;
|
|
318
|
+
}
|
|
319
|
+
function hexBytes(bytes) {
|
|
320
|
+
return bytes.map((x) => ((x >> 4) & 0xf).toString(16) + (x & 0xf).toString(16)).join('');
|
|
321
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VERSION = void 0;
|
|
4
|
+
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
5
|
+
exports.VERSION = {
|
|
6
|
+
"commitHash": "f798e97ba998acc2cc5310278d812448591bd312",
|
|
7
|
+
"version": "24.0.2"
|
|
8
|
+
};
|