Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@taquito/michel-codec

Package Overview
Dependencies
Maintainers
3
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taquito/michel-codec - npm Package Compare versions

Comparing version 11.1.0 to 11.2.0-beta-RC.0

dist/taquito-michel-codec.es6.js

157

dist/lib/base58.js
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeBase58Check = exports.decodeBase58Check = exports.encodeBase58 = exports.decodeBase58 = void 0;
var H = [
const H = [
0x6a09e667 | 0,

@@ -45,3 +14,3 @@ 0xbb67ae85 | 0,

];
var K = [
const K = [
0x428a2f98 | 0, 0x71374491 | 0, 0xb5c0fbcf | 0, 0xe9b5dba5 | 0, 0x3956c25b | 0, 0x59f111f1 | 0, 0x923f82a4 | 0, 0xab1c5ed5 | 0,

@@ -58,24 +27,24 @@ 0xd807aa98 | 0, 0x12835b01 | 0, 0x243185be | 0, 0x550c7dc3 | 0, 0x72be5d74 | 0, 0x80deb1fe | 0, 0x9bdc06a7 | 0, 0xc19bf174 | 0,

function sha256(msg) {
var e_1, _a;
// pad the message
var r = (msg.length + 9) % 64;
var pad = r === 0 ? 0 : 64 - r;
const r = (msg.length + 9) % 64;
const pad = r === 0 ? 0 : 64 - r;
if (msg.length > 268435455) {
throw new Error("sha256: message length is too big: " + msg.length);
throw new Error(`sha256: message length is too big: ${msg.length}`);
}
var l = msg.length << 3;
var buffer = __spread(msg, [
0x80
], (new Array(pad).fill(0)), [
const l = msg.length << 3;
const buffer = [
...msg,
0x80,
...(new Array(pad).fill(0)),
0, 0, 0, 0, (l >> 24) & 0xff, (l >> 16) & 0xff, (l >> 8) & 0xff, l & 0xff,
]);
];
function ror(x, n) {
return (x >>> n) | (x << (32 - n));
}
var h = __spread(H);
var w = new Array(64);
var v = new Array(8);
for (var offset = 0; offset < buffer.length; offset += 64) {
var q = offset;
var i = 0;
const h = [...H];
const w = new Array(64);
const v = new Array(8);
for (let offset = 0; offset < buffer.length; offset += 64) {
let q = offset;
let i = 0;
while (i < 16) {

@@ -87,15 +56,15 @@ w[i] = (buffer[q] << 24) | (buffer[q + 1] << 16) | (buffer[q + 2] << 8) | buffer[q + 3];

while (i < 64) {
var s0 = ror(w[i - 15], 7) ^ ror(w[i - 15], 18) ^ (w[i - 15] >>> 3);
var s1 = ror(w[i - 2], 17) ^ ror(w[i - 2], 19) ^ (w[i - 2] >>> 10);
const s0 = ror(w[i - 15], 7) ^ ror(w[i - 15], 18) ^ (w[i - 15] >>> 3);
const s1 = ror(w[i - 2], 17) ^ ror(w[i - 2], 19) ^ (w[i - 2] >>> 10);
w[i] = ((s1 | 0) + w[i - 7] + s0 + w[i - 16]) | 0;
i++;
}
for (var i_1 = 0; i_1 < 8; i_1++) {
v[i_1] = h[i_1];
for (let i = 0; i < 8; i++) {
v[i] = h[i];
}
for (var i_2 = 0; i_2 < 64; i_2++) {
var b0 = ror(v[0], 2) ^ ror(v[0], 13) ^ ror(v[0], 22);
var b1 = ror(v[4], 6) ^ ror(v[4], 11) ^ ror(v[4], 25);
var t1 = (v[7] + b1 + ((v[4] & v[5]) ^ ((~v[4]) & v[6])) + K[i_2] + w[i_2]) | 0;
var t2 = (b0 + (((v[0] & v[1]) ^ (v[0] & v[2]) ^ (v[1] & v[2])))) | 0;
for (let i = 0; i < 64; i++) {
const b0 = ror(v[0], 2) ^ ror(v[0], 13) ^ ror(v[0], 22);
const b1 = ror(v[4], 6) ^ ror(v[4], 11) ^ ror(v[4], 25);
const t1 = (v[7] + b1 + ((v[4] & v[5]) ^ ((~v[4]) & v[6])) + K[i] + w[i]) | 0;
const t2 = (b0 + (((v[0] & v[1]) ^ (v[0] & v[2]) ^ (v[1] & v[2])))) | 0;
v[7] = v[6];

@@ -110,26 +79,16 @@ v[6] = v[5];

}
for (var i_3 = 0; i_3 < 8; i_3++) {
h[i_3] = (h[i_3] + v[i_3]) | 0;
for (let i = 0; i < 8; i++) {
h[i] = (h[i] + v[i]) | 0;
}
}
var digest = [];
try {
for (var h_1 = __values(h), h_1_1 = h_1.next(); !h_1_1.done; h_1_1 = h_1.next()) {
var v_1 = h_1_1.value;
digest.push((v_1 >> 24) & 0xff);
digest.push((v_1 >> 16) & 0xff);
digest.push((v_1 >> 8) & 0xff);
digest.push(v_1 & 0xff);
}
const digest = [];
for (const v of h) {
digest.push((v >> 24) & 0xff);
digest.push((v >> 16) & 0xff);
digest.push((v >> 8) & 0xff);
digest.push(v & 0xff);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (h_1_1 && !h_1_1.done && (_a = h_1.return)) _a.call(h_1);
}
finally { if (e_1) throw e_1.error; }
}
return digest;
}
var base58alphabetFwd = [
const base58alphabetFwd = [
0, 1, 2, 3, 4, 5, 6,

@@ -146,3 +105,3 @@ 7, 8, -1, -1, -1, -1, -1, -1,

];
var base58alphabetBwd = [
const base58alphabetBwd = [
0, 1, 2, 3, 4, 5, 6, 7,

@@ -158,5 +117,5 @@ 8, 16, 17, 18, 19, 20, 21, 22,

function byteAt(src, i) {
var c = src.charCodeAt(i) - 49;
const c = src.charCodeAt(i) - 49;
if (c >= base58alphabetFwd.length || base58alphabetFwd[c] === -1) {
throw new Error("Base58 decoding error: unexpected character at position " + i + ": " + src[i]);
throw new Error(`Base58 decoding error: unexpected character at position ${i}: ${src[i]}`);
}

@@ -166,4 +125,4 @@ return base58alphabetFwd[c];

function decodeBase58(src) {
var acc = [];
var i = 0;
const acc = [];
let i = 0;
// count and skip leading zeros

@@ -173,5 +132,5 @@ while (i < src.length && byteAt(src, i) === 0) {

}
var zeros = i;
let zeros = i;
while (i < src.length) {
var carry = byteAt(src, i++);
let carry = byteAt(src, i++);
/*

@@ -182,5 +141,5 @@ for every symbol x

*/
var ii = 0;
let ii = 0;
while (carry !== 0 || ii < acc.length) {
var m = (acc[ii] || 0) * 58 + carry;
const m = (acc[ii] || 0) * 58 + carry;
acc[ii++] = m % 256;

@@ -197,4 +156,4 @@ carry = Math.floor(m / 256);

function encodeBase58(src) {
var acc = [];
var i = 0;
const acc = [];
let i = 0;
// count and skip leading zeros

@@ -204,8 +163,8 @@ while (i < src.length && src[i] === 0) {

}
var zeros = i;
let zeros = i;
while (i < src.length) {
var carry = src[i++];
var ii = 0;
let carry = src[i++];
let ii = 0;
while (carry !== 0 || ii < acc.length) {
var m = (acc[ii] || 0) * 256 + carry;
const m = (acc[ii] || 0) * 256 + carry;
acc[ii++] = m % 58;

@@ -219,13 +178,13 @@ carry = Math.floor(m / 58);

acc.reverse();
return String.fromCharCode.apply(String, __spread(acc.map(function (v) { return base58alphabetBwd[v] + 49; })));
return String.fromCharCode(...acc.map(v => base58alphabetBwd[v] + 49));
}
exports.encodeBase58 = encodeBase58;
function decodeBase58Check(src) {
var buffer = decodeBase58(src);
const buffer = decodeBase58(src);
if (buffer.length < 4) {
throw new Error("Base58Check decoding error: data is too short " + buffer.length);
throw new Error(`Base58Check decoding error: data is too short ${buffer.length}`);
}
var data = buffer.slice(0, buffer.length - 4);
var sum = buffer.slice(buffer.length - 4);
var computed = sha256(sha256(data));
const data = buffer.slice(0, buffer.length - 4);
const sum = buffer.slice(buffer.length - 4);
const computed = sha256(sha256(data));
if (sum[0] !== computed[0] ||

@@ -241,6 +200,6 @@ sum[1] !== computed[1] ||

function encodeBase58Check(src) {
var sum = sha256(sha256(src));
return encodeBase58(__spread(src, sum.slice(0, 4)));
const sum = sha256(sha256(src));
return encodeBase58([...src, ...sum.slice(0, 4)]);
}
exports.encodeBase58Check = encodeBase58Check;
//# sourceMappingURL=base58.js.map
"use strict";
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodePublicKeyBytes = exports.decodePublicKeyHashBytes = exports.decodeAddressBytes = exports.unpackDataBytes = exports.unpackData = exports.packDataBytes = exports.packData = void 0;
var michelson_validator_1 = require("./michelson-validator");
var utils_1 = require("./utils");
var primitives = ["parameter", "storage", "code", "False", "Elt", "Left", "None", "Pair",
const michelson_validator_1 = require("./michelson-validator");
const utils_1 = require("./utils");
const primitives = ["parameter", "storage", "code", "False", "Elt", "Left", "None", "Pair",
"Right", "Some", "True", "Unit", "PACK", "UNPACK", "BLAKE2B", "SHA256", "SHA512", "ABS", "ADD",

@@ -80,6 +22,3 @@ "AMOUNT", "AND", "BALANCE", "CAR", "CDR", "CHECK_SIGNATURE", "COMPARE", "CONCAT", "CONS",

"READ_TICKET", "SPLIT_TICKET", "JOIN_TICKETS", "GET_AND_UPDATE"];
var primTags = Object.assign.apply(Object, __spread([{}], primitives.map(function (v, i) {
var _a;
return (_a = {}, _a[v] = i, _a);
})));
const primTags = Object.assign({}, ...primitives.map((v, i) => ({ [v]: i })));
var Tag;

@@ -99,28 +38,23 @@ (function (Tag) {

})(Tag || (Tag = {}));
var Writer = /** @class */ (function () {
function Writer() {
class Writer {
constructor() {
this.buffer = [];
}
Object.defineProperty(Writer.prototype, "length", {
get: function () {
return this.buffer.length;
},
enumerable: false,
configurable: true
});
Writer.prototype.writeBytes = function (val) {
var _a;
(_a = this.buffer).push.apply(_a, __spread(val.map(function (v) { return v & 0xff; })));
};
Writer.prototype.writeUint8 = function (val) {
var v = val | 0;
get length() {
return this.buffer.length;
}
writeBytes(val) {
this.buffer.push(...val.map(v => v & 0xff));
}
writeUint8(val) {
const v = val | 0;
this.buffer.push(v & 0xff);
};
Writer.prototype.writeUint16 = function (val) {
var v = val | 0;
}
writeUint16(val) {
const v = val | 0;
this.buffer.push((v >> 8) & 0xff);
this.buffer.push(v & 0xff);
};
Writer.prototype.writeUint32 = function (val) {
var v = val | 0;
}
writeUint32(val) {
const v = val | 0;
this.buffer.push((v >> 24) & 0xff);

@@ -130,19 +64,16 @@ this.buffer.push((v >> 16) & 0xff);

this.buffer.push(v & 0xff);
};
Writer.prototype.writeInt8 = function (val) {
}
writeInt8(val) {
this.writeUint8(val);
};
Writer.prototype.writeInt16 = function (val) {
}
writeInt16(val) {
this.writeUint16(val);
};
Writer.prototype.writeInt32 = function (val) {
}
writeInt32(val) {
this.writeUint32(val);
};
return Writer;
}());
var boundsErr = new Error("bounds out of range");
var Reader = /** @class */ (function () {
function Reader(buffer, idx, cap) {
if (idx === void 0) { idx = 0; }
if (cap === void 0) { cap = buffer.length; }
}
}
const boundsErr = new Error("bounds out of range");
class Reader {
constructor(buffer, idx = 0, cap = buffer.length) {
this.buffer = buffer;

@@ -152,30 +83,26 @@ this.idx = idx;

}
Object.defineProperty(Reader.prototype, "length", {
/** Remaining length */
get: function () {
return this.cap - this.idx;
},
enumerable: false,
configurable: true
});
Reader.prototype.readBytes = function (len) {
/** Remaining length */
get length() {
return this.cap - this.idx;
}
readBytes(len) {
if (this.cap - this.idx < len) {
throw boundsErr;
}
var ret = this.buffer.slice(this.idx, this.idx + len);
const ret = this.buffer.slice(this.idx, this.idx + len);
this.idx += len;
return ret;
};
Reader.prototype.reader = function (len) {
}
reader(len) {
if (this.cap - this.idx < len) {
throw boundsErr;
}
var ret = new Reader(this.buffer, this.idx, this.idx + len);
const ret = new Reader(this.buffer, this.idx, this.idx + len);
this.idx += len;
return ret;
};
Reader.prototype.copy = function () {
}
copy() {
return new Reader(this.buffer, this.idx, this.cap);
};
Reader.prototype.readUint8 = function () {
}
readUint8() {
if (this.cap - this.idx < 1) {

@@ -185,48 +112,47 @@ throw boundsErr;

return this.buffer[this.idx++] >>> 0;
};
Reader.prototype.readUint16 = function () {
}
readUint16() {
if (this.cap - this.idx < 2) {
throw boundsErr;
}
var x0 = this.buffer[this.idx++];
var x1 = this.buffer[this.idx++];
const x0 = this.buffer[this.idx++];
const x1 = this.buffer[this.idx++];
return ((x0 << 8) | x1) >>> 0;
};
Reader.prototype.readUint32 = function () {
}
readUint32() {
if (this.cap - this.idx < 4) {
throw boundsErr;
}
var x0 = this.buffer[this.idx++];
var x1 = this.buffer[this.idx++];
var x2 = this.buffer[this.idx++];
var x3 = this.buffer[this.idx++];
const x0 = this.buffer[this.idx++];
const x1 = this.buffer[this.idx++];
const x2 = this.buffer[this.idx++];
const x3 = this.buffer[this.idx++];
return ((x0 << 24) | (x1 << 16) | (x2 << 8) | x3) >>> 0;
};
Reader.prototype.readInt8 = function () {
}
readInt8() {
if (this.cap - this.idx < 1) {
throw boundsErr;
}
var x = this.buffer[this.idx++];
const x = this.buffer[this.idx++];
return (x << 24) >> 24;
};
Reader.prototype.readInt16 = function () {
}
readInt16() {
if (this.cap - this.idx < 2) {
throw boundsErr;
}
var x0 = this.buffer[this.idx++];
var x1 = this.buffer[this.idx++];
const x0 = this.buffer[this.idx++];
const x1 = this.buffer[this.idx++];
return (((x0 << 8) | x1) << 16) >> 16;
};
Reader.prototype.readInt32 = function () {
}
readInt32() {
if (this.cap - this.idx < 4) {
throw boundsErr;
}
var x0 = this.buffer[this.idx++];
var x1 = this.buffer[this.idx++];
var x2 = this.buffer[this.idx++];
var x3 = this.buffer[this.idx++];
const x0 = this.buffer[this.idx++];
const x1 = this.buffer[this.idx++];
const x2 = this.buffer[this.idx++];
const x3 = this.buffer[this.idx++];
return (x0 << 24) | (x1 << 16) | (x2 << 8) | x3;
};
return Reader;
}());
}
}
var ContractID;

@@ -244,4 +170,4 @@ (function (ContractID) {

function readPublicKeyHash(rd) {
var type;
var tag = rd.readUint8();
let type;
const tag = rd.readUint8();
switch (tag) {

@@ -258,9 +184,9 @@ case PublicKeyHashID.ED25519:

default:
throw new Error("unknown public key hash tag: " + tag);
throw new Error(`unknown public key hash tag: ${tag}`);
}
return { type: type, hash: rd.readBytes(20) };
return { type, hash: rd.readBytes(20) };
}
function readAddress(rd) {
var address;
var tag = rd.readUint8();
let address;
const tag = rd.readUint8();
switch (tag) {

@@ -278,7 +204,7 @@ case ContractID.Implicit:

default:
throw new Error("unknown address tag: " + tag);
throw new Error(`unknown address tag: ${tag}`);
}
if (rd.length !== 0) {
// entry point
var dec = new TextDecoder();
const dec = new TextDecoder();
address.entryPoint = dec.decode(new Uint8Array(rd.readBytes(rd.length)));

@@ -289,3 +215,3 @@ }

function writePublicKeyHash(a, w) {
var tag;
let tag;
switch (a.type) {

@@ -302,3 +228,3 @@ case "ED25519PublicKeyHash":

default:
throw new Error("unexpected address type: " + a.type);
throw new Error(`unexpected address type: ${a.type}`);
}

@@ -319,4 +245,4 @@ w.writeUint8(tag);

if (a.entryPoint !== undefined && a.entryPoint !== "" && a.entryPoint !== "default") {
var enc = new TextEncoder();
var bytes = enc.encode(a.entryPoint);
const enc = new TextEncoder();
const bytes = enc.encode(a.entryPoint);
w.writeBytes(Array.from(bytes));

@@ -332,5 +258,5 @@ }

function readPublicKey(rd) {
var ln;
var type;
var tag = rd.readUint8();
let ln;
let type;
const tag = rd.readUint8();
switch (tag) {

@@ -350,8 +276,8 @@ case PublicKeyID.ED25519:

default:
throw new Error("unknown public key tag: " + tag);
throw new Error(`unknown public key tag: ${tag}`);
}
return { type: type, publicKey: rd.readBytes(ln) };
return { type, publicKey: rd.readBytes(ln) };
}
function writePublicKey(pk, w) {
var tag;
let tag;
switch (pk.type) {

@@ -368,3 +294,3 @@ case "ED25519PublicKey":

default:
throw new Error("unexpected public key type: " + pk.type);
throw new Error(`unexpected public key type: ${pk.type}`);
}

@@ -375,24 +301,13 @@ w.writeUint8(tag);

function writeExpr(expr, wr, tf) {
var e_1, _a, e_2, _b, e_3, _c;
var _d, _e;
var _f = __read(tf(expr), 2), e = _f[0], args = _f[1];
var _a, _b;
const [e, args] = tf(expr);
if (Array.isArray(e)) {
var w = new Writer();
try {
for (var e_4 = __values(e), e_4_1 = e_4.next(); !e_4_1.done; e_4_1 = e_4.next()) {
var v = e_4_1.value;
var a = args.next();
if (a.done) {
throw new Error("REPORT ME: iterator is done");
}
writeExpr(v, w, a.value);
const w = new Writer();
for (const v of e) {
const a = args.next();
if (a.done) {
throw new Error("REPORT ME: iterator is done");
}
writeExpr(v, w, a.value);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (e_4_1 && !e_4_1.done && (_a = e_4.return)) _a.call(e_4);
}
finally { if (e_1) throw e_1.error; }
}
wr.writeUint8(Tag.Sequence);

@@ -404,4 +319,4 @@ wr.writeUint32(w.length);

if ("string" in e) {
var enc = new TextEncoder();
var bytes = enc.encode(e.string);
const enc = new TextEncoder();
const bytes = enc.encode(e.string);
wr.writeUint8(Tag.String);

@@ -414,11 +329,11 @@ wr.writeUint32(bytes.length);

wr.writeUint8(Tag.Int);
var val = BigInt(e.int);
var sign = val < 0;
let val = BigInt(e.int);
const sign = val < 0;
if (sign) {
val = -val;
}
var i = 0;
let i = 0;
do {
var bits = (i === 0) ? BigInt(6) : BigInt(7);
var byte = val & ((BigInt(1) << bits) - BigInt(1));
const bits = (i === 0) ? BigInt(6) : BigInt(7);
let byte = val & ((BigInt(1) << bits) - BigInt(1));
val >>= bits;

@@ -437,3 +352,3 @@ if (val) {

if ("bytes" in e) {
var bytes = utils_1.parseHex(e.bytes);
const bytes = utils_1.parseHex(e.bytes);
wr.writeUint8(Tag.Bytes);

@@ -444,8 +359,8 @@ wr.writeUint32(bytes.length);

}
var prim = primTags[e.prim];
const prim = primTags[e.prim];
if (prim === undefined) {
throw new TypeError("Can't encode primary: " + e.prim);
throw new TypeError(`Can't encode primary: ${e.prim}`);
}
var tag = (((_d = e.args) === null || _d === void 0 ? void 0 : _d.length) || 0) < 3 ?
Tag.Prim0 + (((_e = e.args) === null || _e === void 0 ? void 0 : _e.length) || 0) * 2 + (e.annots === undefined || e.annots.length === 0 ? 0 : 1) :
const tag = (((_a = e.args) === null || _a === void 0 ? void 0 : _a.length) || 0) < 3 ?
Tag.Prim0 + (((_b = e.args) === null || _b === void 0 ? void 0 : _b.length) || 0) * 2 + (e.annots === undefined || e.annots.length === 0 ? 0 : 1) :
Tag.Prim;

@@ -456,39 +371,19 @@ wr.writeUint8(tag);

if (e.args.length < 3) {
try {
for (var _g = __values(e.args), _h = _g.next(); !_h.done; _h = _g.next()) {
var v = _h.value;
var a = args.next();
if (a.done) {
throw new Error("REPORT ME: iterator is done");
}
writeExpr(v, wr, a.value);
for (const v of e.args) {
const a = args.next();
if (a.done) {
throw new Error("REPORT ME: iterator is done");
}
writeExpr(v, wr, a.value);
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
}
finally { if (e_2) throw e_2.error; }
}
}
else {
var w = new Writer();
try {
for (var _j = __values(e.args), _k = _j.next(); !_k.done; _k = _j.next()) {
var v = _k.value;
var a = args.next();
if (a.done) {
throw new Error("REPORT ME: iterator is done");
}
writeExpr(v, w, a.value);
const w = new Writer();
for (const v of e.args) {
const a = args.next();
if (a.done) {
throw new Error("REPORT ME: iterator is done");
}
writeExpr(v, w, a.value);
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
}
finally { if (e_3) throw e_3.error; }
}
wr.writeUint32(w.length);

@@ -499,4 +394,4 @@ wr.writeBytes(w.buffer);

if (e.annots !== undefined && e.annots.length !== 0) {
var enc = new TextEncoder();
var bytes = enc.encode(e.annots.join(" "));
const enc = new TextEncoder();
const bytes = enc.encode(e.annots.join(" "));
wr.writeUint32(bytes.length);

@@ -510,22 +405,14 @@ wr.writeBytes(Array.from(bytes));

function readExpr(rd, tf) {
function passThrough() {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!true) return [3 /*break*/, 2];
return [4 /*yield*/, readPassThrough];
case 1:
_a.sent();
return [3 /*break*/, 0];
case 2: return [2 /*return*/];
}
});
function* passThrough() {
while (true) {
yield readPassThrough;
}
}
var _a = __read(tf, 2), args = _a[0], tr = _a[1];
var tag = rd.readUint8();
const [args, tr] = tf;
const tag = rd.readUint8();
switch (tag) {
case Tag.Int:
{
var buf = [];
var byte = void 0;
const buf = [];
let byte;
do {

@@ -535,11 +422,11 @@ byte = rd.readInt8();

} while ((byte & 0x80) !== 0);
var val = BigInt(0);
var sign = false;
for (var i = buf.length - 1; i >= 0; i--) {
var bits = (i === 0) ? BigInt(6) : BigInt(7);
var byte_1 = BigInt(buf[i]);
let val = BigInt(0);
let sign = false;
for (let i = buf.length - 1; i >= 0; i--) {
const bits = (i === 0) ? BigInt(6) : BigInt(7);
const byte = BigInt(buf[i]);
val <<= bits;
val |= byte_1 & ((BigInt(1) << bits) - BigInt(1));
val |= byte & ((BigInt(1) << bits) - BigInt(1));
if (i === 0) {
sign = !!(byte_1 & BigInt(0x40));
sign = !!(byte & BigInt(0x40));
}

@@ -554,5 +441,5 @@ }

{
var length_1 = rd.readUint32();
var bytes = rd.readBytes(length_1);
var dec = new TextDecoder();
const length = rd.readUint32();
const bytes = rd.readBytes(length);
const dec = new TextDecoder();
return tr({ string: dec.decode(new Uint8Array(bytes)) });

@@ -562,5 +449,5 @@ }

{
var length_2 = rd.readUint32();
var bytes = rd.readBytes(length_2);
var hex = utils_1.hexBytes(Array.from(bytes));
const length = rd.readUint32();
const bytes = rd.readBytes(length);
const hex = utils_1.hexBytes(Array.from(bytes));
return tr({ bytes: hex });

@@ -570,12 +457,12 @@ }

{
var length_3 = rd.readUint32();
var res = [];
var savedrd = rd.copy();
const length = rd.readUint32();
let res = [];
let savedrd = rd.copy();
// make two passes
var it_1 = passThrough();
for (var n = 0; n < 2; n++) {
var r = savedrd.reader(length_3);
let it = passThrough();
for (let n = 0; n < 2; n++) {
const r = savedrd.reader(length);
res = [];
while (r.length > 0) {
var a = it_1.next();
const a = it.next();
if (a.done) {

@@ -587,3 +474,3 @@ throw new Error("REPORT ME: iterator is done");

// make a second pass with injected side effects
it_1 = args(res);
it = args(res);
savedrd = rd;

@@ -596,19 +483,19 @@ }

if (tag > 9) {
throw new Error("Unknown tag: " + tag);
throw new Error(`Unknown tag: ${tag}`);
}
var p = rd.readUint8();
const p = rd.readUint8();
if (p >= primitives.length) {
throw new Error("Unknown primitive tag: " + p);
throw new Error(`Unknown primitive tag: ${p}`);
}
var prim = primitives[p];
var argn = (tag - 3) >> 1;
var res = { prim: prim };
const prim = primitives[p];
const argn = (tag - 3) >> 1;
let res = { prim };
// make two passes
var it_2 = passThrough();
var savedrd = rd.copy();
for (var n = 0; n < 2; n++) {
res = { prim: prim };
let it = passThrough();
let savedrd = rd.copy();
for (let n = 0; n < 2; n++) {
res = { prim };
if (argn < 3) {
for (var i = 0; i < argn; i++) {
var a = it_2.next();
for (let i = 0; i < argn; i++) {
const a = it.next();
if (a.done) {

@@ -623,6 +510,6 @@ throw new Error("REPORT ME: iterator is done");

res.args = res.args || [];
var length_4 = savedrd.readUint32();
var r = savedrd.reader(length_4);
const length = savedrd.readUint32();
const r = savedrd.reader(length);
while (r.length > 0) {
var a = it_2.next();
const a = it.next();
if (a.done) {

@@ -635,3 +522,3 @@ throw new Error("REPORT ME: iterator is done");

// make a second pass with injected side effects
it_2 = args(res);
it = args(res);
savedrd = rd;

@@ -641,6 +528,6 @@ }

// read annotations
var length_5 = rd.readUint32();
if (length_5 !== 0) {
var bytes = rd.readBytes(length_5);
var dec = new TextDecoder();
const length = rd.readUint32();
if (length !== 0) {
const bytes = rd.readBytes(length);
const dec = new TextDecoder();
res.annots = dec.decode(new Uint8Array(bytes)).split(" ");

@@ -653,47 +540,18 @@ }

}
var isOrData = function (e) { return "prim" in e && (e.prim === "Left" || e.prim === "Right"); };
var isOptionData = function (e) { return "prim" in e && (e.prim === "Some" || e.prim === "None"); };
var getWriteTransformFunc = function (t) {
const isOrData = (e) => "prim" in e && (e.prim === "Left" || e.prim === "Right");
const isOptionData = (e) => "prim" in e && (e.prim === "Some" || e.prim === "None");
const getWriteTransformFunc = (t) => {
if (utils_1.isPairType(t)) {
return function (d) {
return (d) => {
if (!utils_1.isPairData(d)) {
throw new utils_1.MichelsonTypeError(t, d, "pair expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `pair expected: ${JSON.stringify(d)}`);
}
michelson_validator_1.assertDataListIfAny(d);
// combs aren't used in pack format
var tc = utils_1.unpackComb("pair", t);
var dc = utils_1.unpackComb("Pair", d);
return [dc, (function () {
var _a, _b, a, e_5_1;
var e_5, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_d.trys.push([0, 5, 6, 7]);
_a = __values(tc.args), _b = _a.next();
_d.label = 1;
case 1:
if (!!_b.done) return [3 /*break*/, 4];
a = _b.value;
return [4 /*yield*/, getWriteTransformFunc(a)];
case 2:
_d.sent();
_d.label = 3;
case 3:
_b = _a.next();
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5:
e_5_1 = _d.sent();
e_5 = { error: e_5_1 };
return [3 /*break*/, 7];
case 6:
try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
}
finally { if (e_5) throw e_5.error; }
return [7 /*endfinally*/];
case 7: return [2 /*return*/];
}
});
const tc = utils_1.unpackComb("pair", t);
const dc = utils_1.unpackComb("Pair", d);
return [dc, (function* () {
for (const a of tc.args) {
yield getWriteTransformFunc(a);
}
})()];

@@ -704,36 +562,20 @@ };

case "or":
return function (d) {
return (d) => {
if (!isOrData(d)) {
throw new utils_1.MichelsonTypeError(t, d, "or expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `or expected: ${JSON.stringify(d)}`);
}
return [d, (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getWriteTransformFunc(t.args[d.prim === "Left" ? 0 : 1])];
case 1:
_a.sent();
return [2 /*return*/];
}
});
return [d, (function* () {
yield getWriteTransformFunc(t.args[d.prim === "Left" ? 0 : 1]);
})()];
};
case "option":
return function (d) {
return (d) => {
if (!isOptionData(d)) {
throw new utils_1.MichelsonTypeError(t, d, "option expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `option expected: ${JSON.stringify(d)}`);
}
return [d, (function () {
var dd;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
dd = d;
if (!(dd.prim === "Some")) return [3 /*break*/, 2];
return [4 /*yield*/, getWriteTransformFunc(t.args[0])];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
}
});
return [d, (function* () {
const dd = d;
if (dd.prim === "Some") {
yield getWriteTransformFunc(t.args[0]);
}
})()];

@@ -743,129 +585,42 @@ };

case "set":
return function (d) {
return (d) => {
if (!Array.isArray(d)) {
throw new utils_1.MichelsonTypeError(t, d, t.prim + " expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `${t.prim} expected: ${JSON.stringify(d)}`);
}
return [d, (function () {
var d_1, d_1_1, _v, e_6_1;
var e_6, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 5, 6, 7]);
d_1 = __values(d), d_1_1 = d_1.next();
_b.label = 1;
case 1:
if (!!d_1_1.done) return [3 /*break*/, 4];
_v = d_1_1.value;
return [4 /*yield*/, getWriteTransformFunc(t.args[0])];
case 2:
_b.sent();
_b.label = 3;
case 3:
d_1_1 = d_1.next();
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5:
e_6_1 = _b.sent();
e_6 = { error: e_6_1 };
return [3 /*break*/, 7];
case 6:
try {
if (d_1_1 && !d_1_1.done && (_a = d_1.return)) _a.call(d_1);
}
finally { if (e_6) throw e_6.error; }
return [7 /*endfinally*/];
case 7: return [2 /*return*/];
}
});
return [d, (function* () {
for (const _v of d) {
yield getWriteTransformFunc(t.args[0]);
}
})()];
};
case "map":
return function (d) {
return (d) => {
if (!Array.isArray(d)) {
throw new utils_1.MichelsonTypeError(t, d, "map expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `map expected: ${JSON.stringify(d)}`);
}
return [d, (function () {
var d_2, d_2_1, _elt, e_7_1;
var e_7, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 5, 6, 7]);
d_2 = __values(d), d_2_1 = d_2.next();
_b.label = 1;
case 1:
if (!!d_2_1.done) return [3 /*break*/, 4];
_elt = d_2_1.value;
return [4 /*yield*/, function (elt) {
if (!("prim" in elt) || elt.prim !== "Elt") {
throw new utils_1.MichelsonTypeError(t, elt, "map element expected: " + JSON.stringify(elt));
}
return [elt, (function () {
var _a, _b, a, e_8_1;
var e_8, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_d.trys.push([0, 5, 6, 7]);
_a = __values(t.args), _b = _a.next();
_d.label = 1;
case 1:
if (!!_b.done) return [3 /*break*/, 4];
a = _b.value;
return [4 /*yield*/, getWriteTransformFunc(a)];
case 2:
_d.sent();
_d.label = 3;
case 3:
_b = _a.next();
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5:
e_8_1 = _d.sent();
e_8 = { error: e_8_1 };
return [3 /*break*/, 7];
case 6:
try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
}
finally { if (e_8) throw e_8.error; }
return [7 /*endfinally*/];
case 7: return [2 /*return*/];
}
});
})()];
}];
case 2:
_b.sent();
_b.label = 3;
case 3:
d_2_1 = d_2.next();
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5:
e_7_1 = _b.sent();
e_7 = { error: e_7_1 };
return [3 /*break*/, 7];
case 6:
try {
if (d_2_1 && !d_2_1.done && (_a = d_2.return)) _a.call(d_2);
}
finally { if (e_7) throw e_7.error; }
return [7 /*endfinally*/];
case 7: return [2 /*return*/];
}
});
return [d, (function* () {
for (const _elt of d) {
yield (elt) => {
if (!("prim" in elt) || elt.prim !== "Elt") {
throw new utils_1.MichelsonTypeError(t, elt, `map element expected: ${JSON.stringify(elt)}`);
}
return [elt, (function* () {
for (const a of t.args) {
yield getWriteTransformFunc(a);
}
})()];
};
}
})()];
};
case "chain_id":
return function (d) {
return (d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "chain id expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `chain id expected: ${JSON.stringify(d)}`);
}
var bytes;
let bytes;
if ("string" in d) {
var id = utils_1.checkDecodeTezosID(d.string, "ChainID");
const id = utils_1.checkDecodeTezosID(d.string, "ChainID");
if (id === null) {
throw new utils_1.MichelsonTypeError(t, d, "chain id base58 expected: " + d.string);
throw new utils_1.MichelsonTypeError(t, d, `chain id base58 expected: ${d.string}`);
}

@@ -880,11 +635,11 @@ bytes = { bytes: utils_1.hexBytes(id[1]) };

case "signature":
return function (d) {
return (d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "signature expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `signature expected: ${JSON.stringify(d)}`);
}
var bytes;
let bytes;
if ("string" in d) {
var sig = utils_1.checkDecodeTezosID(d.string, "ED25519Signature", "SECP256K1Signature", "P256Signature", "GenericSignature");
const sig = utils_1.checkDecodeTezosID(d.string, "ED25519Signature", "SECP256K1Signature", "P256Signature", "GenericSignature");
if (sig === null) {
throw new utils_1.MichelsonTypeError(t, d, "signature base58 expected: " + d.string);
throw new utils_1.MichelsonTypeError(t, d, `signature base58 expected: ${d.string}`);
}

@@ -899,13 +654,13 @@ bytes = { bytes: utils_1.hexBytes(sig[1]) };

case "key_hash":
return function (d) {
return (d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "key hash expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `key hash expected: ${JSON.stringify(d)}`);
}
var bytes;
let bytes;
if ("string" in d) {
var pkh = utils_1.checkDecodeTezosID(d.string, "ED25519PublicKeyHash", "SECP256K1PublicKeyHash", "P256PublicKeyHash");
const pkh = utils_1.checkDecodeTezosID(d.string, "ED25519PublicKeyHash", "SECP256K1PublicKeyHash", "P256PublicKeyHash");
if (pkh === null) {
throw new utils_1.MichelsonTypeError(t, d, "key hash base58 expected: " + d.string);
throw new utils_1.MichelsonTypeError(t, d, `key hash base58 expected: ${d.string}`);
}
var w = new Writer();
const w = new Writer();
writePublicKeyHash({ type: pkh[0], hash: pkh[1] }, w);

@@ -920,13 +675,13 @@ bytes = { bytes: utils_1.hexBytes(w.buffer) };

case "key":
return function (d) {
return (d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "public key expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `public key expected: ${JSON.stringify(d)}`);
}
var bytes;
let bytes;
if ("string" in d) {
var key = utils_1.checkDecodeTezosID(d.string, "ED25519PublicKey", "SECP256K1PublicKey", "P256PublicKey");
const key = utils_1.checkDecodeTezosID(d.string, "ED25519PublicKey", "SECP256K1PublicKey", "P256PublicKey");
if (key === null) {
throw new utils_1.MichelsonTypeError(t, d, "public key base58 expected: " + d.string);
throw new utils_1.MichelsonTypeError(t, d, `public key base58 expected: ${d.string}`);
}
var w = new Writer();
const w = new Writer();
writePublicKey({ type: key[0], publicKey: key[1] }, w);

@@ -941,14 +696,14 @@ bytes = { bytes: utils_1.hexBytes(w.buffer) };

case "address":
return function (d) {
return (d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "address expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `address expected: ${JSON.stringify(d)}`);
}
var bytes;
let bytes;
if ("string" in d) {
var s = d.string.split("%");
var address = utils_1.checkDecodeTezosID(s[0], "ED25519PublicKeyHash", "SECP256K1PublicKeyHash", "P256PublicKeyHash", "ContractHash");
const s = d.string.split("%");
const address = utils_1.checkDecodeTezosID(s[0], "ED25519PublicKeyHash", "SECP256K1PublicKeyHash", "P256PublicKeyHash", "ContractHash");
if (address === null) {
throw new utils_1.MichelsonTypeError(t, d, "address base58 expected: " + d.string);
throw new utils_1.MichelsonTypeError(t, d, `address base58 expected: ${d.string}`);
}
var w = new Writer();
const w = new Writer();
writeAddress({ type: address[0], hash: address[1], entryPoint: s.length > 1 ? s[1] : undefined }, w);

@@ -963,11 +718,11 @@ bytes = { bytes: utils_1.hexBytes(w.buffer) };

case "timestamp":
return function (d) {
return (d) => {
if (!("string" in d) && !("int" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "timestamp expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `timestamp expected: ${JSON.stringify(d)}`);
}
var int;
let int;
if ("string" in d) {
var p = utils_1.parseDate(d);
const p = utils_1.parseDate(d);
if (p === null) {
throw new utils_1.MichelsonTypeError(t, d, "can't parse date: " + d.string);
throw new utils_1.MichelsonTypeError(t, d, `can't parse date: ${d.string}`);
}

@@ -985,33 +740,16 @@ int = { int: String(Math.floor(p.getTime() / 1000)) };

};
var isPushInstruction = function (e) { return "prim" in e && e.prim === "PUSH"; };
var writePassThrough = function (e) {
const isPushInstruction = (e) => "prim" in e && e.prim === "PUSH";
const writePassThrough = (e) => {
if (isPushInstruction(e)) {
michelson_validator_1.assertMichelsonInstruction(e);
// capture inlined type definition
return [e, (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, writePassThrough];
case 1:
_a.sent();
return [4 /*yield*/, getWriteTransformFunc(e.args[0])];
case 2:
_a.sent();
return [2 /*return*/];
}
});
return [e, (function* () {
yield writePassThrough;
yield getWriteTransformFunc(e.args[0]);
})()];
}
return [e, (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!true) return [3 /*break*/, 2];
return [4 /*yield*/, writePassThrough];
case 1:
_a.sent();
return [3 /*break*/, 0];
case 2: return [2 /*return*/];
}
});
return [e, (function* () {
while (true) {
yield writePassThrough;
}
})()];

@@ -1055,3 +793,3 @@ };

function packData(d, t) {
var w = new Writer();
const w = new Writer();
w.writeUint8(5);

@@ -1088,46 +826,17 @@ writeExpr(d, w, t !== undefined ? getWriteTransformFunc(t) : writePassThrough);

exports.packDataBytes = packDataBytes;
var getReadTransformFuncs = function (t) {
const getReadTransformFuncs = (t) => {
if (utils_1.isPairType(t)) {
var args_1 = Array.isArray(t) ? t : t.args;
const args = Array.isArray(t) ? t : t.args;
return [
function (d) {
(d) => {
if (!utils_1.isPairData(d)) {
throw new utils_1.MichelsonTypeError(t, d, "pair expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `pair expected: ${JSON.stringify(d)}`);
}
return (function () {
var args_2, args_2_1, a, e_9_1;
var e_9, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 5, 6, 7]);
args_2 = __values(args_1), args_2_1 = args_2.next();
_b.label = 1;
case 1:
if (!!args_2_1.done) return [3 /*break*/, 4];
a = args_2_1.value;
return [4 /*yield*/, getReadTransformFuncs(a)];
case 2:
_b.sent();
_b.label = 3;
case 3:
args_2_1 = args_2.next();
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5:
e_9_1 = _b.sent();
e_9 = { error: e_9_1 };
return [3 /*break*/, 7];
case 6:
try {
if (args_2_1 && !args_2_1.done && (_a = args_2.return)) _a.call(args_2);
}
finally { if (e_9) throw e_9.error; }
return [7 /*endfinally*/];
case 7: return [2 /*return*/];
}
});
return (function* () {
for (const a of args) {
yield getReadTransformFuncs(a);
}
})();
},
function (d) { return d; }
(d) => d
];

@@ -1138,40 +847,25 @@ }

return [
function (d) {
(d) => {
if (!isOrData(d)) {
throw new utils_1.MichelsonTypeError(t, d, "or expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `or expected: ${JSON.stringify(d)}`);
}
return (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getReadTransformFuncs(t.args[d.prim === "Left" ? 0 : 1])];
case 1:
_a.sent();
return [2 /*return*/];
}
});
return (function* () {
yield getReadTransformFuncs(t.args[d.prim === "Left" ? 0 : 1]);
})();
},
function (d) { return d; }
(d) => d
];
case "option":
return [
function (d) {
(d) => {
if (!isOptionData(d)) {
throw new utils_1.MichelsonTypeError(t, d, "option expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `option expected: ${JSON.stringify(d)}`);
}
return (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(d.prim === "Some")) return [3 /*break*/, 2];
return [4 /*yield*/, getReadTransformFuncs(t.args[0])];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
}
});
return (function* () {
if (d.prim === "Some") {
yield getReadTransformFuncs(t.args[0]);
}
})();
},
function (d) { return d; }
(d) => d
];

@@ -1181,91 +875,46 @@ case "list":

return [
function (d) {
(d) => {
if (!Array.isArray(d)) {
throw new utils_1.MichelsonTypeError(t, d, t.prim + " expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `${t.prim} expected: ${JSON.stringify(d)}`);
}
return (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!true) return [3 /*break*/, 2];
return [4 /*yield*/, getReadTransformFuncs(t.args[0])];
case 1:
_a.sent();
return [3 /*break*/, 0];
case 2: return [2 /*return*/];
}
});
return (function* () {
while (true) {
yield getReadTransformFuncs(t.args[0]);
}
})();
},
function (d) { return d; }
(d) => d
];
case "map":
return [
function (d) {
(d) => {
if (!Array.isArray(d)) {
throw new utils_1.MichelsonTypeError(t, d, "map expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `map expected: ${JSON.stringify(d)}`);
}
return (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!true) return [3 /*break*/, 2];
return [4 /*yield*/, [
function (elt) {
if (!("prim" in elt) || elt.prim !== "Elt") {
throw new utils_1.MichelsonTypeError(t, elt, "map element expected: " + JSON.stringify(elt));
}
return (function () {
var _a, _b, a, e_10_1;
var e_10, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_d.trys.push([0, 5, 6, 7]);
_a = __values(t.args), _b = _a.next();
_d.label = 1;
case 1:
if (!!_b.done) return [3 /*break*/, 4];
a = _b.value;
return [4 /*yield*/, getReadTransformFuncs(a)];
case 2:
_d.sent();
_d.label = 3;
case 3:
_b = _a.next();
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5:
e_10_1 = _d.sent();
e_10 = { error: e_10_1 };
return [3 /*break*/, 7];
case 6:
try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
}
finally { if (e_10) throw e_10.error; }
return [7 /*endfinally*/];
case 7: return [2 /*return*/];
}
});
})();
},
function (elt) { return elt; }
]];
case 1:
_a.sent();
return [3 /*break*/, 0];
case 2: return [2 /*return*/];
}
});
return (function* () {
while (true) {
yield [
(elt) => {
if (!("prim" in elt) || elt.prim !== "Elt") {
throw new utils_1.MichelsonTypeError(t, elt, `map element expected: ${JSON.stringify(elt)}`);
}
return (function* () {
for (const a of t.args) {
yield getReadTransformFuncs(a);
}
})();
},
(elt) => elt
];
}
})();
},
function (d) { return d; }
(d) => d
];
case "chain_id":
return [
function () { return [][Symbol.iterator](); },
function (d) {
() => [][Symbol.iterator](),
(d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "chain id expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `chain id expected: ${JSON.stringify(d)}`);
}

@@ -1275,5 +924,5 @@ if ("string" in d) {

}
var bytes = utils_1.parseBytes(d.bytes);
const bytes = utils_1.parseBytes(d.bytes);
if (bytes === null) {
throw new utils_1.MichelsonTypeError(t, d, "can't parse bytes: " + d.bytes);
throw new utils_1.MichelsonTypeError(t, d, `can't parse bytes: ${d.bytes}`);
}

@@ -1285,6 +934,6 @@ return { string: utils_1.encodeTezosID("ChainID", bytes) };

return [
function () { return [][Symbol.iterator](); },
function (d) {
() => [][Symbol.iterator](),
(d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "signature expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `signature expected: ${JSON.stringify(d)}`);
}

@@ -1294,5 +943,5 @@ if ("string" in d) {

}
var bytes = utils_1.parseBytes(d.bytes);
const bytes = utils_1.parseBytes(d.bytes);
if (bytes === null) {
throw new utils_1.MichelsonTypeError(t, d, "can't parse bytes: " + d.bytes);
throw new utils_1.MichelsonTypeError(t, d, `can't parse bytes: ${d.bytes}`);
}

@@ -1304,6 +953,6 @@ return { string: utils_1.encodeTezosID("GenericSignature", bytes) };

return [
function () { return [][Symbol.iterator](); },
function (d) {
() => [][Symbol.iterator](),
(d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "key hash expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `key hash expected: ${JSON.stringify(d)}`);
}

@@ -1313,8 +962,8 @@ if ("string" in d) {

}
var bytes = utils_1.parseBytes(d.bytes);
const bytes = utils_1.parseBytes(d.bytes);
if (bytes === null) {
throw new utils_1.MichelsonTypeError(t, d, "can't parse bytes: " + d.bytes);
throw new utils_1.MichelsonTypeError(t, d, `can't parse bytes: ${d.bytes}`);
}
var rd = new Reader(new Uint8Array(bytes));
var addr = readPublicKeyHash(rd);
const rd = new Reader(new Uint8Array(bytes));
const addr = readPublicKeyHash(rd);
return { string: utils_1.encodeTezosID(addr.type, addr.hash) + (addr.entryPoint ? "%" + addr.entryPoint : "") };

@@ -1325,6 +974,6 @@ }

return [
function () { return [][Symbol.iterator](); },
function (d) {
() => [][Symbol.iterator](),
(d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "public key expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `public key expected: ${JSON.stringify(d)}`);
}

@@ -1334,8 +983,8 @@ if ("string" in d) {

}
var bytes = utils_1.parseBytes(d.bytes);
const bytes = utils_1.parseBytes(d.bytes);
if (bytes === null) {
throw new utils_1.MichelsonTypeError(t, d, "can't parse bytes: " + d.bytes);
throw new utils_1.MichelsonTypeError(t, d, `can't parse bytes: ${d.bytes}`);
}
var rd = new Reader(new Uint8Array(bytes));
var pk = readPublicKey(rd);
const rd = new Reader(new Uint8Array(bytes));
const pk = readPublicKey(rd);
return { string: utils_1.encodeTezosID(pk.type, pk.publicKey) };

@@ -1346,6 +995,6 @@ }

return [
function () { return [][Symbol.iterator](); },
function (d) {
() => [][Symbol.iterator](),
(d) => {
if (!("bytes" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "address expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `address expected: ${JSON.stringify(d)}`);
}

@@ -1355,8 +1004,8 @@ if ("string" in d) {

}
var bytes = utils_1.parseBytes(d.bytes);
const bytes = utils_1.parseBytes(d.bytes);
if (bytes === null) {
throw new utils_1.MichelsonTypeError(t, d, "can't parse bytes: " + d.bytes);
throw new utils_1.MichelsonTypeError(t, d, `can't parse bytes: ${d.bytes}`);
}
var rd = new Reader(new Uint8Array(bytes));
var addr = readAddress(rd);
const rd = new Reader(new Uint8Array(bytes));
const addr = readAddress(rd);
return { string: utils_1.encodeTezosID(addr.type, addr.hash) + (addr.entryPoint ? "%" + addr.entryPoint : "") };

@@ -1367,6 +1016,6 @@ }

return [
function () { return [][Symbol.iterator](); },
function (d) {
() => [][Symbol.iterator](),
(d) => {
if (!("int" in d) && !("string" in d)) {
throw new utils_1.MichelsonTypeError(t, d, "address expected: " + JSON.stringify(d));
throw new utils_1.MichelsonTypeError(t, d, `address expected: ${JSON.stringify(d)}`);
}

@@ -1376,3 +1025,3 @@ if ("string" in d) {

}
var date = new Date(parseInt(d.int, 10) * 1000);
const date = new Date(parseInt(d.int, 10) * 1000);
return { string: date.toISOString().slice(0, 19) + "Z" };

@@ -1385,36 +1034,19 @@ }

};
var readPassThrough = [
function (e) {
const readPassThrough = [
(e) => {
if (isPushInstruction(e)) {
michelson_validator_1.assertMichelsonInstruction(e);
// capture inlined type definition
return (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, readPassThrough];
case 1:
_a.sent();
return [4 /*yield*/, getReadTransformFuncs(e.args[0])];
case 2:
_a.sent();
return [2 /*return*/];
}
});
return (function* () {
yield readPassThrough;
yield getReadTransformFuncs(e.args[0]);
})();
}
return (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!true) return [3 /*break*/, 2];
return [4 /*yield*/, readPassThrough];
case 1:
_a.sent();
return [3 /*break*/, 0];
case 2: return [2 /*return*/];
}
});
return (function* () {
while (true) {
yield readPassThrough;
}
})();
},
function (e) { return e; }
(e) => e
];

@@ -1452,7 +1084,7 @@ /**

function unpackData(src, t) {
var r = new Reader(src);
const r = new Reader(src);
if (r.readUint8() !== 5) {
throw new Error("incorrect packed data magic number");
}
var ex = readExpr(r, t !== undefined ? getReadTransformFuncs(t) : readPassThrough);
const ex = readExpr(r, t !== undefined ? getReadTransformFuncs(t) : readPassThrough);
if (michelson_validator_1.assertMichelsonData(ex)) {

@@ -1484,5 +1116,5 @@ return ex;

function unpackDataBytes(src, t) {
var bytes = utils_1.parseBytes(src.bytes);
const bytes = utils_1.parseBytes(src.bytes);
if (bytes === null) {
throw new Error("can't parse bytes: \"" + src.bytes + "\"");
throw new Error(`can't parse bytes: "${src.bytes}"`);
}

@@ -1494,7 +1126,7 @@ return unpackData(bytes, t);

function decodeAddressBytes(b) {
var bytes = utils_1.parseBytes(b.bytes);
const bytes = utils_1.parseBytes(b.bytes);
if (bytes === null) {
throw new Error("can't parse bytes: \"" + b.bytes + "\"");
throw new Error(`can't parse bytes: "${b.bytes}"`);
}
var rd = new Reader(new Uint8Array(bytes));
const rd = new Reader(new Uint8Array(bytes));
return readAddress(rd);

@@ -1504,7 +1136,7 @@ }

function decodePublicKeyHashBytes(b) {
var bytes = utils_1.parseBytes(b.bytes);
const bytes = utils_1.parseBytes(b.bytes);
if (bytes === null) {
throw new Error("can't parse bytes: \"" + b.bytes + "\"");
throw new Error(`can't parse bytes: "${b.bytes}"`);
}
var rd = new Reader(new Uint8Array(bytes));
const rd = new Reader(new Uint8Array(bytes));
return readPublicKeyHash(rd);

@@ -1514,7 +1146,7 @@ }

function decodePublicKeyBytes(b) {
var bytes = utils_1.parseBytes(b.bytes);
const bytes = utils_1.parseBytes(b.bytes);
if (bytes === null) {
throw new Error("can't parse bytes: \"" + b.bytes + "\"");
throw new Error(`can't parse bytes: "${b.bytes}"`);
}
var rd = new Reader(new Uint8Array(bytes));
const rd = new Reader(new Uint8Array(bytes));
return readPublicKey(rd);

@@ -1521,0 +1153,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatError = exports.traceDumpFunc = exports.formatStack = void 0;
var micheline_1 = require("./micheline");
var michelson_typecheck_1 = require("./michelson-typecheck");
var micheline_emitter_1 = require("./micheline-emitter");
var utils_1 = require("./utils");
const micheline_1 = require("./micheline");
const michelson_typecheck_1 = require("./michelson-typecheck");
const micheline_emitter_1 = require("./micheline-emitter");
const utils_1 = require("./utils");
function formatStack(s) {
if ("failed" in s) {
return "[FAILED: " + micheline_emitter_1.emitMicheline(s.failed) + "]";
return `[FAILED: ${micheline_emitter_1.emitMicheline(s.failed)}]`;
}
return s.map(function (v, i) {
var ann = utils_1.unpackAnnotations(v);
return "[" + i + (ann.v ? "/" + ann.v[0] : "") + "]: " + micheline_emitter_1.emitMicheline(v);
return s.map((v, i) => {
const ann = utils_1.unpackAnnotations(v);
return `[${i}${ann.v ? "/" + ann.v[0] : ""}]: ${micheline_emitter_1.emitMicheline(v)}`;
}).join("\n");

@@ -19,3 +19,3 @@ }

function traceDumpFunc(blocks, cb) {
return function (v) {
return (v) => {
var _a;

@@ -25,4 +25,9 @@ if (Array.isArray(v) && !blocks) {

}
var macro = (_a = v.op[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
var msg = (macro ? "Macro" : "Op") + ": " + (macro ? micheline_emitter_1.emitMicheline(macro, undefined, true) + " / " : "") + micheline_emitter_1.emitMicheline(v.op) + "\nInput:\n" + formatStack(v.in) + "\nOutput:\n" + formatStack(v.out) + "\n";
const macro = (_a = v.op[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
const msg = `${macro ? "Macro" : "Op"}: ${macro ? micheline_emitter_1.emitMicheline(macro, undefined, true) + " / " : ""}${micheline_emitter_1.emitMicheline(v.op)}
Input:
${formatStack(v.in)}
Output:
${formatStack(v.out)}
`;
cb(msg);

@@ -35,13 +40,19 @@ };

if (err instanceof michelson_typecheck_1.MichelsonInstructionError) {
var macro = (_a = err.val[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
return (macro ? "Macro" : "Op") + ": " + (macro ? micheline_emitter_1.emitMicheline(macro, undefined, true) + " / " : "") + micheline_emitter_1.emitMicheline(err.val) + "\nStack:\n" + formatStack(err.stackState) + "\n";
const macro = (_a = err.val[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
return `${macro ? "Macro" : "Op"}: ${macro ? micheline_emitter_1.emitMicheline(macro, undefined, true) + " / " : ""}${micheline_emitter_1.emitMicheline(err.val)}
Stack:
${formatStack(err.stackState)}
`;
}
else if (err instanceof utils_1.MichelsonTypeError) {
var type = Array.isArray(err.val) ?
"[" + err.val.map(function (v, i) { return "[" + i + "]: " + micheline_emitter_1.emitMicheline(v); }).join("; ") + "]" :
const type = Array.isArray(err.val) ?
"[" + err.val.map((v, i) => `[${i}]: ${micheline_emitter_1.emitMicheline(v)}`).join("; ") + "]" :
micheline_emitter_1.emitMicheline(err.val);
return "Type: " + type + "\n" + (err.data ? "Data: " + micheline_emitter_1.emitMicheline(err.data) + "\n" : "") + "\n";
return `Type: ${type}
${err.data ? `Data: ${micheline_emitter_1.emitMicheline(err.data)}
` : ""}
`;
}
else {
return "Value: " + micheline_emitter_1.emitMicheline(err.val);
return `Value: ${micheline_emitter_1.emitMicheline(err.val)}`;
}

@@ -48,0 +59,0 @@ }

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.expandMacros = exports.MacroError = void 0;
var michelson_types_1 = require("./michelson-types");
var MacroError = /** @class */ (function (_super) {
__extends(MacroError, _super);
function MacroError(prim, message) {
var _this = _super.call(this, message) || this;
_this.prim = prim;
Object.setPrototypeOf(_this, MacroError.prototype);
return _this;
const michelson_types_1 = require("./michelson-types");
class MacroError extends Error {
constructor(prim, message) {
super(message);
this.prim = prim;
Object.setPrototypeOf(this, MacroError.prototype);
}
return MacroError;
}(Error));
}
exports.MacroError = MacroError;

@@ -76,3 +18,3 @@ function assertArgs(ex, n) {

}
throw new MacroError(ex, "macro " + ex.prim + " expects " + n + " arguments, was given " + ((_b = ex.args) === null || _b === void 0 ? void 0 : _b.length));
throw new MacroError(ex, `macro ${ex.prim} expects ${n} arguments, was given ${(_b = ex.args) === null || _b === void 0 ? void 0 : _b.length}`);
}

@@ -83,3 +25,3 @@ function assertNoAnnots(ex) {

}
throw new MacroError(ex, "unexpected annotation on macro " + ex.prim + ": " + ex.annots);
throw new MacroError(ex, `unexpected annotation on macro ${ex.prim}: ${ex.annots}`);
}

@@ -90,18 +32,18 @@ function assertIntArg(ex, arg) {

}
throw new MacroError(ex, "macro " + ex.prim + " expects int argument");
throw new MacroError(ex, `macro ${ex.prim} expects int argument`);
}
function parsePairUnpairExpr(p, expr, annotations, agg) {
var i = 0;
var ai = 0;
var ann = [null, null];
let i = 0;
let ai = 0;
const ann = [null, null];
// Left expression
var lexpr;
let lexpr;
if (i === expr.length) {
throw new MacroError(p, "unexpected end: " + p.prim);
throw new MacroError(p, `unexpected end: ${p.prim}`);
}
var c = expr[i++];
let c = expr[i++];
switch (c) {
case "P":
{
var _a = parsePairUnpairExpr(p, expr.slice(i), annotations.slice(ai), agg), r = _a.r, n = _a.n, an = _a.an;
const { r, n, an } = parsePairUnpairExpr(p, expr.slice(i), annotations.slice(ai), agg);
lexpr = r;

@@ -118,8 +60,8 @@ i += n;

default:
throw new MacroError(p, p.prim + ": unexpected character: " + c);
throw new MacroError(p, `${p.prim}: unexpected character: ${c}`);
}
// Right expression
var rexpr;
let rexpr;
if (i === expr.length) {
throw new MacroError(p, "unexpected end: " + p.prim);
throw new MacroError(p, `unexpected end: ${p.prim}`);
}

@@ -130,7 +72,4 @@ c = expr[i++];

{
var _b = parsePairUnpairExpr(p, expr.slice(i), annotations.slice(ai), agg), r = _b.r, n = _b.n, an = _b.an;
rexpr = r.map(function (_a) {
var _b = __read(_a, 2), v = _b[0], a = _b[1];
return [v + 1, a];
});
const { r, n, an } = parsePairUnpairExpr(p, expr.slice(i), annotations.slice(ai), agg);
rexpr = r.map(([v, a]) => [v + 1, a]);
i += n;

@@ -146,3 +85,3 @@ ai += an;

default:
throw new MacroError(p, p.prim + ": unexpected character: " + c);
throw new MacroError(p, `${p.prim}: unexpected character: ${c}`);
}

@@ -152,3 +91,3 @@ return { r: agg(lexpr, rexpr, [0, ann]), n: i, an: ai };

function parseSetMapCadr(p, expr, vann, term) {
var c = expr[0];
const c = expr[0];
switch (c) {

@@ -168,3 +107,3 @@ case "A":

{ prim: "SWAP" },
{ prim: "PAIR", annots: __spread(["%@", "%@"], vann) },
{ prim: "PAIR", annots: ["%@", "%@", ...vann] },
] : term.a;

@@ -183,10 +122,10 @@ case "D":

{ prim: "CAR", annots: ["@%%"] },
{ prim: "PAIR", annots: __spread(["%@", "%@"], vann) },
{ prim: "PAIR", annots: ["%@", "%@", ...vann] },
] : term.d;
default:
throw new MacroError(p, p.prim + ": unexpected character: " + c);
throw new MacroError(p, `${p.prim}: unexpected character: ${c}`);
}
}
function trimLast(a, v) {
var l = a.length;
let l = a.length;
while (l > 0 && a[l - 1] === v) {

@@ -198,37 +137,25 @@ l--;

function filterAnnotations(a) {
var e_1, _a;
var fields = [];
var rest = [];
const fields = [];
const rest = [];
if (a !== undefined) {
try {
for (var a_1 = __values(a), a_1_1 = a_1.next(); !a_1_1.done; a_1_1 = a_1.next()) {
var v = a_1_1.value;
(v.length !== 0 && v[0] === "%" ? fields : rest).push(v);
}
for (const v of a) {
(v.length !== 0 && v[0] === "%" ? fields : rest).push(v);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (a_1_1 && !a_1_1.done && (_a = a_1.return)) _a.call(a_1);
}
finally { if (e_1) throw e_1.error; }
}
}
return { fields: fields, rest: rest };
return { fields, rest };
}
function mkPrim(_a) {
var prim = _a.prim, annots = _a.annots, args = _a.args;
return __assign(__assign({ prim: prim }, (annots && { annots: annots })), (args && { args: args }));
function mkPrim({ prim, annots, args }) {
return Object.assign(Object.assign({ prim }, (annots && { annots })), (args && { args }));
}
var pairRe = /^P[PAI]{3,}R$/;
var unpairRe = /^UNP[PAI]{2,}R$/;
var cadrRe = /^C[AD]{2,}R$/;
var setCadrRe = /^SET_C[AD]+R$/;
var mapCadrRe = /^MAP_C[AD]+R$/;
var diipRe = /^DI{2,}P$/;
var duupRe = /^DU+P$/;
const pairRe = /^P[PAI]{3,}R$/;
const unpairRe = /^UNP[PAI]{2,}R$/;
const cadrRe = /^C[AD]{2,}R$/;
const setCadrRe = /^SET_C[AD]+R$/;
const mapCadrRe = /^MAP_C[AD]+R$/;
const diipRe = /^DI{2,}P$/;
const duupRe = /^DU+P$/;
function expandMacros(ex, opt) {
var proto = (opt === null || opt === void 0 ? void 0 : opt.protocol) || michelson_types_1.DefaultProtocol;
const proto = (opt === null || opt === void 0 ? void 0 : opt.protocol) || michelson_types_1.DefaultProtocol;
function mayRename(annots) {
return annots !== undefined ? [{ prim: "RENAME", annots: annots }] : [];
return annots !== undefined ? [{ prim: "RENAME", annots }] : [];
}

@@ -392,3 +319,3 @@ switch (ex.prim) {

if (assertArgs(ex, 1) && assertIntArg(ex, ex.args[0])) {
var n = parseInt(ex.args[0].int, 10);
const n = parseInt(ex.args[0].int, 10);
return mkPrim({

@@ -409,8 +336,10 @@ prim: "GET",

if (assertArgs(ex, 0)) {
var _a = filterAnnotations(ex.annots), fields = _a.fields, rest_1 = _a.rest;
var r_1 = parsePairUnpairExpr(ex, ex.prim.slice(1), fields, function (l, r, top) { return __spread((l || []), (r || []), [top]); }).r;
return r_1.map(function (_a, i) {
var _b = __read(_a, 2), v = _b[0], a = _b[1];
var ann = __spread(trimLast(a, null).map(function (v) { return v === null ? "%" : v; }), ((v === 0 && i === r_1.length - 1) ? rest_1 : []));
var leaf = mkPrim({ prim: "PAIR", annots: ann.length !== 0 ? ann : undefined, });
const { fields, rest } = filterAnnotations(ex.annots);
const { r } = parsePairUnpairExpr(ex, ex.prim.slice(1), fields, (l, r, top) => [...(l || []), ...(r || []), top]);
return r.map(([v, a], i) => {
const ann = [
...trimLast(a, null).map(v => v === null ? "%" : v),
...((v === 0 && i === r.length - 1) ? rest : [])
];
const leaf = mkPrim({ prim: "PAIR", annots: ann.length !== 0 ? ann : undefined, });
return v === 0 ? leaf : {

@@ -426,6 +355,5 @@ prim: "DIP",

if (michelson_types_1.ProtoInferiorTo(proto, michelson_types_1.Protocol.PtEdo2Zk) && assertArgs(ex, 0)) {
var r = parsePairUnpairExpr(ex, ex.prim.slice(3), ex.annots || [], function (l, r, top) { return __spread([top], (r || []), (l || [])); }).r;
return r.map(function (_a) {
var _b = __read(_a, 2), v = _b[0], a = _b[1];
var leaf = [
const { r } = parsePairUnpairExpr(ex, ex.prim.slice(3), ex.annots || [], (l, r, top) => [top, ...(r || []), ...(l || [])]);
return r.map(([v, a]) => {
const leaf = [
{ prim: "DUP" },

@@ -450,6 +378,5 @@ mkPrim({ prim: "CAR", annots: a[0] !== null ? [a[0]] : undefined }),

// 008_edo: annotations are deprecated
var r = parsePairUnpairExpr(ex, ex.prim.slice(3), [], function (l, r, top) { return __spread([top], (r || []), (l || [])); }).r;
return r.map(function (_a) {
var _b = __read(_a, 1), v = _b[0];
var leaf = mkPrim({
const { r } = parsePairUnpairExpr(ex, ex.prim.slice(3), [], (l, r, top) => [top, ...(r || []), ...(l || [])]);
return r.map(([v]) => {
const leaf = mkPrim({
prim: "UNPAIR",

@@ -468,5 +395,5 @@ });

if (assertArgs(ex, 0)) {
var ch_1 = __spread(ex.prim.slice(1, ex.prim.length - 1));
return ch_1.map(function (c, i) {
var ann = i === ch_1.length - 1 ? ex.annots : undefined;
const ch = [...ex.prim.slice(1, ex.prim.length - 1)];
return ch.map((c, i) => {
const ann = i === ch.length - 1 ? ex.annots : undefined;
switch (c) {

@@ -478,3 +405,3 @@ case "A":

default:
throw new MacroError(ex, "unexpected character: " + c);
throw new MacroError(ex, `unexpected character: ${c}`);
}

@@ -487,7 +414,7 @@ });

if (assertArgs(ex, 0)) {
var _b = filterAnnotations(ex.annots), fields = _b.fields, rest = _b.rest;
const { fields, rest } = filterAnnotations(ex.annots);
if (fields.length > 1) {
throw new MacroError(ex, "unexpected annotation on macro " + ex.prim + ": " + fields);
throw new MacroError(ex, `unexpected annotation on macro ${ex.prim}: ${fields}`);
}
var term = fields.length !== 0 ?
const term = fields.length !== 0 ?
{

@@ -527,7 +454,7 @@ a: [

if (assertArgs(ex, 1)) {
var fields = filterAnnotations(ex.annots).fields;
const { fields } = filterAnnotations(ex.annots);
if (fields.length > 1) {
throw new MacroError(ex, "unexpected annotation on macro " + ex.prim + ": " + fields);
throw new MacroError(ex, `unexpected annotation on macro ${ex.prim}: ${fields}`);
}
var term = {
const term = {
a: [

@@ -560,3 +487,3 @@ { prim: "DUP" },

if (assertArgs(ex, 1)) {
var n = 0;
let n = 0;
while (ex.prim[1 + n] === "I") {

@@ -570,3 +497,3 @@ n++;

if (duupRe.test(ex.prim)) {
var n = 0;
let n = 0;
while (ex.prim[1 + n] === "U") {

@@ -573,0 +500,0 @@ n++;

"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.emitMicheline = void 0;
var micheline_1 = require("./micheline");
var Formatter = /** @class */ (function () {
function Formatter(opt, lev) {
if (lev === void 0) { lev = 0; }
const micheline_1 = require("./micheline");
class Formatter {
constructor(opt, lev = 0) {
this.opt = opt;
this.lev = lev;
}
Formatter.prototype.indent = function (n) {
indent(n = 0) {
var _a;
if (n === void 0) { n = 0; }
var ret = "";
let ret = '';
if (((_a = this.opt) === null || _a === void 0 ? void 0 : _a.indent) !== undefined) {
for (var i = this.lev + n; i > 0; i--) {
for (let i = this.lev + n; i > 0; i--) {
ret += this.opt.indent;

@@ -32,47 +19,27 @@ }

return ret;
};
Object.defineProperty(Formatter.prototype, "lf", {
get: function () {
var _a;
return ((_a = this.opt) === null || _a === void 0 ? void 0 : _a.newline) || "";
},
enumerable: false,
configurable: true
});
Object.defineProperty(Formatter.prototype, "lfsp", {
get: function () {
var _a;
return ((_a = this.opt) === null || _a === void 0 ? void 0 : _a.newline) || " ";
},
enumerable: false,
configurable: true
});
Formatter.prototype.down = function (n) {
}
get lf() {
var _a;
return ((_a = this.opt) === null || _a === void 0 ? void 0 : _a.newline) || '';
}
get lfsp() {
var _a;
return ((_a = this.opt) === null || _a === void 0 ? void 0 : _a.newline) || ' ';
}
down(n) {
return new Formatter(this.opt, this.lev + n);
};
return Formatter;
}());
}
}
function hasArgs(node) {
return ("prim" in node) &&
return ('prim' in node &&
((node.annots !== undefined && node.annots.length !== 0) ||
(node.args !== undefined && node.args.length !== 0));
(node.args !== undefined && node.args.length !== 0)));
}
function isMultiline(node) {
var e_1, _a;
if (node.args !== undefined) {
try {
for (var _b = __values(node.args), _c = _b.next(); !_c.done; _c = _b.next()) {
var a = _c.value;
if (Array.isArray(a) || hasArgs(a)) {
return true;
}
for (const a of node.args) {
if (Array.isArray(a) || hasArgs(a)) {
return true;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}

@@ -82,5 +49,4 @@ return false;

function emitExpr(node, f, foldMacros) {
var e_2, _a, e_3, _b;
var _c;
var macro = (_c = node[micheline_1.sourceReference]) === null || _c === void 0 ? void 0 : _c.macro;
var _a;
const macro = (_a = node[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.macro;
if (foldMacros && macro) {

@@ -92,10 +58,10 @@ return emitExpr(macro, f, foldMacros);

}
else if ("string" in node) {
else if ('string' in node) {
return JSON.stringify(node.string);
}
else if ("int" in node) {
else if ('int' in node) {
return node.int;
}
else if ("bytes" in node) {
return "0x" + node.bytes;
else if ('bytes' in node) {
return '0x' + node.bytes;
}

@@ -107,104 +73,53 @@ else {

}
var ret = "(" + node.prim;
let ret = '(' + node.prim;
if (node.annots !== undefined) {
try {
for (var _d = __values(node.annots), _e = _d.next(); !_e.done; _e = _d.next()) {
var a = _e.value;
ret += " " + a;
}
for (const a of node.annots) {
ret += ' ' + a;
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
}
finally { if (e_2) throw e_2.error; }
}
}
if (node.args !== undefined) {
var multiline = isMultiline(node);
try {
for (var _f = __values(node.args), _g = _f.next(); !_g.done; _g = _f.next()) {
var a = _g.value;
if (multiline) {
ret += f.lfsp + f.indent(1) + emitExpr(a, f.down(1), foldMacros);
}
else {
ret += " " + emitExpr(a, f, foldMacros);
}
const multiline = isMultiline(node);
for (const a of node.args) {
if (multiline) {
ret += f.lfsp + f.indent(1) + emitExpr(a, f.down(1), foldMacros);
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
else {
ret += ' ' + emitExpr(a, f, foldMacros);
}
finally { if (e_3) throw e_3.error; }
}
}
return ret + ")";
return ret + ')';
}
}
function emitSeq(node, f, foldMacros) {
var e_4, _a, e_5, _b, e_6, _c;
var ret = "{" + f.lf;
var i = node.length;
try {
for (var node_1 = __values(node), node_1_1 = node_1.next(); !node_1_1.done; node_1_1 = node_1.next()) {
var el = node_1_1.value;
ret += f.indent(1);
if ("prim" in el) {
ret += el.prim;
if (el.annots !== undefined) {
try {
for (var _d = (e_5 = void 0, __values(el.annots)), _e = _d.next(); !_e.done; _e = _d.next()) {
var a = _e.value;
ret += " " + a;
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
}
finally { if (e_5) throw e_5.error; }
}
let ret = '{' + f.lf;
let i = node.length;
for (const el of node) {
ret += f.indent(1);
if ('prim' in el) {
ret += el.prim;
if (el.annots !== undefined) {
for (const a of el.annots) {
ret += ' ' + a;
}
if (el.args !== undefined) {
var multiline = isMultiline(el);
try {
for (var _f = (e_6 = void 0, __values(el.args)), _g = _f.next(); !_g.done; _g = _f.next()) {
var a = _g.value;
if (multiline) {
ret += f.lfsp + f.indent(2) + emitExpr(a, f.down(2), foldMacros);
}
else {
ret += " " + emitExpr(a, f, foldMacros);
}
}
}
if (el.args !== undefined) {
const multiline = isMultiline(el);
for (const a of el.args) {
if (multiline) {
ret += f.lfsp + f.indent(2) + emitExpr(a, f.down(2), foldMacros);
}
catch (e_6_1) { e_6 = { error: e_6_1 }; }
finally {
try {
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
}
finally { if (e_6) throw e_6.error; }
else {
ret += ' ' + emitExpr(a, f, foldMacros);
}
}
}
else {
ret += emitExpr(el, f.down(1), foldMacros);
}
ret += (i > 1 ? ";" + f.lfsp : f.lf);
i--;
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (node_1_1 && !node_1_1.done && (_a = node_1.return)) _a.call(node_1);
else {
ret += emitExpr(el, f.down(1), foldMacros);
}
finally { if (e_4) throw e_4.error; }
ret += i > 1 ? ';' + f.lfsp : f.lf;
i--;
}
return ret + f.indent() + "}";
return ret + f.indent() + '}';
}

@@ -216,7 +131,5 @@ /**

*/
function emitMicheline(expr, opt, foldMacros) {
if (foldMacros === void 0) { foldMacros = false; }
// tslint:disable-next-line: strict-type-predicates
if (typeof expr !== "object") {
throw new TypeError("object type was expected, got " + typeof expr + " instead");
function emitMicheline(expr, opt, foldMacros = false) {
if (typeof expr !== 'object') {
throw new TypeError(`object type was expected, got ${typeof expr} instead`);
}

@@ -223,0 +136,0 @@ return emitExpr(expr, new Formatter(opt), foldMacros);

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = exports.JSONParseError = exports.MichelineParseError = void 0;
var scan_1 = require("./scan");
var micheline_1 = require("./micheline");
var macros_1 = require("./macros");
var global_constants_1 = require("./global-constants");
var MichelineParseError = /** @class */ (function (_super) {
__extends(MichelineParseError, _super);
const scan_1 = require("./scan");
const micheline_1 = require("./micheline");
const macros_1 = require("./macros");
const global_constants_1 = require("./global-constants");
class MichelineParseError extends Error {
/**

@@ -65,13 +13,10 @@ * @param token A token caused the error

*/
function MichelineParseError(token, message) {
var _this = _super.call(this, message) || this;
_this.token = token;
Object.setPrototypeOf(_this, MichelineParseError.prototype);
return _this;
constructor(token, message) {
super(message);
this.token = token;
Object.setPrototypeOf(this, MichelineParseError.prototype);
}
return MichelineParseError;
}(Error));
}
exports.MichelineParseError = MichelineParseError;
var JSONParseError = /** @class */ (function (_super) {
__extends(JSONParseError, _super);
class JSONParseError extends Error {
/**

@@ -81,17 +26,15 @@ * @param node A node caused the error

*/
function JSONParseError(node, message) {
var _this = _super.call(this, message) || this;
_this.node = node;
Object.setPrototypeOf(_this, JSONParseError.prototype);
return _this;
constructor(node, message) {
super(message);
this.node = node;
Object.setPrototypeOf(this, JSONParseError.prototype);
}
return JSONParseError;
}(Error));
}
exports.JSONParseError = JSONParseError;
var errEOF = new MichelineParseError(null, 'Unexpected EOF');
const errEOF = new MichelineParseError(null, 'Unexpected EOF');
function isAnnotation(tok) {
return tok.t === scan_1.Literal.Ident && (tok.v[0] === "@" || tok.v[0] === "%" || tok.v[0] === ":");
return tok.t === scan_1.Literal.Ident && (tok.v[0] === '@' || tok.v[0] === '%' || tok.v[0] === ':');
}
var intRe = new RegExp("^-?[0-9]+$");
var bytesRe = new RegExp("^([0-9a-fA-F]{2})*$");
const intRe = new RegExp('^-?[0-9]+$');
const bytesRe = new RegExp('^([0-9a-fA-F]{2})*$');
/**

@@ -129,12 +72,12 @@ * Converts and validates Michelson expressions between JSON-based Michelson and Micheline

*/
var Parser = /** @class */ (function () {
function Parser(opt) {
class Parser {
constructor(opt) {
this.opt = opt;
}
Parser.prototype.expand = function (ex) {
expand(ex) {
var _a, _b, _c;
if (((_a = this.opt) === null || _a === void 0 ? void 0 : _a.expandGlobalConstant) !== undefined && ex.prim === 'constant') {
var ret = global_constants_1.expandGlobalConstants(ex, this.opt.expandGlobalConstant);
const ret = global_constants_1.expandGlobalConstants(ex, this.opt.expandGlobalConstant);
if (ret !== ex) {
ret[micheline_1.sourceReference] = __assign(__assign({}, (ex[micheline_1.sourceReference] || { first: 0, last: 0 })), { globalConstant: ex });
ret[micheline_1.sourceReference] = Object.assign(Object.assign({}, (ex[micheline_1.sourceReference] || { first: 0, last: 0 })), { globalConstant: ex });
}

@@ -144,5 +87,5 @@ return ret;

if (((_b = this.opt) === null || _b === void 0 ? void 0 : _b.expandMacros) !== undefined ? (_c = this.opt) === null || _c === void 0 ? void 0 : _c.expandMacros : true) {
var ret = macros_1.expandMacros(ex, this.opt);
const ret = macros_1.expandMacros(ex, this.opt);
if (ret !== ex) {
ret[micheline_1.sourceReference] = __assign(__assign({}, (ex[micheline_1.sourceReference] || { first: 0, last: 0 })), { macro: ex });
ret[micheline_1.sourceReference] = Object.assign(Object.assign({}, (ex[micheline_1.sourceReference] || { first: 0, last: 0 })), { macro: ex });
}

@@ -154,12 +97,11 @@ return ret;

}
};
Parser.prototype.parseListExpr = function (scanner, start) {
}
parseListExpr(scanner, start) {
var _a;
var _b;
var ref = {
const ref = {
first: start.first,
last: start.last,
};
var expectBracket = start.t === "(";
var tok;
const expectBracket = start.t === '(';
let tok;
if (expectBracket) {

@@ -176,12 +118,11 @@ tok = scanner.next();

if (tok.value.t !== scan_1.Literal.Ident) {
throw new MichelineParseError(tok.value, "not an identifier: " + tok.value.v);
throw new MichelineParseError(tok.value, `not an identifier: ${tok.value.v}`);
}
var ret = (_a = {
prim: tok.value.v
},
_a[micheline_1.sourceReference] = ref,
_a);
const ret = {
prim: tok.value.v,
[micheline_1.sourceReference]: ref,
};
for (;;) {
var tok_1 = scanner.next();
if (tok_1.done) {
const tok = scanner.next();
if (tok.done) {
if (expectBracket) {

@@ -192,18 +133,18 @@ throw errEOF;

}
else if (tok_1.value.t === ")") {
else if (tok.value.t === ')') {
if (!expectBracket) {
throw new MichelineParseError(tok_1.value, "unexpected closing bracket");
throw new MichelineParseError(tok.value, 'unexpected closing bracket');
}
ref.last = tok_1.value.last;
ref.last = tok.value.last;
break;
}
else if (isAnnotation(tok_1.value)) {
else if (isAnnotation(tok.value)) {
ret.annots = ret.annots || [];
ret.annots.push(tok_1.value.v);
ref.last = tok_1.value.last;
ret.annots.push(tok.value.v);
ref.last = tok.value.last;
}
else {
ret.args = ret.args || [];
var arg = this.parseExpr(scanner, tok_1.value);
ref.last = ((_b = arg[micheline_1.sourceReference]) === null || _b === void 0 ? void 0 : _b.last) || ref.last;
const arg = this.parseExpr(scanner, tok.value);
ref.last = ((_a = arg[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.last) || ref.last;
ret.args.push(arg);

@@ -213,19 +154,17 @@ }

return this.expand(ret);
};
Parser.prototype.parseArgs = function (scanner, start) {
}
parseArgs(scanner, start) {
var _a;
var _b;
// Identifier with arguments
var ref = {
const ref = {
first: start.first,
last: start.last,
};
var p = (_a = {
prim: start.v
},
_a[micheline_1.sourceReference] = ref,
_a);
const p = {
prim: start.v,
[micheline_1.sourceReference]: ref,
};
for (;;) {
var t = scanner.next();
if (t.done || t.value.t === "}" || t.value.t === ";") {
const t = scanner.next();
if (t.done || t.value.t === '}' || t.value.t === ';') {
return [p, t];

@@ -239,4 +178,4 @@ }

else {
var arg = this.parseExpr(scanner, t.value);
ref.last = ((_b = arg[micheline_1.sourceReference]) === null || _b === void 0 ? void 0 : _b.last) || ref.last;
const arg = this.parseExpr(scanner, t.value);
ref.last = ((_a = arg[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.last) || ref.last;
p.args = p.args || [];

@@ -246,13 +185,13 @@ p.args.push(arg);

}
};
Parser.prototype.parseSequenceExpr = function (scanner, start) {
}
parseSequenceExpr(scanner, start) {
var _a, _b;
var ref = {
const ref = {
first: start.first,
last: start.last,
};
var seq = [];
const seq = [];
seq[micheline_1.sourceReference] = ref;
var expectBracket = start.t === "{";
var tok = start.t === "{" ? null : { value: start };
const expectBracket = start.t === '{';
let tok = start.t === '{' ? null : { value: start };
for (;;) {

@@ -273,5 +212,5 @@ if (tok === null) {

}
if (tok.value.t === "}") {
if (tok.value.t === '}') {
if (!expectBracket) {
throw new MichelineParseError(tok.value, "unexpected closing bracket");
throw new MichelineParseError(tok.value, 'unexpected closing bracket');
}

@@ -284,3 +223,3 @@ else {

// Identifier with arguments
var _c = __read(this.parseArgs(scanner, tok.value), 2), itm = _c[0], n = _c[1];
const [itm, n] = this.parseArgs(scanner, tok.value);
ref.last = ((_a = itm[micheline_1.sourceReference]) === null || _a === void 0 ? void 0 : _a.last) || ref.last;

@@ -292,3 +231,3 @@ seq.push(this.expand(itm));

// Other
var ex = this.parseExpr(scanner, tok.value);
const ex = this.parseExpr(scanner, tok.value);
ref.last = ((_b = ex[micheline_1.sourceReference]) === null || _b === void 0 ? void 0 : _b.last) || ref.last;

@@ -304,19 +243,24 @@ seq.push(ex);

}
if (!tok.done && tok.value.t === ";") {
if (!tok.done && tok.value.t === ';') {
tok = null;
}
}
};
Parser.prototype.parseExpr = function (scanner, tok) {
var _a, _b, _c, _d;
}
parseExpr(scanner, tok) {
switch (tok.t) {
case scan_1.Literal.Ident:
return this.expand((_a = { prim: tok.v }, _a[micheline_1.sourceReference] = { first: tok.first, last: tok.last }, _a));
return this.expand({
prim: tok.v,
[micheline_1.sourceReference]: { first: tok.first, last: tok.last },
});
case scan_1.Literal.Number:
return _b = { int: tok.v }, _b[micheline_1.sourceReference] = { first: tok.first, last: tok.last }, _b;
return { int: tok.v, [micheline_1.sourceReference]: { first: tok.first, last: tok.last } };
case scan_1.Literal.String:
return _c = { string: JSON.parse(tok.v) }, _c[micheline_1.sourceReference] = { first: tok.first, last: tok.last }, _c;
return {
string: JSON.parse(tok.v),
[micheline_1.sourceReference]: { first: tok.first, last: tok.last },
};
case scan_1.Literal.Bytes:
return _d = { bytes: tok.v.slice(2) }, _d[micheline_1.sourceReference] = { first: tok.first, last: tok.last }, _d;
case "{":
return { bytes: tok.v.slice(2), [micheline_1.sourceReference]: { first: tok.first, last: tok.last } };
case '{':
return this.parseSequenceExpr(scanner, tok);

@@ -326,3 +270,3 @@ default:

}
};
}
/**

@@ -332,9 +276,8 @@ * Parses a Micheline sequence expression, such as smart contract source. Enclosing curly brackets may be omitted.

*/
Parser.prototype.parseSequence = function (src) {
// tslint:disable-next-line: strict-type-predicates
if (typeof src !== "string") {
throw new TypeError("string type was expected, got " + typeof src + " instead");
parseSequence(src) {
if (typeof src !== 'string') {
throw new TypeError(`string type was expected, got ${typeof src} instead`);
}
var scanner = scan_1.scan(src);
var tok = scanner.next();
const scanner = scan_1.scan(src);
const tok = scanner.next();
if (tok.done) {

@@ -344,3 +287,3 @@ return null;

return this.parseSequenceExpr(scanner, tok.value);
};
}
/**

@@ -351,9 +294,8 @@ * Parse a Micheline sequence expression. Enclosing curly brackets may be omitted.

*/
Parser.prototype.parseList = function (src) {
// tslint:disable-next-line: strict-type-predicates
if (typeof src !== "string") {
throw new TypeError("string type was expected, got " + typeof src + " instead");
parseList(src) {
if (typeof src !== 'string') {
throw new TypeError(`string type was expected, got ${typeof src} instead`);
}
var scanner = scan_1.scan(src);
var tok = scanner.next();
const scanner = scan_1.scan(src);
const tok = scanner.next();
if (tok.done) {

@@ -363,3 +305,3 @@ return null;

return this.parseListExpr(scanner, tok.value);
};
}
/**

@@ -370,9 +312,8 @@ * Parse any Michelson expression

*/
Parser.prototype.parseMichelineExpression = function (src) {
// tslint:disable-next-line: strict-type-predicates
if (typeof src !== "string") {
throw new TypeError("string type was expected, got " + typeof src + " instead");
parseMichelineExpression(src) {
if (typeof src !== 'string') {
throw new TypeError(`string type was expected, got ${typeof src} instead`);
}
var scanner = scan_1.scan(src);
var tok = scanner.next();
const scanner = scan_1.scan(src);
const tok = scanner.next();
if (tok.done) {

@@ -382,3 +323,3 @@ return null;

return this.parseExpr(scanner, tok.value);
};
}
/**

@@ -389,5 +330,5 @@ * Parse a Micheline sequence expression, such as smart contract source. Enclosing curly brackets may be omitted.

*/
Parser.prototype.parseScript = function (src) {
parseScript(src) {
return this.parseSequence(src);
};
}
/**

@@ -399,5 +340,5 @@ * Parse a Micheline sequence expression. Enclosing curly brackets may be omitted.

*/
Parser.prototype.parseData = function (src) {
parseData(src) {
return this.parseList(src);
};
}
/**

@@ -407,52 +348,30 @@ * Takes a JSON-encoded Michelson, validates it, strips away unneeded properties and optionally expands macros (See {@link ParserOptions}).

*/
Parser.prototype.parseJSON = function (src) {
var e_1, _a, e_2, _b, e_3, _c;
// tslint:disable-next-line: strict-type-predicates
if (typeof src !== "object") {
throw new TypeError("object type was expected, got " + typeof src + " instead");
parseJSON(src) {
if (typeof src !== 'object') {
throw new TypeError(`object type was expected, got ${typeof src} instead`);
}
if (Array.isArray(src)) {
var ret = [];
try {
for (var src_1 = __values(src), src_1_1 = src_1.next(); !src_1_1.done; src_1_1 = src_1.next()) {
var n = src_1_1.value;
if (n === null || typeof n !== "object") {
throw new JSONParseError(n, "unexpected sequence element: " + n);
}
ret.push(this.parseJSON(n));
const ret = [];
for (const n of src) {
if (n === null || typeof n !== 'object') {
throw new JSONParseError(n, `unexpected sequence element: ${n}`);
}
ret.push(this.parseJSON(n));
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (src_1_1 && !src_1_1.done && (_a = src_1.return)) _a.call(src_1);
}
finally { if (e_1) throw e_1.error; }
}
return ret;
}
else if ("prim" in src) {
var p = src;
if (typeof p.prim === "string" &&
else if ('prim' in src) {
const p = src;
if (typeof p.prim === 'string' &&
(p.annots === undefined || Array.isArray(p.annots)) &&
(p.args === undefined || Array.isArray(p.args))) {
var ret = {
const ret = {
prim: p.prim,
};
if (p.annots !== undefined) {
try {
for (var _d = __values(p.annots), _e = _d.next(); !_e.done; _e = _d.next()) {
var a = _e.value;
if (typeof a !== "string") {
throw new JSONParseError(a, "string expected: " + a);
}
for (const a of p.annots) {
if (typeof a !== 'string') {
throw new JSONParseError(a, `string expected: ${a}`);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
}
finally { if (e_2) throw e_2.error; }
}
ret.annots = p.annots;

@@ -462,49 +381,38 @@ }

ret.args = [];
try {
for (var _f = __values(p.args), _g = _f.next(); !_g.done; _g = _f.next()) {
var a = _g.value;
if (a === null || typeof a !== "object") {
throw new JSONParseError(a, "unexpected argument: " + a);
}
ret.args.push(this.parseJSON(a));
for (const a of p.args) {
if (a === null || typeof a !== 'object') {
throw new JSONParseError(a, `unexpected argument: ${a}`);
}
ret.args.push(this.parseJSON(a));
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
}
finally { if (e_3) throw e_3.error; }
}
}
return this.expand(ret);
}
throw new JSONParseError(src, "malformed prim expression: " + src);
throw new JSONParseError(src, `malformed prim expression: ${src}`);
}
else if ("string" in src) {
if (typeof src.string === "string") {
else if ('string' in src) {
if (typeof src.string === 'string') {
return { string: src.string };
}
throw new JSONParseError(src, "malformed string literal: " + src);
throw new JSONParseError(src, `malformed string literal: ${src}`);
}
else if ("int" in src) {
if (typeof src.int === "string" && intRe.test(src.int)) {
else if ('int' in src) {
if (typeof src.int === 'string' && intRe.test(src.int)) {
return { int: src.int };
}
throw new JSONParseError(src, "malformed int literal: " + src);
throw new JSONParseError(src, `malformed int literal: ${src}`);
}
else if ("bytes" in src) {
if (typeof src.bytes === "string" &&
else if ('bytes' in src) {
if (typeof src.bytes === 'string' &&
bytesRe.test(src.bytes)) {
return { bytes: src.bytes };
}
throw new JSONParseError(src, "malformed bytes literal: " + src);
throw new JSONParseError(src, `malformed bytes literal: ${src}`);
}
else {
throw new JSONParseError(src, "unexpected object: " + src);
throw new JSONParseError(src, `unexpected object: ${src}`);
}
};
return Parser;
}());
}
}
exports.Parser = Parser;
//# sourceMappingURL=micheline-parser.js.map

@@ -5,3 +5,3 @@ "use strict";

exports.sourceReference = void 0;
exports.sourceReference = Symbol("source_reference");
exports.sourceReference = Symbol('source_reference');
//# sourceMappingURL=micheline.js.map
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.dummyContract = exports.Contract = void 0;
var michelson_typecheck_1 = require("./michelson-typecheck");
var micheline_parser_1 = require("./micheline-parser");
var michelson_validator_1 = require("./michelson-validator");
var Contract = /** @class */ (function () {
function Contract(contract, opt) {
const michelson_typecheck_1 = require("./michelson-typecheck");
const micheline_parser_1 = require("./micheline-parser");
const michelson_validator_1 = require("./michelson-validator");
class Contract {
constructor(contract, opt) {
this.contract = contract;
this.ctx = __assign({ contract: contract }, opt);
this.ctx = Object.assign({ contract }, opt);
this.output = michelson_typecheck_1.assertContractValid(contract, this.ctx);
}
Contract.parse = function (src, opt) {
var p = new micheline_parser_1.Parser(opt);
var expr = typeof src === "string" ? p.parseScript(src) : p.parseJSON(src);
static parse(src, opt) {
const p = new micheline_parser_1.Parser(opt);
const expr = typeof src === "string" ? p.parseScript(src) : p.parseJSON(src);
if (expr === null) {

@@ -34,6 +23,6 @@ throw new Error("empty contract");

throw undefined;
};
Contract.parseTypeExpression = function (src, opt) {
var p = new micheline_parser_1.Parser(opt);
var expr = typeof src === "string" ? p.parseScript(src) : p.parseJSON(src);
}
static parseTypeExpression(src, opt) {
const p = new micheline_parser_1.Parser(opt);
const expr = typeof src === "string" ? p.parseScript(src) : p.parseJSON(src);
if (expr === null) {

@@ -46,6 +35,6 @@ throw new Error("empty type expression");

throw undefined;
};
Contract.parseDataExpression = function (src, opt) {
var p = new micheline_parser_1.Parser(opt);
var expr = typeof src === "string" ? p.parseScript(src) : p.parseJSON(src);
}
static parseDataExpression(src, opt) {
const p = new micheline_parser_1.Parser(opt);
const expr = typeof src === "string" ? p.parseScript(src) : p.parseJSON(src);
if (expr === null) {

@@ -58,26 +47,26 @@ throw new Error("empty data expression");

throw undefined;
};
Contract.prototype.section = function (section) {
}
section(section) {
return michelson_typecheck_1.contractSection(this.contract, section);
};
Contract.prototype.entryPoints = function () {
}
entryPoints() {
return michelson_typecheck_1.contractEntryPoints(this.contract);
};
Contract.prototype.entryPoint = function (ep) {
}
entryPoint(ep) {
return michelson_typecheck_1.contractEntryPoint(this.contract, ep);
};
Contract.prototype.assertDataValid = function (d, t) {
}
assertDataValid(d, t) {
michelson_typecheck_1.assertDataValid(d, t, this.ctx);
};
Contract.prototype.isDataValid = function (d, t) {
}
isDataValid(d, t) {
return michelson_typecheck_1.isDataValid(d, t, this.ctx);
};
Contract.prototype.assertParameterValid = function (ep, d) {
var t = this.entryPoint(ep || undefined);
}
assertParameterValid(ep, d) {
const t = this.entryPoint(ep || undefined);
if (t === null) {
throw new Error("contract has no entrypoint named " + ep);
throw new Error(`contract has no entrypoint named ${ep}`);
}
this.assertDataValid(d, t);
};
Contract.prototype.isParameterValid = function (ep, d) {
}
isParameterValid(ep, d) {
try {

@@ -90,8 +79,7 @@ this.assertParameterValid(ep, d);

}
};
Contract.prototype.functionType = function (inst, stack) {
}
functionType(inst, stack) {
return michelson_typecheck_1.functionType(inst, stack, this.ctx);
};
return Contract;
}());
}
}
exports.Contract = Contract;

@@ -98,0 +86,0 @@ exports.dummyContract = new Contract([

@@ -5,3 +5,3 @@ "use strict";

// Michelson types
exports.refContract = Symbol("ref_contract");
exports.refContract = Symbol('ref_contract');
var Protocol;

@@ -26,6 +26,8 @@ (function (Protocol) {

Protocol["PtHangz2"] = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx";
Protocol["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"; // temporary protocol hash
Protocol["PsiThaCa"] = "PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP";
Protocol["Psithaca2"] = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A";
Protocol["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
})(Protocol = exports.Protocol || (exports.Protocol = {}));
exports.DefaultProtocol = Protocol.PtGRANAD;
var protoLevel = {
exports.DefaultProtocol = Protocol.Psithaca2;
const protoLevel = {
Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P: 0,

@@ -46,3 +48,5 @@ PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY: 1,

PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx: 11,
ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 12
PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP: 12,
Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A: 13,
ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 14,
};

@@ -49,0 +53,0 @@ function ProtoGreaterOfEqual(a, b) {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertDataListIfAny = exports.isInstruction = exports.isMichelsonType = exports.isMichelsonCode = exports.isMichelsonData = exports.isMichelsonScript = exports.assertMichelsonContract = exports.assertMichelsonData = exports.assertMichelsonType = exports.assertViewNameValid = exports.assertMichelsonBigMapStorableType = exports.assertMichelsonPassableType = exports.assertMichelsonStorableType = exports.assertMichelsonPushableType = exports.assertMichelsonPackableType = exports.assertMichelsonComparableType = exports.assertMichelsonInstruction = exports.MichelsonValidationError = exports.instructionIDs = void 0;
var utils_1 = require("./utils");
const utils_1 = require("./utils");
// Michelson validator
var maxViewNameLength = 31;
var noArgInstructionIDs = {
const maxViewNameLength = 31;
const noArgInstructionIDs = {
"ABS": true, "ADD": true, "ADDRESS": true, "AMOUNT": true, "AND": true, "APPLY": true, "BALANCE": true,

@@ -47,3 +23,3 @@ "BLAKE2B": true, "CAR": true, "CDR": true, "CHAIN_ID": true, "CHECK_SIGNATURE": true, "COMPARE": true, "CONCAT": true, "CONS": true, "EDIV": true,

});
var simpleComparableTypeIDs = {
const simpleComparableTypeIDs = {
"unit": true, "never": true, "bool": true, "int": true, "nat": true, "string": true,

@@ -53,3 +29,3 @@ "chain_id": true, "bytes": true, "mutez": true, "key_hash": true, "key": true,

};
var typeIDs = Object.assign({}, simpleComparableTypeIDs, {
const typeIDs = Object.assign({}, simpleComparableTypeIDs, {
"or": true, "pair": true, "set": true, "big_map": true, "contract": true, "lambda": true,

@@ -60,4 +36,3 @@ "list": true, "map": true, "operation": true, "option": true, "bls12_381_g1": true,

});
var MichelsonValidationError = /** @class */ (function (_super) {
__extends(MichelsonValidationError, _super);
class MichelsonValidationError extends utils_1.MichelsonError {
/**

@@ -67,10 +42,8 @@ * @param val Value of a node caused the error

*/
function MichelsonValidationError(val, message) {
var _this = _super.call(this, val, message) || this;
_this.val = val;
Object.setPrototypeOf(_this, MichelsonValidationError.prototype);
return _this;
constructor(val, message) {
super(val, message);
this.val = val;
Object.setPrototypeOf(this, MichelsonValidationError.prototype);
}
return MichelsonValidationError;
}(utils_1.MichelsonError));
}
exports.MichelsonValidationError = MichelsonValidationError;

@@ -123,3 +96,3 @@ function isPrim(ex) {

}
throw new MichelsonValidationError(ex, n + " arguments expected");
throw new MichelsonValidationError(ex, `${n} arguments expected`);
}

@@ -132,21 +105,10 @@ /**

function assertMichelsonInstruction(ex) {
var e_1, _a;
var _b, _c;
var _a, _b;
if (Array.isArray(ex)) {
try {
for (var ex_1 = __values(ex), ex_1_1 = ex_1.next(); !ex_1_1.done; ex_1_1 = ex_1.next()) {
var n = ex_1_1.value;
if (!Array.isArray(n) && !isPrim(n)) {
throw new MichelsonValidationError(ex, "sequence or prim expected");
}
assertMichelsonInstruction(n);
for (const n of ex) {
if (!Array.isArray(n) && !isPrim(n)) {
throw new MichelsonValidationError(ex, "sequence or prim expected");
}
assertMichelsonInstruction(n);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (ex_1_1 && !ex_1_1.done && (_a = ex_1.return)) _a.call(ex_1);
}
finally { if (e_1) throw e_1.error; }
}
return true;

@@ -238,3 +200,3 @@ }

case "DIP":
if (((_b = ex.args) === null || _b === void 0 ? void 0 : _b.length) === 2) {
if (((_a = ex.args) === null || _a === void 0 ? void 0 : _a.length) === 2) {
/* istanbul ignore else */

@@ -249,3 +211,3 @@ if (assertIntLiteral(ex.args[0])) {

}
else if (((_c = ex.args) === null || _c === void 0 ? void 0 : _c.length) === 1) {
else if (((_b = ex.args) === null || _b === void 0 ? void 0 : _b.length) === 1) {
/* istanbul ignore else */

@@ -320,6 +282,6 @@ if (assertSeq(ex.args[0])) {

if (Array.isArray(ex) || ex.prim === "pair" || ex.prim === "or" || ex.prim === "option") {
traverseType(ex, function (ex) { return assertMichelsonComparableType(ex); });
traverseType(ex, (ex) => assertMichelsonComparableType(ex));
}
else if (!Object.prototype.hasOwnProperty.call(simpleComparableTypeIDs, ex.prim)) {
throw new MichelsonValidationError(ex, ex.prim + ": type is not comparable");
throw new MichelsonValidationError(ex, `${ex.prim}: type is not comparable`);
}

@@ -339,5 +301,5 @@ }

ex.prim === "ticket") {
throw new MichelsonValidationError(ex, ex.prim + ": type can't be used inside PACK/UNPACK instructions");
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used inside PACK/UNPACK instructions`);
}
traverseType(ex, function (ex) { return assertMichelsonPackableType(ex); });
traverseType(ex, (ex) => assertMichelsonPackableType(ex));
}

@@ -358,5 +320,5 @@ }

ex.prim === "contract") {
throw new MichelsonValidationError(ex, ex.prim + ": type can't be pushed");
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be pushed`);
}
traverseType(ex, function (ex) { return assertMichelsonPushableType(ex); });
traverseType(ex, (ex) => assertMichelsonPushableType(ex));
}

@@ -374,5 +336,5 @@ }

ex.prim === "contract") {
throw new MichelsonValidationError(ex, ex.prim + ": type can't be used as part of a storage");
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used as part of a storage`);
}
traverseType(ex, function (ex) { return assertMichelsonStorableType(ex); });
traverseType(ex, (ex) => assertMichelsonStorableType(ex));
}

@@ -389,5 +351,5 @@ }

ex.prim === "operation") {
throw new MichelsonValidationError(ex, ex.prim + ": type can't be used as part of a parameter");
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used as part of a parameter`);
}
traverseType(ex, function (ex) { return assertMichelsonPassableType(ex); });
traverseType(ex, (ex) => assertMichelsonPassableType(ex));
}

@@ -406,5 +368,5 @@ }

ex.prim === "sapling_state") {
throw new MichelsonValidationError(ex, ex.prim + ": type can't be used inside a big_map");
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used inside a big_map`);
}
traverseType(ex, function (ex) { return assertMichelsonBigMapStorableType(ex); });
traverseType(ex, (ex) => assertMichelsonBigMapStorableType(ex));
}

@@ -415,9 +377,9 @@ }

exports.assertMichelsonBigMapStorableType = assertMichelsonBigMapStorableType;
var viewRe = new RegExp("^[a-zA-Z0-9_.%@]*$");
const viewRe = new RegExp("^[a-zA-Z0-9_.%@]*$");
function assertViewNameValid(name) {
if (name.string.length > maxViewNameLength) {
throw new MichelsonValidationError(name, "view name too long: " + name.string);
throw new MichelsonValidationError(name, `view name too long: ${name.string}`);
}
if (!viewRe.test(name.string)) {
throw new MichelsonValidationError(name, "invalid character(s) in view name: " + name.string);
throw new MichelsonValidationError(name, `invalid character(s) in view name: ${name.string}`);
}

@@ -438,3 +400,3 @@ }

}
traverseType(ex, function (ex) { return assertMichelsonType(ex); });
traverseType(ex, (ex) => assertMichelsonType(ex));
}

@@ -447,7 +409,7 @@ }

if (Array.isArray(ex) || ex.prim === "pair") {
var args = Array.isArray(ex) ? ex : ex.args;
const args = Array.isArray(ex) ? ex : ex.args;
if (args === undefined || args.length < 2) {
throw new MichelsonValidationError(ex, "at least 2 arguments expected");
}
args.forEach(function (a) {
args.forEach(a => {
if (assertPrimOrSeq(a)) {

@@ -531,3 +493,2 @@ cb(a);

function assertMichelsonData(ex) {
var e_2, _a, e_3, _b;
if (("int" in ex) || ("string" in ex) || ("bytes" in ex)) {

@@ -537,25 +498,15 @@ return true;

if (Array.isArray(ex)) {
var mapElts = 0;
try {
for (var ex_2 = __values(ex), ex_2_1 = ex_2.next(); !ex_2_1.done; ex_2_1 = ex_2.next()) {
var n = ex_2_1.value;
if (isPrim(n) && n.prim === "Elt") {
/* istanbul ignore else */
if (assertArgs(n, 2)) {
assertMichelsonData(n.args[0]);
assertMichelsonData(n.args[1]);
}
mapElts++;
let mapElts = 0;
for (const n of ex) {
if (isPrim(n) && n.prim === "Elt") {
/* istanbul ignore else */
if (assertArgs(n, 2)) {
assertMichelsonData(n.args[0]);
assertMichelsonData(n.args[1]);
}
else {
assertMichelsonData(n);
}
mapElts++;
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (ex_2_1 && !ex_2_1.done && (_a = ex_2.return)) _a.call(ex_2);
else {
assertMichelsonData(n);
}
finally { if (e_2) throw e_2.error; }
}

@@ -580,15 +531,5 @@ if (mapElts !== 0 && mapElts !== ex.length) {

}
try {
for (var _c = __values(ex.args), _d = _c.next(); !_d.done; _d = _c.next()) {
var a = _d.value;
assertMichelsonData(a);
}
for (const a of ex.args) {
assertMichelsonData(a);
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
}
finally { if (e_3) throw e_3.error; }
}
break;

@@ -624,67 +565,56 @@ case "Left":

function assertMichelsonContract(ex) {
var e_4, _a;
/* istanbul ignore else */
if (assertSeq(ex)) {
var toplevelSec = {};
var views = {};
try {
for (var ex_3 = __values(ex), ex_3_1 = ex_3.next(); !ex_3_1.done; ex_3_1 = ex_3.next()) {
var sec = ex_3_1.value;
if (assertPrim(sec)) {
if (sec.prim !== "view") {
if (sec.prim in toplevelSec) {
throw new MichelsonValidationError(ex, "duplicate contract section: " + sec.prim);
const toplevelSec = {};
const views = {};
for (const sec of ex) {
if (assertPrim(sec)) {
if (sec.prim !== "view") {
if (sec.prim in toplevelSec) {
throw new MichelsonValidationError(ex, `duplicate contract section: ${sec.prim}`);
}
toplevelSec[sec.prim] = true;
}
/* istanbul ignore else */
switch (sec.prim) {
case "code":
if (assertArgs(sec, 1)) {
/* istanbul ignore else */
if (assertSeq(sec.args[0])) {
assertMichelsonInstruction(sec.args[0]);
}
}
toplevelSec[sec.prim] = true;
}
/* istanbul ignore else */
switch (sec.prim) {
case "code":
if (assertArgs(sec, 1)) {
/* istanbul ignore else */
if (assertSeq(sec.args[0])) {
assertMichelsonInstruction(sec.args[0]);
break;
case "parameter":
if (assertArgs(sec, 1)) {
assertMichelsonPassableType(sec.args[0]);
}
break;
case "storage":
if (assertArgs(sec, 1)) {
assertMichelsonStorableType(sec.args[0]);
}
break;
case "view":
if (assertArgs(sec, 4)) {
if (assertStringLiteral(sec.args[0])) {
const name = sec.args[0];
if (name.string in views) {
throw new MichelsonValidationError(ex, `duplicate view name: ${name.string}`);
}
views[name.string] = true;
assertViewNameValid(name);
}
break;
case "parameter":
if (assertArgs(sec, 1)) {
assertMichelsonPassableType(sec.args[0]);
assertMichelsonPushableType(sec.args[1]);
assertMichelsonPushableType(sec.args[2]);
if (assertSeq(sec.args[3])) {
assertMichelsonInstruction(sec.args[3]);
}
break;
case "storage":
if (assertArgs(sec, 1)) {
assertMichelsonStorableType(sec.args[0]);
}
break;
case "view":
if (assertArgs(sec, 4)) {
if (assertStringLiteral(sec.args[0])) {
var name_1 = sec.args[0];
if (name_1.string in views) {
throw new MichelsonValidationError(ex, "duplicate view name: " + name_1.string);
}
views[name_1.string] = true;
assertViewNameValid(name_1);
}
assertMichelsonPushableType(sec.args[1]);
assertMichelsonPushableType(sec.args[2]);
if (assertSeq(sec.args[3])) {
assertMichelsonInstruction(sec.args[3]);
}
}
break;
default:
throw new MichelsonValidationError(ex, "unexpected contract section: " + sec.prim);
}
}
break;
default:
throw new MichelsonValidationError(ex, `unexpected contract section: ${sec.prim}`);
}
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (ex_3_1 && !ex_3_1.done && (_a = ex_3.return)) _a.call(ex_3);
}
finally { if (e_4) throw e_4.error; }
}
}

@@ -755,26 +685,15 @@ return true;

function assertDataListIfAny(d) {
var e_5, _a;
if (!Array.isArray(d)) {
return false;
}
try {
for (var d_1 = __values(d), d_1_1 = d_1.next(); !d_1_1.done; d_1_1 = d_1.next()) {
var v = d_1_1.value;
if ("prim" in v) {
if (isInstruction(v)) {
throw new utils_1.MichelsonError(d, "Instruction outside of a lambda: " + JSON.stringify(d));
}
else if (v.prim === "Elt") {
throw new utils_1.MichelsonError(d, "Elt item outside of a map literal: " + JSON.stringify(d));
}
for (const v of d) {
if ("prim" in v) {
if (isInstruction(v)) {
throw new utils_1.MichelsonError(d, `Instruction outside of a lambda: ${JSON.stringify(d)}`);
}
else if (v.prim === "Elt") {
throw new utils_1.MichelsonError(d, `Elt item outside of a map literal: ${JSON.stringify(d)}`);
}
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (d_1_1 && !d_1_1.done && (_a = d_1.return)) _a.call(d_1);
}
finally { if (e_5) throw e_5.error; }
}
return true;

@@ -781,0 +700,0 @@ }

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.scan = exports.Literal = exports.ScanError = void 0;
var ScanError = /** @class */ (function (_super) {
__extends(ScanError, _super);
function ScanError(src, idx, message) {
var _this = _super.call(this, message) || this;
_this.src = src;
_this.idx = idx;
Object.setPrototypeOf(_this, ScanError.prototype);
return _this;
class ScanError extends Error {
constructor(src, idx, message) {
super(message);
this.src = src;
this.idx = idx;
Object.setPrototypeOf(this, ScanError.prototype);
}
return ScanError;
}(Error));
}
exports.ScanError = ScanError;

@@ -64,132 +21,104 @@ var Literal;

})(Literal = exports.Literal || (exports.Literal = {}));
var isSpace = new RegExp("\\s");
var isIdentStart = new RegExp("[:@%_A-Za-z]");
var isIdent = new RegExp("[@%_\\.A-Za-z0-9]");
var isDigit = new RegExp("[0-9]");
var isHex = new RegExp("[0-9a-fA-F]");
function scan(src, scanComments) {
var i, s, start, ii, esc;
if (scanComments === void 0) { scanComments = false; }
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
i = 0;
_a.label = 1;
case 1:
if (!(i < src.length)) return [3 /*break*/, 19];
// Skip space
while (i < src.length && isSpace.test(src[i])) {
i++;
}
if (i === src.length) {
return [2 /*return*/];
}
s = src[i];
start = i;
if (!isIdentStart.test(s)) return [3 /*break*/, 3];
// Identifier
const isSpace = new RegExp("\\s");
const isIdentStart = new RegExp("[:@%_A-Za-z]");
const isIdent = new RegExp("[@%_\\.A-Za-z0-9]");
const isDigit = new RegExp("[0-9]");
const isHex = new RegExp("[0-9a-fA-F]");
function* scan(src, scanComments = false) {
let i = 0;
while (i < src.length) {
// Skip space
while (i < src.length && isSpace.test(src[i])) {
i++;
}
if (i === src.length) {
return;
}
const s = src[i];
const start = i;
if (isIdentStart.test(s)) {
// Identifier
i++;
while (i < src.length && isIdent.test(src[i])) {
i++;
while (i < src.length && isIdent.test(src[i])) {
i++;
}
return [4 /*yield*/, { t: Literal.Ident, v: src.slice(start, i), first: start, last: i }];
case 2:
_a.sent();
return [3 /*break*/, 18];
case 3:
if (!(src.length - i > 1 && src.substr(i, 2) === "0x")) return [3 /*break*/, 5];
// Bytes
i += 2;
while (i < src.length && isHex.test(src[i])) {
i++;
}
if (((i - start) & 1) !== 0) {
throw new ScanError(src, i, "Bytes literal length is expected to be power of two");
}
return [4 /*yield*/, { t: Literal.Bytes, v: src.slice(start, i), first: start, last: i }];
case 4:
_a.sent();
return [3 /*break*/, 18];
case 5:
if (!(isDigit.test(s) || s === "-")) return [3 /*break*/, 7];
// Number
if (s === "-") {
i++;
}
ii = i;
while (i < src.length && isDigit.test(src[i])) {
i++;
}
if (ii === i) {
throw new ScanError(src, i, "Number literal is too short");
}
return [4 /*yield*/, { t: Literal.Number, v: src.slice(start, i), first: start, last: i }];
case 6:
_a.sent();
return [3 /*break*/, 18];
case 7:
if (!(s === "\"")) return [3 /*break*/, 9];
// String
}
yield { t: Literal.Ident, v: src.slice(start, i), first: start, last: i };
}
else if (src.length - i > 1 && src.substr(i, 2) === "0x") {
// Bytes
i += 2;
while (i < src.length && isHex.test(src[i])) {
i++;
esc = false;
for (; i < src.length && (esc || src[i] !== "\""); i++) {
if (!esc && src[i] === "\\") {
esc = true;
}
else {
esc = false;
}
}
if (i === src.length) {
throw new ScanError(src, i, "Unterminated string literal");
}
}
if (((i - start) & 1) !== 0) {
throw new ScanError(src, i, "Bytes literal length is expected to be power of two");
}
yield { t: Literal.Bytes, v: src.slice(start, i), first: start, last: i };
}
else if (isDigit.test(s) || s === "-") {
// Number
if (s === "-") {
i++;
return [4 /*yield*/, { t: Literal.String, v: src.slice(start, i), first: start, last: i }];
case 8:
_a.sent();
return [3 /*break*/, 18];
case 9:
if (!(s === "#")) return [3 /*break*/, 12];
// Comment
}
const ii = i;
while (i < src.length && isDigit.test(src[i])) {
i++;
while (i < src.length && src[i] !== "\n") {
i++;
}
if (ii === i) {
throw new ScanError(src, i, "Number literal is too short");
}
yield { t: Literal.Number, v: src.slice(start, i), first: start, last: i };
}
else if (s === "\"") {
// String
i++;
let esc = false;
for (; i < src.length && (esc || src[i] !== "\""); i++) {
if (!esc && src[i] === "\\") {
esc = true;
}
if (!scanComments) return [3 /*break*/, 11];
return [4 /*yield*/, { t: Literal.Comment, v: src.slice(start, i), first: start, last: i }];
case 10:
_a.sent();
_a.label = 11;
case 11: return [3 /*break*/, 18];
case 12:
if (!(src.length - i > 1 && src.substr(i, 2) === "/*")) return [3 /*break*/, 15];
// C style comment
i += 2;
while (i < src.length && !(src.length - i > 1 && src.substr(i, 2) === "*/")) {
i++;
else {
esc = false;
}
if (i === src.length) {
throw new ScanError(src, i, "Unterminated C style comment");
}
i += 2;
if (!scanComments) return [3 /*break*/, 14];
return [4 /*yield*/, { t: Literal.Comment, v: src.slice(start, i), first: start, last: i }];
case 13:
_a.sent();
_a.label = 14;
case 14: return [3 /*break*/, 18];
case 15:
if (!(s === "(" || s === ")" || s === "{" || s === "}" || s === ";")) return [3 /*break*/, 17];
}
if (i === src.length) {
throw new ScanError(src, i, "Unterminated string literal");
}
i++;
yield { t: Literal.String, v: src.slice(start, i), first: start, last: i };
}
else if (s === "#") {
// Comment
i++;
while (i < src.length && src[i] !== "\n") {
i++;
return [4 /*yield*/, { t: s, v: s, first: start, last: i }];
case 16:
_a.sent();
return [3 /*break*/, 18];
case 17: throw new ScanError(src, i, "Invalid character at offset " + i + ": `" + s + "'");
case 18: return [3 /*break*/, 1];
case 19: return [2 /*return*/];
}
if (scanComments) {
yield { t: Literal.Comment, v: src.slice(start, i), first: start, last: i };
}
}
});
else if (src.length - i > 1 && src.substr(i, 2) === "/*") {
// C style comment
i += 2;
while (i < src.length && !(src.length - i > 1 && src.substr(i, 2) === "*/")) {
i++;
}
if (i === src.length) {
throw new ScanError(src, i, "Unterminated C style comment");
}
i += 2;
if (scanComments) {
yield { t: Literal.Comment, v: src.slice(start, i), first: start, last: i };
}
}
else if (s === "(" || s === ")" || s === "{" || s === "}" || s === ";") {
i++;
yield { t: s, v: s, first: start, last: i };
}
else {
throw new ScanError(src, i, `Invalid character at offset ${i}: \`${s}'`);
}
}
}
exports.scan = scan;
//# sourceMappingURL=scan.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.hexBytes = exports.parseHex = exports.parseDate = exports.isPairData = exports.isPairType = exports.unpackComb = exports.encodeTezosID = exports.checkDecodeTezosID = exports.tezosPrefix = exports.unpackAnnotations = exports.isNatural = exports.isDecimal = exports.compareBytes = exports.parseBytes = exports.LongInteger = exports.MichelsonTypeError = exports.isMichelsonError = exports.MichelsonError = void 0;
var base58_1 = require("./base58");
var MichelsonError = /** @class */ (function (_super) {
__extends(MichelsonError, _super);
const base58_1 = require("./base58");
class MichelsonError extends Error {
/**

@@ -67,10 +11,8 @@ * @param val Value of a AST node caused the error

*/
function MichelsonError(val, message) {
var _this = _super.call(this, message) || this;
_this.val = val;
Object.setPrototypeOf(_this, MichelsonError.prototype);
return _this;
constructor(val, message) {
super(message);
this.val = val;
Object.setPrototypeOf(this, MichelsonError.prototype);
}
return MichelsonError;
}(Error));
}
exports.MichelsonError = MichelsonError;

@@ -81,4 +23,3 @@ function isMichelsonError(err) {

exports.isMichelsonError = isMichelsonError;
var MichelsonTypeError = /** @class */ (function (_super) {
__extends(MichelsonTypeError, _super);
class MichelsonTypeError extends MichelsonError {
/**

@@ -89,16 +30,14 @@ * @param val Value of a type node caused the error

*/
function MichelsonTypeError(val, data, message) {
var _this = _super.call(this, val, message) || this;
constructor(val, data, message) {
super(val, message);
if (data !== undefined) {
_this.data = data;
this.data = data;
}
Object.setPrototypeOf(_this, MichelsonTypeError.prototype);
return _this;
Object.setPrototypeOf(this, MichelsonTypeError.prototype);
}
return MichelsonTypeError;
}(MichelsonError));
}
exports.MichelsonTypeError = MichelsonTypeError;
// Ad hoc big integer parser
var LongInteger = /** @class */ (function () {
function LongInteger(arg) {
class LongInteger {
constructor(arg) {
this.neg = false;

@@ -109,5 +48,5 @@ this.buf = [];

}
if (typeof arg === "string") {
for (var i = 0; i < arg.length; i++) {
var c = arg.charCodeAt(i);
if (typeof arg === 'string') {
for (let i = 0; i < arg.length; i++) {
const c = arg.charCodeAt(i);
if (i === 0 && c === 0x2d) {

@@ -118,3 +57,3 @@ this.neg = true;

if (c < 0x30 || c > 0x39) {
throw new Error("unexpected character in integer constant: " + arg[i]);
throw new Error(`unexpected character in integer constant: ${arg[i]}`);
}

@@ -133,11 +72,11 @@ this.append(c - 0x30);

}
LongInteger.prototype.append = function (c) {
var i = 0;
append(c) {
let i = 0;
while (c !== 0 || i < this.buf.length) {
var m = (this.buf[i] || 0) * 10 + c;
const m = (this.buf[i] || 0) * 10 + c;
this.buf[i++] = m % 256;
c = Math.floor(m / 256);
}
};
LongInteger.prototype.cmp = function (arg) {
}
cmp(arg) {
if (this.neg !== arg.neg) {

@@ -147,3 +86,3 @@ return (arg.neg ? 1 : 0) - (this.neg ? 1 : 0);

else {
var ret = 0;
let ret = 0;
if (this.buf.length !== arg.buf.length) {

@@ -153,3 +92,3 @@ ret = this.buf.length < arg.buf.length ? -1 : 1;

else if (this.buf.length !== 0) {
var i = arg.buf.length - 1;
let i = arg.buf.length - 1;
while (i >= 0 && this.buf[i] === arg.buf[i]) {

@@ -162,17 +101,12 @@ i--;

}
};
Object.defineProperty(LongInteger.prototype, "sign", {
get: function () {
return this.buf.length === 0 ? 0 : this.neg ? -1 : 1;
},
enumerable: false,
configurable: true
});
return LongInteger;
}());
}
get sign() {
return this.buf.length === 0 ? 0 : this.neg ? -1 : 1;
}
}
exports.LongInteger = LongInteger;
function parseBytes(s) {
var ret = [];
for (var i = 0; i < s.length; i += 2) {
var x = parseInt(s.slice(i, i + 2), 16);
const ret = [];
for (let i = 0; i < s.length; i += 2) {
const x = parseInt(s.slice(i, i + 2), 16);
if (Number.isNaN(x)) {

@@ -191,3 +125,3 @@ return null;

else if (a.length !== 0) {
var i = 0;
let i = 0;
while (i < a.length && a[i] === b[i]) {

@@ -205,3 +139,2 @@ i++;

try {
// tslint:disable-next-line: no-unused-expression
new LongInteger(x);

@@ -224,51 +157,40 @@ return true;

exports.isNatural = isNatural;
var annRe = /^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z.%@]*)?)$/;
const annRe = /^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z.%@]*)?)$/;
function unpackAnnotations(p, opt) {
var e_1, _a;
if (Array.isArray(p)) {
return {};
}
var field;
var type;
var vars;
let field;
let type;
let vars;
if (p.annots !== undefined) {
try {
for (var _b = __values(p.annots), _c = _b.next(); !_c.done; _c = _b.next()) {
var v = _c.value;
if (v.length !== 0) {
if (!annRe.test(v) ||
(!(opt === null || opt === void 0 ? void 0 : opt.specialVar) && (v === "@%" || v === "@%%")) ||
(!(opt === null || opt === void 0 ? void 0 : opt.specialFields) && v === "%@")) {
throw new MichelsonError(p, p.prim + ": unexpected annotation: " + v);
}
switch (v[0]) {
case "%":
if ((opt === null || opt === void 0 ? void 0 : opt.emptyFields) || v.length > 1) {
field = field || [];
field.push(v);
}
break;
case ":":
if (v.length > 1) {
type = type || [];
type.push(v);
}
break;
case "@":
if ((opt === null || opt === void 0 ? void 0 : opt.emptyVar) || v.length > 1) {
vars = vars || [];
vars.push(v);
}
break;
}
for (const v of p.annots) {
if (v.length !== 0) {
if (!annRe.test(v) ||
(!(opt === null || opt === void 0 ? void 0 : opt.specialVar) && (v === '@%' || v === '@%%')) ||
(!(opt === null || opt === void 0 ? void 0 : opt.specialFields) && v === '%@')) {
throw new MichelsonError(p, `${p.prim}: unexpected annotation: ${v}`);
}
switch (v[0]) {
case '%':
if ((opt === null || opt === void 0 ? void 0 : opt.emptyFields) || v.length > 1) {
field = field || [];
field.push(v);
}
break;
case ':':
if (v.length > 1) {
type = type || [];
type.push(v);
}
break;
case '@':
if ((opt === null || opt === void 0 ? void 0 : opt.emptyVar) || v.length > 1) {
vars = vars || [];
vars.push(v);
}
break;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}

@@ -308,31 +230,16 @@ return { f: field, t: type, v: vars };

};
function checkDecodeTezosID(id) {
var e_2, _a;
var types = [];
for (var _i = 1; _i < arguments.length; _i++) {
types[_i - 1] = arguments[_i];
}
var buf = base58_1.decodeBase58Check(id);
try {
for (var types_1 = __values(types), types_1_1 = types_1.next(); !types_1_1.done; types_1_1 = types_1.next()) {
var t = types_1_1.value;
var _b = __read(exports.tezosPrefix[t], 2), plen = _b[0], p = _b[1];
if (buf.length === plen + p.length) {
var i = 0;
while (i < p.length && buf[i] === p[i]) {
i++;
}
if (i === p.length) {
return [t, buf.slice(p.length)];
}
function checkDecodeTezosID(id, ...types) {
const buf = base58_1.decodeBase58Check(id);
for (const t of types) {
const [plen, p] = exports.tezosPrefix[t];
if (buf.length === plen + p.length) {
let i = 0;
while (i < p.length && buf[i] === p[i]) {
i++;
}
if (i === p.length) {
return [t, buf.slice(p.length)];
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (types_1_1 && !types_1_1.done && (_a = types_1.return)) _a.call(types_1);
}
finally { if (e_2) throw e_2.error; }
}
return null;

@@ -342,24 +249,26 @@ }

function encodeTezosID(id, data) {
var _a = __read(exports.tezosPrefix[id], 2), plen = _a[0], p = _a[1];
const [plen, p] = exports.tezosPrefix[id];
if (data.length !== plen) {
throw new Error("incorrect data length for " + id + ": " + data.length);
throw new Error(`incorrect data length for ${id}: ${data.length}`);
}
return base58_1.encodeBase58Check(__spread(p, data));
return base58_1.encodeBase58Check([...p, ...data]);
}
exports.encodeTezosID = encodeTezosID;
function unpackComb(id, v) {
var vv = v;
var args = Array.isArray(vv) ? vv : vv.args;
const vv = v;
const args = Array.isArray(vv) ? vv : vv.args;
if (args.length === 2) {
// it's a way to make a union of two interfaces not an interface with two independent properties of union types
var ret = id === "pair" ? {
prim: "pair",
args: args,
} : {
prim: "Pair",
args: args,
};
const ret = id === 'pair'
? {
prim: 'pair',
args,
}
: {
prim: 'Pair',
args,
};
return ret;
}
return __assign(__assign({}, (Array.isArray(vv) ? { prim: id } : vv)), { args: [
return Object.assign(Object.assign({}, (Array.isArray(vv) ? { prim: id } : vv)), { args: [
args[0],

@@ -374,12 +283,12 @@ {

function isPairType(t) {
return Array.isArray(t) || t.prim === "pair";
return Array.isArray(t) || t.prim === 'pair';
}
exports.isPairType = isPairType;
function isPairData(d) {
return Array.isArray(d) || "prim" in d && d.prim === "Pair";
return Array.isArray(d) || ('prim' in d && d.prim === 'Pair');
}
exports.isPairData = isPairData;
var 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]))$/;
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]))$/;
function parseDate(a) {
if ("string" in a) {
if ('string' in a) {
if (isNatural(a.string)) {

@@ -389,3 +298,3 @@ return new Date(parseInt(a.string, 10));

else if (rfc3339Re.test(a.string)) {
var x = new Date(a.string);
const x = new Date(a.string);
if (!Number.isNaN(x.valueOf)) {

@@ -403,8 +312,8 @@ return x;

function parseHex(s) {
var res = [];
for (var i = 0; i < s.length; i += 2) {
var ss = s.slice(i, i + 2);
var x = parseInt(ss, 16);
const res = [];
for (let i = 0; i < s.length; i += 2) {
const ss = s.slice(i, i + 2);
const x = parseInt(ss, 16);
if (Number.isNaN(x)) {
throw new Error("can't parse hex byte: " + ss);
throw new Error(`can't parse hex byte: ${ss}`);
}

@@ -417,5 +326,5 @@ res.push(x);

function hexBytes(bytes) {
return bytes.map(function (x) { return ((x >> 4) & 0xf).toString(16) + (x & 0xf).toString(16); }).join("");
return bytes.map((x) => ((x >> 4) & 0xf).toString(16) + (x & 0xf).toString(16)).join('');
}
exports.hexBytes = hexBytes;
//# sourceMappingURL=utils.js.map

@@ -5,8 +5,6 @@ "use strict";

// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
/* tslint:disable */
exports.VERSION = {
"commitHash": "e1723ab725df70755b4cd73b75aa981f913d0d5c",
"version": "11.1.0"
"commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
"version": "11.2.0-beta-RC.0"
};
/* tslint:enable */
//# sourceMappingURL=version.js.map

@@ -1,2 +0,2 @@

import { Expr } from "./micheline";
import { Expr } from './micheline';
export interface FormatOptions {

@@ -3,0 +3,0 @@ /**

@@ -1,4 +0,4 @@

import { MichelsonType, MichelsonData, MichelsonCode, MichelsonContract, MichelsonContractSection, MichelsonReturnType, MichelsonContractView } from "./michelson-types";
import { MichelsonError } from "./utils";
import { ParserOptions } from "./micheline-parser";
import { MichelsonType, MichelsonData, MichelsonCode, MichelsonContract, MichelsonContractSection, MichelsonReturnType, MichelsonContractView } from './michelson-types';
import { MichelsonError } from './utils';
import { ParserOptions } from './micheline-parser';
export interface Context extends ParserOptions {

@@ -23,3 +23,3 @@ contract?: MichelsonContract;

}
export declare function contractSection<T extends "parameter" | "storage" | "code">(contract: MichelsonContract, section: T): MichelsonContractSection<T>;
export declare function contractSection<T extends 'parameter' | 'storage' | 'code'>(contract: MichelsonContract, section: T): MichelsonContractSection<T>;
export declare function contractViews(contract: MichelsonContract): {

@@ -26,0 +26,0 @@ [name: string]: MichelsonContractView;

@@ -1,2 +0,2 @@

import { Prim, Expr, IntLiteral, StringLiteral, BytesLiteral, List, Node } from "./micheline";
import { Prim, Expr, IntLiteral, StringLiteral, BytesLiteral, List, Node } from './micheline';
interface Prim0<PT extends string = string> extends Prim<PT> {

@@ -8,4 +8,4 @@ args?: never;

}
declare type MichelsonNoArgInstructionID = "ABS" | "ADD" | "ADDRESS" | "AMOUNT" | "AND" | "APPLY" | "BALANCE" | "BLAKE2B" | "CAR" | "CDR" | "CHAIN_ID" | "CHECK_SIGNATURE" | "COMPARE" | "CONCAT" | "CONS" | "EDIV" | "EQ" | "EXEC" | "FAILWITH" | "GE" | "GET_AND_UPDATE" | "GT" | "HASH_KEY" | "IMPLICIT_ACCOUNT" | "INT" | "ISNAT" | "JOIN_TICKETS" | "KECCAK" | "LE" | "LEVEL" | "LSL" | "LSR" | "LT" | "MEM" | "MUL" | "NEG" | "NEQ" | "NEVER" | "NOT" | "NOW" | "OR" | "PACK" | "PAIRING_CHECK" | "READ_TICKET" | "SAPLING_VERIFY_UPDATE" | "SELF" | "SELF_ADDRESS" | "SENDER" | "SET_DELEGATE" | "SHA256" | "SHA3" | "SHA512" | "SIZE" | "SLICE" | "SOME" | "SOURCE" | "SPLIT_TICKET" | "SUB" | "SWAP" | "TICKET" | "TOTAL_VOTING_POWER" | "TRANSFER_TOKENS" | "UNIT" | "VOTING_POWER" | "XOR" | "RENAME" | "OPEN_CHEST";
declare type MichelsonRegularInstructionID = "CONTRACT" | "CREATE_CONTRACT" | "DIG" | "DIP" | "DROP" | "DUG" | "DUP" | "EMPTY_BIG_MAP" | "EMPTY_MAP" | "EMPTY_SET" | "GET" | "IF" | "IF_CONS" | "IF_LEFT" | "IF_NONE" | "ITER" | "LAMBDA" | "LEFT" | "LOOP" | "LOOP_LEFT" | "MAP" | "NIL" | "NONE" | "PAIR" | "PUSH" | "RIGHT" | "SAPLING_EMPTY_STATE" | "UNPACK" | "UNPAIR" | "UPDATE" | "CAST" | "VIEW" | "CREATE_ACCOUNT" | "STEPS_TO_QUOTA";
declare type MichelsonNoArgInstructionID = 'ABS' | 'ADD' | 'ADDRESS' | 'AMOUNT' | 'AND' | 'APPLY' | 'BALANCE' | 'BLAKE2B' | 'CAR' | 'CDR' | 'CHAIN_ID' | 'CHECK_SIGNATURE' | 'COMPARE' | 'CONCAT' | 'CONS' | 'EDIV' | 'EQ' | 'EXEC' | 'FAILWITH' | 'GE' | 'GET_AND_UPDATE' | 'GT' | 'HASH_KEY' | 'IMPLICIT_ACCOUNT' | 'INT' | 'ISNAT' | 'JOIN_TICKETS' | 'KECCAK' | 'LE' | 'LEVEL' | 'LSL' | 'LSR' | 'LT' | 'MEM' | 'MUL' | 'NEG' | 'NEQ' | 'NEVER' | 'NOT' | 'NOW' | 'OR' | 'PACK' | 'PAIRING_CHECK' | 'READ_TICKET' | 'SAPLING_VERIFY_UPDATE' | 'SELF' | 'SELF_ADDRESS' | 'SENDER' | 'SET_DELEGATE' | 'SHA256' | 'SHA3' | 'SHA512' | 'SIZE' | 'SLICE' | 'SOME' | 'SOURCE' | 'SPLIT_TICKET' | 'SUB' | 'SWAP' | 'TICKET' | 'TOTAL_VOTING_POWER' | 'TRANSFER_TOKENS' | 'UNIT' | 'VOTING_POWER' | 'XOR' | 'RENAME' | 'OPEN_CHEST';
declare type MichelsonRegularInstructionID = 'CONTRACT' | 'CREATE_CONTRACT' | 'DIG' | 'DIP' | 'DROP' | 'DUG' | 'DUP' | 'EMPTY_BIG_MAP' | 'EMPTY_MAP' | 'EMPTY_SET' | 'GET' | 'IF' | 'IF_CONS' | 'IF_LEFT' | 'IF_NONE' | 'ITER' | 'LAMBDA' | 'LEFT' | 'LOOP' | 'LOOP_LEFT' | 'MAP' | 'NIL' | 'NONE' | 'PAIR' | 'PUSH' | 'RIGHT' | 'SAPLING_EMPTY_STATE' | 'UNPACK' | 'UNPAIR' | 'UPDATE' | 'CAST' | 'VIEW' | 'CREATE_ACCOUNT' | 'STEPS_TO_QUOTA';
export declare type MichelsonInstructionID = MichelsonNoArgInstructionID | MichelsonRegularInstructionID;

@@ -19,73 +19,78 @@ declare type InstrPrim<PT extends MichelsonInstructionID, AT extends Expr[]> = Prim<PT, AT>;

export declare type MichelsonNoArgInstruction = Instr0<MichelsonNoArgInstructionID>;
export declare type MichelsonInstruction = MichelsonNoArgInstruction | InstrX<"DIG" | "DUG" | "SAPLING_EMPTY_STATE", [IntLiteral]> | InstrX<"NONE" | "LEFT" | "RIGHT" | "NIL" | "CAST", [MichelsonType]> | InstrX<"IF_NONE" | "IF_LEFT" | "IF_CONS" | "IF", [InstructionList, InstructionList]> | InstrX<"MAP" | "ITER" | "LOOP" | "LOOP_LEFT" | "DIP", [InstructionList]> | InstrX<"UNPACK", [MichelsonType]> | InstrX<"CONTRACT", [MichelsonType]> | InstrX<"CREATE_CONTRACT", [MichelsonContract]> | InstrX<"PUSH", [MichelsonType, MichelsonData]> | InstrX<"EMPTY_SET", [MichelsonType]> | InstrX<"EMPTY_MAP", [MichelsonType, MichelsonType]> | InstrX<"EMPTY_BIG_MAP", [MichelsonType, MichelsonType]> | InstrX<"LAMBDA", [MichelsonType, MichelsonType, InstructionList]> | InstrX<"DIP", [IntLiteral, InstructionList] | [InstructionList]> | InstrX<"VIEW", [StringLiteral, MichelsonType]> | InstrPrim<"DROP" | "PAIR" | "UNPAIR" | "DUP" | "GET" | "UPDATE", [IntLiteral]>;
export declare type MichelsonSimpleComparableTypeID = "string" | "nat" | "int" | "bytes" | "bool" | "mutez" | "key_hash" | "address" | "timestamp" | "never" | "key" | "unit" | "signature" | "chain_id";
export declare type MichelsonTypeID = MichelsonSimpleComparableTypeID | "option" | "list" | "set" | "contract" | "operation" | "pair" | "or" | "lambda" | "map" | "big_map" | "sapling_transaction" | "sapling_state" | "ticket" | "bls12_381_g1" | "bls12_381_g2" | "bls12_381_fr" | "chest_key" | "chest";
export declare type MichelsonInstruction = MichelsonNoArgInstruction | InstrX<'DIG' | 'DUG' | 'SAPLING_EMPTY_STATE', [IntLiteral]> | InstrX<'NONE' | 'LEFT' | 'RIGHT' | 'NIL' | 'CAST', [MichelsonType]> | InstrX<'IF_NONE' | 'IF_LEFT' | 'IF_CONS' | 'IF', [InstructionList, InstructionList]> | InstrX<'MAP' | 'ITER' | 'LOOP' | 'LOOP_LEFT' | 'DIP', [InstructionList]> | InstrX<'UNPACK', [MichelsonType]> | InstrX<'CONTRACT', [MichelsonType]> | InstrX<'CREATE_CONTRACT', [MichelsonContract]> | InstrX<'PUSH', [MichelsonType, MichelsonData]> | InstrX<'EMPTY_SET', [MichelsonType]> | InstrX<'EMPTY_MAP', [MichelsonType, MichelsonType]> | InstrX<'EMPTY_BIG_MAP', [MichelsonType, MichelsonType]> | InstrX<'LAMBDA', [MichelsonType, MichelsonType, InstructionList]> | InstrX<'DIP', [IntLiteral, InstructionList] | [InstructionList]> | InstrX<'VIEW', [StringLiteral, MichelsonType]> | InstrPrim<'DROP' | 'PAIR' | 'UNPAIR' | 'DUP' | 'GET' | 'UPDATE', [IntLiteral]>;
export declare type MichelsonSimpleComparableTypeID = 'string' | 'nat' | 'int' | 'bytes' | 'bool' | 'mutez' | 'key_hash' | 'address' | 'timestamp' | 'never' | 'key' | 'unit' | 'signature' | 'chain_id';
export declare type MichelsonTypeID = MichelsonSimpleComparableTypeID | 'option' | 'list' | 'set' | 'contract' | 'operation' | 'pair' | 'or' | 'lambda' | 'map' | 'big_map' | 'sapling_transaction' | 'sapling_state' | 'ticket' | 'bls12_381_g1' | 'bls12_381_g2' | 'bls12_381_fr' | 'chest_key' | 'chest';
declare type Type0<PT extends MichelsonTypeID> = Prim0<PT>;
declare type TypeX<PT extends MichelsonTypeID, AT extends Expr[]> = PrimX<PT, AT>;
export declare const refContract: unique symbol;
export interface MichelsonTypeAddress extends Type0<"address"> {
export interface MichelsonTypeAddress extends Type0<'address'> {
[refContract]?: MichelsonTypeContract<MichelsonType>;
}
export declare type MichelsonTypeInt = Type0<"int">;
export declare type MichelsonTypeNat = Type0<"nat">;
export declare type MichelsonTypeString = Type0<"string">;
export declare type MichelsonTypeBytes = Type0<"bytes">;
export declare type MichelsonTypeMutez = Type0<"mutez">;
export declare type MichelsonTypeBool = Type0<"bool">;
export declare type MichelsonTypeKeyHash = Type0<"key_hash">;
export declare type MichelsonTypeTimestamp = Type0<"timestamp">;
export declare type MichelsonTypeKey = Type0<"key">;
export declare type MichelsonTypeUnit = Type0<"unit">;
export declare type MichelsonTypeSignature = Type0<"signature">;
export declare type MichelsonTypeOperation = Type0<"operation">;
export declare type MichelsonTypeChainID = Type0<"chain_id">;
export declare type MichelsonTypeNever = Type0<"never">;
export declare type MichelsonTypeBLS12_381_G1 = Type0<"bls12_381_g1">;
export declare type MichelsonTypeBLS12_381_G2 = Type0<"bls12_381_g2">;
export declare type MichelsonTypeBLS12_381_FR = Type0<"bls12_381_fr">;
export declare type MichelsonTypeChestKey = Type0<"chest_key">;
export declare type MichelsonTypeChest = Type0<"chest">;
export declare type MichelsonTypeInt = Type0<'int'>;
export declare type MichelsonTypeNat = Type0<'nat'>;
export declare type MichelsonTypeString = Type0<'string'>;
export declare type MichelsonTypeBytes = Type0<'bytes'>;
export declare type MichelsonTypeMutez = Type0<'mutez'>;
export declare type MichelsonTypeBool = Type0<'bool'>;
export declare type MichelsonTypeKeyHash = Type0<'key_hash'>;
export declare type MichelsonTypeTimestamp = Type0<'timestamp'>;
export declare type MichelsonTypeKey = Type0<'key'>;
export declare type MichelsonTypeUnit = Type0<'unit'>;
export declare type MichelsonTypeSignature = Type0<'signature'>;
export declare type MichelsonTypeOperation = Type0<'operation'>;
export declare type MichelsonTypeChainID = Type0<'chain_id'>;
export declare type MichelsonTypeNever = Type0<'never'>;
export declare type MichelsonTypeBLS12_381_G1 = Type0<'bls12_381_g1'>;
export declare type MichelsonTypeBLS12_381_G2 = Type0<'bls12_381_g2'>;
export declare type MichelsonTypeBLS12_381_FR = Type0<'bls12_381_fr'>;
export declare type MichelsonTypeChestKey = Type0<'chest_key'>;
export declare type MichelsonTypeChest = Type0<'chest'>;
declare type TypeList<T extends MichelsonType[]> = T & Node;
export declare type MichelsonTypePair<T extends MichelsonType[]> = TypeX<"pair", T> | TypeList<T>;
export interface MichelsonTypeOption<T extends MichelsonType> extends TypeX<"option", [T]> {
export declare type MichelsonTypePair<T extends MichelsonType[]> = TypeX<'pair', T> | TypeList<T>;
export interface MichelsonTypeOption<T extends MichelsonType> extends TypeX<'option', [T]> {
}
export interface MichelsonTypeList<T extends MichelsonType> extends TypeX<"list", [T]> {
export interface MichelsonTypeList<T extends MichelsonType> extends TypeX<'list', [T]> {
}
export interface MichelsonTypeContract<T extends MichelsonType> extends TypeX<"contract", [T]> {
export interface MichelsonTypeContract<T extends MichelsonType> extends TypeX<'contract', [T]> {
}
export interface MichelsonTypeOr<T extends [MichelsonType, MichelsonType]> extends TypeX<"or", T> {
export interface MichelsonTypeOr<T extends [MichelsonType, MichelsonType]> extends TypeX<'or', T> {
}
export interface MichelsonTypeLambda<Arg extends MichelsonType, Ret extends MichelsonType> extends TypeX<"lambda", [Arg, Ret]> {
export interface MichelsonTypeLambda<Arg extends MichelsonType, Ret extends MichelsonType> extends TypeX<'lambda', [Arg, Ret]> {
}
export interface MichelsonTypeSet<T extends MichelsonType> extends TypeX<"set", [T]> {
export interface MichelsonTypeSet<T extends MichelsonType> extends TypeX<'set', [T]> {
}
export interface MichelsonTypeMap<K extends MichelsonType, V extends MichelsonType> extends TypeX<"map", [K, V]> {
export interface MichelsonTypeMap<K extends MichelsonType, V extends MichelsonType> extends TypeX<'map', [K, V]> {
}
export interface MichelsonTypeBigMap<K extends MichelsonType, V extends MichelsonType> extends TypeX<"big_map", [K, V]> {
export interface MichelsonTypeBigMap<K extends MichelsonType, V extends MichelsonType> extends TypeX<'big_map', [K, V]> {
}
export interface MichelsonTypeSaplingState<S extends string = string> extends TypeX<"sapling_state", [IntLiteral<S>]> {
export interface MichelsonTypeSaplingState<S extends string = string> extends TypeX<'sapling_state', [IntLiteral<S>]> {
}
export interface MichelsonTypeSaplingTransaction<S extends string = string> extends TypeX<"sapling_transaction", [IntLiteral<S>]> {
export interface MichelsonTypeSaplingTransaction<S extends string = string> extends TypeX<'sapling_transaction', [IntLiteral<S>]> {
}
export interface MichelsonTypeTicket<T extends MichelsonType> extends TypeX<"ticket", [T]> {
export interface MichelsonTypeTicket<T extends MichelsonType> extends TypeX<'ticket', [T]> {
}
export declare type MichelsonType<T extends MichelsonTypeID = MichelsonTypeID> = T extends "int" ? MichelsonTypeInt : T extends "nat" ? MichelsonTypeNat : T extends "string" ? MichelsonTypeString : T extends "bytes" ? MichelsonTypeBytes : T extends "mutez" ? MichelsonTypeMutez : T extends "bool" ? MichelsonTypeBool : T extends "key_hash" ? MichelsonTypeKeyHash : T extends "timestamp" ? MichelsonTypeTimestamp : T extends "address" ? MichelsonTypeAddress : T extends "key" ? MichelsonTypeKey : T extends "unit" ? MichelsonTypeUnit : T extends "signature" ? MichelsonTypeSignature : T extends "operation" ? MichelsonTypeOperation : T extends "chain_id" ? MichelsonTypeChainID : T extends "option" ? MichelsonTypeOption<MichelsonType> : T extends "list" ? MichelsonTypeList<MichelsonType> : T extends "contract" ? MichelsonTypeContract<MichelsonType> : T extends "ticket" ? MichelsonTypeTicket<MichelsonType> : T extends "pair" ? MichelsonTypePair<MichelsonType[]> : T extends "or" ? MichelsonTypeOr<[MichelsonType, MichelsonType]> : T extends "lambda" ? MichelsonTypeLambda<MichelsonType, MichelsonType> : T extends "set" ? MichelsonTypeSet<MichelsonType> : T extends "map" ? MichelsonTypeMap<MichelsonType, MichelsonType> : T extends "big_map" ? MichelsonTypeBigMap<MichelsonType, MichelsonType> : T extends "never" ? MichelsonTypeNever : T extends "bls12_381_g1" ? MichelsonTypeBLS12_381_G1 : T extends "bls12_381_g2" ? MichelsonTypeBLS12_381_G2 : T extends "bls12_381_fr" ? MichelsonTypeBLS12_381_FR : T extends "sapling_transaction" ? MichelsonTypeSaplingTransaction : T extends "sapling_state" ? MichelsonTypeSaplingState : T extends "chest_key" ? MichelsonTypeChestKey : MichelsonTypeChest;
export declare type MichelsonDataID = "Unit" | "True" | "False" | "None" | "Pair" | "Left" | "Right" | "Some";
export declare type MichelsonType<T extends MichelsonTypeID = MichelsonTypeID> = T extends 'int' ? MichelsonTypeInt : T extends 'nat' ? MichelsonTypeNat : T extends 'string' ? MichelsonTypeString : T extends 'bytes' ? MichelsonTypeBytes : T extends 'mutez' ? MichelsonTypeMutez : T extends 'bool' ? MichelsonTypeBool : T extends 'key_hash' ? MichelsonTypeKeyHash : T extends 'timestamp' ? MichelsonTypeTimestamp : T extends 'address' ? MichelsonTypeAddress : T extends 'key' ? MichelsonTypeKey : T extends 'unit' ? MichelsonTypeUnit : T extends 'signature' ? MichelsonTypeSignature : T extends 'operation' ? MichelsonTypeOperation : T extends 'chain_id' ? MichelsonTypeChainID : T extends 'option' ? MichelsonTypeOption<MichelsonType> : T extends 'list' ? MichelsonTypeList<MichelsonType> : T extends 'contract' ? MichelsonTypeContract<MichelsonType> : T extends 'ticket' ? MichelsonTypeTicket<MichelsonType> : T extends 'pair' ? MichelsonTypePair<MichelsonType[]> : T extends 'or' ? MichelsonTypeOr<[MichelsonType, MichelsonType]> : T extends 'lambda' ? MichelsonTypeLambda<MichelsonType, MichelsonType> : T extends 'set' ? MichelsonTypeSet<MichelsonType> : T extends 'map' ? MichelsonTypeMap<MichelsonType, MichelsonType> : T extends 'big_map' ? MichelsonTypeBigMap<MichelsonType, MichelsonType> : T extends 'never' ? MichelsonTypeNever : T extends 'bls12_381_g1' ? MichelsonTypeBLS12_381_G1 : T extends 'bls12_381_g2' ? MichelsonTypeBLS12_381_G2 : T extends 'bls12_381_fr' ? MichelsonTypeBLS12_381_FR : T extends 'sapling_transaction' ? MichelsonTypeSaplingTransaction : T extends 'sapling_state' ? MichelsonTypeSaplingState : T extends 'chest_key' ? MichelsonTypeChestKey : MichelsonTypeChest;
export declare type MichelsonDataID = 'Unit' | 'True' | 'False' | 'None' | 'Pair' | 'Left' | 'Right' | 'Some';
declare type Data0<PT extends MichelsonDataID> = Prim0<PT>;
declare type DataX<PT extends MichelsonDataID, AT extends MichelsonData[]> = PrimX<PT, AT>;
export declare type MichelsonDataOption = DataX<"Some", [MichelsonData]> | Data0<"None">;
export declare type MichelsonDataOr = DataX<"Left" | "Right", [MichelsonData]>;
export declare type MichelsonDataOption = DataX<'Some', [MichelsonData]> | Data0<'None'>;
export declare type MichelsonDataOr = DataX<'Left' | 'Right', [MichelsonData]>;
declare type DataList<T extends MichelsonData[]> = T & Node;
export declare type MichelsonDataPair<T extends MichelsonData[]> = DataX<"Pair", T> | DataList<T>;
export declare type MichelsonMapElt = PrimX<"Elt", [MichelsonData, MichelsonData]>;
export declare type MichelsonDataPair<T extends MichelsonData[]> = DataX<'Pair', T> | DataList<T>;
export declare type MichelsonMapElt = PrimX<'Elt', [MichelsonData, MichelsonData]>;
export declare type MichelsonMapEltList = List<MichelsonMapElt>;
export declare type MichelsonData = IntLiteral | StringLiteral | BytesLiteral | Data0<"Unit" | "True" | "False"> | MichelsonDataOption | MichelsonDataOr | DataList<MichelsonData[]> | MichelsonDataPair<MichelsonData[]> | InstructionList | MichelsonMapEltList;
export declare type MichelsonSectionID = "parameter" | "storage" | "code" | "view";
export declare type MichelsonData = IntLiteral | StringLiteral | BytesLiteral | Data0<'Unit' | 'True' | 'False'> | MichelsonDataOption | MichelsonDataOr | DataList<MichelsonData[]> | MichelsonDataPair<MichelsonData[]> | InstructionList | MichelsonMapEltList;
export declare type MichelsonSectionID = 'parameter' | 'storage' | 'code' | 'view';
declare type SectionPrim<PT extends MichelsonSectionID, AT extends Expr[]> = PrimX<PT, AT>;
export declare type MichelsonContractParameter = SectionPrim<"parameter", [MichelsonType]>;
export declare type MichelsonContractStorage = SectionPrim<"storage", [MichelsonType]>;
export declare type MichelsonContractCode = SectionPrim<"code", [InstructionList]>;
export declare type MichelsonContractView = SectionPrim<"view", [StringLiteral, MichelsonType, MichelsonType, InstructionList]>;
export declare type MichelsonContractParameter = SectionPrim<'parameter', [MichelsonType]>;
export declare type MichelsonContractStorage = SectionPrim<'storage', [MichelsonType]>;
export declare type MichelsonContractCode = SectionPrim<'code', [InstructionList]>;
export declare type MichelsonContractView = SectionPrim<'view', [
StringLiteral,
MichelsonType,
MichelsonType,
InstructionList
]>;
export declare type MichelsonContract = MichelsonContractSection[];
export declare type MichelsonContractSection<T extends MichelsonSectionID = MichelsonSectionID> = T extends "parameter" ? MichelsonContractParameter : T extends "storage" ? MichelsonContractStorage : T extends "view" ? MichelsonContractView : MichelsonContractCode;
export declare type MichelsonContractSection<T extends MichelsonSectionID = MichelsonSectionID> = T extends 'parameter' ? MichelsonContractParameter : T extends 'storage' ? MichelsonContractStorage : T extends 'view' ? MichelsonContractView : MichelsonContractCode;
export interface MichelsonTypeFailed {

@@ -113,5 +118,7 @@ failed: MichelsonType;

PtHangz2 = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",
PsiThaCa = "PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP",
Psithaca2 = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",
ProtoALpha = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"
}
export declare const DefaultProtocol = Protocol.PtGRANAD;
export declare const DefaultProtocol = Protocol.Psithaca2;
export declare type ProtocolID = `${Protocol}`;

@@ -118,0 +125,0 @@ export declare function ProtoGreaterOfEqual(a: ProtocolID, b: ProtocolID): boolean;

@@ -1,3 +0,3 @@

import { Prim, Expr, StringLiteral, IntLiteral } from "./micheline";
import { MichelsonData, MichelsonDataPair, MichelsonType, MichelsonTypePair } from "./michelson-types";
import { Prim, Expr, StringLiteral, IntLiteral } from './micheline';
import { MichelsonData, MichelsonDataPair, MichelsonType, MichelsonTypePair } from './michelson-types';
export declare type Tuple<N extends number, T> = N extends 1 ? [T] : N extends 2 ? [T, T] : N extends 3 ? [T, T, T] : N extends 4 ? [T, T, T, T] : N extends 5 ? [T, T, T, T, T] : N extends 6 ? [T, T, T, T, T, T] : N extends 7 ? [T, T, T, T, T, T, T] : N extends 8 ? [T, T, T, T, T, T, T, T] : T[];

@@ -8,5 +8,5 @@ declare type RequiredProp<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;

};
export declare type ReqArgs<T extends Prim> = RequiredProp<T, "args">;
export declare type NoArgs<T extends Prim> = OmitProp<T, "args">;
export declare type NoAnnots<T extends Prim> = OmitProp<T, "annots">;
export declare type ReqArgs<T extends Prim> = RequiredProp<T, 'args'>;
export declare type NoArgs<T extends Prim> = OmitProp<T, 'args'>;
export declare type NoAnnots<T extends Prim> = OmitProp<T, 'annots'>;
export declare type Nullable<T> = {

@@ -58,3 +58,3 @@ [P in keyof T]: T[P] | null;

export declare function unpackAnnotations(p: Prim | Expr[], opt?: UnpackAnnotationsOptions): UnpackedAnnotations;
export declare type TezosIDType = "BlockHash" | "OperationHash" | "OperationListHash" | "OperationListListHash" | "ProtocolHash" | "ContextHash" | "ED25519PublicKeyHash" | "SECP256K1PublicKeyHash" | "P256PublicKeyHash" | "ContractHash" | "CryptoboxPublicKeyHash" | "ED25519Seed" | "ED25519PublicKey" | "SECP256K1SecretKey" | "P256SecretKey" | "ED25519EncryptedSeed" | "SECP256K1EncryptedSecretKey" | "P256EncryptedSecretKey" | "SECP256K1PublicKey" | "P256PublicKey" | "SECP256K1Scalar" | "SECP256K1Element" | "ED25519SecretKey" | "ED25519Signature" | "SECP256K1Signature" | "P256Signature" | "GenericSignature" | "ChainID";
export declare type TezosIDType = 'BlockHash' | 'OperationHash' | 'OperationListHash' | 'OperationListListHash' | 'ProtocolHash' | 'ContextHash' | 'ED25519PublicKeyHash' | 'SECP256K1PublicKeyHash' | 'P256PublicKeyHash' | 'ContractHash' | 'CryptoboxPublicKeyHash' | 'ED25519Seed' | 'ED25519PublicKey' | 'SECP256K1SecretKey' | 'P256SecretKey' | 'ED25519EncryptedSeed' | 'SECP256K1EncryptedSecretKey' | 'P256EncryptedSecretKey' | 'SECP256K1PublicKey' | 'P256PublicKey' | 'SECP256K1Scalar' | 'SECP256K1Element' | 'ED25519SecretKey' | 'ED25519Signature' | 'SECP256K1Signature' | 'P256Signature' | 'GenericSignature' | 'ChainID';
export declare type TezosIDPrefix = [number, number[]];

@@ -64,4 +64,4 @@ export declare const tezosPrefix: Record<TezosIDType, TezosIDPrefix>;

export declare function encodeTezosID(id: TezosIDType, data: number[] | Uint8Array): string;
declare type PairTypeOrDataPrim<I extends "pair" | "Pair"> = I extends "pair" ? Extract<MichelsonTypePair<MichelsonType[]>, Prim> : Extract<MichelsonDataPair<MichelsonData[]>, Prim>;
export declare function unpackComb<I extends "pair" | "Pair">(id: I, v: I extends "pair" ? MichelsonTypePair<MichelsonType[]> : MichelsonDataPair<MichelsonData[]>): PairTypeOrDataPrim<I>;
declare type PairTypeOrDataPrim<I extends 'pair' | 'Pair'> = I extends 'pair' ? Extract<MichelsonTypePair<MichelsonType[]>, Prim> : Extract<MichelsonDataPair<MichelsonData[]>, Prim>;
export declare function unpackComb<I extends 'pair' | 'Pair'>(id: I, v: I extends 'pair' ? MichelsonTypePair<MichelsonType[]> : MichelsonDataPair<MichelsonData[]>): PairTypeOrDataPrim<I>;
export declare function isPairType(t: MichelsonType): t is MichelsonTypePair<MichelsonType[]>;

@@ -68,0 +68,0 @@ export declare function isPairData(d: Expr): d is MichelsonDataPair<MichelsonData[]>;

{
"name": "@taquito/michel-codec",
"version": "11.1.0",
"version": "11.2.0-beta-RC.0",
"description": "Michelson parser/validator/formatter",

@@ -11,3 +11,3 @@ "keywords": [

"main": "./dist/taquito-michel-codec.umd.js",
"module": "./dist/taquito-michel-codec.es5.js",
"module": "./dist/taquito-michel-codec.es6.js",
"typings": "./dist/types/taquito-michel-codec.d.ts",

@@ -38,4 +38,4 @@ "files": [

"version-stamp": "node ../taquito/version-stamping.js",
"build": "npm run version-stamp && tsc --project ./tsconfig.prod.json --module commonjs && rollup -c rollup.config.ts",
"start": "npm run version-stamp && rollup -c rollup.config.ts -w"
"build": "tsc --project ./tsconfig.prod.json --module commonjs && rollup -c rollup.config.ts",
"start": "rollup -c rollup.config.ts -w"
},

@@ -72,26 +72,26 @@ "lint-staged": {

"devDependencies": {
"@types/bluebird": "^3.5.36",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.2",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"eslint": "^7.29.0",
"@types/node": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"eslint": "^8.5.0",
"jest": "^26.6.3",
"jest-config": "^26.6.3",
"jest-extended": "^0.11.5",
"lint-staged": "^11.0.0",
"jest-extended": "^1.2.0",
"lint-staged": "^12.1.2",
"lodash.camelcase": "^4.3.0",
"prettier": "^2.3.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"rollup": "^2.51.1",
"rollup": "^2.61.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-typescript2": "^0.31.1",
"ts-jest": "^26.4.4",
"ts-node": "^10.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^9.0.0",
"ts-node": "^10.4.0",
"ts-toolbelt": "^9.6.0",
"typedoc": "^0.20.36",
"typescript": "~4.1.5"
},
"gitHead": "b45707bca75a6a5163b6ef20c80db5975b02e894"
"gitHead": "7cc9152cdad01bacca4a1b682c7cb0a33a24f544"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc