@taquito/michel-codec 10.2.1 → 11.0.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/dist/lib/base58.js +8 -9
- package/dist/lib/base58.js.map +1 -1
- package/dist/lib/binary.js +6 -7
- package/dist/lib/binary.js.map +1 -1
- package/dist/lib/formatters.js.map +1 -1
- package/dist/lib/macros.js +29 -28
- package/dist/lib/macros.js.map +1 -1
- package/dist/lib/micheline-emitter.js.map +1 -1
- package/dist/lib/micheline-parser.js +18 -20
- package/dist/lib/micheline-parser.js.map +1 -1
- package/dist/lib/michelson-contract.js.map +1 -1
- package/dist/lib/michelson-typecheck.js +359 -315
- package/dist/lib/michelson-typecheck.js.map +1 -1
- package/dist/lib/michelson-types.js +33 -2
- package/dist/lib/michelson-types.js.map +1 -1
- package/dist/lib/michelson-validator.js +74 -23
- package/dist/lib/michelson-validator.js.map +1 -1
- package/dist/lib/scan.js +0 -2
- package/dist/lib/scan.js.map +1 -1
- package/dist/lib/utils.js +5 -8
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/version.js +2 -2
- package/dist/taquito-michel-codec.es5.js +519 -386
- package/dist/taquito-michel-codec.es5.js.map +1 -1
- package/dist/taquito-michel-codec.umd.js +521 -385
- package/dist/taquito-michel-codec.umd.js.map +1 -1
- package/dist/types/micheline-parser.d.ts +5 -5
- package/dist/types/michelson-typecheck.d.ts +4 -1
- package/dist/types/michelson-types.d.ts +23 -34
- package/dist/types/michelson-validator.d.ts +5 -4
- package/dist/types/taquito-michel-codec.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/package.json +4 -4
- package/signature.json +1 -1
|
@@ -112,10 +112,11 @@ function __read(o, n) {
|
|
|
112
112
|
return ar;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
/** @deprecated */
|
|
116
|
+
function __spread() {
|
|
117
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
118
|
+
ar = ar.concat(__read(arguments[i]));
|
|
119
|
+
return ar;
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
var ScanError = /** @class */ (function (_super) {
|
|
@@ -271,17 +272,47 @@ function scan(src, scanComments) {
|
|
|
271
272
|
var refContract = Symbol("ref_contract");
|
|
272
273
|
var Protocol;
|
|
273
274
|
(function (Protocol) {
|
|
275
|
+
Protocol["Ps9mPmXa"] = "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P";
|
|
276
|
+
Protocol["PtCJ7pwo"] = "PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY";
|
|
277
|
+
Protocol["PsYLVpVv"] = "PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt";
|
|
278
|
+
Protocol["PsddFKi3"] = "PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP";
|
|
274
279
|
Protocol["Pt24m4xi"] = "Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd";
|
|
275
280
|
Protocol["PsBABY5H"] = "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU";
|
|
276
281
|
Protocol["PsBabyM1"] = "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS";
|
|
277
282
|
Protocol["PsCARTHA"] = "PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb";
|
|
278
283
|
Protocol["PsDELPH1"] = "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo";
|
|
284
|
+
Protocol["PtEdoTez"] = "PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq";
|
|
279
285
|
Protocol["PtEdo2Zk"] = "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA";
|
|
286
|
+
Protocol["PsFLoren"] = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i";
|
|
280
287
|
Protocol["PsFLorena"] = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i";
|
|
288
|
+
Protocol["PtGRANAD"] = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV";
|
|
281
289
|
Protocol["PtGRANADs"] = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV";
|
|
282
290
|
Protocol["PtHangzH"] = "PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r";
|
|
291
|
+
Protocol["PtHangz2"] = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx";
|
|
292
|
+
Protocol["PtIdiaza"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"; // temporary protocol hash
|
|
283
293
|
})(Protocol || (Protocol = {}));
|
|
284
|
-
var DefaultProtocol = Protocol.
|
|
294
|
+
var DefaultProtocol = Protocol.PtGRANAD;
|
|
295
|
+
var protoLevel = {
|
|
296
|
+
Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P: 0,
|
|
297
|
+
PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY: 1,
|
|
298
|
+
PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt: 2,
|
|
299
|
+
PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP: 3,
|
|
300
|
+
Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd: 4,
|
|
301
|
+
PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU: 5,
|
|
302
|
+
PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS: 5,
|
|
303
|
+
PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb: 6,
|
|
304
|
+
PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo: 7,
|
|
305
|
+
PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq: 8,
|
|
306
|
+
PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA: 8,
|
|
307
|
+
PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i: 9,
|
|
308
|
+
PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV: 10,
|
|
309
|
+
PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r: 11,
|
|
310
|
+
PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx: 11,
|
|
311
|
+
ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 12
|
|
312
|
+
};
|
|
313
|
+
function ProtoGreaterOfEqual(a, b) {
|
|
314
|
+
return protoLevel[a] >= protoLevel[b];
|
|
315
|
+
}
|
|
285
316
|
|
|
286
317
|
var MacroError = /** @class */ (function (_super) {
|
|
287
318
|
__extends(MacroError, _super);
|
|
@@ -324,11 +355,13 @@ function parsePairUnpairExpr(p, expr, annotations, agg) {
|
|
|
324
355
|
var c = expr[i++];
|
|
325
356
|
switch (c) {
|
|
326
357
|
case "P":
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
358
|
+
{
|
|
359
|
+
var _a = parsePairUnpairExpr(p, expr.slice(i), annotations.slice(ai), agg), r = _a.r, n = _a.n, an = _a.an;
|
|
360
|
+
lexpr = r;
|
|
361
|
+
i += n;
|
|
362
|
+
ai += an;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
332
365
|
case "A":
|
|
333
366
|
if (ai !== annotations.length) {
|
|
334
367
|
ann[0] = annotations[ai++];
|
|
@@ -345,14 +378,16 @@ function parsePairUnpairExpr(p, expr, annotations, agg) {
|
|
|
345
378
|
c = expr[i++];
|
|
346
379
|
switch (c) {
|
|
347
380
|
case "P":
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
381
|
+
{
|
|
382
|
+
var _b = parsePairUnpairExpr(p, expr.slice(i), annotations.slice(ai), agg), r = _b.r, n = _b.n, an = _b.an;
|
|
383
|
+
rexpr = r.map(function (_a) {
|
|
384
|
+
var _b = __read(_a, 2), v = _b[0], a = _b[1];
|
|
385
|
+
return [v + 1, a];
|
|
386
|
+
});
|
|
387
|
+
i += n;
|
|
388
|
+
ai += an;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
356
391
|
case "I":
|
|
357
392
|
if (ai !== annotations.length) {
|
|
358
393
|
ann[1] = annotations[ai++];
|
|
@@ -379,7 +414,7 @@ function parseSetMapCadr(p, expr, vann, term) {
|
|
|
379
414
|
},
|
|
380
415
|
{ prim: "CDR", annots: ["@%%"] },
|
|
381
416
|
{ prim: "SWAP" },
|
|
382
|
-
{ prim: "PAIR", annots:
|
|
417
|
+
{ prim: "PAIR", annots: __spread(["%@", "%@"], vann) },
|
|
383
418
|
] : term.a;
|
|
384
419
|
case "D":
|
|
385
420
|
return expr.length > 1 ?
|
|
@@ -393,7 +428,7 @@ function parseSetMapCadr(p, expr, vann, term) {
|
|
|
393
428
|
]],
|
|
394
429
|
},
|
|
395
430
|
{ prim: "CAR", annots: ["@%%"] },
|
|
396
|
-
{ prim: "PAIR", annots:
|
|
431
|
+
{ prim: "PAIR", annots: __spread(["%@", "%@"], vann) },
|
|
397
432
|
] : term.d;
|
|
398
433
|
default:
|
|
399
434
|
throw new MacroError(p, p.prim + ": unexpected character: " + c);
|
|
@@ -617,10 +652,10 @@ function expandMacros(ex, opt) {
|
|
|
617
652
|
if (pairRe.test(ex.prim)) {
|
|
618
653
|
if (assertArgs$1(ex, 0)) {
|
|
619
654
|
var _a = filterAnnotations(ex.annots), fields = _a.fields, rest_1 = _a.rest;
|
|
620
|
-
var r_1 = parsePairUnpairExpr(ex, ex.prim.slice(1), fields, function (l, r, top) { return
|
|
655
|
+
var r_1 = parsePairUnpairExpr(ex, ex.prim.slice(1), fields, function (l, r, top) { return __spread((l || []), (r || []), [top]); }).r;
|
|
621
656
|
return r_1.map(function (_a, i) {
|
|
622
657
|
var _b = __read(_a, 2), v = _b[0], a = _b[1];
|
|
623
|
-
var ann =
|
|
658
|
+
var ann = __spread(trimLast(a, null).map(function (v) { return v === null ? "%" : v; }), ((v === 0 && i === r_1.length - 1) ? rest_1 : []));
|
|
624
659
|
var leaf = mkPrim({ prim: "PAIR", annots: ann.length !== 0 ? ann : undefined, });
|
|
625
660
|
return v === 0 ? leaf : {
|
|
626
661
|
prim: "DIP",
|
|
@@ -631,13 +666,13 @@ function expandMacros(ex, opt) {
|
|
|
631
666
|
}
|
|
632
667
|
// UNPAPPAIIR macro
|
|
633
668
|
if (unpairRe.test(ex.prim)) {
|
|
634
|
-
if (proto
|
|
669
|
+
if (ProtoGreaterOfEqual(proto, Protocol.PtEdo2Zk)) {
|
|
635
670
|
if (ex.prim === "UNPAIR") {
|
|
636
671
|
return ex;
|
|
637
672
|
}
|
|
638
673
|
if (assertArgs$1(ex, 0)) {
|
|
639
674
|
// 008_edo: annotations are deprecated
|
|
640
|
-
var r = parsePairUnpairExpr(ex, ex.prim.slice(3), [], function (l, r, top) { return
|
|
675
|
+
var r = parsePairUnpairExpr(ex, ex.prim.slice(3), [], function (l, r, top) { return __spread([top], (r || []), (l || [])); }).r;
|
|
641
676
|
return r.map(function (_a) {
|
|
642
677
|
var _b = __read(_a, 1), v = _b[0];
|
|
643
678
|
var leaf = mkPrim({
|
|
@@ -651,7 +686,7 @@ function expandMacros(ex, opt) {
|
|
|
651
686
|
}
|
|
652
687
|
}
|
|
653
688
|
else if (assertArgs$1(ex, 0)) {
|
|
654
|
-
var r = parsePairUnpairExpr(ex, ex.prim.slice(3), ex.annots || [], function (l, r, top) { return
|
|
689
|
+
var r = parsePairUnpairExpr(ex, ex.prim.slice(3), ex.annots || [], function (l, r, top) { return __spread([top], (r || []), (l || [])); }).r;
|
|
655
690
|
return r.map(function (_a) {
|
|
656
691
|
var _b = __read(_a, 2), v = _b[0], a = _b[1];
|
|
657
692
|
var leaf = [
|
|
@@ -672,7 +707,7 @@ function expandMacros(ex, opt) {
|
|
|
672
707
|
// C[AD]+R macro
|
|
673
708
|
if (cadrRe.test(ex.prim)) {
|
|
674
709
|
if (assertArgs$1(ex, 0)) {
|
|
675
|
-
var ch_1 =
|
|
710
|
+
var ch_1 = __spread(ex.prim.slice(1, ex.prim.length - 1));
|
|
676
711
|
return ch_1.map(function (c, i) {
|
|
677
712
|
var ann = i === ch_1.length - 1 ? ex.annots : undefined;
|
|
678
713
|
switch (c) {
|
|
@@ -773,7 +808,7 @@ function expandMacros(ex, opt) {
|
|
|
773
808
|
while (ex.prim[1 + n] === "U") {
|
|
774
809
|
n++;
|
|
775
810
|
}
|
|
776
|
-
if (proto
|
|
811
|
+
if (ProtoGreaterOfEqual(proto, Protocol.PtEdo2Zk)) {
|
|
777
812
|
if (n === 1) {
|
|
778
813
|
return ex;
|
|
779
814
|
}
|
|
@@ -853,12 +888,12 @@ var JSONParseError = /** @class */ (function (_super) {
|
|
|
853
888
|
}
|
|
854
889
|
return JSONParseError;
|
|
855
890
|
}(Error));
|
|
856
|
-
var errEOF = new MichelineParseError(null,
|
|
891
|
+
var errEOF = new MichelineParseError(null, "Unexpected EOF");
|
|
857
892
|
function isAnnotation(tok) {
|
|
858
|
-
return tok.t === Literal.Ident && (tok.v[0] ===
|
|
893
|
+
return tok.t === Literal.Ident && (tok.v[0] === "@" || tok.v[0] === "%" || tok.v[0] === ":");
|
|
859
894
|
}
|
|
860
|
-
var intRe = new RegExp(
|
|
861
|
-
var bytesRe = new RegExp(
|
|
895
|
+
var intRe = new RegExp("^-?[0-9]+$");
|
|
896
|
+
var bytesRe = new RegExp("^([0-9a-fA-F]{2})*$");
|
|
862
897
|
/**
|
|
863
898
|
* Converts and validates Michelson expressions between JSON-based Michelson and Micheline
|
|
864
899
|
*
|
|
@@ -943,7 +978,7 @@ var Parser = /** @class */ (function () {
|
|
|
943
978
|
}
|
|
944
979
|
break;
|
|
945
980
|
}
|
|
946
|
-
else if (tok_1.value.t ===
|
|
981
|
+
else if (tok_1.value.t === ")") {
|
|
947
982
|
if (!expectBracket) {
|
|
948
983
|
throw new MichelineParseError(tok_1.value, "unexpected closing bracket");
|
|
949
984
|
}
|
|
@@ -979,7 +1014,7 @@ var Parser = /** @class */ (function () {
|
|
|
979
1014
|
_a);
|
|
980
1015
|
for (;;) {
|
|
981
1016
|
var t = scanner.next();
|
|
982
|
-
if (t.done || t.value.t ===
|
|
1017
|
+
if (t.done || t.value.t === "}" || t.value.t === ";") {
|
|
983
1018
|
return [p, t];
|
|
984
1019
|
}
|
|
985
1020
|
if (isAnnotation(t.value)) {
|
|
@@ -1064,7 +1099,7 @@ var Parser = /** @class */ (function () {
|
|
|
1064
1099
|
return _c = { string: JSON.parse(tok.v) }, _c[sourceReference] = { first: tok.first, last: tok.last }, _c;
|
|
1065
1100
|
case Literal.Bytes:
|
|
1066
1101
|
return _d = { bytes: tok.v.slice(2) }, _d[sourceReference] = { first: tok.first, last: tok.last }, _d;
|
|
1067
|
-
case
|
|
1102
|
+
case "{":
|
|
1068
1103
|
return this.parseSequenceExpr(scanner, tok);
|
|
1069
1104
|
default:
|
|
1070
1105
|
return this.parseListExpr(scanner, tok);
|
|
@@ -1152,7 +1187,7 @@ var Parser = /** @class */ (function () {
|
|
|
1152
1187
|
try {
|
|
1153
1188
|
for (var src_1 = __values(src), src_1_1 = src_1.next(); !src_1_1.done; src_1_1 = src_1.next()) {
|
|
1154
1189
|
var n = src_1_1.value;
|
|
1155
|
-
if (n === null || typeof n !==
|
|
1190
|
+
if (n === null || typeof n !== "object") {
|
|
1156
1191
|
throw new JSONParseError(n, "unexpected sequence element: " + n);
|
|
1157
1192
|
}
|
|
1158
1193
|
ret.push(this.parseJSON(n));
|
|
@@ -1167,9 +1202,9 @@ var Parser = /** @class */ (function () {
|
|
|
1167
1202
|
}
|
|
1168
1203
|
return ret;
|
|
1169
1204
|
}
|
|
1170
|
-
else if (
|
|
1205
|
+
else if ("prim" in src) {
|
|
1171
1206
|
var p = src;
|
|
1172
|
-
if (typeof p.prim ===
|
|
1207
|
+
if (typeof p.prim === "string" &&
|
|
1173
1208
|
(p.annots === undefined || Array.isArray(p.annots)) &&
|
|
1174
1209
|
(p.args === undefined || Array.isArray(p.args))) {
|
|
1175
1210
|
var ret = {
|
|
@@ -1179,7 +1214,7 @@ var Parser = /** @class */ (function () {
|
|
|
1179
1214
|
try {
|
|
1180
1215
|
for (var _d = __values(p.annots), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1181
1216
|
var a = _e.value;
|
|
1182
|
-
if (typeof a !==
|
|
1217
|
+
if (typeof a !== "string") {
|
|
1183
1218
|
throw new JSONParseError(a, "string expected: " + a);
|
|
1184
1219
|
}
|
|
1185
1220
|
}
|
|
@@ -1198,7 +1233,7 @@ var Parser = /** @class */ (function () {
|
|
|
1198
1233
|
try {
|
|
1199
1234
|
for (var _f = __values(p.args), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1200
1235
|
var a = _g.value;
|
|
1201
|
-
if (a === null || typeof a !==
|
|
1236
|
+
if (a === null || typeof a !== "object") {
|
|
1202
1237
|
throw new JSONParseError(a, "unexpected argument: " + a);
|
|
1203
1238
|
}
|
|
1204
1239
|
ret.args.push(this.parseJSON(a));
|
|
@@ -1216,20 +1251,20 @@ var Parser = /** @class */ (function () {
|
|
|
1216
1251
|
}
|
|
1217
1252
|
throw new JSONParseError(src, "malformed prim expression: " + src);
|
|
1218
1253
|
}
|
|
1219
|
-
else if (
|
|
1220
|
-
if (typeof src.string ===
|
|
1254
|
+
else if ("string" in src) {
|
|
1255
|
+
if (typeof src.string === "string") {
|
|
1221
1256
|
return { string: src.string };
|
|
1222
1257
|
}
|
|
1223
1258
|
throw new JSONParseError(src, "malformed string literal: " + src);
|
|
1224
1259
|
}
|
|
1225
|
-
else if (
|
|
1226
|
-
if (typeof src.int ===
|
|
1260
|
+
else if ("int" in src) {
|
|
1261
|
+
if (typeof src.int === "string" && intRe.test(src.int)) {
|
|
1227
1262
|
return { int: src.int };
|
|
1228
1263
|
}
|
|
1229
1264
|
throw new JSONParseError(src, "malformed int literal: " + src);
|
|
1230
1265
|
}
|
|
1231
|
-
else if (
|
|
1232
|
-
if (typeof src.bytes ===
|
|
1266
|
+
else if ("bytes" in src) {
|
|
1267
|
+
if (typeof src.bytes === "string" &&
|
|
1233
1268
|
bytesRe.test(src.bytes)) {
|
|
1234
1269
|
return { bytes: src.bytes };
|
|
1235
1270
|
}
|
|
@@ -1477,15 +1512,15 @@ function sha256(msg) {
|
|
|
1477
1512
|
throw new Error("sha256: message length is too big: " + msg.length);
|
|
1478
1513
|
}
|
|
1479
1514
|
var l = msg.length << 3;
|
|
1480
|
-
var buffer =
|
|
1515
|
+
var buffer = __spread(msg, [
|
|
1481
1516
|
0x80
|
|
1482
|
-
]
|
|
1517
|
+
], (new Array(pad).fill(0)), [
|
|
1483
1518
|
0, 0, 0, 0, (l >> 24) & 0xff, (l >> 16) & 0xff, (l >> 8) & 0xff, l & 0xff,
|
|
1484
1519
|
]);
|
|
1485
1520
|
function ror(x, n) {
|
|
1486
1521
|
return (x >>> n) | (x << (32 - n));
|
|
1487
1522
|
}
|
|
1488
|
-
var h =
|
|
1523
|
+
var h = __spread(H);
|
|
1489
1524
|
var w = new Array(64);
|
|
1490
1525
|
var v = new Array(8);
|
|
1491
1526
|
for (var offset = 0; offset < buffer.length; offset += 64) {
|
|
@@ -1619,7 +1654,7 @@ function encodeBase58(src) {
|
|
|
1619
1654
|
acc.push(0);
|
|
1620
1655
|
}
|
|
1621
1656
|
acc.reverse();
|
|
1622
|
-
return String.fromCharCode.apply(String,
|
|
1657
|
+
return String.fromCharCode.apply(String, __spread(acc.map(function (v) { return base58alphabetBwd[v] + 49; })));
|
|
1623
1658
|
}
|
|
1624
1659
|
function decodeBase58Check(src) {
|
|
1625
1660
|
var buffer = decodeBase58(src);
|
|
@@ -1639,7 +1674,7 @@ function decodeBase58Check(src) {
|
|
|
1639
1674
|
}
|
|
1640
1675
|
function encodeBase58Check(src) {
|
|
1641
1676
|
var sum = sha256(sha256(src));
|
|
1642
|
-
return encodeBase58(
|
|
1677
|
+
return encodeBase58(__spread(src, sum.slice(0, 4)));
|
|
1643
1678
|
}
|
|
1644
1679
|
|
|
1645
1680
|
var MichelsonError = /** @class */ (function (_super) {
|
|
@@ -1787,7 +1822,7 @@ function isNatural(x) {
|
|
|
1787
1822
|
return false;
|
|
1788
1823
|
}
|
|
1789
1824
|
}
|
|
1790
|
-
var annRe = /^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z
|
|
1825
|
+
var annRe = /^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z.%@]*)?)$/;
|
|
1791
1826
|
function unpackAnnotations(p, opt) {
|
|
1792
1827
|
var e_1, _a;
|
|
1793
1828
|
if (Array.isArray(p)) {
|
|
@@ -1905,7 +1940,7 @@ function encodeTezosID(id, data) {
|
|
|
1905
1940
|
if (data.length !== plen) {
|
|
1906
1941
|
throw new Error("incorrect data length for " + id + ": " + data.length);
|
|
1907
1942
|
}
|
|
1908
|
-
return encodeBase58Check(
|
|
1943
|
+
return encodeBase58Check(__spread(p, data));
|
|
1909
1944
|
}
|
|
1910
1945
|
function unpackComb(id, v) {
|
|
1911
1946
|
var vv = v;
|
|
@@ -1970,6 +2005,7 @@ function hexBytes(bytes) {
|
|
|
1970
2005
|
}
|
|
1971
2006
|
|
|
1972
2007
|
// Michelson validator
|
|
2008
|
+
var maxViewNameLength = 31;
|
|
1973
2009
|
var noArgInstructionIDs = {
|
|
1974
2010
|
"ABS": true, "ADD": true, "ADDRESS": true, "AMOUNT": true, "AND": true, "APPLY": true, "BALANCE": true,
|
|
1975
2011
|
"BLAKE2B": true, "CAR": true, "CDR": true, "CHAIN_ID": true, "CHECK_SIGNATURE": true, "COMPARE": true, "CONCAT": true, "CONS": true, "EDIV": true,
|
|
@@ -1978,13 +2014,13 @@ var noArgInstructionIDs = {
|
|
|
1978
2014
|
"NEG": true, "NEQ": true, "NEVER": true, "NOT": true, "NOW": true, "OR": true, "PACK": true, "PAIRING_CHECK": true, "READ_TICKET": true,
|
|
1979
2015
|
"SAPLING_VERIFY_UPDATE": true, "SELF": true, "SELF_ADDRESS": true, "SENDER": true, "SET_DELEGATE": true, "SHA256": true, "SHA3": true,
|
|
1980
2016
|
"SHA512": true, "SIZE": true, "SLICE": true, "SOME": true, "SOURCE": true, "SPLIT_TICKET": true, "SUB": true, "SWAP": true, "TICKET": true,
|
|
1981
|
-
"TOTAL_VOTING_POWER": true, "TRANSFER_TOKENS": true, "UNIT": true, "VOTING_POWER": true, "XOR": true, "RENAME": true,
|
|
2017
|
+
"TOTAL_VOTING_POWER": true, "TRANSFER_TOKENS": true, "UNIT": true, "VOTING_POWER": true, "XOR": true, "RENAME": true, "OPEN_CHEST": true,
|
|
1982
2018
|
};
|
|
1983
2019
|
var instructionIDs = Object.assign({}, noArgInstructionIDs, {
|
|
1984
2020
|
"CONTRACT": true, "CREATE_CONTRACT": true, "DIG": true, "DIP": true, "DROP": true,
|
|
1985
2021
|
"DUG": true, "DUP": true, "EMPTY_BIG_MAP": true, "EMPTY_MAP": true, "EMPTY_SET": true, "GET": true, "IF": true, "IF_CONS": true, "IF_LEFT": true,
|
|
1986
2022
|
"IF_NONE": true, "ITER": true, "LAMBDA": true, "LEFT": true, "LOOP": true, "LOOP_LEFT": true, "MAP": true, "NIL": true, "NONE": true, "PAIR": true,
|
|
1987
|
-
"PUSH": true, "RIGHT": true, "SAPLING_EMPTY_STATE": true, "UNPACK": true, "UNPAIR": true, "UPDATE": true, "CAST": true,
|
|
2023
|
+
"PUSH": true, "RIGHT": true, "SAPLING_EMPTY_STATE": true, "UNPACK": true, "UNPAIR": true, "UPDATE": true, "CAST": true, "VIEW": true,
|
|
1988
2024
|
});
|
|
1989
2025
|
var simpleComparableTypeIDs = {
|
|
1990
2026
|
"unit": true, "never": true, "bool": true, "int": true, "nat": true, "string": true,
|
|
@@ -1995,13 +2031,14 @@ var typeIDs = Object.assign({}, simpleComparableTypeIDs, {
|
|
|
1995
2031
|
"or": true, "pair": true, "set": true, "big_map": true, "contract": true, "lambda": true,
|
|
1996
2032
|
"list": true, "map": true, "operation": true, "option": true, "bls12_381_g1": true,
|
|
1997
2033
|
"bls12_381_g2": true, "bls12_381_fr": true, "sapling_transaction": true, "sapling_state": true, "ticket": true,
|
|
2034
|
+
"chest_key": true, "chest": true,
|
|
1998
2035
|
});
|
|
1999
2036
|
var MichelsonValidationError = /** @class */ (function (_super) {
|
|
2000
2037
|
__extends(MichelsonValidationError, _super);
|
|
2001
2038
|
/**
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2039
|
+
* @param val Value of a node caused the error
|
|
2040
|
+
* @param message An error message
|
|
2041
|
+
*/
|
|
2005
2042
|
function MichelsonValidationError(val, message) {
|
|
2006
2043
|
var _this = _super.call(this, val, message) || this;
|
|
2007
2044
|
_this.val = val;
|
|
@@ -2045,6 +2082,12 @@ function assertIntLiteral(ex) {
|
|
|
2045
2082
|
}
|
|
2046
2083
|
throw new MichelsonValidationError(ex, "int literal expected");
|
|
2047
2084
|
}
|
|
2085
|
+
function assertStringLiteral(ex) {
|
|
2086
|
+
if ("string" in ex) {
|
|
2087
|
+
return true;
|
|
2088
|
+
}
|
|
2089
|
+
throw new MichelsonValidationError(ex, "string literal expected");
|
|
2090
|
+
}
|
|
2048
2091
|
function assertArgs(ex, n) {
|
|
2049
2092
|
var _a;
|
|
2050
2093
|
if ((n === 0 && ex.args === undefined) || ((_a = ex.args) === null || _a === void 0 ? void 0 : _a.length) === n) {
|
|
@@ -2221,6 +2264,17 @@ function assertMichelsonInstruction(ex) {
|
|
|
2221
2264
|
}
|
|
2222
2265
|
}
|
|
2223
2266
|
break;
|
|
2267
|
+
case "VIEW":
|
|
2268
|
+
/* istanbul ignore else */
|
|
2269
|
+
if (assertArgs(ex, 2)) {
|
|
2270
|
+
if (assertStringLiteral(ex.args[0])) {
|
|
2271
|
+
assertViewNameValid(ex.args[0]);
|
|
2272
|
+
}
|
|
2273
|
+
if (assertMichelsonType(ex.args[1])) {
|
|
2274
|
+
assertMichelsonPushableType(ex.args[1]);
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
break;
|
|
2224
2278
|
default:
|
|
2225
2279
|
throw new MichelsonValidationError(ex, "instruction expected");
|
|
2226
2280
|
}
|
|
@@ -2314,6 +2368,15 @@ function assertMichelsonBigMapStorableType(ex) {
|
|
|
2314
2368
|
}
|
|
2315
2369
|
return true;
|
|
2316
2370
|
}
|
|
2371
|
+
var viewRe = new RegExp("^[a-zA-Z0-9_.%@]*$");
|
|
2372
|
+
function assertViewNameValid(name) {
|
|
2373
|
+
if (name.string.length > maxViewNameLength) {
|
|
2374
|
+
throw new MichelsonValidationError(name, "view name too long: " + name.string);
|
|
2375
|
+
}
|
|
2376
|
+
if (!viewRe.test(name.string)) {
|
|
2377
|
+
throw new MichelsonValidationError(name, "invalid character(s) in view name: " + name.string);
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2317
2380
|
/**
|
|
2318
2381
|
* Checks if the node is a valid Michelson type expression.
|
|
2319
2382
|
* This is a type guard function which either returns true of throws an exception.
|
|
@@ -2508,33 +2571,57 @@ function assertMichelsonContract(ex) {
|
|
|
2508
2571
|
var e_4, _a;
|
|
2509
2572
|
/* istanbul ignore else */
|
|
2510
2573
|
if (assertSeq(ex)) {
|
|
2511
|
-
var
|
|
2574
|
+
var toplevelSec = {};
|
|
2575
|
+
var views = {};
|
|
2512
2576
|
try {
|
|
2513
2577
|
for (var ex_3 = __values(ex), ex_3_1 = ex_3.next(); !ex_3_1.done; ex_3_1 = ex_3.next()) {
|
|
2514
2578
|
var sec = ex_3_1.value;
|
|
2515
2579
|
if (assertPrim(sec)) {
|
|
2516
|
-
if (sec.prim !== "
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2580
|
+
if (sec.prim !== "view") {
|
|
2581
|
+
if (sec.prim in toplevelSec) {
|
|
2582
|
+
throw new MichelsonValidationError(ex, "duplicate contract section: " + sec.prim);
|
|
2583
|
+
}
|
|
2584
|
+
toplevelSec[sec.prim] = true;
|
|
2521
2585
|
}
|
|
2522
|
-
ent[sec.prim] = true;
|
|
2523
2586
|
/* istanbul ignore else */
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2587
|
+
switch (sec.prim) {
|
|
2588
|
+
case "code":
|
|
2589
|
+
if (assertArgs(sec, 1)) {
|
|
2527
2590
|
/* istanbul ignore else */
|
|
2528
2591
|
if (assertSeq(sec.args[0])) {
|
|
2529
2592
|
assertMichelsonInstruction(sec.args[0]);
|
|
2530
2593
|
}
|
|
2531
|
-
|
|
2532
|
-
|
|
2594
|
+
}
|
|
2595
|
+
break;
|
|
2596
|
+
case "parameter":
|
|
2597
|
+
if (assertArgs(sec, 1)) {
|
|
2533
2598
|
assertMichelsonPassableType(sec.args[0]);
|
|
2534
|
-
|
|
2535
|
-
|
|
2599
|
+
}
|
|
2600
|
+
break;
|
|
2601
|
+
case "storage":
|
|
2602
|
+
if (assertArgs(sec, 1)) {
|
|
2536
2603
|
assertMichelsonStorableType(sec.args[0]);
|
|
2537
|
-
|
|
2604
|
+
}
|
|
2605
|
+
break;
|
|
2606
|
+
case "view":
|
|
2607
|
+
if (assertArgs(sec, 4)) {
|
|
2608
|
+
if (assertStringLiteral(sec.args[0])) {
|
|
2609
|
+
var name_1 = sec.args[0];
|
|
2610
|
+
if (name_1.string in views) {
|
|
2611
|
+
throw new MichelsonValidationError(ex, "duplicate view name: " + name_1.string);
|
|
2612
|
+
}
|
|
2613
|
+
views[name_1.string] = true;
|
|
2614
|
+
assertViewNameValid(name_1);
|
|
2615
|
+
}
|
|
2616
|
+
assertMichelsonPushableType(sec.args[1]);
|
|
2617
|
+
assertMichelsonPushableType(sec.args[2]);
|
|
2618
|
+
if (assertSeq(sec.args[3])) {
|
|
2619
|
+
assertMichelsonInstruction(sec.args[3]);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
break;
|
|
2623
|
+
default:
|
|
2624
|
+
throw new MichelsonValidationError(ex, "unexpected contract section: " + sec.prim);
|
|
2538
2625
|
}
|
|
2539
2626
|
}
|
|
2540
2627
|
}
|
|
@@ -2648,10 +2735,10 @@ var primitives = ["parameter", "storage", "code", "False", "Elt", "Left", "None"
|
|
|
2648
2735
|
"SHA3", "PAIRING_CHECK", "bls12_381_g1", "bls12_381_g2", "bls12_381_fr", "sapling_state",
|
|
2649
2736
|
"sapling_transaction", "SAPLING_EMPTY_STATE", "SAPLING_VERIFY_UPDATE", "ticket", "TICKET",
|
|
2650
2737
|
"READ_TICKET", "SPLIT_TICKET", "JOIN_TICKETS", "GET_AND_UPDATE"];
|
|
2651
|
-
var primTags = Object.assign.apply(Object,
|
|
2738
|
+
var primTags = Object.assign.apply(Object, __spread([{}], primitives.map(function (v, i) {
|
|
2652
2739
|
var _a;
|
|
2653
2740
|
return (_a = {}, _a[v] = i, _a);
|
|
2654
|
-
})))
|
|
2741
|
+
})));
|
|
2655
2742
|
var Tag;
|
|
2656
2743
|
(function (Tag) {
|
|
2657
2744
|
Tag[Tag["Int"] = 0] = "Int";
|
|
@@ -2679,7 +2766,7 @@ var Writer = /** @class */ (function () {
|
|
|
2679
2766
|
});
|
|
2680
2767
|
Writer.prototype.writeBytes = function (val) {
|
|
2681
2768
|
var _a;
|
|
2682
|
-
(_a = this.buffer).push.apply(_a,
|
|
2769
|
+
(_a = this.buffer).push.apply(_a, __spread(val.map(function (v) { return v & 0xff; })));
|
|
2683
2770
|
};
|
|
2684
2771
|
Writer.prototype.writeUint8 = function (val) {
|
|
2685
2772
|
var v = val | 0;
|
|
@@ -4374,10 +4461,6 @@ function assertDataValidInternal(d, t, ctx) {
|
|
|
4374
4461
|
}
|
|
4375
4462
|
}
|
|
4376
4463
|
throw new MichelsonTypeError(t, d, "chain id expected: " + JSON.stringify(d));
|
|
4377
|
-
case "operation":
|
|
4378
|
-
throw new MichelsonTypeError(t, d, "operation type can't be represented as a literal value");
|
|
4379
|
-
case "contract":
|
|
4380
|
-
throw new MichelsonTypeError(t, d, "contract type can't be represented as a literal value");
|
|
4381
4464
|
// Complex types
|
|
4382
4465
|
case "option":
|
|
4383
4466
|
if ("prim" in d) {
|
|
@@ -4485,7 +4568,8 @@ function assertDataValidInternal(d, t, ctx) {
|
|
|
4485
4568
|
throw new MichelsonTypeError(t, d, "sapling state expected: " + JSON.stringify(d));
|
|
4486
4569
|
case "ticket":
|
|
4487
4570
|
assertDataValidInternal(d, {
|
|
4488
|
-
prim: "pair",
|
|
4571
|
+
prim: "pair",
|
|
4572
|
+
args: [
|
|
4489
4573
|
{ prim: "address" },
|
|
4490
4574
|
t.args[0],
|
|
4491
4575
|
{ prim: "nat" },
|
|
@@ -4493,7 +4577,7 @@ function assertDataValidInternal(d, t, ctx) {
|
|
|
4493
4577
|
}, ctx);
|
|
4494
4578
|
return;
|
|
4495
4579
|
default:
|
|
4496
|
-
throw new MichelsonTypeError(t, d, "
|
|
4580
|
+
throw new MichelsonTypeError(t, d, "type " + typeID(t) + " don't have Michelson literal representation");
|
|
4497
4581
|
}
|
|
4498
4582
|
}
|
|
4499
4583
|
function instructionListType(inst, stack, ctx) {
|
|
@@ -4581,7 +4665,7 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4581
4665
|
args[_i] = arguments[_i];
|
|
4582
4666
|
}
|
|
4583
4667
|
try {
|
|
4584
|
-
return fn.apply(void 0,
|
|
4668
|
+
return fn.apply(void 0, __spread(args));
|
|
4585
4669
|
}
|
|
4586
4670
|
catch (err) {
|
|
4587
4671
|
if (err instanceof MichelsonError) {
|
|
@@ -4634,7 +4718,7 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4634
4718
|
var tx = tt;
|
|
4635
4719
|
var t = Array.isArray(tx) ? { prim: "pair", args: tx } : tx;
|
|
4636
4720
|
var src = argAnn(t);
|
|
4637
|
-
var ann = (a.v !== undefined || a.t !== undefined || a.f !== undefined) ?
|
|
4721
|
+
var ann = (a.v !== undefined || a.t !== undefined || a.f !== undefined) ? __spread(((a.v === null ? src.v : a.v) || []), ((a.t === null ? src.t : a.t) || []), ((a.f === null ? src.f : a.f) || [])) : undefined;
|
|
4638
4722
|
t.annots; var rest = __rest(t, ["annots"]);
|
|
4639
4723
|
return __assign(__assign({}, rest), (ann && ann.length !== 0 && { annots: ann }));
|
|
4640
4724
|
}
|
|
@@ -4678,7 +4762,7 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4678
4762
|
}
|
|
4679
4763
|
var right = p.args[1];
|
|
4680
4764
|
if (isPairType(right)) {
|
|
4681
|
-
return
|
|
4765
|
+
return __spread([p.args[0]], getN(right, n, i - 1));
|
|
4682
4766
|
}
|
|
4683
4767
|
else {
|
|
4684
4768
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": at least " + n + " fields are expected");
|
|
@@ -4752,35 +4836,35 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4752
4836
|
if (n === 0) {
|
|
4753
4837
|
throw new MichelsonInstructionError(instruction, stack, "DUP 0 is forbidden");
|
|
4754
4838
|
}
|
|
4755
|
-
var
|
|
4756
|
-
if (typeID(
|
|
4839
|
+
var s = args(n - 1, null)[0];
|
|
4840
|
+
if (typeID(s) === "ticket") {
|
|
4757
4841
|
throw new MichelsonInstructionError(instruction, stack, "ticket can't be DUPed");
|
|
4758
4842
|
}
|
|
4759
|
-
return
|
|
4843
|
+
return __spread([s], stack);
|
|
4760
4844
|
}
|
|
4761
4845
|
case "SWAP":
|
|
4762
4846
|
{
|
|
4763
|
-
var
|
|
4847
|
+
var s = args(0, null, null);
|
|
4764
4848
|
instructionAnn({});
|
|
4765
|
-
return
|
|
4849
|
+
return __spread([s[1], s[0]], stack.slice(2));
|
|
4766
4850
|
}
|
|
4767
4851
|
case "SOME":
|
|
4768
|
-
return
|
|
4852
|
+
return __spread([annotate({ prim: "option", args: [args(0, null)[0]] }, instructionAnn({ t: 1, v: 1 }))], stack.slice(1));
|
|
4769
4853
|
case "UNIT":
|
|
4770
|
-
return
|
|
4854
|
+
return __spread([annotate({ prim: "unit" }, instructionAnn({ v: 1, t: 1 }))], stack);
|
|
4771
4855
|
case "PAIR":
|
|
4772
4856
|
{
|
|
4773
4857
|
var n = instruction.args ? parseInt(instruction.args[0].int, 10) : 2;
|
|
4774
4858
|
if (n < 2) {
|
|
4775
4859
|
throw new MichelsonInstructionError(instruction, stack, "PAIR " + n + " is forbidden");
|
|
4776
4860
|
}
|
|
4777
|
-
var
|
|
4861
|
+
var s = args.apply(void 0, __spread([0], new Array(n).fill(null)));
|
|
4778
4862
|
var ia_1 = instructionAnn({ f: n, t: 1, v: 1 }, { specialFields: true });
|
|
4779
4863
|
var trim_1 = function (s) {
|
|
4780
4864
|
var i = s.lastIndexOf(".");
|
|
4781
4865
|
return s.slice(i > 0 ? i + 1 : 1);
|
|
4782
4866
|
};
|
|
4783
|
-
var retArgs =
|
|
4867
|
+
var retArgs = s.map(function (v, i) {
|
|
4784
4868
|
var _a;
|
|
4785
4869
|
var va = argAnn(v);
|
|
4786
4870
|
var f = ia_1.f && ia_1.f.length > i && ia_1.f[i] !== "%" ?
|
|
@@ -4790,12 +4874,12 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4790
4874
|
undefined;
|
|
4791
4875
|
return annotate(v, { v: null, t: null, f: f });
|
|
4792
4876
|
});
|
|
4793
|
-
return
|
|
4877
|
+
return __spread([
|
|
4794
4878
|
annotate({
|
|
4795
4879
|
prim: "pair",
|
|
4796
4880
|
args: retArgs,
|
|
4797
4881
|
}, { t: ia_1.t, v: ia_1.v })
|
|
4798
|
-
],
|
|
4882
|
+
], stack.slice(n));
|
|
4799
4883
|
}
|
|
4800
4884
|
case "UNPAIR":
|
|
4801
4885
|
{
|
|
@@ -4803,55 +4887,55 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4803
4887
|
if (n < 2) {
|
|
4804
4888
|
throw new MichelsonInstructionError(instruction, stack, "UNPAIR " + n + " is forbidden");
|
|
4805
4889
|
}
|
|
4806
|
-
var
|
|
4890
|
+
var s_1 = args(0, ["pair"])[0];
|
|
4807
4891
|
var ia_2 = instructionAnn({ f: 2, v: 2 }, { specialVar: true });
|
|
4808
|
-
var fields = getN(
|
|
4809
|
-
return
|
|
4892
|
+
var fields = getN(s_1, n);
|
|
4893
|
+
return __spread(fields.map(function (field, i) { return annotateField(s_1, field, ia_2, i, i === 0 ? "car" : "cdr"); }), stack.slice(1));
|
|
4810
4894
|
}
|
|
4811
4895
|
case "CAR":
|
|
4812
4896
|
case "CDR":
|
|
4813
4897
|
{
|
|
4814
|
-
var
|
|
4815
|
-
var field =
|
|
4898
|
+
var s = unpackComb("pair", args(0, ["pair"])[0]);
|
|
4899
|
+
var field = s.args[instruction.prim === "CAR" ? 0 : 1];
|
|
4816
4900
|
var ia = instructionAnn({ f: 1, v: 1 }, { specialVar: true });
|
|
4817
|
-
return
|
|
4901
|
+
return __spread([annotateField(s, field, ia, 0, instruction.prim.toLocaleLowerCase())], stack.slice(1));
|
|
4818
4902
|
}
|
|
4819
4903
|
case "CONS":
|
|
4820
4904
|
{
|
|
4821
|
-
var
|
|
4822
|
-
ensureTypesEqual(
|
|
4823
|
-
return
|
|
4905
|
+
var s = args(0, null, ["list"]);
|
|
4906
|
+
ensureTypesEqual(s[0], s[1].args[0]);
|
|
4907
|
+
return __spread([annotateVar({ prim: "list", args: [s[1].args[0]] })], stack.slice(2));
|
|
4824
4908
|
}
|
|
4825
4909
|
case "SIZE":
|
|
4826
4910
|
args(0, ["string", "list", "set", "map", "bytes"]);
|
|
4827
|
-
return
|
|
4911
|
+
return __spread([annotateVar({ prim: "nat" })], stack.slice(1));
|
|
4828
4912
|
case "MEM":
|
|
4829
4913
|
{
|
|
4830
|
-
var
|
|
4831
|
-
ensureComparableType(
|
|
4832
|
-
ensureTypesEqual(
|
|
4833
|
-
return
|
|
4914
|
+
var s = args(0, null, ["set", "map", "big_map"]);
|
|
4915
|
+
ensureComparableType(s[0]);
|
|
4916
|
+
ensureTypesEqual(s[0], s[1].args[0]);
|
|
4917
|
+
return __spread([annotateVar({ prim: "bool" })], stack.slice(2));
|
|
4834
4918
|
}
|
|
4835
4919
|
case "GET":
|
|
4836
4920
|
if (instruction.args) {
|
|
4837
4921
|
// comb operation
|
|
4838
4922
|
var n = parseInt(instruction.args[0].int, 10);
|
|
4839
|
-
var
|
|
4840
|
-
return
|
|
4923
|
+
var s = args(0, ["pair"])[0];
|
|
4924
|
+
return __spread([annotateVar(getNth(s, n))], stack.slice(1));
|
|
4841
4925
|
}
|
|
4842
4926
|
else {
|
|
4843
4927
|
// map operation
|
|
4844
|
-
var
|
|
4845
|
-
ensureComparableType(
|
|
4846
|
-
ensureTypesEqual(
|
|
4847
|
-
return
|
|
4928
|
+
var s = args(0, null, ["map", "big_map"]);
|
|
4929
|
+
ensureComparableType(s[0]);
|
|
4930
|
+
ensureTypesEqual(s[0], s[1].args[0]);
|
|
4931
|
+
return __spread([annotateVar({ prim: "option", args: [s[1].args[1]] })], stack.slice(2));
|
|
4848
4932
|
}
|
|
4849
4933
|
case "UPDATE":
|
|
4850
4934
|
if (instruction.args) {
|
|
4851
4935
|
// comb operation
|
|
4852
4936
|
var n = parseInt(instruction.args[0].int, 10);
|
|
4853
|
-
var
|
|
4854
|
-
return
|
|
4937
|
+
var s = args(0, null, ["pair"]);
|
|
4938
|
+
return __spread([annotateVar(updateNth(s[1], s[0], n))], stack.slice(2));
|
|
4855
4939
|
}
|
|
4856
4940
|
else {
|
|
4857
4941
|
// map operation
|
|
@@ -4860,94 +4944,94 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4860
4944
|
if (s0[1].prim === "bool") {
|
|
4861
4945
|
var s1_1 = args(2, ["set"]);
|
|
4862
4946
|
ensureTypesEqual(s0[0], s1_1[0].args[0]);
|
|
4863
|
-
return
|
|
4947
|
+
return __spread([annotateVar({
|
|
4864
4948
|
prim: "set",
|
|
4865
4949
|
args: [annotate(s0[0], { t: null })],
|
|
4866
|
-
})],
|
|
4950
|
+
})], stack.slice(3));
|
|
4867
4951
|
}
|
|
4868
4952
|
var s1 = args(2, ["map", "big_map"]);
|
|
4869
4953
|
ensureTypesEqual(s0[0], s1[0].args[0]);
|
|
4870
4954
|
if (s1[0].prim === "map") {
|
|
4871
|
-
return
|
|
4955
|
+
return __spread([annotateVar({
|
|
4872
4956
|
prim: "map",
|
|
4873
4957
|
args: [
|
|
4874
4958
|
annotate(s0[0], { t: null }),
|
|
4875
4959
|
annotate(s0[1].args[0], { t: null }),
|
|
4876
4960
|
],
|
|
4877
|
-
})],
|
|
4961
|
+
})], stack.slice(3));
|
|
4878
4962
|
}
|
|
4879
4963
|
ensureBigMapStorableType(s0[1].args[0]);
|
|
4880
|
-
return
|
|
4964
|
+
return __spread([annotateVar({
|
|
4881
4965
|
prim: "big_map",
|
|
4882
4966
|
args: [
|
|
4883
4967
|
annotate(s0[0], { t: null }),
|
|
4884
4968
|
annotate(s0[1].args[0], { t: null }),
|
|
4885
4969
|
],
|
|
4886
|
-
})],
|
|
4970
|
+
})], stack.slice(3));
|
|
4887
4971
|
}
|
|
4888
4972
|
case "GET_AND_UPDATE":
|
|
4889
4973
|
{
|
|
4890
4974
|
var ia = instructionAnn({ v: 2 });
|
|
4891
|
-
var
|
|
4892
|
-
ensureComparableType(
|
|
4893
|
-
ensureTypesEqual(
|
|
4894
|
-
ensureTypesEqual(
|
|
4975
|
+
var s = args(0, null, ["option"], ["map", "big_map"]);
|
|
4976
|
+
ensureComparableType(s[0]);
|
|
4977
|
+
ensureTypesEqual(s[0], s[2].args[0]);
|
|
4978
|
+
ensureTypesEqual(s[1].args[0], s[2].args[1]);
|
|
4895
4979
|
var va = (_c = ia.v) === null || _c === void 0 ? void 0 : _c.map(function (v) { return v !== "@" ? [v] : undefined; });
|
|
4896
|
-
if (
|
|
4897
|
-
return
|
|
4898
|
-
annotate({ prim: "option", args: [
|
|
4980
|
+
if (s[2].prim === "map") {
|
|
4981
|
+
return __spread([
|
|
4982
|
+
annotate({ prim: "option", args: [s[2].args[1]] }, { v: va === null || va === void 0 ? void 0 : va[0] }),
|
|
4899
4983
|
annotate({
|
|
4900
4984
|
prim: "map",
|
|
4901
4985
|
args: [
|
|
4902
|
-
annotate(
|
|
4903
|
-
annotate(
|
|
4986
|
+
annotate(s[0], { t: null }),
|
|
4987
|
+
annotate(s[1].args[0], { t: null }),
|
|
4904
4988
|
],
|
|
4905
4989
|
}, { v: va === null || va === void 0 ? void 0 : va[1] })
|
|
4906
|
-
],
|
|
4990
|
+
], stack.slice(3));
|
|
4907
4991
|
}
|
|
4908
|
-
ensureBigMapStorableType(
|
|
4909
|
-
return
|
|
4910
|
-
annotate({ prim: "option", args: [
|
|
4992
|
+
ensureBigMapStorableType(s[1].args[0]);
|
|
4993
|
+
return __spread([
|
|
4994
|
+
annotate({ prim: "option", args: [s[2].args[1]] }, { v: va === null || va === void 0 ? void 0 : va[0] }),
|
|
4911
4995
|
annotate({
|
|
4912
4996
|
prim: "big_map",
|
|
4913
4997
|
args: [
|
|
4914
|
-
annotate(
|
|
4915
|
-
annotate(
|
|
4998
|
+
annotate(s[0], { t: null }),
|
|
4999
|
+
annotate(s[1].args[0], { t: null }),
|
|
4916
5000
|
],
|
|
4917
5001
|
}, { v: va === null || va === void 0 ? void 0 : va[1] })
|
|
4918
|
-
],
|
|
5002
|
+
], stack.slice(3));
|
|
4919
5003
|
}
|
|
4920
5004
|
case "EXEC":
|
|
4921
5005
|
{
|
|
4922
|
-
var
|
|
4923
|
-
ensureTypesEqual(
|
|
4924
|
-
return
|
|
5006
|
+
var s = args(0, null, ["lambda"]);
|
|
5007
|
+
ensureTypesEqual(s[0], s[1].args[0]);
|
|
5008
|
+
return __spread([annotateVar(s[1].args[1])], stack.slice(2));
|
|
4925
5009
|
}
|
|
4926
5010
|
case "APPLY":
|
|
4927
5011
|
{
|
|
4928
|
-
var
|
|
4929
|
-
ensureStorableType(
|
|
4930
|
-
ensurePushableType(
|
|
4931
|
-
if (!isPairType(
|
|
4932
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": function's argument must be a pair: " + typeID(
|
|
5012
|
+
var s = args(0, null, ["lambda"]);
|
|
5013
|
+
ensureStorableType(s[0]);
|
|
5014
|
+
ensurePushableType(s[0]);
|
|
5015
|
+
if (!isPairType(s[1].args[0])) {
|
|
5016
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": function's argument must be a pair: " + typeID(s[1].args[0]));
|
|
4933
5017
|
}
|
|
4934
|
-
var pt =
|
|
4935
|
-
ensureTypesEqual(
|
|
4936
|
-
return
|
|
5018
|
+
var pt = s[1].args[0];
|
|
5019
|
+
ensureTypesEqual(s[0], typeArgs(pt)[0]);
|
|
5020
|
+
return __spread([annotateVar({ prim: "lambda", args: [typeArgs(pt)[1], s[1].args[1]] })], stack.slice(2));
|
|
4937
5021
|
}
|
|
4938
5022
|
case "FAILWITH":
|
|
4939
5023
|
{
|
|
4940
|
-
var
|
|
4941
|
-
if (proto
|
|
4942
|
-
ensurePackableType(
|
|
5024
|
+
var s = args(0, null)[0];
|
|
5025
|
+
if (ProtoGreaterOfEqual(proto, Protocol.PtEdo2Zk)) {
|
|
5026
|
+
ensurePackableType(s);
|
|
4943
5027
|
}
|
|
4944
|
-
return { failed:
|
|
5028
|
+
return { failed: s };
|
|
4945
5029
|
}
|
|
4946
5030
|
case "NEVER":
|
|
4947
5031
|
args(0, ["never"]);
|
|
4948
5032
|
return { failed: { prim: "never" } };
|
|
4949
5033
|
case "RENAME":
|
|
4950
|
-
return
|
|
5034
|
+
return __spread([annotateVar(args(0, null)[0])], stack.slice(1));
|
|
4951
5035
|
case "CONCAT":
|
|
4952
5036
|
{
|
|
4953
5037
|
var s0 = args(0, ["string", "list", "bytes"]);
|
|
@@ -4955,140 +5039,140 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
4955
5039
|
if (typeID(s0[0].args[0]) !== "string" && typeID(s0[0].args[0]) !== "bytes") {
|
|
4956
5040
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't concatenate list of " + typeID(s0[0].args[0]) + "'s");
|
|
4957
5041
|
}
|
|
4958
|
-
return
|
|
5042
|
+
return __spread([annotateVar(s0[0].args[0])], stack.slice(1));
|
|
4959
5043
|
}
|
|
4960
5044
|
var s1 = args(1, ["string", "bytes"]);
|
|
4961
5045
|
if (s0[0].prim !== s1[0].prim) {
|
|
4962
5046
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't concatenate " + s0[0].prim + " with " + s1[0].prim);
|
|
4963
5047
|
}
|
|
4964
|
-
return
|
|
5048
|
+
return __spread([annotateVar(s1[0])], stack.slice(2));
|
|
4965
5049
|
}
|
|
4966
5050
|
case "SLICE":
|
|
4967
|
-
return
|
|
5051
|
+
return __spread([annotateVar({ prim: "option", args: [args(0, ["nat"], ["nat"], ["string", "bytes"])[2]] }, "@slice")], stack.slice(3));
|
|
4968
5052
|
case "PACK":
|
|
4969
5053
|
{
|
|
4970
|
-
var
|
|
4971
|
-
ensurePackableType(
|
|
4972
|
-
return
|
|
5054
|
+
var s = args(0, null)[0];
|
|
5055
|
+
ensurePackableType(s);
|
|
5056
|
+
return __spread([annotateVar({ prim: "bytes" }, "@packed")], stack.slice(1));
|
|
4973
5057
|
}
|
|
4974
5058
|
case "ADD":
|
|
4975
5059
|
{
|
|
4976
|
-
var
|
|
4977
|
-
if (
|
|
4978
|
-
return
|
|
5060
|
+
var s = args(0, ["nat", "int", "timestamp", "mutez", "bls12_381_g1", "bls12_381_g2", "bls12_381_fr"], ["nat", "int", "timestamp", "mutez", "bls12_381_g1", "bls12_381_g2", "bls12_381_fr"]);
|
|
5061
|
+
if (s[0].prim === "nat" && s[1].prim === "int" || s[0].prim === "int" && s[1].prim === "nat") {
|
|
5062
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(2));
|
|
4979
5063
|
}
|
|
4980
|
-
else if (
|
|
4981
|
-
return
|
|
5064
|
+
else if (s[0].prim === "int" && s[1].prim === "timestamp" || s[0].prim === "timestamp" && s[1].prim === "int") {
|
|
5065
|
+
return __spread([annotateVar({ prim: "timestamp" })], stack.slice(2));
|
|
4982
5066
|
}
|
|
4983
|
-
else if ((
|
|
4984
|
-
return
|
|
5067
|
+
else if ((s[0].prim === "int" || s[0].prim === "nat" || s[0].prim === "mutez" || s[0].prim === "bls12_381_g1" || s[0].prim === "bls12_381_g2" || s[0].prim === "bls12_381_fr") && s[0].prim === s[1].prim) {
|
|
5068
|
+
return __spread([annotateVar(s[0])], stack.slice(2));
|
|
4985
5069
|
}
|
|
4986
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't add " +
|
|
5070
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't add " + s[0].prim + " to " + s[1].prim);
|
|
4987
5071
|
}
|
|
4988
5072
|
case "SUB":
|
|
4989
5073
|
{
|
|
4990
|
-
var
|
|
4991
|
-
if (((
|
|
4992
|
-
|
|
4993
|
-
return
|
|
5074
|
+
var s = args(0, ["nat", "int", "timestamp", "mutez"], ["nat", "int", "timestamp", "mutez"]);
|
|
5075
|
+
if (((s[0].prim === "nat" || s[0].prim === "int") && (s[1].prim === "nat" || s[1].prim === "int")) ||
|
|
5076
|
+
s[0].prim === "timestamp" && s[1].prim === "timestamp") {
|
|
5077
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(2));
|
|
4994
5078
|
}
|
|
4995
|
-
else if (
|
|
4996
|
-
return
|
|
5079
|
+
else if (s[0].prim === "timestamp" && s[1].prim === "int") {
|
|
5080
|
+
return __spread([annotateVar({ prim: "timestamp" })], stack.slice(2));
|
|
4997
5081
|
}
|
|
4998
|
-
else if (
|
|
4999
|
-
return
|
|
5082
|
+
else if (s[0].prim === "mutez" && s[1].prim === "mutez") {
|
|
5083
|
+
return __spread([annotateVar({ prim: "mutez" })], stack.slice(2));
|
|
5000
5084
|
}
|
|
5001
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't subtract " +
|
|
5085
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't subtract " + s[0].prim + " from " + s[1].prim);
|
|
5002
5086
|
}
|
|
5003
5087
|
case "MUL":
|
|
5004
5088
|
{
|
|
5005
|
-
var
|
|
5006
|
-
if (
|
|
5007
|
-
return
|
|
5089
|
+
var s = args(0, ["nat", "int", "mutez", "bls12_381_g1", "bls12_381_g2", "bls12_381_fr"], ["nat", "int", "mutez", "bls12_381_g1", "bls12_381_g2", "bls12_381_fr"]);
|
|
5090
|
+
if (s[0].prim === "nat" && s[1].prim === "int" || s[0].prim === "int" && s[1].prim === "nat") {
|
|
5091
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(2));
|
|
5008
5092
|
}
|
|
5009
|
-
else if (
|
|
5010
|
-
return
|
|
5093
|
+
else if (s[0].prim === "nat" && s[1].prim === "mutez" || s[0].prim === "mutez" && s[1].prim === "nat") {
|
|
5094
|
+
return __spread([annotateVar({ prim: "mutez" })], stack.slice(2));
|
|
5011
5095
|
}
|
|
5012
|
-
else if ((
|
|
5013
|
-
(
|
|
5014
|
-
return
|
|
5096
|
+
else if ((s[0].prim === "bls12_381_g1" || s[0].prim === "bls12_381_g2" || s[0].prim === "bls12_381_fr") && s[1].prim === "bls12_381_fr" ||
|
|
5097
|
+
(s[0].prim === "nat" || s[0].prim === "int") && s[0].prim === s[1].prim) {
|
|
5098
|
+
return __spread([annotateVar(s[0])], stack.slice(2));
|
|
5015
5099
|
}
|
|
5016
|
-
else if ((
|
|
5017
|
-
(
|
|
5018
|
-
return
|
|
5100
|
+
else if ((s[0].prim === "nat" || s[0].prim === "int") && s[1].prim === "bls12_381_fr" ||
|
|
5101
|
+
(s[1].prim === "nat" || s[1].prim === "int") && s[0].prim === "bls12_381_fr") {
|
|
5102
|
+
return __spread([annotateVar({ prim: "bls12_381_fr" })], stack.slice(2));
|
|
5019
5103
|
}
|
|
5020
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't multiply " +
|
|
5104
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't multiply " + s[0].prim + " by " + s[1].prim);
|
|
5021
5105
|
}
|
|
5022
5106
|
case "EDIV":
|
|
5023
5107
|
{
|
|
5024
5108
|
var res = function (a, b) { return ({ prim: "option", args: [{ prim: "pair", args: [{ prim: a }, { prim: b }] }] }); };
|
|
5025
|
-
var
|
|
5026
|
-
if (
|
|
5027
|
-
return
|
|
5109
|
+
var s = args(0, ["nat", "int", "mutez"], ["nat", "int", "mutez"]);
|
|
5110
|
+
if (s[0].prim === "nat" && s[1].prim === "nat") {
|
|
5111
|
+
return __spread([annotateVar(res("nat", "nat"))], stack.slice(2));
|
|
5028
5112
|
}
|
|
5029
|
-
else if ((
|
|
5030
|
-
return
|
|
5113
|
+
else if ((s[0].prim === "nat" || s[0].prim === "int") && (s[1].prim === "nat" || s[1].prim === "int")) {
|
|
5114
|
+
return __spread([annotateVar(res("int", "nat"))], stack.slice(2));
|
|
5031
5115
|
}
|
|
5032
|
-
else if (
|
|
5033
|
-
return
|
|
5116
|
+
else if (s[0].prim === "mutez" && s[1].prim === "nat") {
|
|
5117
|
+
return __spread([annotateVar(res("mutez", "mutez"))], stack.slice(2));
|
|
5034
5118
|
}
|
|
5035
|
-
else if (
|
|
5036
|
-
return
|
|
5119
|
+
else if (s[0].prim === "mutez" && s[1].prim === "mutez") {
|
|
5120
|
+
return __spread([annotateVar(res("nat", "mutez"))], stack.slice(2));
|
|
5037
5121
|
}
|
|
5038
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't euclideally divide " +
|
|
5122
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": can't euclideally divide " + s[0].prim + " by " + s[1].prim);
|
|
5039
5123
|
}
|
|
5040
5124
|
case "ABS":
|
|
5041
5125
|
args(0, ["int"]);
|
|
5042
|
-
return
|
|
5126
|
+
return __spread([annotateVar({ prim: "nat" })], stack.slice(1));
|
|
5043
5127
|
case "ISNAT":
|
|
5044
5128
|
args(0, ["int"]);
|
|
5045
|
-
return
|
|
5129
|
+
return __spread([annotateVar({ prim: "option", args: [{ prim: "nat" }] })], stack.slice(1));
|
|
5046
5130
|
case "INT":
|
|
5047
5131
|
args(0, ["nat", "bls12_381_fr"]);
|
|
5048
|
-
return
|
|
5132
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(1));
|
|
5049
5133
|
case "NEG":
|
|
5050
5134
|
{
|
|
5051
|
-
var
|
|
5052
|
-
if (
|
|
5053
|
-
return
|
|
5135
|
+
var s = args(0, ["nat", "int", "bls12_381_g1", "bls12_381_g2", "bls12_381_fr"])[0];
|
|
5136
|
+
if (s.prim === "nat" || s.prim === "int") {
|
|
5137
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(1));
|
|
5054
5138
|
}
|
|
5055
|
-
return
|
|
5139
|
+
return __spread([annotateVar(s)], stack.slice(1));
|
|
5056
5140
|
}
|
|
5057
5141
|
case "LSL":
|
|
5058
5142
|
case "LSR":
|
|
5059
5143
|
args(0, ["nat"], ["nat"]);
|
|
5060
|
-
return
|
|
5144
|
+
return __spread([annotateVar({ prim: "nat" })], stack.slice(2));
|
|
5061
5145
|
case "OR":
|
|
5062
5146
|
case "XOR":
|
|
5063
5147
|
{
|
|
5064
|
-
var
|
|
5065
|
-
if (
|
|
5066
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": both arguments must be of the same type: " +
|
|
5148
|
+
var s = args(0, ["nat", "bool"], ["nat", "bool"]);
|
|
5149
|
+
if (s[0].prim !== s[1].prim) {
|
|
5150
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": both arguments must be of the same type: " + s[0].prim + ", " + s[1].prim);
|
|
5067
5151
|
}
|
|
5068
|
-
return
|
|
5152
|
+
return __spread([annotateVar(s[1])], stack.slice(2));
|
|
5069
5153
|
}
|
|
5070
5154
|
case "AND":
|
|
5071
5155
|
{
|
|
5072
|
-
var
|
|
5073
|
-
if ((
|
|
5074
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": both arguments must be of the same type: " +
|
|
5156
|
+
var s = args(0, ["nat", "bool", "int"], ["nat", "bool"]);
|
|
5157
|
+
if ((s[0].prim !== "int" || s[1].prim !== "nat") && s[0].prim !== s[1].prim) {
|
|
5158
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": both arguments must be of the same type: " + s[0].prim + ", " + s[1].prim);
|
|
5075
5159
|
}
|
|
5076
|
-
return
|
|
5160
|
+
return __spread([annotateVar(s[1])], stack.slice(2));
|
|
5077
5161
|
}
|
|
5078
5162
|
case "NOT":
|
|
5079
5163
|
{
|
|
5080
|
-
var
|
|
5081
|
-
if (
|
|
5082
|
-
return
|
|
5164
|
+
var s = args(0, ["nat", "bool", "int"])[0];
|
|
5165
|
+
if (s.prim === "bool") {
|
|
5166
|
+
return __spread([annotateVar({ prim: "bool" })], stack.slice(1));
|
|
5083
5167
|
}
|
|
5084
|
-
return
|
|
5168
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(1));
|
|
5085
5169
|
}
|
|
5086
5170
|
case "COMPARE":
|
|
5087
5171
|
{
|
|
5088
|
-
var
|
|
5089
|
-
ensureComparableType(
|
|
5090
|
-
ensureComparableType(
|
|
5091
|
-
return
|
|
5172
|
+
var s = args(0, null, null);
|
|
5173
|
+
ensureComparableType(s[0]);
|
|
5174
|
+
ensureComparableType(s[1]);
|
|
5175
|
+
return __spread([annotateVar({ prim: "int" })], stack.slice(2));
|
|
5092
5176
|
}
|
|
5093
5177
|
case "EQ":
|
|
5094
5178
|
case "NEQ":
|
|
@@ -5097,7 +5181,7 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5097
5181
|
case "LE":
|
|
5098
5182
|
case "GE":
|
|
5099
5183
|
args(0, ["int"]);
|
|
5100
|
-
return
|
|
5184
|
+
return __spread([annotateVar({ prim: "bool" })], stack.slice(1));
|
|
5101
5185
|
case "SELF":
|
|
5102
5186
|
{
|
|
5103
5187
|
if ((ctx === null || ctx === void 0 ? void 0 : ctx.contract) === undefined) {
|
|
@@ -5108,55 +5192,55 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5108
5192
|
if (ep === null) {
|
|
5109
5193
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": contract has no entrypoint " + ep);
|
|
5110
5194
|
}
|
|
5111
|
-
return
|
|
5195
|
+
return __spread([annotate({ prim: "contract", args: [ep] }, { v: ia.v ? ia.v : ["@self"] })], stack);
|
|
5112
5196
|
}
|
|
5113
5197
|
case "TRANSFER_TOKENS":
|
|
5114
5198
|
{
|
|
5115
|
-
var
|
|
5116
|
-
ensureTypesEqual(
|
|
5117
|
-
return
|
|
5199
|
+
var s = args(0, null, ["mutez"], ["contract"]);
|
|
5200
|
+
ensureTypesEqual(s[0], s[2].args[0]);
|
|
5201
|
+
return __spread([annotateVar({ prim: "operation" })], stack.slice(3));
|
|
5118
5202
|
}
|
|
5119
5203
|
case "SET_DELEGATE":
|
|
5120
5204
|
{
|
|
5121
|
-
var
|
|
5122
|
-
if (typeID(
|
|
5123
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": key hash expected: " + typeID(
|
|
5205
|
+
var s = args(0, ["option"])[0];
|
|
5206
|
+
if (typeID(s.args[0]) !== "key_hash") {
|
|
5207
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": key hash expected: " + typeID(s.args[0]));
|
|
5124
5208
|
}
|
|
5125
|
-
return
|
|
5209
|
+
return __spread([annotateVar({ prim: "operation" })], stack.slice(1));
|
|
5126
5210
|
}
|
|
5127
5211
|
case "IMPLICIT_ACCOUNT":
|
|
5128
5212
|
args(0, ["key_hash"]);
|
|
5129
|
-
return
|
|
5213
|
+
return __spread([annotateVar({ prim: "contract", args: [{ prim: "unit" }] })], stack.slice(1));
|
|
5130
5214
|
case "NOW":
|
|
5131
|
-
return
|
|
5215
|
+
return __spread([annotateVar({ prim: "timestamp" }, "@now")], stack);
|
|
5132
5216
|
case "AMOUNT":
|
|
5133
|
-
return
|
|
5217
|
+
return __spread([annotateVar({ prim: "mutez" }, "@amount")], stack);
|
|
5134
5218
|
case "BALANCE":
|
|
5135
|
-
return
|
|
5219
|
+
return __spread([annotateVar({ prim: "mutez" }, "@balance")], stack);
|
|
5136
5220
|
case "CHECK_SIGNATURE":
|
|
5137
5221
|
args(0, ["key"], ["signature"], ["bytes"]);
|
|
5138
|
-
return
|
|
5222
|
+
return __spread([annotateVar({ prim: "bool" })], stack.slice(3));
|
|
5139
5223
|
case "BLAKE2B":
|
|
5140
5224
|
case "SHA256":
|
|
5141
5225
|
case "SHA512":
|
|
5142
5226
|
case "KECCAK":
|
|
5143
5227
|
case "SHA3":
|
|
5144
5228
|
args(0, ["bytes"]);
|
|
5145
|
-
return
|
|
5229
|
+
return __spread([annotateVar({ prim: "bytes" })], stack.slice(1));
|
|
5146
5230
|
case "HASH_KEY":
|
|
5147
5231
|
args(0, ["key"]);
|
|
5148
|
-
return
|
|
5232
|
+
return __spread([annotateVar({ prim: "key_hash" })], stack.slice(1));
|
|
5149
5233
|
case "SOURCE":
|
|
5150
|
-
return
|
|
5234
|
+
return __spread([annotateVar({ prim: "address" }, "@source")], stack);
|
|
5151
5235
|
case "SENDER":
|
|
5152
|
-
return
|
|
5236
|
+
return __spread([annotateVar({ prim: "address" }, "@sender")], stack);
|
|
5153
5237
|
case "ADDRESS":
|
|
5154
5238
|
{
|
|
5155
|
-
var
|
|
5239
|
+
var s = args(0, ["contract"])[0];
|
|
5156
5240
|
var ia = instructionAnn({ v: 1 });
|
|
5157
|
-
return
|
|
5158
|
-
annotate((_a = { prim: "address" }, _a[refContract] =
|
|
5159
|
-
],
|
|
5241
|
+
return __spread([
|
|
5242
|
+
annotate((_a = { prim: "address" }, _a[refContract] = s, _a), { v: ia.v ? ia.v : varSuffix(argAnn(s), "address") })
|
|
5243
|
+
], stack.slice(1));
|
|
5160
5244
|
}
|
|
5161
5245
|
case "SELF_ADDRESS":
|
|
5162
5246
|
{
|
|
@@ -5164,10 +5248,10 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5164
5248
|
if ((ctx === null || ctx === void 0 ? void 0 : ctx.contract) !== undefined) {
|
|
5165
5249
|
addr[refContract] = { prim: "contract", args: [contractSection(ctx.contract, "parameter").args[0]] };
|
|
5166
5250
|
}
|
|
5167
|
-
return
|
|
5251
|
+
return __spread([annotateVar(addr, "@address")], stack);
|
|
5168
5252
|
}
|
|
5169
5253
|
case "CHAIN_ID":
|
|
5170
|
-
return
|
|
5254
|
+
return __spread([annotateVar({ prim: "chain_id" })], stack);
|
|
5171
5255
|
case "DROP":
|
|
5172
5256
|
{
|
|
5173
5257
|
instructionAnn({});
|
|
@@ -5179,25 +5263,25 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5179
5263
|
{
|
|
5180
5264
|
instructionAnn({});
|
|
5181
5265
|
var n = parseInt(instruction.args[0].int, 10);
|
|
5182
|
-
return
|
|
5266
|
+
return __spread([args(n, null)[0]], stack.slice(0, n), stack.slice(n + 1));
|
|
5183
5267
|
}
|
|
5184
5268
|
case "DUG":
|
|
5185
5269
|
{
|
|
5186
5270
|
instructionAnn({});
|
|
5187
5271
|
var n = parseInt(instruction.args[0].int, 10);
|
|
5188
|
-
return
|
|
5272
|
+
return __spread(stack.slice(1, n + 1), [args(0, null)[0]], stack.slice(n + 1));
|
|
5189
5273
|
}
|
|
5190
5274
|
case "NONE":
|
|
5191
5275
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5192
|
-
return
|
|
5276
|
+
return __spread([annotate({ prim: "option", args: [instruction.args[0]] }, instructionAnn({ t: 1, v: 1 }))], stack);
|
|
5193
5277
|
case "LEFT":
|
|
5194
5278
|
case "RIGHT":
|
|
5195
5279
|
{
|
|
5196
|
-
var
|
|
5280
|
+
var s = args(0, null)[0];
|
|
5197
5281
|
var ia = instructionAnn({ f: 2, t: 1, v: 1 }, { specialFields: true });
|
|
5198
|
-
var va = argAnn(
|
|
5282
|
+
var va = argAnn(s);
|
|
5199
5283
|
var children = [
|
|
5200
|
-
annotate(
|
|
5284
|
+
annotate(s, {
|
|
5201
5285
|
t: null,
|
|
5202
5286
|
v: null,
|
|
5203
5287
|
f: ia.f && ia.f.length > 0 && ia.f[0] !== "%" ?
|
|
@@ -5211,23 +5295,23 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5211
5295
|
f: ia.f && ia.f.length > 1 && ia.f[1] !== "%" ? ia.f : undefined,
|
|
5212
5296
|
}),
|
|
5213
5297
|
];
|
|
5214
|
-
return
|
|
5298
|
+
return __spread([annotate({
|
|
5215
5299
|
prim: "or", args: instruction.prim === "LEFT" ? children : [children[1], children[0]]
|
|
5216
|
-
}, { t: ia.t, v: ia.v })],
|
|
5300
|
+
}, { t: ia.t, v: ia.v })], stack.slice(1));
|
|
5217
5301
|
}
|
|
5218
5302
|
case "NIL":
|
|
5219
5303
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5220
|
-
return
|
|
5304
|
+
return __spread([annotate({ prim: "list", args: [instruction.args[0]] }, instructionAnn({ t: 1, v: 1 }))], stack);
|
|
5221
5305
|
case "UNPACK":
|
|
5222
5306
|
args(0, ["bytes"]);
|
|
5223
5307
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5224
|
-
return
|
|
5308
|
+
return __spread([annotateVar({ prim: "option", args: [instruction.args[0]] }, "@unpacked")], stack.slice(1));
|
|
5225
5309
|
case "CONTRACT":
|
|
5226
5310
|
{
|
|
5227
|
-
var
|
|
5311
|
+
var s = args(0, ["address"])[0];
|
|
5228
5312
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5229
5313
|
var ia = instructionAnn({ v: 1, f: 1 });
|
|
5230
|
-
var contract =
|
|
5314
|
+
var contract = s[refContract];
|
|
5231
5315
|
if (contract !== undefined) {
|
|
5232
5316
|
var ep = contractEntryPoint(contract, (_e = ia.f) === null || _e === void 0 ? void 0 : _e[0]);
|
|
5233
5317
|
if (ep === null) {
|
|
@@ -5235,51 +5319,53 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5235
5319
|
}
|
|
5236
5320
|
ensureTypesEqual(ep, instruction.args[0]);
|
|
5237
5321
|
}
|
|
5238
|
-
return
|
|
5239
|
-
annotate({ prim: "option", args: [{ prim: "contract", args: [instruction.args[0]] }] }, { v: ia.v ? ia.v : varSuffix(argAnn(
|
|
5240
|
-
],
|
|
5322
|
+
return __spread([
|
|
5323
|
+
annotate({ prim: "option", args: [{ prim: "contract", args: [instruction.args[0]] }] }, { v: ia.v ? ia.v : varSuffix(argAnn(s), "contract") })
|
|
5324
|
+
], stack.slice(1));
|
|
5241
5325
|
}
|
|
5242
5326
|
case "CAST":
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5327
|
+
{
|
|
5328
|
+
instructionAnn({});
|
|
5329
|
+
var s = args(0, null)[0];
|
|
5330
|
+
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5331
|
+
ensureTypesEqual(instruction.args[0], s);
|
|
5332
|
+
return __spread([instruction.args[0]], stack.slice(1));
|
|
5333
|
+
}
|
|
5248
5334
|
case "IF_NONE":
|
|
5249
5335
|
{
|
|
5250
5336
|
instructionAnn({});
|
|
5251
|
-
var
|
|
5337
|
+
var s = args(0, ["option"])[0];
|
|
5252
5338
|
var tail = stack.slice(1);
|
|
5253
5339
|
var br0 = functionTypeInternal(instruction.args[0], tail, ctx);
|
|
5254
|
-
var br1 = functionTypeInternal(instruction.args[1],
|
|
5340
|
+
var br1 = functionTypeInternal(instruction.args[1], __spread([annotate(s.args[0], { t: null, v: varSuffix(argAnn(s), "some") })], tail), ctx);
|
|
5255
5341
|
return branchType(br0, br1);
|
|
5256
5342
|
}
|
|
5257
5343
|
case "IF_LEFT":
|
|
5258
5344
|
{
|
|
5259
5345
|
instructionAnn({});
|
|
5260
|
-
var
|
|
5261
|
-
var va = argAnn(
|
|
5262
|
-
var lefta = argAnn(
|
|
5263
|
-
var righta = argAnn(
|
|
5346
|
+
var s = args(0, ["or"])[0];
|
|
5347
|
+
var va = argAnn(s);
|
|
5348
|
+
var lefta = argAnn(s.args[0]);
|
|
5349
|
+
var righta = argAnn(s.args[1]);
|
|
5264
5350
|
var tail = stack.slice(1);
|
|
5265
|
-
var br0 = functionTypeInternal(instruction.args[0],
|
|
5266
|
-
annotate(
|
|
5267
|
-
],
|
|
5268
|
-
var br1 = functionTypeInternal(instruction.args[1],
|
|
5269
|
-
annotate(
|
|
5270
|
-
],
|
|
5351
|
+
var br0 = functionTypeInternal(instruction.args[0], __spread([
|
|
5352
|
+
annotate(s.args[0], { t: null, v: varSuffix(va, lefta.f ? lefta.f[0].slice(1) : "left") })
|
|
5353
|
+
], tail), ctx);
|
|
5354
|
+
var br1 = functionTypeInternal(instruction.args[1], __spread([
|
|
5355
|
+
annotate(s.args[1], { t: null, v: varSuffix(va, righta.f ? righta.f[0].slice(1) : "right") })
|
|
5356
|
+
], tail), ctx);
|
|
5271
5357
|
return branchType(br0, br1);
|
|
5272
5358
|
}
|
|
5273
5359
|
case "IF_CONS":
|
|
5274
5360
|
{
|
|
5275
5361
|
instructionAnn({});
|
|
5276
|
-
var
|
|
5277
|
-
var va = argAnn(
|
|
5362
|
+
var s = args(0, ["list"])[0];
|
|
5363
|
+
var va = argAnn(s);
|
|
5278
5364
|
var tail = stack.slice(1);
|
|
5279
|
-
var br0 = functionTypeInternal(instruction.args[0],
|
|
5280
|
-
annotate(
|
|
5281
|
-
annotate(
|
|
5282
|
-
],
|
|
5365
|
+
var br0 = functionTypeInternal(instruction.args[0], __spread([
|
|
5366
|
+
annotate(s.args[0], { t: null, v: varSuffix(va, "hd") }),
|
|
5367
|
+
annotate(s, { t: null, v: varSuffix(va, "tl") })
|
|
5368
|
+
], tail), ctx);
|
|
5283
5369
|
var br1 = functionTypeInternal(instruction.args[1], tail, ctx);
|
|
5284
5370
|
return branchType(br0, br1);
|
|
5285
5371
|
}
|
|
@@ -5294,10 +5380,10 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5294
5380
|
}
|
|
5295
5381
|
case "MAP":
|
|
5296
5382
|
{
|
|
5297
|
-
var
|
|
5383
|
+
var s = args(0, ["list", "map"])[0];
|
|
5298
5384
|
var tail = stack.slice(1);
|
|
5299
|
-
var elt =
|
|
5300
|
-
var body = functionTypeInternal(instruction.args[0],
|
|
5385
|
+
var elt = s.prim === "map" ? { prim: "pair", args: s.args } : s.args[0];
|
|
5386
|
+
var body = functionTypeInternal(instruction.args[0], __spread([annotate(elt, { t: null, v: varSuffix(argAnn(s), "elt") })], tail), ctx);
|
|
5301
5387
|
if ("failed" in body) {
|
|
5302
5388
|
return body;
|
|
5303
5389
|
}
|
|
@@ -5305,18 +5391,18 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5305
5391
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": function must return a value");
|
|
5306
5392
|
}
|
|
5307
5393
|
ensureStacksEqual(body.slice(1), tail);
|
|
5308
|
-
if (
|
|
5309
|
-
return
|
|
5394
|
+
if (s.prim === "list") {
|
|
5395
|
+
return __spread([annotateVar({ prim: "list", args: [body[0]] })], tail);
|
|
5310
5396
|
}
|
|
5311
|
-
return
|
|
5397
|
+
return __spread([annotateVar({ prim: "map", args: [s.args[0], body[0]] })], tail);
|
|
5312
5398
|
}
|
|
5313
5399
|
case "ITER":
|
|
5314
5400
|
{
|
|
5315
5401
|
instructionAnn({});
|
|
5316
|
-
var
|
|
5402
|
+
var s = args(0, ["set", "list", "map"])[0];
|
|
5317
5403
|
var tail = stack.slice(1);
|
|
5318
|
-
var elt =
|
|
5319
|
-
var body = functionTypeInternal(instruction.args[0],
|
|
5404
|
+
var elt = s.prim === "map" ? { prim: "pair", args: s.args } : s.args[0];
|
|
5405
|
+
var body = functionTypeInternal(instruction.args[0], __spread([annotate(elt, { t: null, v: varSuffix(argAnn(s), "elt") })], tail), ctx);
|
|
5320
5406
|
if ("failed" in body) {
|
|
5321
5407
|
return body;
|
|
5322
5408
|
}
|
|
@@ -5332,20 +5418,20 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5332
5418
|
if ("failed" in body) {
|
|
5333
5419
|
return body;
|
|
5334
5420
|
}
|
|
5335
|
-
ensureStacksEqual(body,
|
|
5421
|
+
ensureStacksEqual(body, __spread([{ prim: "bool" }], tail));
|
|
5336
5422
|
return tail;
|
|
5337
5423
|
}
|
|
5338
5424
|
case "LOOP_LEFT":
|
|
5339
5425
|
{
|
|
5340
5426
|
instructionAnn({});
|
|
5341
|
-
var
|
|
5427
|
+
var s = args(0, ["or"])[0];
|
|
5342
5428
|
var tail = stack.slice(1);
|
|
5343
|
-
var body = functionTypeInternal(instruction.args[0],
|
|
5429
|
+
var body = functionTypeInternal(instruction.args[0], __spread([annotate(s.args[0], { t: null, v: varSuffix(argAnn(s), "left") })], tail), ctx);
|
|
5344
5430
|
if ("failed" in body) {
|
|
5345
5431
|
return body;
|
|
5346
5432
|
}
|
|
5347
|
-
ensureStacksEqual(body,
|
|
5348
|
-
return
|
|
5433
|
+
ensureStacksEqual(body, __spread([s], tail));
|
|
5434
|
+
return __spread([annotate(s.args[1], { t: null, v: instructionAnn({ v: 1 }).v })], tail);
|
|
5349
5435
|
}
|
|
5350
5436
|
case "DIP":
|
|
5351
5437
|
{
|
|
@@ -5361,48 +5447,48 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5361
5447
|
if ("failed" in body) {
|
|
5362
5448
|
return body;
|
|
5363
5449
|
}
|
|
5364
|
-
return
|
|
5450
|
+
return __spread(head, body);
|
|
5365
5451
|
}
|
|
5366
5452
|
case "CREATE_CONTRACT":
|
|
5367
5453
|
{
|
|
5368
5454
|
var ia = instructionAnn({ v: 2 });
|
|
5369
|
-
var
|
|
5370
|
-
if (typeID(
|
|
5371
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": key hash expected: " + typeID(
|
|
5455
|
+
var s = args(0, ["option"], ["mutez"], null);
|
|
5456
|
+
if (typeID(s[0].args[0]) !== "key_hash") {
|
|
5457
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": key hash expected: " + typeID(s[0].args[0]));
|
|
5372
5458
|
}
|
|
5373
|
-
if (ensureStorableType(
|
|
5459
|
+
if (ensureStorableType(s[2])) {
|
|
5374
5460
|
assertContractValid(instruction.args[0]);
|
|
5375
|
-
assertScalarTypesEqual(contractSection(instruction.args[0], "storage").args[0],
|
|
5461
|
+
assertScalarTypesEqual(contractSection(instruction.args[0], "storage").args[0], s[2]);
|
|
5376
5462
|
}
|
|
5377
5463
|
var va = (_f = ia.v) === null || _f === void 0 ? void 0 : _f.map(function (v) { return v !== "@" ? [v] : undefined; });
|
|
5378
|
-
return
|
|
5464
|
+
return __spread([
|
|
5379
5465
|
annotate({ prim: "operation" }, { v: va === null || va === void 0 ? void 0 : va[0] }),
|
|
5380
5466
|
annotate((_b = {
|
|
5381
5467
|
prim: "address"
|
|
5382
5468
|
},
|
|
5383
5469
|
_b[refContract] = { prim: "contract", args: [contractSection(instruction.args[0], "parameter").args[0]] },
|
|
5384
5470
|
_b), { v: va === null || va === void 0 ? void 0 : va[1] })
|
|
5385
|
-
],
|
|
5471
|
+
], stack.slice(3));
|
|
5386
5472
|
}
|
|
5387
5473
|
case "PUSH":
|
|
5388
5474
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5389
5475
|
assertDataValidInternal(instruction.args[1], instruction.args[0], __assign(__assign({}, ctx), { contract: undefined }));
|
|
5390
|
-
return
|
|
5476
|
+
return __spread([annotateVar(instruction.args[0])], stack);
|
|
5391
5477
|
case "EMPTY_SET":
|
|
5392
5478
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5393
5479
|
ensureComparableType(instruction.args[0]);
|
|
5394
|
-
return
|
|
5480
|
+
return __spread([annotate({ prim: "set", args: instruction.args }, instructionAnn({ t: 1, v: 1 }))], stack);
|
|
5395
5481
|
case "EMPTY_MAP":
|
|
5396
5482
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5397
5483
|
ensureComparableType(instruction.args[0]);
|
|
5398
5484
|
assertTypeAnnotationsValid(instruction.args[1]);
|
|
5399
|
-
return
|
|
5485
|
+
return __spread([annotate({ prim: "map", args: instruction.args }, instructionAnn({ t: 1, v: 1 }))], stack);
|
|
5400
5486
|
case "EMPTY_BIG_MAP":
|
|
5401
5487
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
5402
5488
|
ensureComparableType(instruction.args[0]);
|
|
5403
5489
|
assertTypeAnnotationsValid(instruction.args[1]);
|
|
5404
5490
|
ensureBigMapStorableType(instruction.args[0]);
|
|
5405
|
-
return
|
|
5491
|
+
return __spread([annotate({ prim: "big_map", args: instruction.args }, instructionAnn({ t: 1, v: 1 }))], stack);
|
|
5406
5492
|
case "LAMBDA":
|
|
5407
5493
|
{
|
|
5408
5494
|
assertTypeAnnotationsValid(instruction.args[0]);
|
|
@@ -5415,68 +5501,68 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5415
5501
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": function must return a value");
|
|
5416
5502
|
}
|
|
5417
5503
|
ensureTypesEqual(instruction.args[1], body[0]);
|
|
5418
|
-
return
|
|
5504
|
+
return __spread([annotateVar({ prim: "lambda", args: [instruction.args[0], instruction.args[1]] })], stack);
|
|
5419
5505
|
}
|
|
5420
5506
|
case "LEVEL":
|
|
5421
|
-
return
|
|
5507
|
+
return __spread([annotateVar({ prim: "nat" }, "@level")], stack);
|
|
5422
5508
|
case "TOTAL_VOTING_POWER":
|
|
5423
|
-
return
|
|
5509
|
+
return __spread([annotateVar({ prim: "nat" })], stack);
|
|
5424
5510
|
case "VOTING_POWER":
|
|
5425
5511
|
args(0, ["key_hash"]);
|
|
5426
|
-
return
|
|
5512
|
+
return __spread([annotateVar({ prim: "nat" })], stack.slice(1));
|
|
5427
5513
|
case "TICKET":
|
|
5428
5514
|
{
|
|
5429
|
-
var
|
|
5430
|
-
ensureComparableType(
|
|
5431
|
-
return
|
|
5515
|
+
var s = args(0, null, ["nat"])[0];
|
|
5516
|
+
ensureComparableType(s);
|
|
5517
|
+
return __spread([annotate({ prim: "ticket", args: [s] }, instructionAnn({ t: 1, v: 1 }))], stack.slice(2));
|
|
5432
5518
|
}
|
|
5433
5519
|
case "JOIN_TICKETS":
|
|
5434
5520
|
{
|
|
5435
|
-
var
|
|
5436
|
-
if (typeID(
|
|
5437
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": ticket expected: " + typeID(
|
|
5521
|
+
var s = unpackComb("pair", args(0, ["pair"])[0]);
|
|
5522
|
+
if (typeID(s.args[0]) !== "ticket") {
|
|
5523
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": ticket expected: " + typeID(s.args[0]));
|
|
5438
5524
|
}
|
|
5439
|
-
ensureTypesEqual(
|
|
5440
|
-
return
|
|
5525
|
+
ensureTypesEqual(s.args[0], s.args[1]);
|
|
5526
|
+
return __spread([annotateVar({
|
|
5441
5527
|
prim: "option",
|
|
5442
|
-
args: [annotate(
|
|
5443
|
-
})],
|
|
5528
|
+
args: [annotate(s.args[0], { t: null })],
|
|
5529
|
+
})], stack.slice(1));
|
|
5444
5530
|
}
|
|
5445
5531
|
case "SPLIT_TICKET":
|
|
5446
5532
|
{
|
|
5447
|
-
var
|
|
5448
|
-
var p = unpackComb("pair",
|
|
5533
|
+
var s = args(0, ["ticket"], ["pair"]);
|
|
5534
|
+
var p = unpackComb("pair", s[1]);
|
|
5449
5535
|
if (typeID(p.args[0]) !== "nat") {
|
|
5450
5536
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": nat expected: " + typeID(p.args[0]));
|
|
5451
5537
|
}
|
|
5452
5538
|
ensureTypesEqual(p.args[0], p.args[1]);
|
|
5453
|
-
return
|
|
5539
|
+
return __spread([annotateVar({
|
|
5454
5540
|
prim: "option",
|
|
5455
5541
|
args: [{
|
|
5456
5542
|
prim: "pair",
|
|
5457
5543
|
args: [
|
|
5458
|
-
annotate(
|
|
5459
|
-
annotate(
|
|
5544
|
+
annotate(s[0], { t: null }),
|
|
5545
|
+
annotate(s[0], { t: null }),
|
|
5460
5546
|
],
|
|
5461
5547
|
}],
|
|
5462
|
-
})],
|
|
5548
|
+
})], stack.slice(2));
|
|
5463
5549
|
}
|
|
5464
5550
|
case "READ_TICKET":
|
|
5465
5551
|
{
|
|
5466
5552
|
var ia = instructionAnn({ v: 2 });
|
|
5467
|
-
var
|
|
5553
|
+
var s = args(0, ["ticket"])[0];
|
|
5468
5554
|
var va = (_g = ia.v) === null || _g === void 0 ? void 0 : _g.map(function (v) { return v !== "@" ? [v] : undefined; });
|
|
5469
|
-
return
|
|
5555
|
+
return __spread([
|
|
5470
5556
|
annotate({
|
|
5471
5557
|
prim: "pair",
|
|
5472
5558
|
args: [
|
|
5473
5559
|
{ prim: "address" },
|
|
5474
|
-
annotate(
|
|
5560
|
+
annotate(s.args[0], { t: null }),
|
|
5475
5561
|
{ prim: "nat" },
|
|
5476
5562
|
]
|
|
5477
5563
|
}, { v: va === null || va === void 0 ? void 0 : va[0] }),
|
|
5478
|
-
annotate(
|
|
5479
|
-
],
|
|
5564
|
+
annotate(s, { v: va === null || va === void 0 ? void 0 : va[1], t: null })
|
|
5565
|
+
], stack.slice(1));
|
|
5480
5566
|
}
|
|
5481
5567
|
case "PAIRING_CHECK":
|
|
5482
5568
|
{
|
|
@@ -5491,26 +5577,35 @@ function functionTypeInternal(inst, stack, ctx) {
|
|
|
5491
5577
|
if (typeID(c.args[1]) !== "bls12_381_g2") {
|
|
5492
5578
|
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": bls12_381_g2 expected: " + typeID(c.args[1]));
|
|
5493
5579
|
}
|
|
5494
|
-
return
|
|
5580
|
+
return __spread([annotateVar({ prim: "bool" })], stack.slice(1));
|
|
5495
5581
|
}
|
|
5496
5582
|
case "SAPLING_EMPTY_STATE":
|
|
5497
|
-
return
|
|
5583
|
+
return __spread([annotate({ prim: "sapling_state", args: [instruction.args[0]] }, instructionAnn({ v: 1, t: 1 }))], stack);
|
|
5498
5584
|
case "SAPLING_VERIFY_UPDATE":
|
|
5499
5585
|
{
|
|
5500
|
-
var
|
|
5501
|
-
if (parseInt(
|
|
5502
|
-
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": sapling memo size mismatch: " +
|
|
5586
|
+
var s = args(0, ["sapling_transaction"], ["sapling_state"]);
|
|
5587
|
+
if (parseInt(s[0].args[0].int, 10) !== parseInt(s[1].args[0].int, 10)) {
|
|
5588
|
+
throw new MichelsonInstructionError(instruction, stack, instruction.prim + ": sapling memo size mismatch: " + s[0].args[0].int + " != " + s[1].args[0].int);
|
|
5503
5589
|
}
|
|
5504
|
-
return
|
|
5590
|
+
return __spread([annotateVar({
|
|
5505
5591
|
prim: "option",
|
|
5506
5592
|
args: [{
|
|
5507
5593
|
prim: "pair",
|
|
5508
5594
|
args: [
|
|
5509
5595
|
{ prim: "int" },
|
|
5510
|
-
annotate(
|
|
5596
|
+
annotate(s[1], { t: null }),
|
|
5511
5597
|
],
|
|
5512
5598
|
}],
|
|
5513
|
-
})],
|
|
5599
|
+
})], stack.slice(2));
|
|
5600
|
+
}
|
|
5601
|
+
case "OPEN_CHEST":
|
|
5602
|
+
args(0, ["chest_key"], ["chest"], ["nat"]);
|
|
5603
|
+
return __spread([annotateVar({ prim: "or", args: [{ prim: "bytes" }, { prim: "bool" }] })], stack.slice(3));
|
|
5604
|
+
case "VIEW":
|
|
5605
|
+
{
|
|
5606
|
+
var s = args(0, null, ["address"]);
|
|
5607
|
+
ensurePushableType(s[0]);
|
|
5608
|
+
return __spread([annotateVar({ prim: "option", args: [instruction.args[1]] })], stack.slice(2));
|
|
5514
5609
|
}
|
|
5515
5610
|
default:
|
|
5516
5611
|
throw new MichelsonError(instruction, "unexpected instruction: " + instruction.prim);
|
|
@@ -5545,8 +5640,28 @@ function contractSection(contract, section) {
|
|
|
5545
5640
|
}
|
|
5546
5641
|
throw new MichelsonError(contract, "missing contract section: " + section);
|
|
5547
5642
|
}
|
|
5548
|
-
function
|
|
5643
|
+
function contractViews(contract) {
|
|
5549
5644
|
var e_9, _a;
|
|
5645
|
+
var views = {};
|
|
5646
|
+
try {
|
|
5647
|
+
for (var contract_2 = __values(contract), contract_2_1 = contract_2.next(); !contract_2_1.done; contract_2_1 = contract_2.next()) {
|
|
5648
|
+
var s = contract_2_1.value;
|
|
5649
|
+
if (s.prim === "view") {
|
|
5650
|
+
views[s.args[0].string] = s;
|
|
5651
|
+
}
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
5655
|
+
finally {
|
|
5656
|
+
try {
|
|
5657
|
+
if (contract_2_1 && !contract_2_1.done && (_a = contract_2.return)) _a.call(contract_2);
|
|
5658
|
+
}
|
|
5659
|
+
finally { if (e_9) throw e_9.error; }
|
|
5660
|
+
}
|
|
5661
|
+
return views;
|
|
5662
|
+
}
|
|
5663
|
+
function isContract(v) {
|
|
5664
|
+
var e_10, _a;
|
|
5550
5665
|
if (Array.isArray(v)) {
|
|
5551
5666
|
try {
|
|
5552
5667
|
for (var v_1 = __values(v), v_1_1 = v_1.next(); !v_1_1.done; v_1_1 = v_1.next()) {
|
|
@@ -5556,12 +5671,12 @@ function isContract(v) {
|
|
|
5556
5671
|
}
|
|
5557
5672
|
}
|
|
5558
5673
|
}
|
|
5559
|
-
catch (
|
|
5674
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
5560
5675
|
finally {
|
|
5561
5676
|
try {
|
|
5562
5677
|
if (v_1_1 && !v_1_1.done && (_a = v_1.return)) _a.call(v_1);
|
|
5563
5678
|
}
|
|
5564
|
-
finally { if (
|
|
5679
|
+
finally { if (e_10) throw e_10.error; }
|
|
5565
5680
|
}
|
|
5566
5681
|
}
|
|
5567
5682
|
return false;
|
|
@@ -5585,7 +5700,7 @@ function contractEntryPoints(src) {
|
|
|
5585
5700
|
var param = contractSection(src, "parameter");
|
|
5586
5701
|
var ch = contractEntryPoints(param.args[0]);
|
|
5587
5702
|
var a = unpackAnnotations(param);
|
|
5588
|
-
return a.f ?
|
|
5703
|
+
return a.f ? __spread([[a.f[0], param.args[0]]], ch) : ch;
|
|
5589
5704
|
}
|
|
5590
5705
|
if (isOrType(src)) {
|
|
5591
5706
|
var args_2 = typeArgs(src);
|
|
@@ -5593,49 +5708,67 @@ function contractEntryPoints(src) {
|
|
|
5593
5708
|
var a = unpackAnnotations(args_2[n]);
|
|
5594
5709
|
if (typeID(args_2[n]) === "or") {
|
|
5595
5710
|
var ch = contractEntryPoints(args_2[n]);
|
|
5596
|
-
return a.f ?
|
|
5711
|
+
return a.f ? __spread([[a.f[0], args_2[n]]], ch) : ch;
|
|
5597
5712
|
}
|
|
5598
5713
|
return a.f ? [[a.f[0], args_2[n]]] : [];
|
|
5599
5714
|
};
|
|
5600
|
-
return
|
|
5715
|
+
return __spread(getArg(0), getArg(1));
|
|
5601
5716
|
}
|
|
5602
5717
|
return [];
|
|
5603
5718
|
}
|
|
5604
5719
|
// Contract validation
|
|
5605
5720
|
function assertContractValid(contract, ctx) {
|
|
5721
|
+
var e_11, _a;
|
|
5722
|
+
var assertSection = function (parameter, storage, ret, code) {
|
|
5723
|
+
assertTypeAnnotationsValid(parameter, true);
|
|
5724
|
+
assertTypeAnnotationsValid(storage);
|
|
5725
|
+
var arg = {
|
|
5726
|
+
prim: "pair",
|
|
5727
|
+
args: [
|
|
5728
|
+
__assign(__assign({}, parameter), { annots: ["@parameter"] }),
|
|
5729
|
+
__assign(__assign({}, storage), { annots: ["@storage"] }),
|
|
5730
|
+
]
|
|
5731
|
+
};
|
|
5732
|
+
var out = functionTypeInternal(code, [arg], __assign(__assign({}, ctx), { contract: contract }));
|
|
5733
|
+
if ("failed" in out) {
|
|
5734
|
+
return out;
|
|
5735
|
+
}
|
|
5736
|
+
try {
|
|
5737
|
+
assertStacksEqual(out, [ret]);
|
|
5738
|
+
}
|
|
5739
|
+
catch (err) {
|
|
5740
|
+
if (err instanceof MichelsonError) {
|
|
5741
|
+
throw new MichelsonInstructionError(code, out, err.message);
|
|
5742
|
+
}
|
|
5743
|
+
else {
|
|
5744
|
+
throw err;
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
return out;
|
|
5748
|
+
};
|
|
5606
5749
|
var parameter = contractSection(contract, "parameter").args[0];
|
|
5607
|
-
assertTypeAnnotationsValid(parameter, true);
|
|
5608
5750
|
var storage = contractSection(contract, "storage").args[0];
|
|
5609
|
-
assertTypeAnnotationsValid(storage);
|
|
5610
|
-
var arg = {
|
|
5611
|
-
"prim": "pair",
|
|
5612
|
-
args: [
|
|
5613
|
-
__assign(__assign({}, parameter), { annots: ["@parameter"] }),
|
|
5614
|
-
__assign(__assign({}, storage), { annots: ["@storage"] }),
|
|
5615
|
-
]
|
|
5616
|
-
};
|
|
5617
5751
|
var code = contractSection(contract, "code").args[0];
|
|
5618
|
-
var ret = functionTypeInternal(code, [arg], __assign(__assign({}, ctx), { contract: contract }));
|
|
5619
|
-
if ("failed" in ret) {
|
|
5620
|
-
return ret;
|
|
5621
|
-
}
|
|
5622
5752
|
var expected = {
|
|
5623
|
-
|
|
5753
|
+
prim: "pair",
|
|
5624
5754
|
args: [
|
|
5625
|
-
{
|
|
5755
|
+
{ prim: "list", args: [{ prim: "operation" }] },
|
|
5626
5756
|
storage,
|
|
5627
5757
|
]
|
|
5628
5758
|
};
|
|
5759
|
+
var ret = assertSection(parameter, storage, expected, code);
|
|
5629
5760
|
try {
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
if (err instanceof MichelsonError) {
|
|
5634
|
-
throw new MichelsonInstructionError(code, ret, err.message);
|
|
5761
|
+
for (var _b = __values(Object.values(contractViews(contract))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
5762
|
+
var view = _c.value;
|
|
5763
|
+
assertSection(view.args[1], storage, view.args[2], view.args[3]);
|
|
5635
5764
|
}
|
|
5636
|
-
|
|
5637
|
-
|
|
5765
|
+
}
|
|
5766
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
5767
|
+
finally {
|
|
5768
|
+
try {
|
|
5769
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
5638
5770
|
}
|
|
5771
|
+
finally { if (e_11) throw e_11.error; }
|
|
5639
5772
|
}
|
|
5640
5773
|
return ret;
|
|
5641
5774
|
}
|
|
@@ -5645,19 +5778,19 @@ function assertDataValid(d, t, ctx) {
|
|
|
5645
5778
|
assertDataValidInternal(d, t, ctx || null);
|
|
5646
5779
|
}
|
|
5647
5780
|
function functionType(inst, stack, ctx) {
|
|
5648
|
-
var
|
|
5781
|
+
var e_12, _a, e_13, _b;
|
|
5649
5782
|
try {
|
|
5650
5783
|
for (var stack_1 = __values(stack), stack_1_1 = stack_1.next(); !stack_1_1.done; stack_1_1 = stack_1.next()) {
|
|
5651
5784
|
var t = stack_1_1.value;
|
|
5652
5785
|
assertTypeAnnotationsValid(t);
|
|
5653
5786
|
}
|
|
5654
5787
|
}
|
|
5655
|
-
catch (
|
|
5788
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
5656
5789
|
finally {
|
|
5657
5790
|
try {
|
|
5658
5791
|
if (stack_1_1 && !stack_1_1.done && (_a = stack_1.return)) _a.call(stack_1);
|
|
5659
5792
|
}
|
|
5660
|
-
finally { if (
|
|
5793
|
+
finally { if (e_12) throw e_12.error; }
|
|
5661
5794
|
}
|
|
5662
5795
|
if ((ctx === null || ctx === void 0 ? void 0 : ctx.contract) !== undefined) {
|
|
5663
5796
|
try {
|
|
@@ -5667,18 +5800,18 @@ function functionType(inst, stack, ctx) {
|
|
|
5667
5800
|
assertTypeAnnotationsValid(sec);
|
|
5668
5801
|
}
|
|
5669
5802
|
}
|
|
5670
|
-
catch (
|
|
5803
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
5671
5804
|
finally {
|
|
5672
5805
|
try {
|
|
5673
5806
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5674
5807
|
}
|
|
5675
|
-
finally { if (
|
|
5808
|
+
finally { if (e_13) throw e_13.error; }
|
|
5676
5809
|
}
|
|
5677
5810
|
}
|
|
5678
5811
|
return functionTypeInternal(inst, stack, ctx || null);
|
|
5679
5812
|
}
|
|
5680
5813
|
function assertTypesEqual(a, b, field) {
|
|
5681
|
-
var
|
|
5814
|
+
var e_14, _a, e_15, _b;
|
|
5682
5815
|
if (field === void 0) { field = false; }
|
|
5683
5816
|
if (Array.isArray(a)) {
|
|
5684
5817
|
try {
|
|
@@ -5688,12 +5821,12 @@ function assertTypesEqual(a, b, field) {
|
|
|
5688
5821
|
assertTypeAnnotationsValid(v);
|
|
5689
5822
|
}
|
|
5690
5823
|
}
|
|
5691
|
-
catch (
|
|
5824
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
5692
5825
|
finally {
|
|
5693
5826
|
try {
|
|
5694
5827
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
5695
5828
|
}
|
|
5696
|
-
finally { if (
|
|
5829
|
+
finally { if (e_14) throw e_14.error; }
|
|
5697
5830
|
}
|
|
5698
5831
|
try {
|
|
5699
5832
|
for (var _e = __values(b), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -5701,12 +5834,12 @@ function assertTypesEqual(a, b, field) {
|
|
|
5701
5834
|
assertTypeAnnotationsValid(v);
|
|
5702
5835
|
}
|
|
5703
5836
|
}
|
|
5704
|
-
catch (
|
|
5837
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
5705
5838
|
finally {
|
|
5706
5839
|
try {
|
|
5707
5840
|
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
5708
5841
|
}
|
|
5709
|
-
finally { if (
|
|
5842
|
+
finally { if (e_15) throw e_15.error; }
|
|
5710
5843
|
}
|
|
5711
5844
|
}
|
|
5712
5845
|
else {
|
|
@@ -5881,10 +6014,10 @@ function formatError(err) {
|
|
|
5881
6014
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5882
6015
|
/* tslint:disable */
|
|
5883
6016
|
var VERSION = {
|
|
5884
|
-
"commitHash": "
|
|
5885
|
-
"version": "
|
|
6017
|
+
"commitHash": "8d7ecc86ce608bff9ee8c6cf0cd7d795263b8bda",
|
|
6018
|
+
"version": "11.0.1"
|
|
5886
6019
|
};
|
|
5887
6020
|
/* tslint:enable */
|
|
5888
6021
|
|
|
5889
|
-
export { Contract, DefaultProtocol, JSONParseError, MacroError, MichelineParseError, MichelsonError, MichelsonInstructionError, MichelsonTypeError, MichelsonValidationError, Parser, Protocol, VERSION, assertContractValid, assertDataListIfAny, assertDataValid, assertMichelsonBigMapStorableType, assertMichelsonComparableType, assertMichelsonContract, assertMichelsonData, assertMichelsonInstruction, assertMichelsonPackableType, assertMichelsonPassableType, assertMichelsonPushableType, assertMichelsonStorableType, assertMichelsonType, assertTypeAnnotationsValid, assertTypesEqual, contractEntryPoint, contractEntryPoints, contractSection, decodeAddressBytes, decodePublicKeyBytes, decodePublicKeyHashBytes, dummyContract, emitMicheline, formatError, formatStack, functionType, instructionIDs, isContractValid, isDataValid, isInstruction, isMichelsonCode, isMichelsonData, isMichelsonError, isMichelsonScript, isMichelsonType, isTypeAnnotationsValid, isTypeEqual, packData, packDataBytes, refContract, sourceReference, traceDumpFunc, unpackData, unpackDataBytes };
|
|
6022
|
+
export { Contract, DefaultProtocol, JSONParseError, MacroError, MichelineParseError, MichelsonError, MichelsonInstructionError, MichelsonTypeError, MichelsonValidationError, Parser, ProtoGreaterOfEqual, Protocol, VERSION, assertContractValid, assertDataListIfAny, assertDataValid, assertMichelsonBigMapStorableType, assertMichelsonComparableType, assertMichelsonContract, assertMichelsonData, assertMichelsonInstruction, assertMichelsonPackableType, assertMichelsonPassableType, assertMichelsonPushableType, assertMichelsonStorableType, assertMichelsonType, assertTypeAnnotationsValid, assertTypesEqual, assertViewNameValid, contractEntryPoint, contractEntryPoints, contractSection, contractViews, decodeAddressBytes, decodePublicKeyBytes, decodePublicKeyHashBytes, dummyContract, emitMicheline, formatError, formatStack, functionType, instructionIDs, isContractValid, isDataValid, isInstruction, isMichelsonCode, isMichelsonData, isMichelsonError, isMichelsonScript, isMichelsonType, isTypeAnnotationsValid, isTypeEqual, packData, packDataBytes, refContract, sourceReference, traceDumpFunc, unpackData, unpackDataBytes };
|
|
5890
6023
|
//# sourceMappingURL=taquito-michel-codec.es5.js.map
|