From e162c6f1872cf13ff6bd3a529826c42268217609 Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Wed, 29 Jul 2020 20:04:30 -0400 Subject: [PATCH 1/9] - enable reading of public keys for secp256k1 and r1 curves --- src/chain/tezos/TezosMessageUtil.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/chain/tezos/TezosMessageUtil.ts b/src/chain/tezos/TezosMessageUtil.ts index 42a837bd..5f6a22ce 100644 --- a/src/chain/tezos/TezosMessageUtil.ts +++ b/src/chain/tezos/TezosMessageUtil.ts @@ -262,7 +262,7 @@ export namespace TezosMessageUtils { return "00" + base58check.decode(publicKey).slice(4).toString("hex"); } else if (publicKey.startsWith("sppk")) { // secp256k1 return "01" + base58check.decode(publicKey).slice(4).toString("hex"); - } else if (publicKey.startsWith("p2pk")) { // p256 + } else if (publicKey.startsWith("p2pk")) { // secp256r1 (p256) return "02" + base58check.decode(publicKey).slice(4).toString("hex"); } else { throw new Error('Unrecognized key type'); @@ -270,18 +270,22 @@ export namespace TezosMessageUtils { } /** - * Reads a key without a prefix from binary and decodes it into a Base58-check representation. + * Deserialize a key without a prefix from binary and decodes it into a Base58-check representation. * * @param {Buffer | Uint8Array} b Bytes containing the key. - * @param hint One of 'edsk' (private key), 'edpk' (public key). + * @param hint */ export function readKeyWithHint(b: Buffer | Uint8Array, hint: string): string { const key = !(b instanceof Buffer) ? Buffer.from(b) : b; - if (hint === 'edsk') { + if (hint === 'edsk') { // ed25519 secret key return base58check.encode(Buffer.from('2bf64e07' + key.toString('hex'), 'hex')); - } else if (hint === 'edpk') { + } else if (hint === 'edpk') { // ed25519 public key return readPublicKey(`00${key.toString('hex')}`); + } else if (hint === 'sppk') {// secp256k1 public key + return readPublicKey(`01${key.toString('hex')}`); + } else if (hint === 'p2pk') {// secp256r1 public key + return readPublicKey(`02${key.toString('hex')}`); } else { throw new Error(`Unrecognized key hint, '${hint}'`); } @@ -294,10 +298,8 @@ export namespace TezosMessageUtils { * @param hint Key type, usually the curve it was generated from, eg: 'edsk'. */ export function writeKeyWithHint(key: string, hint: string): Buffer { - if (hint === 'edsk' || hint === 'edpk') { // ed25519 + if (hint === 'edsk' || hint === 'edpk' || hint === 'sppk' || hint === 'p2pk') { return base58check.decode(key).slice(4); - //} else if (hint === 'sppk') { // secp256k1 - //} else if (hint === 'p2pk') { // secp256r1 } else { throw new Error(`Unrecognized key hint, '${hint}'`); } From 711560ffbb92f74331fc8cd8a70c6d7189feb410 Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Wed, 29 Jul 2020 20:42:19 -0400 Subject: [PATCH 2/9] - docs --- src/chain/tezos/TezosMessageUtil.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chain/tezos/TezosMessageUtil.ts b/src/chain/tezos/TezosMessageUtil.ts index 5f6a22ce..7180bc2f 100644 --- a/src/chain/tezos/TezosMessageUtil.ts +++ b/src/chain/tezos/TezosMessageUtil.ts @@ -10,6 +10,8 @@ import { SignerCurve } from "../../types/ExternalInterfaces"; /** * A collection of functions to encode and decode various Tezos P2P message components like amounts, addresses, hashes, etc. + * + * Magic prefixes taken from: https://gitlab.com/tezos/tezos/blob/master/src/lib_crypto/base58.ml#L343 */ export namespace TezosMessageUtils { /** From 8b8920119f5091943a4421ab2e9be00653c51c00 Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Wed, 29 Jul 2020 20:45:15 -0400 Subject: [PATCH 3/9] - docs --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index ecb72952..baa0f720 100644 --- a/docs/README.md +++ b/docs/README.md @@ -58,7 +58,7 @@ Unlike the nodejs sample, it's not possible to configure fetch or logger referen crossorigin="anonymous"> From 35a9d01ec5fdb792d5e33aa92797bf4552048f9a Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Fri, 31 Jul 2020 17:13:30 -0400 Subject: [PATCH 4/9] - throw more detailed errors from TezosNodeWriter --- .../chain/tezos/lexer/MichelsonParser.spec.ts | 1 - src/chain/tezos/TezosNodeWriter.ts | 3 ++- src/types/ErrorTypes.ts | 12 ++++++------ src/types/tezos/TezosErrorTypes.ts | 4 +--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/integration_test/chain/tezos/lexer/MichelsonParser.spec.ts b/integration_test/chain/tezos/lexer/MichelsonParser.spec.ts index 34296ee1..a8811e6e 100644 --- a/integration_test/chain/tezos/lexer/MichelsonParser.spec.ts +++ b/integration_test/chain/tezos/lexer/MichelsonParser.spec.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import * as Michelson from '../../../../src/chain/tezos/lexer/Michelson'; import * as nearley from 'nearley'; -import * as request from 'request-promise'; function michelsonToMicheline(code: string): string { const processedCode = code.trim().split('\n').map(l => l.replace(/\#[\s\S]+$/, '').trim()).join(' '); diff --git a/src/chain/tezos/TezosNodeWriter.ts b/src/chain/tezos/TezosNodeWriter.ts index d28fafda..bd516d60 100644 --- a/src/chain/tezos/TezosNodeWriter.ts +++ b/src/chain/tezos/TezosNodeWriter.ts @@ -3,6 +3,7 @@ import * as blakejs from 'blakejs'; import { KeyStore, Signer } from '../../types/ExternalInterfaces'; import * as TezosTypes from '../../types/tezos/TezosChainTypes'; import { TezosConstants } from '../../types/tezos/TezosConstants'; +import { ServiceResponseError } from '../../types/ErrorTypes'; import * as TezosP2PMessageTypes from '../../types/tezos/TezosP2PMessageTypes'; import { TezosNodeReader } from './TezosNodeReader'; import { TezosMessageCodec } from './TezosMessageCodec'; @@ -741,7 +742,7 @@ export namespace TezosNodeWriter { if (errors.length > 0) { log.debug(`errors found in response:\n${response}`); - throw new Error(errors); // TODO: use TezosResponseError + throw new ServiceResponseError(200, '', '', '', response); } } } diff --git a/src/types/ErrorTypes.ts b/src/types/ErrorTypes.ts index a93a659a..af680438 100644 --- a/src/types/ErrorTypes.ts +++ b/src/types/ErrorTypes.ts @@ -6,15 +6,15 @@ export class ServiceRequestError extends Error { httpStatus: number; httpMessage: string; serverURL: string; - data: string | null; + request: string | null; - constructor(httpStatus: number, httpMessage: string, serverURL: string, data: string | null){ + constructor(httpStatus: number, httpMessage: string, serverURL: string, request: string | null) { super(); this.httpStatus = httpStatus; this.httpMessage = httpMessage; this.serverURL = serverURL; - this.data = data; + this.request = request; } } @@ -25,16 +25,16 @@ export class ServiceResponseError extends Error { httpStatus: number; httpMessage: string; serverURL: string; - data: string | null; + request: string | null; response: any; - constructor(httpStatus: number, httpMessage: string, serverURL: string, data: string | null, response: any){ + constructor(httpStatus: number, httpMessage: string, serverURL: string, request: string | null, response: any) { super(); this.httpStatus = httpStatus; this.httpMessage = httpMessage; this.serverURL = serverURL; - this.data = data; + this.request = request; this.response = response; } } diff --git a/src/types/tezos/TezosErrorTypes.ts b/src/types/tezos/TezosErrorTypes.ts index 5dc79ef1..a60896e2 100644 --- a/src/types/tezos/TezosErrorTypes.ts +++ b/src/types/tezos/TezosErrorTypes.ts @@ -21,14 +21,12 @@ export class TezosRequestError extends ServiceRequestError { * A specialization of ServiceResponseError for Tezos services. */ export class TezosResponseError extends ServiceResponseError { - requestBody: string | null; kind: TezosResponseErrorKind; constructor(httpStatus: number, httpMessage: string, serverURL: string, requestBody: string | null, response: any, kind: TezosResponseErrorKind){ - super(httpStatus, httpMessage, serverURL, null, response); + super(httpStatus, httpMessage, serverURL, requestBody, response); this.kind = kind; - this.requestBody = requestBody; } } From 2052b35e2a13241978f58a840cfca81806db6a54 Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Fri, 31 Jul 2020 17:15:47 -0400 Subject: [PATCH 5/9] - updated web dist, hash: 114/lUbyDt1Bd381PVOEHawYWxotfafYbfLLQFCztjN1u+JMigfduIngtJBjD+ZB --- dist-web/conseiljs.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist-web/conseiljs.min.js b/dist-web/conseiljs.min.js index 503d335b..87d3087d 100644 --- a/dist-web/conseiljs.min.js +++ b/dist-web/conseiljs.min.js @@ -1,2 +1,2 @@ /*! For license information please see conseiljs.min.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.conseiljs=t():e.conseiljs=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=44)}([function(e,t,r){"use strict";(function(e){var n=r(46),o=r(47),s=r(31);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(i()=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return C(this,t,r);case"base64":return _(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,o){var s,i=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;i=2,a/=2,u/=2,r/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o){var l=-1;for(s=r;sa&&(r=a-u),s=r;s>=0;s--){for(var p=!0,f=0;fo&&(n=o):n=o;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var i=0;i>8,o=r%256,s.push(o),s.push(n);return s}(t,e.length-r),e,r,n)}function _(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function R(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+p<=r)switch(p){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[o+1]))&&(u=(31&c)<<6|63&s)>127&&(l=u);break;case 3:s=e[o+1],i=e[o+2],128==(192&s)&&128==(192&i)&&(u=(15&c)<<12|(63&s)<<6|63&i)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=e[o+1],i=e[o+2],a=e[o+3],128==(192&s)&&128==(192&i)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&i)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,p=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=p}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(n>>>=0),i=(r>>>=0)-(t>>>=0),a=Math.min(s,i),c=this.slice(n,o),l=e.slice(t,r),p=0;po)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return D(this,e,t,r);case"utf8":case"utf-8":return P(this,e,t,r);case"ascii":return $(this,e,t,r);case"latin1":case"binary":return v(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function S(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;on)&&(r=n);for(var o="",s=t;sr)throw new RangeError("Trying to access beyond buffer length")}function w(e,t,r,n,o,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,s=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function N(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,s=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function x(e,t,r,n,o,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,s){return s||x(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function F(e,t,r,n,s){return s||x(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||T(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],o=1,s=0;++s=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,o=1,s=this[e+--n];n>0&&(o*=256);)s+=this[e+--n]*o;return s>=(o*=128)&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||T(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||T(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||w(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+o]=e/s&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);w(this,e,t,r,o-1,-o)}var s=0,i=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);w(this,e,t,r,o-1,-o)}var s=r-1,i=1,a=0;for(this[t+s]=255&e;--s>=0&&(i*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/i>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return F(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return F(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function W(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(10))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){var n=r(0),o=n.Buffer;function s(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return o(e,t,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(s(n,t),t.Buffer=i),s(o,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=o(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=r(79),a=o(r(14)),u=o(r(12)).default.log,c=a.default.fetch;!function(e){function t(e,t){const r=`${e}/${t}`;return c(r,{method:"get"}).then(n=>{if(!n.ok)throw u.error(`TezosNodeReader.performGetRequest error: ${n.status} for ${t} on ${e}`),new i.TezosRequestError(n.status,n.statusText,r,null);return n}).then(r=>{const n=r.json();return u.debug(`TezosNodeReader.performGetRequest response: ${n} for ${t} on ${e}`),n})}function r(e,r="head",n="main"){return t(e,`chains/${n}/blocks/${r}`).then(e=>e)}function o(e,r,n,o="main"){return t(e,`chains/${o}/blocks/${r}/context/contracts/${n}`).then(e=>e)}function a(e,r,o,s="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${s}/blocks/${r}/context/contracts/${o}/manager_key`);return n?n.toString():""}))}e.getBlock=r,e.getBlockHead=function(e){return r(e)},e.getBlockAtOffset=function(e,o,s="main"){return n(this,void 0,void 0,(function*(){if(o<=0)return r(e);const n=yield r(e);return t(e,`chains/${s}/blocks/${Number(n.header.level)-o}`).then(e=>e)}))},e.getAccountForBlock=o,e.getCounterForAccount=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${o}/blocks/head/context/contracts/${r}/counter`).then(e=>e.toString());return parseInt(n.toString(),10)}))},e.getSpendableBalanceForAccount=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${o}/blocks/head/context/contracts/${r}`).then(e=>e);return parseInt(n.balance.toString(),10)}))},e.getAccountManagerForBlock=a,e.isImplicitAndEmpty=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield o(e,"head",t),n=t.toLowerCase().startsWith("tz"),s=0===Number(r.balance);return n&&s}))},e.isManagerKeyRevealedForAccount=function(e,t){return n(this,void 0,void 0,(function*(){return(yield a(e,"head",t)).length>0}))},e.getContractStorage=function(e,r,n="head",o="main"){return t(e,`chains/${o}/blocks/${n}/context/contracts/${r}/storage`)},e.getValueForBigMapKey=function(e,r,n,o="head",s="main"){return t(e,`chains/${s}/blocks/${o}/context/big_maps/${r}/${n}`).catch(e=>{})},e.getMempoolOperation=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${o}/mempool/pending_operations`).catch(()=>{});return s.JSONPath({path:`$.applied[?(@.hash=='${r}')]`,json:n})[0]}))},e.estimateBranchTimeout=function(e,t,o="main"){return n(this,void 0,void 0,(function*(){const n=r(e,t,o),s=r(e,"head",o);return 64-(yield Promise.all([n,s]).then(e=>Number(e[1].header.level)-Number(e[0].header.level)))}))},e.getMempoolOperationsForAccount=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){return(yield t(e,`chains/${o}/mempool/pending_operations`).catch(()=>{})).applied.filter(e=>e.contents.some(e=>e.source===r||e.destination===r)).map(e=>(e.contents=e.contents.filter(e=>e.source===r||e.destination===r),e))}))}}(t.TezosNodeReader||(t.TezosNodeReader={}))},function(e,t,r){"use strict";(function(e){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=n(r(51)),i=n(r(32)),a=o(r(16)),u=r(9),c=r(5),l=r(43);!function(t){function r(t){if(t<0)throw new Error("Use writeSignedInt to encode negative numbers");return e.from(e.from(function(e){if(e<128)return("0"+e.toString(16)).slice(-2);let t="";if(e>2147483648){let r=i.default(e);for(;r.greater(0);)t=("0"+r.and(127).toString(16)).slice(-2)+t,r=r.shiftRight(7)}else{let r=e;for(;r>0;)t=("0"+(127&r).toString(16)).slice(-2)+t,r>>=7}return t}(t),"hex").map((e,t)=>0===t?e:128^e).reverse()).toString("hex")}function n(e){if(0===e)return"00";const t=i.default(e).abs(),r=t.bitLength().toJSNumber();let n=[],o=t;for(let t=0;t("0"+e.toString(16)).slice(-2)).join("")}function o(t){return function(e){if(2===e.length)return parseInt(e,16);if(e.length<=8){let t=parseInt(e.slice(-2),16);for(let r=1;r0===t?e:127&e)).toString("hex"))}function p(t){const r=!(64&e.from(t.slice(0,2),"hex")[0]),n=e.from(t,"hex").map((e,t)=>0===t?63&e:127&e);let o=i.default.zero;for(let e=n.length-1;e>=0;e--)o=0===e?o.or(n[e]):o.or(i.default(n[e]).shiftLeft(7*e-1));return r?o.toJSNumber():o.negate().toJSNumber()}function f(e){return D(e.length)+e.split("").map(e=>e.charCodeAt(0).toString(16)).join("")}function h(e){if(0===parseInt(e.substring(0,8),16))return"";const t=e.slice(8);let r="";for(let e=0;e0},t.writeInt=r,t.writeSignedInt=n,t.readInt=o,t.readSignedInt=p,t.findInt=function(e,t,r=!1){let n="",s=0;for(;t+2*se.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1?e.slice(0,s+1)+" return "+e.slice(s+1):" return "+e;return a(Function,l(r).concat([i])).apply(void 0,l(o))}};function g(e,t){return(e=e.slice()).push(t),e}function m(e,t){return(t=t.slice()).unshift(e),t}var b=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e);var t,r=(t=n,function(){var e,r=o(t);if(i()){var n=o(this).constructor;e=Reflect.construct(r,arguments,n)}else e=r.apply(this,arguments);return c(this,e)});function n(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=r.call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)')).avoidNew=!0,t.value=e,t.name="NewError",t}return n}(u(Error));function y(e,t,r,o,s){if(!(this instanceof y))try{return new y(e,t,r,o,s)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(s=o,o=r,r=t,t=e,e=null);var i=e&&"object"===n(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!h.call(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.preventEval=e.preventEval||!1,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||o||null,this.otherTypeCallback=e.otherTypeCallback||s||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:i?e.path:t};i?"json"in e&&(a.json=e.json):a.json=r;var u=this.evaluate(a);if(!u||"object"!==n(u))throw new b(u);return u}}y.prototype.evaluate=function(e,t,r,o){var s=this,i=this.parent,a=this.parentProperty,u=this.flatten,c=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=o||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===n(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!h.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,u=h.call(e,"flatten")?e.flatten:u,this.currResultType=h.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=h.call(e,"sandbox")?e.sandbox:this.currSandbox,c=h.call(e,"wrap")?e.wrap:c,this.currPreventEval=h.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=h.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=h.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=h.call(e,"parent")?e.parent:i,a=h.call(e,"parentProperty")?e.parentProperty:a,e=e.path}if(i=i||null,a=a||null,Array.isArray(e)&&(e=y.toPathString(e)),(e||""===e)&&t){this._obj=t;var l=y.toPathArray(e);"$"===l[0]&&l.length>1&&l.shift(),this._hasParentSelector=null;var p=this._trace(l,t,["$"],i,a,r).filter((function(e){return e&&!e.isParentSelector}));return p.length?c||1!==p.length||p[0].hasArrExpr?p.reduce((function(e,t){var r=s._getPreferredOutput(t);return u&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(p[0]):c?[]:void 0}},y.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){default:throw new TypeError("Unknown result type");case"all":var r=Array.isArray(e.path)?e.path:y.toPathArray(e.path);return e.pointer=y.toPointer(r),e.path="string"==typeof e.path?e.path:y.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return y.toPathString(e[t]);case"pointer":return y.toPointer(e.path)}},y.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:y.toPathString(e.path),t(n,r,e)}},y.prototype._trace=function(e,t,r,o,s,i,a,u){var c,l=this;if(!e.length)return c={path:r,value:t,parent:o,parentProperty:s,hasArrExpr:a},this._handleCallback(c,i,"value"),c;var f=e[0],d=e.slice(1),b=[];function y(e){Array.isArray(e)?e.forEach((function(e){b.push(e)})):b.push(e)}if(("string"!=typeof f||u)&&t&&h.call(t,f))y(this._trace(d,t[f],g(r,f),t,f,i,a));else if("*"===f)this._walk(f,d,t,r,o,s,i,(function(e,t,r,n,o,s,i,a){y(l._trace(m(e,r),n,o,s,i,a,!0,!0))}));else if(".."===f)y(this._trace(d,t,r,o,s,i,a)),this._walk(f,d,t,r,o,s,i,(function(e,t,r,o,s,i,a,u){"object"===n(o[e])&&y(l._trace(m(t,r),o[e],g(s,e),o,e,u,!0))}));else{if("^"===f)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:d,isParentSelector:!0};if("~"===f)return c={path:g(r,f),value:s,parent:o,parentProperty:null},this._handleCallback(c,i,"property"),c;if("$"===f)y(this._trace(d,t,r,null,null,i,a));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(f))y(this._slice(f,d,t,r,o,s,i));else if(0===f.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(f,d,t,r,o,s,i,(function(e,t,r,n,o,s,i,a){l._eval(t.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),n[e],e,o,s,i)&&y(l._trace(m(e,r),n,o,s,i,a,!0))}))}else if("("===f[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");y(this._trace(m(this._eval(f,t,r[r.length-1],r.slice(0,-1),o,s),d),t,r,o,s,i,a))}else if("@"===f[0]){var D=!1,P=f.slice(1,-2);switch(P){default:throw new TypeError("Unknown value type "+P);case"scalar":t&&["object","function"].includes(n(t))||(D=!0);break;case"boolean":case"string":case"undefined":case"function":n(t)===P&&(D=!0);break;case"integer":!Number.isFinite(t)||t%1||(D=!0);break;case"number":Number.isFinite(t)&&(D=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(D=!0);break;case"object":t&&n(t)===P&&(D=!0);break;case"array":Array.isArray(t)&&(D=!0);break;case"other":D=this.currOtherTypeCallback(t,r,o,s);break;case"null":null===t&&(D=!0)}if(D)return c={path:r,value:t,parent:o,parentProperty:s},this._handleCallback(c,i,"value"),c}else if("`"===f[0]&&t&&h.call(t,f.slice(1))){var $=f.slice(1);y(this._trace(d,t[$],g(r,$),t,$,i,a,!0))}else if(f.includes(",")){var v,A=function(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=p(e))){var t=0,r=function(){};return{s:r,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o,s=!0,i=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(f.split(","));try{for(A.s();!(v=A.n()).done;){var I=v.value;y(this._trace(m(I,d),t,r,o,s,i,!0))}}catch(e){A.e(e)}finally{A.f()}}else!u&&t&&h.call(t,f)&&y(this._trace(d,t[f],g(r,f),t,f,i,a,!0))}if(this._hasParentSelector)for(var _=0;_\n${n}`),d(n,{method:"post",body:o,headers:{"content-type":"application/json"}})}function o(e,t){g.debug("TezosNodeWriter.forgeOperations:"),g.debug(JSON.stringify(t));let r=p.TezosMessageUtils.writeBranch(e);return t.forEach(e=>r+=l.TezosMessageCodec.encodeOperation(e)),r}function s(e,t,o,s,i,a="main"){return n(this,void 0,void 0,(function*(){const n=[{protocol:o,branch:t,contents:s,signature:i.signature}],u=yield r(e,`chains/${a}/blocks/head/helpers/preapply/operations`,n),c=yield u.text();let l;try{g.debug("TezosNodeWriter.preapplyOperation received "+c),l=JSON.parse(c)}catch(e){throw g.error("TezosNodeWriter.preapplyOperation failed to parse response"),new Error(`Could not parse JSON from response of chains/${a}/blocks/head/helpers/preapply/operation: '${c}' for ${n}`)}return _(c),l}))}function b(e,t,o="main"){return n(this,void 0,void 0,(function*(){const n=yield r(e,"injection/operation?chain="+o,t.bytes.toString("hex")),s=yield n.text();return _(s),s}))}function y(t,r,i,a=54){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeReader.getBlockAtOffset(t,a),l=o(n.hash,r),f=yield i.signOperation(e.from(u.TezosConstants.OperationGroupWatermark+l,"hex")),h={bytes:e.concat([e.from(l,"hex"),f]),signature:p.TezosMessageUtils.readSignatureWithHint(f,i.getSignerCurve())},d=yield s(t,n.hash,n.protocol,r,h),g=yield b(t,h);return{results:d[0],operationGroupID:g}}))}function D(e,t,r,o,s){return n(this,void 0,void 0,(function*(){if(!(yield c.TezosNodeReader.isManagerKeyRevealedForAccount(e,r))){const e={kind:"reveal",source:r,fee:"0",counter:(o+1).toString(),gas_limit:"10600",storage_limit:"0",public_key:t};return s.forEach((e,t)=>{const r=o+2+t;e.counter=r.toString()}),[e,...s]}return s}))}function P(e,t,r,o,s=u.TezosConstants.DefaultDelegationFee,i=54){return n(this,void 0,void 0,(function*(){const n=(yield c.TezosNodeReader.getCounterForAccount(e,r.publicKeyHash))+1,a={kind:"delegation",source:r.publicKeyHash,fee:s.toString(),counter:n.toString(),storage_limit:u.TezosConstants.DefaultDelegationStorageLimit+"",gas_limit:u.TezosConstants.DefaultDelegationGasLimit+"",delegate:o},l=yield D(e,r.publicKey,r.publicKeyHash,n-1,[a]);return y(e,l,t,i)}))}function $(e,t,r,n,o,s,i,u,c,l){let p=void 0,h=void 0;return c===a.TezosParameterFormat.Michelson?(p=JSON.parse(f.TezosLanguageUtil.translateMichelsonToMicheline(i)),g.debug(`TezosNodeWriter.sendOriginationOperation code translation:\n${i}\n->\n${JSON.stringify(p)}`),h=JSON.parse(f.TezosLanguageUtil.translateMichelsonToMicheline(u)),g.debug(`TezosNodeWriter.sendOriginationOperation storage translation:\n${u}\n->\n${JSON.stringify(h)}`)):c===a.TezosParameterFormat.Micheline&&(p=JSON.parse(i),h=JSON.parse(u)),{kind:"origination",source:e.publicKeyHash,fee:n.toString(),counter:l.toString(),gas_limit:s.toString(),storage_limit:o.toString(),balance:t.toString(),delegate:r,script:{code:p,storage:h}}}function v(e,t,r,o,s,i,u,l,p,f,h=a.TezosParameterFormat.Micheline,d=54){return n(this,void 0,void 0,(function*(){const n=(yield c.TezosNodeReader.getCounterForAccount(e,r.publicKeyHash))+1,a=A(r.publicKeyHash,n,o,s,i,u,l,p,f,h),g=yield D(e,r.publicKey,r.publicKeyHash,n-1,[a]);return y(e,g,t,d)}))}function A(e,t,r,n,o,s,i,u,c,l=a.TezosParameterFormat.Micheline){let p={destination:r,amount:n.toString(),storage_limit:s.toString(),gas_limit:i.toString(),counter:t.toString(),fee:o.toString(),source:e,kind:"transaction"};if(void 0!==c){if(l===a.TezosParameterFormat.Michelson){const e=f.TezosLanguageUtil.translateParameterMichelsonToMicheline(c);p.parameters={entrypoint:u||"default",value:JSON.parse(e)}}else if(l===a.TezosParameterFormat.Micheline)p.parameters={entrypoint:u||"default",value:JSON.parse(c)};else if(l===a.TezosParameterFormat.MichelsonLambda){const e=f.TezosLanguageUtil.translateMichelsonToMicheline("code "+c);p.parameters={entrypoint:u||"default",value:JSON.parse(e)}}}else void 0!==u&&(p.parameters={entrypoint:u,value:[]});return p}function I(e,t,o){return n(this,void 0,void 0,(function*(){const n=yield r(e,`chains/${t}/blocks/head/helpers/scripts/run_operation`,{chain_id:"NetXdQprcVkpaWU",operation:{branch:"BL94i2ShahPx3BoNs6tJdXDdGeoJ9ukwujUA2P8WJwULYNdimmq",contents:[o],signature:"edsigu6xFLH2NpJ1VcYshpjW99Yc1TAL1m2XBqJyXrxcZQgBMo8sszw2zm626yjpA3pWMhjpsahLrWdmvX9cqhd4ZEUchuBuFYy"}}),s=yield n.text();_(s);const i=JSON.parse(s);let a=0,u=0;for(let e of i.contents){try{a+=parseInt(e.metadata.operation_result.consumed_gas)||0,u+=parseInt(e.metadata.operation_result.paid_storage_size_diff)||0}catch(e){}const t=e.metadata.internal_operation_results;if(void 0!==t)for(const e of t){const t=e.result;a+=parseInt(t.consumed_gas)||0,u+=parseInt(t.paid_storage_size_diff)||0}}return{gas:a,storageCost:u}}))}function _(e){let t="";try{const r=JSON.parse(e),n=Array.isArray(r)?r:[r];"kind"in n[0]?t=n.map(e=>`(${e.kind}: ${e.id})`).join(""):1===n.length&&1===n[0].contents.length&&"activate_account"===n[0].contents[0].kind||(t=n.map(e=>e.contents).map(e=>e.map(e=>e.metadata.operation_result).filter(e=>"applied"!==e.status).map(e=>`${e.status}: ${e.errors.map(e=>`(${e.kind}: ${e.id})`).join(", ")}\n`)).join(""))}catch(r){if(e.startsWith("Failed to parse the request body: "))t=e.slice(34);else{const t=e.replace(/\"/g,"").replace(/\n/,"");51===t.length&&"o"===t.charAt(0)||g.error(`failed to parse errors: '${r}' from '${e}'\n, PLEASE report this to the maintainers`)}}if(t.length>0)throw g.debug("errors found in response:\n"+e),new Error(t)}t.forgeOperations=o,t.forgeOperationsRemotely=function(e,t,o,s="main"){return n(this,void 0,void 0,(function*(){g.debug("TezosNodeWriter.forgeOperations:"),g.debug(JSON.stringify(o)),g.warn("forgeOperationsRemotely() is not intrinsically trustless");const n=yield r(e,`chains/${s}/blocks/head/helpers/forge/operations`,{branch:t,contents:o}),i=(yield n.text()).replace(/\n/g,"").replace(/['"]+/g,"");let a=Array.from(o.map(e=>e.kind)),u=!1;for(let e of a)if(u=["reveal","transaction","delegation","origination"].includes(e),u)break;if(u){const e=l.TezosMessageCodec.parseOperationGroup(i);for(let t=0;t{t.feed(e)}),t.results[0]}function n(e,t){let r=e;e.script&&(r=e.script);for(let e=0;e`"${e}"`).join(", "),consumed:t.consumed}}function d(e){let t=new Map;t.parameter=e.search(/(^|\s+)parameter/m),t.storage=e.search(/(^|\s+)storage/m),t.code=e.search(/(^|\s+)code/m);const r=Object.values(t).sort((e,t)=>Number(e)-Number(t));t[Object.keys(t).find(e=>t[e]===r[0])+""]=e.substring(r[0],r[1]),t[Object.keys(t).find(e=>t[e]===r[1])+""]=e.substring(r[1],r[2]),t[Object.keys(t).find(e=>t[e]===r[2])+""]=e.substring(r[2]);return[t.parameter,t.storage,t.code].map(e=>e.trim().split("\n").map(e=>e.replace(/\#[\s\S]+$/,"").trim()).filter(e=>e.length>0).join(" "))}function g(e){return e.replace(/\n/g," ").replace(/ +/g," ").replace(/\[{/g,"[ {").replace(/}\]/g,"} ]").replace(/},{/g,"}, {").replace(/\]}/g,"] }").replace(/":"/g,'": "').replace(/":\[/g,'": [').replace(/{"/g,'{ "').replace(/"}/g,'" }').replace(/,"/g,', "').replace(/","/g,'", "').replace(/\[\[/g,"[ [").replace(/\]\]/g,"] ]").replace(/\["/g,'[ "').replace(/"\]/g,'" ]').replace(/\[ +\]/g,"[]").trim()}t.hexToMicheline=function e(t){if(t.length<2)throw new Error(`Malformed Micheline fragment '${t}'`);let r="",n=0,o=t.substring(n,n+2);switch(n+=2,o){case"00":{const e=a.TezosMessageUtils.findInt(t.substring(n),0,!0);r+=`{ "int": "${e.value}" }`,n+=e.length;break}case"01":{const e=l(t.substring(n));r+=`{ "string": "${e.code}" }`,n+=e.consumed;break}case"02":{const o=parseInt(t.substring(n,n+8),16);n+=8;let s=[],i=0;for(;i2&&(r+=`, "annots": [ ${e.code} ] }`),n+=e.consumed}else r+=" }",n+=8;break}case"0a":{const e=parseInt(t.substring(n,n+8),16);n+=8,r+=`{ "bytes": "${t.substring(n,n+2*e)}" }`,n+=2*e;break}default:throw new Error(`Unknown Micheline field type '${o}'`)}return{code:r,consumed:n}},t.hexToMichelson=function e(t){if(t.length<2)throw new Error(`Malformed Michelson fragment '${t}'`);let r="",n=0,o=t.substring(n,n+2);switch(n+=2,o){case"00":{const e=a.TezosMessageUtils.findInt(t.substring(n),0,!0);r+=` ${e.value} `,n+=e.length;break}case"01":{const e=l(t.substring(n));r+=` "${e.code}" `,n+=e.consumed;break}case"02":{const o=parseInt(t.substring(n,n+8),16);n+=8;let s=[],i=0;for(;i2&&(r+=` ${e.code} )`),n+=e.consumed}else r+=" )",n+=8;break}case"0a":{const e=parseInt(t.substring(n,n+8),16);n+=8,r+=` 0x${t.substring(n,n+2*e)} `,n+=2*e;break}default:throw new Error(`Unknown Micheline field type '${o}'`)}return{code:r,consumed:n}},t.translateMichelsonToMicheline=r,t.translateParameterMichelsonToMicheline=function(e){return r(e)},t.translateMichelsonToHex=function(e){return function(e){const t=JSON.parse(e);let r=[];return r.push(n(t,"code")),r.push(n(t,"storage")),r}(r(e)).map(e=>g(e)).map(e=>c(e)).reduce((e,t)=>e+(("0000000"+(t.length/2).toString(16)).slice(-8)+t),"")},t.translateMichelineToHex=c,t.preProcessMichelsonScript=d,t.normalizeMichelineWhiteSpace=g,t.normalizeMichelsonWhiteSpace=function(e){return e.replace(/\s{2,}/g," ").replace(/\( /g,"(").replace(/ \)/g,")")},t.stripComments=function(e){return e.trim().split("\n").map(e=>e.replace(/\#[\s\S]+$/,"").trim()).filter(e=>e.length>0).join(" ")}}(t.TezosLanguageUtil||(t.TezosLanguageUtil={}))}).call(this,r(0).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n=r(18),o=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=p;var s=r(15);s.inherits=r(1);var i=r(36),a=r(24);s.inherits(p,i);for(var u=o(a.prototype),c=0;c=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,o=(r-n)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s},o.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{static setFetch(e){this.actualFetch=e}}t.default=n,n.fetch=(e,t)=>n.actualFetch(e,t)},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,r(0).Buffer)},function(e,t,r){var n=r(75),o=r(76);e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},function(e,t){var r,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var u,c=[],l=!1,p=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&h())}function h(){if(!l){var e=a(f);l=!0;for(var t=c.length;t;){for(u=c,c=[];++p1)for(var r=1;r0)throw new Error("RegExp has capture groups: "+m+"\nUse (?: … ) instead");if(!h.lineBreaks&&m.test("\n"))throw new Error("Rule should declare lineBreaks: "+m);p.push(s(g))}}var b=n&&n.fallback,y=r&&!b?"ym":"gm",D=r||b?"":"|";return{regexp:new RegExp(i(p)+D,y),groups:c,fast:o,error:n||l}}function f(e,t,r){var n=e&&(e.push||e.next);if(n&&!r[n])throw new Error("Missing state '"+n+"' (in token '"+e.defaultType+"' of state '"+t+"')");if(e&&e.pop&&1!=+e.pop)throw new Error("pop must be 1 (in token '"+e.defaultType+"' of state '"+t+"')")}var h=function(e,t){this.startState=t,this.states=e,this.buffer="",this.stack=[],this.reset()};h.prototype.reset=function(e,t){return this.buffer=e||"",this.index=0,this.line=t?t.line:1,this.col=t?t.col:1,this.queuedToken=t?t.queuedToken:null,this.queuedThrow=t?t.queuedThrow:null,this.setState(t?t.state:this.startState),this.stack=t&&t.stack?t.stack.slice():[],this},h.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},h.prototype.setState=function(e){if(e&&this.state!==e){this.state=e;var t=this.states[e];this.groups=t.groups,this.error=t.error,this.re=t.regexp,this.fast=t.fast}},h.prototype.popState=function(){this.setState(this.stack.pop())},h.prototype.pushState=function(e){this.stack.push(this.state),this.setState(e)};var d=r?function(e,t){return e.exec(t)}:function(e,t){var r=e.exec(t);return 0===r[0].length?null:r};function g(){return this.value}if(h.prototype._getGroup=function(e){for(var t=this.groups.length,r=0;r0&&i.length>o&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,a=u,console&&console.warn&&console.warn(a)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=f.bind(n);return o.listener=r,n.wrapFn=o,o}function d(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)s(u,this,t);else{var c=u.length,l=m(u,c);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return d(this,e,!0)},a.prototype.rawListeners=function(e){return d(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){(t=e.exports=r(36)).Stream=t,t.Readable=t,t.Writable=r(24),t.Duplex=r(11),t.Transform=r(39),t.PassThrough=r(60)},function(e,t,r){"use strict";(function(t,n,o){var s=r(18);function i(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var o=n.callback;t.pendingcb--,o(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=y;var a,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:s.nextTick;y.WritableState=b;var c=r(15);c.inherits=r(1);var l={deprecate:r(59)},p=r(37),f=r(2).Buffer,h=o.Uint8Array||function(){};var d,g=r(38);function m(){}function b(e,t){a=a||r(11),e=e||{};var n=t instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var o=e.highWaterMark,c=e.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:n&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var p=!1===e.decodeStrings;this.decodeStrings=!p,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(s.nextTick(o,n),s.nextTick(I,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),I(e,t))}(e,r,n,t,o);else{var i=v(r);i||r.corked||r.bufferProcessing||!r.bufferedRequest||$(e,r),n?u(P,e,r,i,o):P(e,r,i,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function y(e){if(a=a||r(11),!(d.call(y,this)||this instanceof a))return new y(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),p.call(this)}function D(e,t,r,n,o,s,i){t.writelen=n,t.writecb=i,t.writing=!0,t.sync=!0,r?e._writev(o,t.onwrite):e._write(o,s,t.onwrite),t.sync=!1}function P(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),I(e,t)}function $(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,o=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)o[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;o.allBuffers=u,D(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new i(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,p=r.callback;if(D(e,t,!1,t.objectMode?1:c.length,c,l,p),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function v(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),I(e,t)}))}function I(e,t){var r=v(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,s.nextTick(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}c.inherits(y,p),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:l.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===y&&(e&&e._writableState instanceof b)}})):d=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,r){var n,o=this._writableState,i=!1,a=!o.objectMode&&(n=e,f.isBuffer(n)||n instanceof h);return a&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=m),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),s.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var o=!0,i=!1;return null===r?i=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),s.nextTick(n,i),o=!1),o}(this,o,e,r))&&(o.pendingcb++,i=function(e,t,r,n,o,s){if(!r){var i=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,r));return t}(t,n,o);n!==i&&(r=!0,o="buffer",n=i)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,I(e,t),r&&(t.finished?s.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=g.destroy,y.prototype._undestroy=g.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(17),r(57).setImmediate,r(10))},function(e,t,r){"use strict";var n=r(2).Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=p,t=3;break;default:return this.write=f,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function i(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function p(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return o>0&&(e.lastNeed=o-1),o;if(--n=0)return o>0&&(e.lastNeed=o-2),o;if(--n=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=r(27),s=r(20),i=r(28);!function(e){function t(e,t,r,o){return n(this,void 0,void 0,(function*(){return i.ConseilDataClient.executeEntityQuery(e,"tezos",t,r,o)}))}function r(e,r){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addOrdering(o.ConseilQueryBuilder.blankQuery(),"level",s.ConseilSortDirection.DESC),1);return(yield t(e,r,"blocks",n))[0]}))}function a(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"blocks",o)}))}function u(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"operations",o)}))}function c(e,t,i,a,c=60){return n(this,void 0,void 0,(function*(){if(a<=0)throw new Error("Invalid duration");const n=(yield r(e,t)).level;let l=n,p=o.ConseilQueryBuilder.blankQuery();for(p=o.ConseilQueryBuilder.addPredicate(p,"operation_group_hash",s.ConseilOperator.EQ,[i],!1),p=o.ConseilQueryBuilder.addPredicate(p,"timestamp",s.ConseilOperator.AFTER,[(new Date).getTime()-6e4],!1),p=o.ConseilQueryBuilder.setLimit(p,1);n+a>l;){const o=yield u(e,t,p);if(o.length>0)return o[0];if(l=(yield r(e,t)).level,n+asetTimeout(e,1e3*c))}throw new Error(`Did not observe ${i} on ${t} in ${a} block${a>1?"s":""} since ${n}`)}))}e.getTezosEntityData=t,e.getBlockHead=r,e.getBlock=function(e,i,a){return n(this,void 0,void 0,(function*(){if("head"===a)return r(e,i);const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"hash",s.ConseilOperator.EQ,[a],!1),1);return(yield t(e,i,"blocks",n))[0]}))},e.getBlockByLevel=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"level",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"blocks",n))[0]}))},e.getAccount=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"account_id",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"accounts",n))[0]}))},e.getOperationGroup=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"hash",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"operation_groups",n))[0]}))},e.getOperation=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"operation_group_hash",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"operations",n))[0]}))},e.getBlocks=a,e.getAccounts=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"accounts",o)}))},e.getOperationGroups=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"operation_groups",o)}))},e.getOperations=u,e.getFeeStatistics=function(e,r,i){return n(this,void 0,void 0,(function*(){let n=o.ConseilQueryBuilder.blankQuery();return n=o.ConseilQueryBuilder.addPredicate(n,"kind",s.ConseilOperator.EQ,[i]),n=o.ConseilQueryBuilder.addOrdering(n,"timestamp",s.ConseilSortDirection.DESC),n=o.ConseilQueryBuilder.setLimit(n,1),t(e,r,"fees",n)}))},e.getProposals=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"proposals",o)}))},e.getBakers=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"bakers",o)}))},e.getBallots=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"ballots",o)}))},e.awaitOperationConfirmation=c,e.awaitOperationForkConfirmation=function(e,t,i,u,l){return n(this,void 0,void 0,(function*(){const n=yield c(e,t,i,u),p=n.block_level,f=n.block_hash;let h=p;for(yield new Promise(e=>setTimeout(e,50*l*1e3));h=p+l)break;yield new Promise(e=>setTimeout(e,6e4))}let d=o.ConseilQueryBuilder.blankQuery();d=o.ConseilQueryBuilder.addFields(d,"level","hash","predecessor"),d=o.ConseilQueryBuilder.addPredicate(d,"level",s.ConseilOperator.BETWEEN,[p-1,p+l]),d=o.ConseilQueryBuilder.setLimit(d,2*l);const g=yield a(e,t,d);return g.length===l+2?function(e,t,r){try{return e.sort((e,t)=>parseInt(e.level)-parseInt(t.level)).reduce((n,o,s)=>{if(!n)throw new Error("Block sequence mismatch");return s>1?o.predecessor===e[s-1].hash:1===s?n&&o.level===t&&o.hash===r&&o.predecessor===e[s-1].hash:0===s||void 0},!0)}catch(e){return!1}}(g,p,f):function(e,t,r,n){throw new Error("Not implemented")}()}))},e.getBigMapData=function(e,r){return n(this,void 0,void 0,(function*(){if(!r.startsWith("KT1"))throw new Error("Invalid address");const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addFields(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"account_id",s.ConseilOperator.EQ,[r],!1),"big_map_id"),100),i=yield t(e,e.network,"originated_account_maps",n);if(i.length<1)return;const a=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"big_map_id",i.length>1?s.ConseilOperator.IN:s.ConseilOperator.EQ,i.map(e=>e.big_map_id),!1),100),u=yield t(e,e.network,"big_maps",a),c=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addFields(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"big_map_id",i.length>1?s.ConseilOperator.IN:s.ConseilOperator.EQ,i.map(e=>e.big_map_id),!1),"big_map_id","key","value"),1e3),l=yield t(e,e.network,"big_map_contents",c);let p=[];for(const e of u){const t={index:Number(e.big_map_id),key:e.key_type,value:e.value_type};let r=[];for(const e of l.filter(e=>e.big_map_id===t.index))r.push({key:JSON.stringify(e.key),value:JSON.stringify(e.value)});p.push({definition:t,content:r})}return{contract:r,maps:p}}))},e.getBigMapValueForKey=function(e,r,i="",a=-1){return n(this,void 0,void 0,(function*(){if(!i.startsWith("KT1"))throw new Error("Invalid address");if(r.length<1)throw new Error("Invalid key");if(a<0&&0===i.length)throw new Error("One of contract or mapIndex must be specified");if(a<0&&i.length>0){let r=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.blankQuery(),1);r=o.ConseilQueryBuilder.addFields(r,"big_map_id"),r=o.ConseilQueryBuilder.addPredicate(r,"account_id",s.ConseilOperator.EQ,[i],!1),r=o.ConseilQueryBuilder.addOrdering(r,"big_map_id",s.ConseilSortDirection.DESC);const n=yield t(e,e.network,"originated_account_maps",r);if(n.length<1)throw new Error("Could not find any maps for "+i);a=n[0]}let n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.blankQuery(),1);n=o.ConseilQueryBuilder.addFields(n,"value"),n=o.ConseilQueryBuilder.addPredicate(n,"key",s.ConseilOperator.EQ,[r],!1),n=o.ConseilQueryBuilder.addPredicate(n,"big_map_id",s.ConseilOperator.EQ,[a],!1);const u=yield t(e,e.network,"big_map_contents",n);if(u.length<1)throw new Error(`Could not a value for key ${r} in map ${a}`);return u[0]}))},e.getEntityQueryForId=function(e){let t=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.blankQuery(),1);if("number"==typeof e){if(Number(e)<0)throw new Error("Invalid numeric id parameter");return{entity:"blocks",query:o.ConseilQueryBuilder.addPredicate(t,"level",s.ConseilOperator.EQ,[e],!1)}}if("string"==typeof e){const r=String(e);if(r.startsWith("tz1")||r.startsWith("tz2")||r.startsWith("tz3")||r.startsWith("KT1"))return{entity:"accounts",query:o.ConseilQueryBuilder.addPredicate(t,"account_id",s.ConseilOperator.EQ,[e],!1)};if(r.startsWith("B"))return{entity:"blocks",query:o.ConseilQueryBuilder.addPredicate(t,"hash",s.ConseilOperator.EQ,[e],!1)};if(r.startsWith("o"))return t=o.ConseilQueryBuilder.setLimit(t,1e3),{entity:"operations",query:o.ConseilQueryBuilder.addPredicate(t,"operation_group_hash",s.ConseilOperator.EQ,[e],!1)}}throw new Error("Invalid id parameter")}}(t.TezosConseilClient||(t.TezosConseilClient={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(20);!function(e){e.blankQuery=function(){return{fields:[],predicates:[],orderBy:[],aggregation:[],limit:100}},e.addFields=function(e,...t){let r=Object.assign({},e),n=new Set(e.fields);return t.forEach(e=>n.add(e)),r.fields=Array.from(n.values()),r},e.addPredicate=function(e,t,r,o,s=!1,i){if(r===n.ConseilOperator.BETWEEN&&2!==o.length)throw new Error("BETWEEN operation requires a list of two values.");if(r===n.ConseilOperator.IN&&o.length<2)throw new Error("IN operation requires a list of two or more values.");if(1!==o.length&&r!==n.ConseilOperator.IN&&r!==n.ConseilOperator.BETWEEN&&r!==n.ConseilOperator.ISNULL)throw new Error(`invalid values list for ${r}.`);let a=Object.assign({},e);return a.predicates.push({field:t,operation:r,set:o,inverse:s,group:i}),a},e.addOrdering=function(e,t,r=n.ConseilSortDirection.ASC){let o=Object.assign({},e);return o.orderBy.push({field:t,direction:r}),o},e.setLimit=function(e,t){if(t<1)throw new Error("Limit cannot be less than one.");let r=Object.assign({},e);return r.limit=t,r},e.setOutputType=function(e,t){let r=Object.assign({},e);return r.output=t,r},e.addAggregationFunction=function(e,t,r){if(!e.fields.includes(t))throw new Error("Cannot apply an aggregation function on a field not being returned.");let n=Object.assign({},e);return n.aggregation.push({field:t,function:r}),n}}(t.ConseilQueryBuilder||(t.ConseilQueryBuilder={}))},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(29),i=o(r(14)),a=o(r(12)).default.log,u=i.default.fetch;!function(e){e.executeEntityQuery=function(e,t,r,o,i){return n(this,void 0,void 0,(function*(){const n=`${e.url}/v2/data/${t}/${r}/${o}`;return a.debug(`ConseilDataClient.executeEntityQuery request: ${n}, ${JSON.stringify(i)}`),u(n,{method:"post",headers:{apiKey:e.apiKey,"Content-Type":"application/json"},body:JSON.stringify(i)}).then(e=>{if(!e.ok)throw a.error(`ConseilDataClient.executeEntityQuery request: ${n}, ${JSON.stringify(i)}, failed with ${e.statusText}(${e.status})`),new s.ConseilRequestError(e.status,e.statusText,n,i);return e}).then(e=>{const t=e.headers.get("content-type").toLowerCase().includes("application/json"),r=t?e.json():e.text();return a.debug("ConseilDataClient.executeEntityQuery response: "+(t?JSON.stringify(r):r)),r})}))}}(t.ConseilDataClient||(t.ConseilDataClient={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(30);class o extends n.ServiceRequestError{constructor(e,t,r,n){super(e,t,r,null),this.conseilQuery=n}toString(){return`ConseilRequestError for ${this.serverURL} with ${this.httpStatus} and ${this.httpMessage}`}}t.ConseilRequestError=o;class s extends n.ServiceResponseError{constructor(e,t,r,n,o){super(e,t,r,null,o),this.conseilQuery=n}}t.ConseilResponseError=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e,t,r,n){super(),this.httpStatus=e,this.httpMessage=t,this.serverURL=r,this.data=n}}t.ServiceRequestError=n;class o extends Error{constructor(e,t,r,n,o){super(),this.httpStatus=e,this.httpMessage=t,this.serverURL=r,this.data=n,this.response=o}}t.ServiceResponseError=o},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){(function(e){var n,o=function(e){"use strict";var t=1e7,r=9007199254740992,n=p(r),s="function"==typeof BigInt;function i(e,t,r,n){return void 0===e?i[0]:void 0!==t&&(10!=+t||r)?L(e,t,r,n):H(e)}function a(e,t){this.value=e,this.sign=t,this.isSmall=!1}function u(e){this.value=e,this.sign=e<0,this.isSmall=!0}function c(e){this.value=e}function l(e){return-r0?Math.floor(e):Math.ceil(e)}function m(e,r){var n,o,s=e.length,i=r.length,a=new Array(s),u=0,c=t;for(o=0;o=c?1:0,a[o]=n-u*c;for(;o0&&a.push(u),a}function b(e,t){return e.length>=t.length?m(e,t):m(t,e)}function y(e,r){var n,o,s=e.length,i=new Array(s),a=t;for(o=0;o0;)i[o++]=r%a,r=Math.floor(r/a);return i}function D(e,t){var r,n,o=e.length,s=t.length,i=new Array(o),a=0;for(r=0;r0;)i[o++]=u%a,u=Math.floor(u/a);return i}function A(e,t){for(var r=[];t-- >0;)r.push(0);return r.concat(e)}function I(e,r,n){return new a(e=0;--r)o=(s=1e7*o+e[r])-(n=g(s/t))*t,a[r]=0|n;return[a,0|o]}function S(e,r){var n,o=H(r);if(s)return[new c(e.value/o.value),new c(e.value%o.value)];var l,m=e.value,b=o.value;if(0===b)throw new Error("Cannot divide by zero");if(e.isSmall)return o.isSmall?[new u(g(m/b)),new u(m%b)]:[i[0],e];if(o.isSmall){if(1===b)return[e,i[0]];if(-1==b)return[e.negate(),i[0]];var y=Math.abs(b);if(y=0;o--){for(n=h-1,y[o+p]!==m&&(n=Math.floor((y[o+p]*h+y[o+p-1])/m)),s=0,i=0,u=D.length,a=0;au&&(o=1e7*(o+1)),r=Math.ceil(o/s);do{if(C(i=v(t,r),l)<=0)break;r--}while(r);c.push(r),l=D(l,i)}return c.reverse(),[f(c),f(l)]}(m,b))[0];var A=e.sign!==o.sign,I=n[1],_=e.sign;return"number"==typeof l?(A&&(l=-l),l=new u(l)):l=new a(l,A),"number"==typeof I?(_&&(I=-I),I=new u(I)):I=new a(I,_),[l,I]}function C(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var r=e.length-1;r>=0;r--)if(e[r]!==t[r])return e[r]>t[r]?1:-1;return 0}function U(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function E(e,t){for(var r,n,s,i=e.prev(),a=i,u=0;a.isEven();)a=a.divide(2),u++;e:for(n=0;n=0?n=D(e,t):(n=D(t,e),r=!r),"number"==typeof(n=f(n))?(r&&(n=-n),new u(n)):new a(n,r)}(r,n,this.sign)},a.prototype.minus=a.prototype.subtract,u.prototype.subtract=function(e){var t=H(e),r=this.value;if(r<0!==t.sign)return this.add(t.negate());var n=t.value;return t.isSmall?new u(r-n):P(n,Math.abs(r),r>=0)},u.prototype.minus=u.prototype.subtract,c.prototype.subtract=function(e){return new c(this.value-H(e).value)},c.prototype.minus=c.prototype.subtract,a.prototype.negate=function(){return new a(this.value,!this.sign)},u.prototype.negate=function(){var e=this.sign,t=new u(-this.value);return t.sign=!e,t},c.prototype.negate=function(){return new c(-this.value)},a.prototype.abs=function(){return new a(this.value,!1)},u.prototype.abs=function(){return new u(Math.abs(this.value))},c.prototype.abs=function(){return new c(this.value>=0?this.value:-this.value)},a.prototype.multiply=function(e){var r,n,o,s=H(e),u=this.value,c=s.value,l=this.sign!==s.sign;if(s.isSmall){if(0===c)return i[0];if(1===c)return this;if(-1===c)return this.negate();if((r=Math.abs(c))0?function e(t,r){var n=Math.max(t.length,r.length);if(n<=30)return $(t,r);n=Math.ceil(n/2);var o=t.slice(n),s=t.slice(0,n),i=r.slice(n),a=r.slice(0,n),u=e(s,a),c=e(o,i),l=e(b(s,o),b(a,i)),p=b(b(u,A(D(D(l,u),c),n)),A(c,2*n));return h(p),p}(u,c):$(u,c),l)},a.prototype.times=a.prototype.multiply,u.prototype._multiplyBySmall=function(e){return l(e.value*this.value)?new u(e.value*this.value):I(Math.abs(e.value),p(Math.abs(this.value)),this.sign!==e.sign)},a.prototype._multiplyBySmall=function(e){return 0===e.value?i[0]:1===e.value?this:-1===e.value?this.negate():I(Math.abs(e.value),this.value,this.sign!==e.sign)},u.prototype.multiply=function(e){return H(e)._multiplyBySmall(this)},u.prototype.times=u.prototype.multiply,c.prototype.multiply=function(e){return new c(this.value*H(e).value)},c.prototype.times=c.prototype.multiply,a.prototype.square=function(){return new a(_(this.value),!1)},u.prototype.square=function(){var e=this.value*this.value;return l(e)?new u(e):new a(_(p(Math.abs(this.value))),!1)},c.prototype.square=function(e){return new c(this.value*this.value)},a.prototype.divmod=function(e){var t=S(this,e);return{quotient:t[0],remainder:t[1]}},c.prototype.divmod=u.prototype.divmod=a.prototype.divmod,a.prototype.divide=function(e){return S(this,e)[0]},c.prototype.over=c.prototype.divide=function(e){return new c(this.value/H(e).value)},u.prototype.over=u.prototype.divide=a.prototype.over=a.prototype.divide,a.prototype.mod=function(e){return S(this,e)[1]},c.prototype.mod=c.prototype.remainder=function(e){return new c(this.value%H(e).value)},u.prototype.remainder=u.prototype.mod=a.prototype.remainder=a.prototype.mod,a.prototype.pow=function(e){var t,r,n,o=H(e),s=this.value,a=o.value;if(0===a)return i[1];if(0===s)return i[0];if(1===s)return i[1];if(-1===s)return o.isEven()?i[1]:i[-1];if(o.sign)return i[0];if(!o.isSmall)throw new Error("The exponent "+o.toString()+" is too large.");if(this.isSmall&&l(t=Math.pow(s,a)))return new u(g(t));for(r=this,n=i[1];!0&a&&(n=n.times(r),--a),0!==a;)a/=2,r=r.square();return n},u.prototype.pow=a.prototype.pow,c.prototype.pow=function(e){var t=H(e),r=this.value,n=t.value,o=BigInt(0),s=BigInt(1),a=BigInt(2);if(n===o)return i[1];if(r===o)return i[0];if(r===s)return i[1];if(r===BigInt(-1))return t.isEven()?i[1]:i[-1];if(t.isNegative())return new c(o);for(var u=this,l=i[1];(n&s)===s&&(l=l.times(u),--n),n!==o;)n/=a,u=u.square();return l},a.prototype.modPow=function(e,t){if(e=H(e),(t=H(t)).isZero())throw new Error("Cannot take modPow with modulus 0");var r=i[1],n=this.mod(t);for(e.isNegative()&&(e=e.multiply(i[-1]),n=n.modInv(t));e.isPositive();){if(n.isZero())return i[0];e.isOdd()&&(r=r.multiply(n).mod(t)),e=e.divide(2),n=n.square().mod(t)}return r},c.prototype.modPow=u.prototype.modPow=a.prototype.modPow,a.prototype.compareAbs=function(e){var t=H(e),r=this.value,n=t.value;return t.isSmall?1:C(r,n)},u.prototype.compareAbs=function(e){var t=H(e),r=Math.abs(this.value),n=t.value;return t.isSmall?r===(n=Math.abs(n))?0:r>n?1:-1:-1},c.prototype.compareAbs=function(e){var t=this.value,r=H(e).value;return(t=t>=0?t:-t)===(r=r>=0?r:-r)?0:t>r?1:-1},a.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=H(e),r=this.value,n=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:C(r,n)*(this.sign?-1:1)},a.prototype.compareTo=a.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=H(e),r=this.value,n=t.value;return t.isSmall?r==n?0:r>n?1:-1:r<0!==t.sign?r<0?-1:1:r<0?1:-1},u.prototype.compareTo=u.prototype.compare,c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,r=H(e).value;return t===r?0:t>r?1:-1},c.prototype.compareTo=c.prototype.compare,a.prototype.equals=function(e){return 0===this.compare(e)},c.prototype.eq=c.prototype.equals=u.prototype.eq=u.prototype.equals=a.prototype.eq=a.prototype.equals,a.prototype.notEquals=function(e){return 0!==this.compare(e)},c.prototype.neq=c.prototype.notEquals=u.prototype.neq=u.prototype.notEquals=a.prototype.neq=a.prototype.notEquals,a.prototype.greater=function(e){return this.compare(e)>0},c.prototype.gt=c.prototype.greater=u.prototype.gt=u.prototype.greater=a.prototype.gt=a.prototype.greater,a.prototype.lesser=function(e){return this.compare(e)<0},c.prototype.lt=c.prototype.lesser=u.prototype.lt=u.prototype.lesser=a.prototype.lt=a.prototype.lesser,a.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},c.prototype.geq=c.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals=a.prototype.geq=a.prototype.greaterOrEquals,a.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},c.prototype.leq=c.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals=a.prototype.leq=a.prototype.lesserOrEquals,a.prototype.isEven=function(){return 0==(1&this.value[0])},u.prototype.isEven=function(){return 0==(1&this.value)},c.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},a.prototype.isOdd=function(){return 1==(1&this.value[0])},u.prototype.isOdd=function(){return 1==(1&this.value)},c.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},a.prototype.isPositive=function(){return!this.sign},u.prototype.isPositive=function(){return this.value>0},c.prototype.isPositive=u.prototype.isPositive,a.prototype.isNegative=function(){return this.sign},u.prototype.isNegative=function(){return this.value<0},c.prototype.isNegative=u.prototype.isNegative,a.prototype.isUnit=function(){return!1},u.prototype.isUnit=function(){return 1===Math.abs(this.value)},c.prototype.isUnit=function(){return this.abs().value===BigInt(1)},a.prototype.isZero=function(){return!1},u.prototype.isZero=function(){return 0===this.value},c.prototype.isZero=function(){return this.value===BigInt(0)},a.prototype.isDivisibleBy=function(e){var t=H(e);return!t.isZero()&&(!!t.isUnit()||(0===t.compareAbs(2)?this.isEven():this.mod(t).isZero()))},c.prototype.isDivisibleBy=u.prototype.isDivisibleBy=a.prototype.isDivisibleBy,a.prototype.isPrime=function(e){var t=U(this);if(void 0!==t)return t;var r=this.abs(),n=r.bitLength();if(n<=64)return E(r,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var s=Math.log(2)*n.toJSNumber(),i=Math.ceil(!0===e?2*Math.pow(s,2):s),a=[],u=0;u-r?new u(e-1):new a(n,!0)},c.prototype.prev=function(){return new c(this.value-BigInt(1))};for(var T=[1];2*T[T.length-1]<=t;)T.push(2*T[T.length-1]);var w=T.length,O=T[w-1];function N(e){return Math.abs(e)<=t}function x(e,t,r){t=H(t);for(var n=e.isNegative(),s=t.isNegative(),i=n?e.not():e,a=s?t.not():t,u=0,c=0,l=null,p=null,f=[];!i.isZero()||!a.isZero();)u=(l=S(i,O))[1].toJSNumber(),n&&(u=O-1-u),c=(p=S(a,O))[1].toJSNumber(),s&&(c=O-1-c),i=l[0],a=p[0],f.push(r(u,c));for(var h=0!==r(n?1:0,s?1:0)?o(-1):o(0),d=f.length-1;d>=0;d-=1)h=h.multiply(O).add(o(f[d]));return h}a.prototype.shiftLeft=function(e){var t=H(e).toJSNumber();if(!N(t))throw new Error(String(t)+" is too large for shifting.");if(t<0)return this.shiftRight(-t);var r=this;if(r.isZero())return r;for(;t>=w;)r=r.multiply(O),t-=w-1;return r.multiply(T[t])},c.prototype.shiftLeft=u.prototype.shiftLeft=a.prototype.shiftLeft,a.prototype.shiftRight=function(e){var t,r=H(e).toJSNumber();if(!N(r))throw new Error(String(r)+" is too large for shifting.");if(r<0)return this.shiftLeft(-r);for(var n=this;r>=w;){if(n.isZero()||n.isNegative()&&n.isUnit())return n;n=(t=S(n,O))[1].isNegative()?t[0].prev():t[0],r-=w-1}return(t=S(n,T[r]))[1].isNegative()?t[0].prev():t[0]},c.prototype.shiftRight=u.prototype.shiftRight=a.prototype.shiftRight,a.prototype.not=function(){return this.negate().prev()},c.prototype.not=u.prototype.not=a.prototype.not,a.prototype.and=function(e){return x(this,e,(function(e,t){return e&t}))},c.prototype.and=u.prototype.and=a.prototype.and,a.prototype.or=function(e){return x(this,e,(function(e,t){return e|t}))},c.prototype.or=u.prototype.or=a.prototype.or,a.prototype.xor=function(e){return x(this,e,(function(e,t){return e^t}))},c.prototype.xor=u.prototype.xor=a.prototype.xor;function M(e){var r=e.value,n="number"==typeof r?r|1<<30:"bigint"==typeof r?r|BigInt(1<<30):r[0]+r[1]*t|1073758208;return n&-n}function F(e,t){return e=H(e),t=H(t),e.greater(t)?e:t}function G(e,t){return e=H(e),t=H(t),e.lesser(t)?e:t}function k(e,t){if(e=H(e).abs(),t=H(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var r,n,o=i[1];e.isEven()&&t.isEven();)r=G(M(e),M(t)),e=e.divide(r),t=t.divide(r),o=o.multiply(r);for(;e.isEven();)e=e.divide(M(e));do{for(;t.isEven();)t=t.divide(M(t));e.greater(t)&&(n=t,t=e,e=n),t=t.subtract(e)}while(!t.isZero());return o.isUnit()?e:e.multiply(o)}a.prototype.bitLength=function(){var e=this;return e.compareTo(o(0))<0&&(e=e.negate().subtract(o(1))),0===e.compareTo(o(0))?o(0):o(function e(t,r){if(r.compareTo(t)<=0){var n=e(t,r.square(r)),s=n.p,i=n.e,a=s.multiply(r);return a.compareTo(t)<=0?{p:a,e:2*i+1}:{p:s,e:2*i}}return{p:o(1),e:0}}(e,o(2)).e).add(o(1))},c.prototype.bitLength=u.prototype.bitLength=a.prototype.bitLength;var L=function(e,t,r,n){r=r||"0123456789abcdefghijklmnopqrstuvwxyz",e=String(e),n||(e=e.toLowerCase(),r=r.toLowerCase());var o,s=e.length,i=Math.abs(t),a={};for(o=0;o=i)){if("1"===l&&1===i)continue;throw new Error(l+" is not a valid digit in base "+t+".")}}t=H(t);var u=[],c="-"===e[0];for(o=c?1:0;o"!==e[o]&&o=0;n--)o=o.add(e[n].times(s)),s=s.times(t);return r?o.negate():o}function B(e,t){if((t=o(t)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var n=!1;if(e.isNegative()&&t.isPositive()&&(n=!0,e=e.abs()),t.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:n};for(var s,i=[],a=e;a.isNegative()||a.compareAbs(t)>=0;){s=a.divmod(t),a=s.quotient;var u=s.remainder;u.isNegative()&&(u=t.minus(u).abs(),a=a.next()),i.push(u.toJSNumber())}return i.push(a.toJSNumber()),{value:i.reverse(),isNegative:n}}function z(e,t,r){var n=B(e,t);return(n.isNegative?"-":"")+n.value.map((function(e){return function(e,t){return e<(t=t||"0123456789abcdefghijklmnopqrstuvwxyz").length?t[e]:"<"+e+">"}(e,r)})).join("")}function j(e){if(l(+e)){var t=+e;if(t===g(t))return s?new c(BigInt(t)):new u(t);throw new Error("Invalid integer: "+e)}var r="-"===e[0];r&&(e=e.slice(1));var n=e.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var o=n[1];if("+"===o[0]&&(o=o.slice(1)),(o=+o)!==g(o)||!l(o))throw new Error("Invalid integer: "+o+" is not a valid exponent.");var i=n[0],p=i.indexOf(".");if(p>=0&&(o-=i.length-p-1,i=i.slice(0,p)+i.slice(p+1)),o<0)throw new Error("Cannot include negative exponent part for integers");e=i+=new Array(o+1).join("0")}if(!/^([0-9][0-9]*)$/.test(e))throw new Error("Invalid integer: "+e);if(s)return new c(BigInt(r?"-"+e:e));for(var f=[],d=e.length,m=d-7;d>0;)f.push(+e.slice(m,d)),(m-=7)<0&&(m=0),d-=7;return h(f),new a(f,r)}function H(e){return"number"==typeof e?function(e){if(s)return new c(BigInt(e));if(l(e)){if(e!==g(e))throw new Error(e+" is not an integer.");return new u(e)}return j(e.toString())}(e):"string"==typeof e?j(e):"bigint"==typeof e?new c(e):e}a.prototype.toArray=function(e){return B(this,e)},u.prototype.toArray=function(e){return B(this,e)},c.prototype.toArray=function(e){return B(this,e)},a.prototype.toString=function(e,t){if(void 0===e&&(e=10),10!==e)return z(this,e,t);for(var r,n=this.value,o=n.length,s=String(n[--o]);--o>=0;)r=String(n[o]),s+="0000000".slice(r.length)+r;return(this.sign?"-":"")+s},u.prototype.toString=function(e,t){return void 0===e&&(e=10),10!=e?z(this,e,t):String(this.value)},c.prototype.toString=u.prototype.toString,c.prototype.toJSON=a.prototype.toJSON=u.prototype.toJSON=function(){return this.toString()},a.prototype.valueOf=function(){return parseInt(this.toString(),10)},a.prototype.toJSNumber=a.prototype.valueOf,u.prototype.valueOf=function(){return this.value},u.prototype.toJSNumber=u.prototype.valueOf,c.prototype.valueOf=c.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var Q=0;Q<1e3;Q++)i[Q]=H(Q),Q>0&&(i[-Q]=H(-Q));return i.one=i[1],i.zero=i[0],i.minusOne=i[-1],i.max=F,i.min=G,i.gcd=k,i.lcm=function(e,t){return e=H(e).abs(),t=H(t).abs(),e.divide(k(e,t)).multiply(t)},i.isInstance=function(e){return e instanceof a||e instanceof u||e instanceof c},i.randBetween=function(e,r,n){e=H(e),r=H(r);var o=n||Math.random,s=G(e,r),a=F(e,r).subtract(s).add(1);if(a.isSmall)return s.add(Math.floor(o()*a));for(var u=B(a,t).value,c=[],l=!0,p=0;p0&&t.push(" ⬆ ︎"+n+" more lines identical to this"),n=0,t.push(" "+i)),r=i}},s.prototype.getSymbolDisplay=function(e){var t=typeof e;if("string"===t)return e;if("object"===t&&e.literal)return JSON.stringify(e.literal);if("object"===t&&e instanceof RegExp)return"character matching "+e;if("object"===t&&e.type)return e.type+" token";throw new Error("Unknown symbol type: "+e)},s.prototype.buildFirstStateStack=function(e,t){if(-1!==t.indexOf(e))return null;if(0===e.wantedBy.length)return[e];var r=e.wantedBy[0],n=[e].concat(t),o=this.buildFirstStateStack(r,n);return null===o?null:[e].concat(o)},s.prototype.save=function(){var e=this.table[this.current];return e.lexerState=this.lexerState,e},s.prototype.restore=function(e){var t=e.index;this.current=t,this.table[t]=e,this.table.splice(t+1),this.lexerState=e.lexerState,this.results=this.finish()},s.prototype.rewind=function(e){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[e])},s.prototype.finish=function(){var e=[],t=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(r){r.rule.name===t&&r.dot===r.rule.symbols.length&&0===r.reference&&r.data!==s.fail&&e.push(r)})),e.map((function(e){return e.data}))},{Parser:s,Grammar:n,Rule:e}},e.exports?e.exports=o():n.nearley=o()},function(e,t,r){"use strict";var n=r(2).Buffer,o=r(35).Transform;function s(e){o.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(1)(s,o),s.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},s.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},s.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,o=0;this._blockOffset+e.length-o>=this._blockSize;){for(var s=this._blockOffset;s0;++i)this._length[i]+=a,(a=this._length[i]/4294967296|0)>0&&(this._length[i]-=4294967296*a);return this},s.prototype._update=function(){throw new Error("_update is not implemented")},s.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},s.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=s},function(e,t,r){e.exports=o;var n=r(22).EventEmitter;function o(){n.call(this)}r(1)(o,n),o.Readable=r(23),o.Writable=r(61),o.Duplex=r(62),o.Transform=r(63),o.PassThrough=r(64),o.Stream=o,o.prototype.pipe=function(e,t){var r=this;function o(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",o),e.on("drain",s),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",u));var i=!1;function a(){i||(i=!0,e.end())}function u(){i||(i=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(l(),0===n.listenerCount(this,"error"))throw e}function l(){r.removeListener("data",o),e.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("error",c),e.on("error",c),r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}},function(e,t,r){"use strict";(function(t,n){var o=r(18);e.exports=D;var s,i=r(31);D.ReadableState=y;r(22).EventEmitter;var a=function(e,t){return e.listeners(t).length},u=r(37),c=r(2).Buffer,l=t.Uint8Array||function(){};var p=r(15);p.inherits=r(1);var f=r(54),h=void 0;h=f&&f.debuglog?f.debuglog("stream"):function(){};var d,g=r(55),m=r(38);p.inherits(D,u);var b=["error","close","destroy","pause","resume"];function y(e,t){e=e||{};var n=t instanceof(s=s||r(11));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var o=e.highWaterMark,i=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:n&&(i||0===i)?i:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=r(25).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function D(e){if(s=s||r(11),!(this instanceof D))return new D(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function P(e,t,r,n,o){var s,i=e._readableState;null===t?(i.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,A(e)}(e,i)):(o||(s=function(e,t){var r;n=t,c.isBuffer(n)||n instanceof l||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(i,t)),s?e.emit("error",s):i.objectMode||t&&t.length>0?("string"==typeof t||i.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?i.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):$(e,i,t,!0):i.ended?e.emit("error",new Error("stream.push() after EOF")):(i.reading=!1,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?$(e,i,t,!1):_(e,i)):$(e,i,t,!1))):n||(i.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function A(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?o.nextTick(I,e):I(e))}function I(e){h("emit readable"),e.emit("readable"),U(e)}function _(e,t){t.readingMore||(t.readingMore=!0,o.nextTick(R,e,t))}function R(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;es.length?s.length:e;if(i===s.length?o+=s:o+=s.slice(0,e),0===(e-=i)){i===s.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(i));break}++n}return t.length-=n,o}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,o=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var s=n.data,i=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,i),0===(e-=i)){i===s.length?(++o,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(i));break}++o}return t.length-=o,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function T(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,o.nextTick(w,t,e))}function w(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function O(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):A(this),null;if(0===(e=v(e,t))&&t.ended)return 0===t.length&&T(this),null;var n,o=t.needReadable;return h("need readable",o),(0===t.length||t.length-e0?E(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&T(this)),null!==n&&this.emit("data",n),n},D.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},D.prototype.pipe=function(e,t){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,h("pipe count=%d opts=%j",s.pipesCount,t);var u=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?l:D;function c(t,n){h("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,h("cleanup"),e.removeListener("close",b),e.removeListener("finish",y),e.removeListener("drain",p),e.removeListener("error",m),e.removeListener("unpipe",c),r.removeListener("end",l),r.removeListener("end",D),r.removeListener("data",g),f=!0,!s.awaitDrain||e._writableState&&!e._writableState.needDrain||p())}function l(){h("onend"),e.end()}s.endEmitted?o.nextTick(u):r.once("end",u),e.on("unpipe",c);var p=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,U(e))}}(r);e.on("drain",p);var f=!1;var d=!1;function g(t){h("ondata"),d=!1,!1!==e.write(t)||d||((1===s.pipesCount&&s.pipes===e||s.pipesCount>1&&-1!==O(s.pipes,e))&&!f&&(h("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function m(t){h("onerror",t),D(),e.removeListener("error",m),0===a(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",y),D()}function y(){h("onfinish"),e.removeListener("close",b),D()}function D(){h("unpipe"),r.unpipe(e)}return r.on("data",g),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?i(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",m),e.once("close",b),e.once("finish",y),e.emit("pipe",r),s.flowing||(h("pipe resume"),r.resume()),e},D.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function f(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function h(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,o),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,o=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,d=0|this._f,g=0|this._g,m=0|this._h,b=0;b<16;++b)r[b]=e.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((t=r[b-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[b-7]+h(r[b-15])+r[b-16];for(var y=0;y<64;++y){var D=m+f(u)+c(u,d,g)+i[y]+r[y]|0,P=p(n)+l(n,o,s)|0;m=g,g=d,d=u,u=a+D|0,a=s,s=o,o=n,n=D+P|0}this._a=n+this._a|0,this._b=o+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=g+this._g|0,this._h=m+this._h|0},u.prototype._hash=function(){var e=s.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=u},function(e,t,r){var n=r(1),o=r(13),s=r(2).Buffer,i=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function l(e,t,r){return e&t|r&(e|t)}function p(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function f(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function b(e,t){return e>>>0>>0?1:0}n(u,o),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,o=0|this._ch,s=0|this._dh,a=0|this._eh,u=0|this._fh,y=0|this._gh,D=0|this._hh,P=0|this._al,$=0|this._bl,v=0|this._cl,A=0|this._dl,I=0|this._el,_=0|this._fl,R=0|this._gl,S=0|this._hl,C=0;C<32;C+=2)t[C]=e.readInt32BE(4*C),t[C+1]=e.readInt32BE(4*C+4);for(;C<160;C+=2){var U=t[C-30],E=t[C-30+1],T=h(U,E),w=d(E,U),O=g(U=t[C-4],E=t[C-4+1]),N=m(E,U),x=t[C-14],M=t[C-14+1],F=t[C-32],G=t[C-32+1],k=w+M|0,L=T+x+b(k,w)|0;L=(L=L+O+b(k=k+N|0,N)|0)+F+b(k=k+G|0,G)|0,t[C]=L,t[C+1]=k}for(var W=0;W<160;W+=2){L=t[W],k=t[W+1];var B=l(r,n,o),z=l(P,$,v),j=p(r,P),H=p(P,r),Q=f(a,I),J=f(I,a),q=i[W],K=i[W+1],Y=c(a,u,y),V=c(I,_,R),Z=S+J|0,X=D+Q+b(Z,S)|0;X=(X=(X=X+Y+b(Z=Z+V|0,V)|0)+q+b(Z=Z+K|0,K)|0)+L+b(Z=Z+k|0,k)|0;var ee=H+z|0,te=j+B+b(ee,H)|0;D=y,S=R,y=u,R=_,u=a,_=I,a=s+X+b(I=A+Z|0,A)|0,s=o,A=v,o=n,v=$,n=r,$=P,r=X+te+b(P=Z+ee|0,Z)|0}this._al=this._al+P|0,this._bl=this._bl+$|0,this._cl=this._cl+v|0,this._dl=this._dl+A|0,this._el=this._el+I|0,this._fl=this._fl+_|0,this._gl=this._gl+R|0,this._hl=this._hl+S|0,this._ah=this._ah+r+b(this._al,P)|0,this._bh=this._bh+n+b(this._bl,$)|0,this._ch=this._ch+o+b(this._cl,v)|0,this._dh=this._dh+s+b(this._dl,A)|0,this._eh=this._eh+a+b(this._el,I)|0,this._fh=this._fh+u+b(this._fl,_)|0,this._gh=this._gh+y+b(this._gl,R)|0,this._hh=this._hh+D+b(this._hl,S)|0},u.prototype._hash=function(){var e=s.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=u},function(e,t,r){(function(t){function r(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){var r;if(e instanceof Uint8Array)r=e;else if(e instanceof t)r=new Uint8Array(e);else{if("string"!=typeof e)throw new Error("Input must be an string, Buffer or Uint8Array");r=new Uint8Array(t.from(e,"utf8"))}return r},toHex:function(e){return Array.prototype.map.call(e,(function(e){return(e<16?"0":"")+e.toString(16)})).join("")},debugPrint:function(e,t,n){for(var o="\n"+e+" = ",s=0;s0?i-4:i;for(r=0;r>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,s=[],i=0,a=r-o;ia?a:i+16383));1===o?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return s.join("")};for(var n=[],o=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=i.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var o,s,i=[],a=t;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,o){var s,i,a=8*o-n-1,u=(1<>1,l=-7,p=r?o-1:0,f=r?-1:1,h=e[t+p];for(p+=f,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+p],p+=f,l-=8);for(i=s&(1<<-l)-1,s>>=-l,l+=n;l>0;i=256*i+e[t+p],p+=f,l-=8);if(0===s)s=1-c;else{if(s===u)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,n),s-=c}return(h?-1:1)*i*Math.pow(2,s-n)},t.write=function(e,t,r,n,o,s){var i,a,u,c=8*s-o-1,l=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:s-1,d=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),(t+=i+p>=1?f/u:f*Math.pow(2,1-p))*u>=2&&(i++,u/=2),i+p>=l?(a=0,i=l):i+p>=1?(a=(t*u-1)*Math.pow(2,o),i+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),i=0));o>=8;e[r+h]=255&a,h+=d,a/=256,o-=8);for(i=i<0;e[r+h]=255&i,h+=d,i/=256,c-=8);e[r+h-d]|=128*g}},function(e,t,r){"use strict";function n(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0});const o=r(21),s=r(32),i=['"parameter"','"storage"','"code"','"False"','"Elt"','"Left"','"None"','"Pair"','"Right"','"Some"','"True"','"Unit"','"PACK"','"UNPACK"','"BLAKE2B"','"SHA256"','"SHA512"','"ABS"','"ADD"','"AMOUNT"','"AND"','"BALANCE"','"CAR"','"CDR"','"CHECK_SIGNATURE"','"COMPARE"','"CONCAT"','"CONS"','"CREATE_ACCOUNT"','"CREATE_CONTRACT"','"IMPLICIT_ACCOUNT"','"DIP"','"DROP"','"DUP"','"EDIV"','"EMPTY_MAP"','"EMPTY_SET"','"EQ"','"EXEC"','"FAILWITH"','"GE"','"GET"','"GT"','"HASH_KEY"','"IF"','"IF_CONS"','"IF_LEFT"','"IF_NONE"','"INT"','"LAMBDA"','"LE"','"LEFT"','"LOOP"','"LSL"','"LSR"','"LT"','"MAP"','"MEM"','"MUL"','"NEG"','"NEQ"','"NIL"','"NONE"','"NOT"','"NOW"','"OR"','"PAIR"','"PUSH"','"RIGHT"','"SIZE"','"SOME"','"SOURCE"','"SENDER"','"SELF"','"STEPS_TO_QUOTA"','"SUB"','"SWAP"','"TRANSFER_TOKENS"','"SET_DELEGATE"','"UNIT"','"UPDATE"','"XOR"','"ITER"','"LOOP_LEFT"','"ADDRESS"','"CONTRACT"','"ISNAT"','"CAST"','"RENAME"','"bool"','"contract"','"int"','"key"','"key_hash"','"lambda"','"list"','"map"','"big_map"','"nat"','"option"','"or"','"pair"','"set"','"signature"','"string"','"bytes"','"mutez"','"timestamp"','"unit"','"operation"','"address"','"SLICE"','"DIG"','"DUG"','"EMPTY_BIG_MAP"','"APPLY"','"chain_id"','"CHAIN_ID"'],a=o.compile({keyword:i,lbrace:"{",rbrace:"}",lbracket:"[",rbracket:"]",colon:":",comma:",",_:/[ \t]+/,quotedValue:/\"[\S\s]*?\"/}),u=e=>("00"+i.indexOf(e).toString(16)).slice(-2),c=e=>("0000000"+e.toString(16)).slice(-8),l=e=>{if(0===e)return"00";const t=s(e).abs(),r=t.bitLength().toJSNumber();let n=[],o=t;for(let t=0;t("0"+e.toString(16)).slice(-2)).join("")},p={Lexer:a,ParserRules:[{name:"main",symbols:["staticObject"],postprocess:n},{name:"main",symbols:["primBare"],postprocess:n},{name:"main",symbols:["primArg"],postprocess:n},{name:"main",symbols:["primAnn"],postprocess:n},{name:"main",symbols:["primArgAnn"],postprocess:n},{name:"main",symbols:["anyArray"],postprocess:n},{name:"staticInt$ebnf$1",symbols:[]},{name:"staticInt$ebnf$1",symbols:["staticInt$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"staticInt",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"int"'},"staticInt$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("quotedValue")?{type:"quotedValue"}:quotedValue,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{const t=e[6].toString();return"00"+l(parseInt(t.substring(1,t.length-1)))}},{name:"staticString$ebnf$1",symbols:[]},{name:"staticString$ebnf$1",symbols:["staticString$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"staticString",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"string"'},"staticString$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("quotedValue")?{type:"quotedValue"}:quotedValue,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t=e[6].toString();t=t.substring(1,t.length-1);const r=c(t.length);return t=t.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),"01"+r+t}},{name:"staticBytes$ebnf$1",symbols:[]},{name:"staticBytes$ebnf$1",symbols:["staticBytes$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"staticBytes",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"bytes"'},"staticBytes$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("quotedValue")?{type:"quotedValue"}:quotedValue,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t=e[6].toString();t=t.substring(1,t.length-1);return"0a"+c(t.length/2)+t}},{name:"staticObject",symbols:["staticInt"],postprocess:n},{name:"staticObject",symbols:["staticString"],postprocess:n},{name:"staticObject",symbols:["staticBytes"],postprocess:n},{name:"primBare$ebnf$1",symbols:[]},{name:"primBare$ebnf$1",symbols:["primBare$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"primBare",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primBare$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"03"+u(e[6].toString())},{name:"primArg$ebnf$1",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArg$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$3$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$1",symbols:["any","primArg$ebnf$3$subexpression$1$ebnf$1","primArg$ebnf$3$subexpression$1$ebnf$2"]},{name:"primArg$ebnf$3",symbols:["primArg$ebnf$3$subexpression$1"]},{name:"primArg$ebnf$3$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArg$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$3$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$2",symbols:["any","primArg$ebnf$3$subexpression$2$ebnf$1","primArg$ebnf$3$subexpression$2$ebnf$2"]},{name:"primArg$ebnf$3",symbols:["primArg$ebnf$3","primArg$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primArg",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primArg$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"args"'},"primArg$ebnf$2",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primArg$ebnf$3",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t="05";2==e[15].length?t="07":e[15].length>2&&(t="09");const r=u(e[6].toString());let n=e[15].map(e=>e[0]).join("");return"09"===t&&(n=("0000000"+(n.length/2).toString(16)).slice(-8)+n,n+="00000000"),t+r+n}},{name:"primAnn$ebnf$1",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$1",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$2",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$1",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primAnn$ebnf$3$subexpression$1$ebnf$1","primAnn$ebnf$3$subexpression$1$ebnf$2"]},{name:"primAnn$ebnf$3",symbols:["primAnn$ebnf$3$subexpression$1"]},{name:"primAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$2",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primAnn$ebnf$3$subexpression$2$ebnf$1","primAnn$ebnf$3$subexpression$2$ebnf$2"]},{name:"primAnn$ebnf$3",symbols:["primAnn$ebnf$3","primAnn$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primAnn",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primAnn$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"annots"'},"primAnn$ebnf$2",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primAnn$ebnf$3",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{const t=u(e[6].toString());let r=e[15].map(e=>{let t=e[0].toString();return t=t.substring(1,t.length-1),t}).join(" ");return r=r.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),r=c(r.length/2)+r,"04"+t+r}},{name:"primArgAnn$ebnf$1",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$1",symbols:["any","primArgAnn$ebnf$3$subexpression$1$ebnf$1","primArgAnn$ebnf$3$subexpression$1$ebnf$2"]},{name:"primArgAnn$ebnf$3",symbols:["primArgAnn$ebnf$3$subexpression$1"]},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$2",symbols:["any","primArgAnn$ebnf$3$subexpression$2$ebnf$1","primArgAnn$ebnf$3$subexpression$2$ebnf$2"]},{name:"primArgAnn$ebnf$3",symbols:["primArgAnn$ebnf$3","primArgAnn$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primArgAnn$ebnf$4",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$4",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$1",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primArgAnn$ebnf$5$subexpression$1$ebnf$1","primArgAnn$ebnf$5$subexpression$1$ebnf$2"]},{name:"primArgAnn$ebnf$5",symbols:["primArgAnn$ebnf$5$subexpression$1"]},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$2",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primArgAnn$ebnf$5$subexpression$2$ebnf$1","primArgAnn$ebnf$5$subexpression$2$ebnf$2"]},{name:"primArgAnn$ebnf$5",symbols:["primArgAnn$ebnf$5","primArgAnn$ebnf$5$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primArgAnn",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primArgAnn$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"args"'},"primArgAnn$ebnf$2",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primArgAnn$ebnf$3",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"annots"'},"primArgAnn$ebnf$4",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primArgAnn$ebnf$5",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t="06";2==e[15].length?t="08":e[15].length>2&&(t="09");const r=u(e[6].toString());let n=e[15].map(e=>e[0]).join(""),o=e[26].map(e=>{let t=e[0].toString();return t=t.substring(1,t.length-1),t}).join(" ");return o=o.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),o=c(o.length/2)+o,"09"===t&&(n=("0000000"+(n.length/2).toString(16)).slice(-8)+n),t+r+n+o}},{name:"primAny",symbols:["primBare"],postprocess:n},{name:"primAny",symbols:["primArg"],postprocess:n},{name:"primAny",symbols:["primAnn"],postprocess:n},{name:"primAny",symbols:["primArgAnn"],postprocess:n},{name:"any",symbols:["primAny"],postprocess:n},{name:"any",symbols:["staticObject"],postprocess:n},{name:"any",symbols:["anyArray"],postprocess:n},{name:"anyArray",symbols:[a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("rbracket")?{type:"rbracket"}:rbracket],postprocess:function(e){return"0200000000"}},{name:"anyArray$ebnf$1$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"anyArray$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"anyArray$ebnf$1$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$1",symbols:["any","anyArray$ebnf$1$subexpression$1$ebnf$1","anyArray$ebnf$1$subexpression$1$ebnf$2"]},{name:"anyArray$ebnf$1",symbols:["anyArray$ebnf$1$subexpression$1"]},{name:"anyArray$ebnf$1$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"anyArray$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"anyArray$ebnf$1$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$2",symbols:["any","anyArray$ebnf$1$subexpression$2$ebnf$1","anyArray$ebnf$1$subexpression$2$ebnf$2"]},{name:"anyArray$ebnf$1",symbols:["anyArray$ebnf$1","anyArray$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"anyArray",symbols:[a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"anyArray$ebnf$1",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket],postprocess:e=>{const t=e[2].map(e=>e[0]).join("");return"02"+c(t.length/2)+t}}],ParserStart:"main"};t.default=p},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";function n(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0});const o=r(21),s=/SET_C[AD]+R/,i=/DII+P/,a=/DUU+P/,u=new RegExp(i),c=new RegExp(a),l=["ASSERT","ASSERT_EQ","ASSERT_NEQ","ASSERT_GT","ASSERT_LT","ASSERT_GE","ASSERT_LE","ASSERT_NONE","ASSERT_SOME","ASSERT_LEFT","ASSERT_RIGHT","ASSERT_CMPEQ","ASSERT_CMPNEQ","ASSERT_CMPGT","ASSERT_CMPLT","ASSERT_CMPGE","ASSERT_CMPLE"],p=["IFCMPEQ","IFCMPNEQ","IFCMPLT","IFCMPGT","IFCMPLE","IFCMPGE"],f=["CMPEQ","CMPNEQ","CMPLT","CMPGT","CMPLE","CMPGE"],h=["IFEQ","IFNEQ","IFLT","IFGT","IFLE","IFGE"],d=o.compile({annot:/[\@\%\:][a-z_A-Z0-9]+/,lparen:"(",rparen:")",lbrace:"{",rbrace:"}",ws:/[ \t]+/,semicolon:";",bytes:/0x[0-9a-fA-F]+/,number:/-?[0-9]+(?!x)/,parameter:["parameter","Parameter"],storage:["Storage","storage"],code:["Code","code"],comparableType:["int","nat","string","bytes","mutez","bool","key_hash","timestamp","chain_id"],constantType:["key","unit","signature","operation","address"],singleArgType:["option","list","set","contract"],doubleArgType:["pair","or","lambda","map","big_map"],baseInstruction:["ABS","ADD","ADDRESS","AMOUNT","AND","BALANCE","BLAKE2B","CAR","CAST","CDR","CHECK_SIGNATURE","COMPARE","CONCAT","CONS","CONTRACT","DIP","EDIV","EMPTY_SET","EQ","EXEC","FAIL","FAILWITH","GE","GET","GT","HASH_KEY","IF","IF_CONS","IF_LEFT","IF_NONE","IF_RIGHT","IMPLICIT_ACCOUNT","INT","ISNAT","ITER","LAMBDA","LE","LEFT","LOOP","LOOP_LEFT","LSL","LSR","LT","MAP","MEM","MUL","NEG","NEQ","NIL","NONE","NOT","NOW","OR","PACK","PAIR","REDUCE","RENAME","RIGHT","SELF","SENDER","SET_DELEGATE","SHA256","SHA512","SIZE","SLICE","SOME","SOURCE","STEPS_TO_QUOTA","SUB","SWAP","TRANSFER_TOKENS","UNIT","UNPACK","UPDATE","XOR","UNPAIR","UNPAPAIR","IF_SOME","IFCMPEQ","IFCMPNEQ","IFCMPLT","IFCMPGT","IFCMPLE","IFCMPGE","CMPEQ","CMPNEQ","CMPLT","CMPGT","CMPLE","CMPGE","IFEQ","NEQ","IFLT","IFGT","IFLE","IFGE","EMPTY_BIG_MAP","APPLY","CHAIN_ID"],macroCADR:/C[AD]+R/,macroDIP:i,macroDUP:a,macroSETCADR:s,macroASSERTlist:l,constantData:["Unit","True","False","None","instruction"],singleArgData:["Left","Right","Some"],doubleArgData:["Pair"],elt:"Elt",word:/[a-zA-Z_0-9]+/,string:/"(?:\\["\\]|[^\n"\\])*"/}),g=e=>new RegExp("^C(A|D)(A|D)+R$").test(e),m=e=>f.includes(e),b=e=>c.test(e),y=e=>l.includes(e),D=e=>"FAIL"===e,P=e=>p.includes(e)||h.includes(e)||"IF_SOME"===e,$=(e,t,r,n)=>{const o=n?`, "annots": [${n}]`:"";switch(e){case"IFCMPEQ":return`[{"prim":"COMPARE"},{"prim":"EQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPGE":return`[{"prim":"COMPARE"},{"prim":"GE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPGT":return`[{"prim":"COMPARE"},{"prim":"GT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPLE":return`[{"prim":"COMPARE"},{"prim":"LE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPLT":return`[{"prim":"COMPARE"},{"prim":"LT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPNEQ":return`[{"prim":"COMPARE"},{"prim":"NEQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFEQ":return`[{"prim":"EQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFGE":return`[{"prim":"GE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFGT":return`[{"prim":"GT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFLE":return`[{"prim":"LE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFLT":return`[{"prim":"LT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFNEQ":return`[{"prim":"NEQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IF_SOME":return`[{"prim":"IF_NONE","args":[ [${r}], [${t}]]${o}}]`;default:throw new Error("Could not process "+e)}},v=e=>u.test(e),A=(e,t,r)=>{let n="";if(u.test(e)){const o=e.length-2;for(let e=0;e"UNPAIR"==e||"UNPAPAIR"==e,_=e=>s.test(e),R=e=>{if(0===e.length)return"";const t=e.charAt(0);if(1===e.length){if("A"===t)return'[{"prim": "CDR","annots":["@%%"]}, {"prim": "SWAP"}, {"prim": "PAIR","annots":["%","%@"]}]';if("D"===t)return'[{"prim": "CAR","annots":["@%%"]}, {"prim": "PAIR","annots":["%@","%"]}]'}return"A"===t?`[{"prim": "DUP"}, {"prim": "DIP", "args": [[{"prim": "CAR","annots":["@%%"]}, ${R(e.slice(1))}]]}, {"prim": "CDR","annots":["@%%"]}, {"prim": "SWAP"}, {"prim": "PAIR","annots":["%@","%@"]}]`:"D"===t?`[{"prim": "DUP"}, {"prim": "DIP", "args": [[{"prim": "CDR","annots":["@%%"]}, ${R(e.slice(1))}]]}, {"prim": "CAR","annots":["@%%"]}, {"prim": "PAIR","annots":["%@","%@"]}]`:void 0},S=e=>!!y(e)||(!!m(e)||(!!v(e)||(!!b(e)||(!!D(e)||(!!P(e)||(!!g(e)||(!!I(e)||(!!_(e)||void 0)))))))),C=(e,t)=>g(e)?((e,t)=>{var r=e.slice(1,-1).split("").map(e=>"A"===e?'{ "prim": "CAR" }':'{ "prim": "CDR" }');if(null!=t){const n=e.slice(-2,-1);"A"===n?r[r.length-1]=`{ "prim": "CAR", "annots": [${t}] }`:"D"===n&&(r[r.length-1]=`{ "prim": "CDR", "annots": [${t}] }`)}return`[${r.join(", ")}]`})(e,t):y(e)?((e,t)=>{const r=t?`, "annots": [${t}]`:"";switch(e){case"ASSERT":return`[{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPEQ":return`[[{"prim":"COMPARE"},{"prim":"EQ"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPGE":return`[[{"prim":"COMPARE"},{"prim":"GE"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPGT":return`[[{"prim":"COMPARE"},{"prim":"GT"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPLE":return`[[{"prim":"COMPARE"},{"prim":"LE"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPLT":return`[[{"prim":"COMPARE"},{"prim":"LT"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPNEQ":return`[[{"prim":"COMPARE"},{"prim":"NEQ"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_EQ":return`[{"prim":"EQ"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]]`;case"ASSERT_GE":return`[{"prim":"GE"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_GT":return`[{"prim":"GT"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_LE":return`[{"prim":"LE"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_LT":return`[{"prim":"LT"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_NEQ":return`[{"prim":"NEQ"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_NONE":return'[{"prim":"IF_NONE","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"}]]]}]';case"ASSERT_SOME":return'[{"prim":"IF_NONE","args":[[[{"prim":"UNIT"},{"prim":"FAILWITH"}]],[]]}]';case"ASSERT_LEFT":case"ASSERT_RIGHT":return"";default:throw new Error("Could not process "+e)}})(e,t):m(e)?((e,t)=>{var r=e.substring(3),n=T([""+r]);return null!=t&&(n=`{ "prim": "${r}", "annots": [${t}] }`),`[${T(["COMPARE"])}, ${n}]`})(e,t):v(e)?A(e,t):b(e)?((e,t)=>{let r="";if(c.test(e)){const n=e.length-3;for(let e=0;enull==t?'[ { "prim": "UNIT" }, { "prim": "FAILWITH" } ]':`[ { "prim": "UNIT" }, { "prim": "FAILWITH", "annots": [${t}] } ]`)(0,t):P(e)?$(e,t):I(e)?((e,t)=>"UNPAIR"==e?null==t?'[ [ { "prim": "DUP" }, { "prim": "CAR" }, { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ]':1==t.length?`[ [ { "prim": "DUP" }, { "prim": "CAR", "annots": [${t}] }, { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ]`:2==t.length?`[ [ { "prim": "DUP" }, { "prim": "CAR", "annots": [${t[0]}] }, { "prim": "DIP", "args": [ [ { "prim": "CDR", "annots": [${t[1]}] } ] ] } ] ]`:"":"UNPAPAIR"==e?null==t?'[ [ { "prim": "DUP" },\n { "prim": "CAR" },\n { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ],\n {"prim":"DIP","args":[[[{"prim":"DUP"},{"prim":"CAR"},{"prim":"DIP","args":[[{"prim":"CDR"}]]}]]]}]':`[ [ { "prim": "DUP" },\n { "prim": "CAR" },\n { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ],\n {"prim":"DIP","args":[[[{"prim":"DUP"},{"prim":"CAR"},{"prim":"DIP","args":[[{"prim":"CDR"}]],"annots": [${t}]}]]]}]`:void 0)(e,t):_(e)?((e,t)=>R(e.slice(5,-1)))(e):void 0,U=e=>`{ "int": "${parseInt(e[0])}" }`,E=e=>`{ "string": ${e[0]} }`,T=e=>{const t=e[0].toString();if(1==e.length)return S(t)?[C(t,null)]:`{ "prim": "${e[0]}" }`;{const r=e[1].map(e=>`"${e[1]}"`);return S(t)?[C(t,r)]:`{ "prim": "${e[0]}", "annots": [${r}] }`}},w=e=>`{ "prim": "${e[0]}", "args": [ ${e[2]} ] }`,O=e=>{const t=e[3].map(e=>`"${e[1]}"`);return`{ "prim": "${e[2]}", "annots": [${t}] }`},N=e=>{const t=""+e[0].toString(),r=e[1].map(e=>`"${e[1]}"`);return v(t)?A(t,e[2],r):`{ "prim": "${e[0]}", "args": [ ${e[3]} ], "annots": [${r}] }`},x=e=>`{ "prim": "${e[2]}", "args": [ ${e[4+(7===e.length?0:2)]} ] }`,M=e=>`{ "prim": "${e[0]}", "args": [ ${e[2]}, ${e[4]} ] }`,F=e=>`{ "prim": "${e[2]}", "args": [ ${e[4]}, ${e[6]} ] }`,G=e=>Array.isArray(e)&&Array.isArray(e[0])?e[0]:e,k=e=>""+e[2].map(e=>e[0]).map(e=>G(e)),L=e=>`[ ${e[2].map(e=>e[0]).map(e=>G(e))} ]`,W=e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "${e[0]}", "args": [ ${e[4]}, ${e[6]} ], "annots": [${t}] }`},B=e=>`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" } ] }`,z={Lexer:d,ParserRules:[{name:"main",symbols:["instruction"],postprocess:n},{name:"main",symbols:["data"],postprocess:n},{name:"main",symbols:["type"],postprocess:n},{name:"main",symbols:["parameter"],postprocess:n},{name:"main",symbols:["storage"],postprocess:n},{name:"main",symbols:["code"],postprocess:n},{name:"main",symbols:["script"],postprocess:n},{name:"main",symbols:["parameterValue"],postprocess:n},{name:"main",symbols:["storageValue"],postprocess:n},{name:"main",symbols:["typeData"],postprocess:n},{name:"script",symbols:["parameter","_","storage","_","code"],postprocess:e=>`[ ${e[0]}, ${e[2]}, { "prim": "code", "args": [ [ ${e[4]} ] ] } ]`},{name:"parameterValue",symbols:[d.has("parameter")?{type:"parameter"}:parameter,"_","typeData","_","semicolons"],postprocess:w},{name:"storageValue",symbols:[d.has("storage")?{type:"storage"}:storage,"_","typeData","_","semicolons"],postprocess:w},{name:"parameter",symbols:[d.has("parameter")?{type:"parameter"}:parameter,"_","type","_","semicolons"],postprocess:w},{name:"storage",symbols:[d.has("storage")?{type:"storage"}:storage,"_","type","_","semicolons"],postprocess:w},{name:"code",symbols:[d.has("code")?{type:"code"}:code,"_","subInstruction","_","semicolons","_"],postprocess:e=>e[2]},{name:"code",symbols:[d.has("code")?{type:"code"}:code,"_",{literal:"{};"}],postprocess:e=>"code {}"},{name:"type",symbols:[d.has("comparableType")?{type:"comparableType"}:comparableType],postprocess:T},{name:"type",symbols:[d.has("constantType")?{type:"constantType"}:constantType],postprocess:T},{name:"type",symbols:[d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","type"],postprocess:w},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","type","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:x},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_",d.has("lparen")?{type:"lparen"}:lparen,"_","type","_",d.has("rparen")?{type:"rparen"}:rparen,"_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:x},{name:"type",symbols:[d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","type","_","type"],postprocess:M},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","type","_","type","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:F},{name:"type$ebnf$1$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$1",symbols:["type$ebnf$1$subexpression$1"]},{name:"type$ebnf$1$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$1",symbols:["type$ebnf$1","type$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("comparableType")?{type:"comparableType"}:comparableType,"type$ebnf$1"],postprocess:T},{name:"type$ebnf$2$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$2",symbols:["type$ebnf$2$subexpression$1"]},{name:"type$ebnf$2$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$2",symbols:["type$ebnf$2","type$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("constantType")?{type:"constantType"}:constantType,"type$ebnf$2"],postprocess:T},{name:"type$ebnf$3$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$3",symbols:["type$ebnf$3$subexpression$1"]},{name:"type$ebnf$3$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$3",symbols:["type$ebnf$3","type$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("comparableType")?{type:"comparableType"}:comparableType,"type$ebnf$3","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:O},{name:"type$ebnf$4$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$4",symbols:["type$ebnf$4$subexpression$1"]},{name:"type$ebnf$4$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$4",symbols:["type$ebnf$4","type$ebnf$4$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("constantType")?{type:"constantType"}:constantType,"type$ebnf$4","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:O},{name:"type$ebnf$5$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$5",symbols:["type$ebnf$5$subexpression$1"]},{name:"type$ebnf$5$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$5",symbols:["type$ebnf$5","type$ebnf$5$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"type$ebnf$5","_","type",d.has("rparen")?{type:"rparen"}:rparen],postprocess:e=>{const t=e[3].map(e=>`"${e[1]}"`);return`{ "prim": "${e[2]}", "args": [ ${e[5]} ], "annots": [${t}] }`}},{name:"type$ebnf$6$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$6",symbols:["type$ebnf$6$subexpression$1"]},{name:"type$ebnf$6$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$6",symbols:["type$ebnf$6","type$ebnf$6$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"type$ebnf$6","_","type","_","type",d.has("rparen")?{type:"rparen"}:rparen],postprocess:e=>{const t=e[3].map(e=>`"${e[1]}"`);return`{ "prim": "${e[2]}", "args": [ ${e[5]}, ${e[7]} ], "annots": [${t}] }`}},{name:"typeData",symbols:[d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","typeData"],postprocess:w},{name:"typeData",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","typeData","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:x},{name:"typeData",symbols:[d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","typeData","_","typeData"],postprocess:M},{name:"typeData",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","typeData","_","typeData","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:F},{name:"typeData",symbols:["subTypeData"],postprocess:n},{name:"typeData",symbols:["subTypeElt"],postprocess:n},{name:"typeData",symbols:[d.has("number")?{type:"number"}:number],postprocess:U},{name:"typeData",symbols:[d.has("string")?{type:"string"}:string],postprocess:E},{name:"typeData",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>[]},{name:"data",symbols:[d.has("constantData")?{type:"constantData"}:constantData],postprocess:T},{name:"data",symbols:[d.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_","data"],postprocess:w},{name:"data",symbols:[d.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_","data","_","data"],postprocess:M},{name:"data",symbols:["subData"],postprocess:n},{name:"data",symbols:["subElt"],postprocess:n},{name:"data",symbols:[d.has("string")?{type:"string"}:string],postprocess:E},{name:"data",symbols:[d.has("bytes")?{type:"bytes"}:bytes],postprocess:e=>`{ "bytes": "${e[0].toString().slice(2)}" }`},{name:"data",symbols:[d.has("number")?{type:"number"}:number],postprocess:U},{name:"subData",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subData$ebnf$1$subexpression$1",symbols:["data","_"]},{name:"subData$ebnf$1",symbols:["subData$ebnf$1$subexpression$1"]},{name:"subData$ebnf$1$subexpression$2",symbols:["data","_"]},{name:"subData$ebnf$1",symbols:["subData$ebnf$1","subData$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subData",symbols:[{literal:"("},"_","subData$ebnf$1",{literal:")"}],postprocess:k},{name:"subData$ebnf$2$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subData$ebnf$2$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subData$ebnf$2$subexpression$1",symbols:["data","_","subData$ebnf$2$subexpression$1$ebnf$1","_"]},{name:"subData$ebnf$2",symbols:["subData$ebnf$2$subexpression$1"]},{name:"subData$ebnf$2$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subData$ebnf$2$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subData$ebnf$2$subexpression$2",symbols:["data","_","subData$ebnf$2$subexpression$2$ebnf$1","_"]},{name:"subData$ebnf$2",symbols:["subData$ebnf$2","subData$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subData",symbols:[{literal:"{"},"_","subData$ebnf$2",{literal:"}"}],postprocess:L},{name:"subElt",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subElt$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subElt$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subElt$ebnf$1$subexpression$1",symbols:["elt","subElt$ebnf$1$subexpression$1$ebnf$1","_"]},{name:"subElt$ebnf$1",symbols:["subElt$ebnf$1$subexpression$1"]},{name:"subElt$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subElt$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subElt$ebnf$1$subexpression$2",symbols:["elt","subElt$ebnf$1$subexpression$2$ebnf$1","_"]},{name:"subElt$ebnf$1",symbols:["subElt$ebnf$1","subElt$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subElt",symbols:[{literal:"{"},"_","subElt$ebnf$1",{literal:"}"}],postprocess:L},{name:"elt",symbols:[d.has("elt")?{type:"elt"}:elt,"_","data","_","data"],postprocess:M},{name:"subTypeData",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subTypeData$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$1$subexpression$1",symbols:["data","subTypeData$ebnf$1$subexpression$1$ebnf$1","_"]},{name:"subTypeData$ebnf$1",symbols:["subTypeData$ebnf$1$subexpression$1"]},{name:"subTypeData$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$1$subexpression$2",symbols:["data","subTypeData$ebnf$1$subexpression$2$ebnf$1","_"]},{name:"subTypeData$ebnf$1",symbols:["subTypeData$ebnf$1","subTypeData$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeData",symbols:[{literal:"{"},"_","subTypeData$ebnf$1",{literal:"}"}],postprocess:k},{name:"subTypeData$ebnf$2$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$2$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$2$subexpression$1",symbols:["data","subTypeData$ebnf$2$subexpression$1$ebnf$1","_"]},{name:"subTypeData$ebnf$2",symbols:["subTypeData$ebnf$2$subexpression$1"]},{name:"subTypeData$ebnf$2$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$2$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$2$subexpression$2",symbols:["data","subTypeData$ebnf$2$subexpression$2$ebnf$1","_"]},{name:"subTypeData$ebnf$2",symbols:["subTypeData$ebnf$2","subTypeData$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeData",symbols:[{literal:"("},"_","subTypeData$ebnf$2",{literal:")"}],postprocess:k},{name:"subTypeElt",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subTypeElt$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$1$subexpression$1",symbols:["typeElt","subTypeElt$ebnf$1$subexpression$1$ebnf$1","_"]},{name:"subTypeElt$ebnf$1",symbols:["subTypeElt$ebnf$1$subexpression$1"]},{name:"subTypeElt$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$1$subexpression$2",symbols:["typeElt","subTypeElt$ebnf$1$subexpression$2$ebnf$1","_"]},{name:"subTypeElt$ebnf$1",symbols:["subTypeElt$ebnf$1","subTypeElt$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeElt",symbols:[{literal:"[{"},"_","subTypeElt$ebnf$1",{literal:"}]"}],postprocess:k},{name:"subTypeElt$ebnf$2$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$2$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$2$subexpression$1",symbols:["typeElt","_","subTypeElt$ebnf$2$subexpression$1$ebnf$1","_"]},{name:"subTypeElt$ebnf$2",symbols:["subTypeElt$ebnf$2$subexpression$1"]},{name:"subTypeElt$ebnf$2$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$2$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$2$subexpression$2",symbols:["typeElt","_","subTypeElt$ebnf$2$subexpression$2$ebnf$1","_"]},{name:"subTypeElt$ebnf$2",symbols:["subTypeElt$ebnf$2","subTypeElt$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeElt",symbols:[{literal:"[{"},"_","subTypeElt$ebnf$2",{literal:"}]"}],postprocess:k},{name:"typeElt",symbols:[d.has("elt")?{type:"elt"}:elt,"_","typeData","_","typeData"],postprocess:M},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>""},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_","instruction","_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>e[2]},{name:"subInstruction$ebnf$1$subexpression$1",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$1",symbols:["subInstruction$ebnf$1$subexpression$1"]},{name:"subInstruction$ebnf$1$subexpression$2",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$1",symbols:["subInstruction$ebnf$1","subInstruction$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_","subInstruction$ebnf$1","instruction","_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>e[2].map(e=>e[0]).concat(e[3]).map(e=>G(e))},{name:"subInstruction$ebnf$2$subexpression$1",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$2",symbols:["subInstruction$ebnf$2$subexpression$1"]},{name:"subInstruction$ebnf$2$subexpression$2",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$2",symbols:["subInstruction$ebnf$2","subInstruction$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_","subInstruction$ebnf$2",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:k},{name:"instructions",symbols:[d.has("baseInstruction")?{type:"baseInstruction"}:baseInstruction]},{name:"instructions",symbols:[d.has("macroCADR")?{type:"macroCADR"}:macroCADR]},{name:"instructions",symbols:[d.has("macroDIP")?{type:"macroDIP"}:macroDIP]},{name:"instructions",symbols:[d.has("macroDUP")?{type:"macroDUP"}:macroDUP]},{name:"instructions",symbols:[d.has("macroSETCADR")?{type:"macroSETCADR"}:macroSETCADR]},{name:"instructions",symbols:[d.has("macroASSERTlist")?{type:"macroASSERTlist"}:macroASSERTlist]},{name:"instruction",symbols:["instructions"],postprocess:T},{name:"instruction",symbols:["subInstruction"],postprocess:n},{name:"instruction$ebnf$1$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$1",symbols:["instruction$ebnf$1$subexpression$1"]},{name:"instruction$ebnf$1$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$1",symbols:["instruction$ebnf$1","instruction$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$1","_"],postprocess:T},{name:"instruction",symbols:["instructions","_","subInstruction"],postprocess:e=>{const t=""+e[0].toString();return v(t)?A(t,e[2]):`{ "prim": "${e[0]}", "args": [ [ ${e[2]} ] ] }`}},{name:"instruction$ebnf$2$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$2",symbols:["instruction$ebnf$2$subexpression$1"]},{name:"instruction$ebnf$2$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$2",symbols:["instruction$ebnf$2","instruction$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$2","_","subInstruction"],postprocess:N},{name:"instruction",symbols:["instructions","_","type"],postprocess:w},{name:"instruction$ebnf$3$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$3",symbols:["instruction$ebnf$3$subexpression$1"]},{name:"instruction$ebnf$3$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$3",symbols:["instruction$ebnf$3","instruction$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$3","_","type"],postprocess:N},{name:"instruction",symbols:["instructions","_","data"],postprocess:w},{name:"instruction$ebnf$4$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$4",symbols:["instruction$ebnf$4$subexpression$1"]},{name:"instruction$ebnf$4$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$4",symbols:["instruction$ebnf$4","instruction$ebnf$4$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$4","_","data"],postprocess:N},{name:"instruction",symbols:["instructions","_","type","_","type","_","subInstruction"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ ${e[2]}, ${e[4]}, [${e[6]}] ] }`},{name:"instruction$ebnf$5$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$5",symbols:["instruction$ebnf$5$subexpression$1"]},{name:"instruction$ebnf$5$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$5",symbols:["instruction$ebnf$5","instruction$ebnf$5$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$5","_","type","_","type","_","subInstruction"],postprocess:e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "${e[0]}", "args": [ ${e[3]}, ${e[5]}, ${e[7]} ], "annots": [${t}] }`}},{name:"instruction",symbols:["instructions","_","subInstruction","_","subInstruction"],postprocess:e=>{const t=""+e[0].toString();return P(t)?$(t,e[2],e[4]):`{ "prim": "${e[0]}", "args": [ [${e[2]}], [${e[4]}] ] }`}},{name:"instruction$ebnf$6$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$6",symbols:["instruction$ebnf$6$subexpression$1"]},{name:"instruction$ebnf$6$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$6",symbols:["instruction$ebnf$6","instruction$ebnf$6$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$6","_","subInstruction","_","subInstruction"],postprocess:W},{name:"instruction",symbols:["instructions","_","type","_","type"],postprocess:M},{name:"instruction$ebnf$7$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$7",symbols:["instruction$ebnf$7$subexpression$1"]},{name:"instruction$ebnf$7$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$7",symbols:["instruction$ebnf$7","instruction$ebnf$7$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$7","_","type","_","type"],postprocess:W},{name:"instruction",symbols:[{literal:"PUSH"},"_","type","_","data"],postprocess:M},{name:"instruction",symbols:[{literal:"PUSH"},"_","type","_",d.has("lbrace")?{type:"lbrace"}:lbrace,d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>`{ "prim": "${e[0]}", "args": [${e[2]}, []] }`},{name:"instruction$ebnf$8$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$8",symbols:["instruction$ebnf$8$subexpression$1"]},{name:"instruction$ebnf$8$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$8",symbols:["instruction$ebnf$8","instruction$ebnf$8$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"PUSH"},"instruction$ebnf$8","_","type","_","data"],postprocess:e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "PUSH", "args": [ ${e[3]}, ${e[5]} ], "annots": [${t}] }`}},{name:"instruction$ebnf$9",symbols:[/[0-9]/]},{name:"instruction$ebnf$9",symbols:["instruction$ebnf$9",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DIP"},"_","instruction$ebnf$9","_","subInstruction"],postprocess:e=>e.length>4?`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" }, [ ${e[4]} ] ] }`:`{ "prim": "${e[0]}", "args": [ ${e[2]} ] }`},{name:"instruction$ebnf$10",symbols:[/[0-9]/]},{name:"instruction$ebnf$10",symbols:["instruction$ebnf$10",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DUP"},"_","instruction$ebnf$10"],postprocess:e=>{const t=Number(e[2]);return 1===t?'{ "prim": "DUP" }':2===t?'[{ "prim": "DIP", "args": [[ {"prim": "DUP"} ]] }, { "prim": "SWAP" }]':`[{ "prim": "DIP", "args": [ {"int": "${t-1}"}, [{ "prim": "DUP" }] ] }, { "prim": "DIG", "args": [ {"int": "${t}"} ] }]`}},{name:"instruction",symbols:[{literal:"DUP"}],postprocess:T},{name:"instruction$ebnf$11$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$11",symbols:["instruction$ebnf$11$subexpression$1"]},{name:"instruction$ebnf$11$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$11",symbols:["instruction$ebnf$11","instruction$ebnf$11$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DUP"},"instruction$ebnf$11","_"],postprocess:T},{name:"instruction$ebnf$12",symbols:[/[0-9]/]},{name:"instruction$ebnf$12",symbols:["instruction$ebnf$12",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DIG"},"_","instruction$ebnf$12"],postprocess:B},{name:"instruction$ebnf$13",symbols:[/[0-9]/]},{name:"instruction$ebnf$13",symbols:["instruction$ebnf$13",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DUG"},"_","instruction$ebnf$13"],postprocess:B},{name:"instruction$ebnf$14",symbols:[/[0-9]/]},{name:"instruction$ebnf$14",symbols:["instruction$ebnf$14",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DROP"},"_","instruction$ebnf$14"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" } ] }`},{name:"instruction",symbols:[{literal:"DROP"}],postprocess:T},{name:"instruction",symbols:[{literal:"CREATE_CONTRACT"},"_",d.has("lbrace")?{type:"lbrace"}:lbrace,"_","parameter","_","storage","_","code","_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>`{ "prim":"CREATE_CONTRACT", "args": [ [ ${e[4]}, ${e[6]}, {"prim": "code" , "args":[ [ ${e[8]} ] ] } ] ] }`},{name:"instruction",symbols:[{literal:"EMPTY_MAP"},"_","type","_","type"],postprocess:M},{name:"instruction",symbols:[{literal:"EMPTY_MAP"},"_",d.has("lparen")?{type:"lparen"}:lparen,"_","type","_",d.has("rparen")?{type:"rparen"}:rparen,"_","type"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ ${e[4]}, ${e[8]} ] }`},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1",/[\s]/],postprocess:e=>e[0].concat([e[1]])},{name:"_",symbols:["_$ebnf$1"]},{name:"semicolons$ebnf$1",symbols:[/[;]/],postprocess:n},{name:"semicolons$ebnf$1",symbols:[],postprocess:()=>null},{name:"semicolons",symbols:["semicolons$ebnf$1"]}],ParserStart:"main"};t.default=z},function(e,t,r){"use strict";var n=r(52),o=r(72);e.exports=o((function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}))},function(e,t,r){"use strict";var n=r(1),o=r(53),s=r(65),i=r(66),a=r(71);function u(e){a.call(this,"digest"),this._hash=e}n(u,a),u.prototype._update=function(e){this._hash.update(e)},u.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new o:"rmd160"===e||"ripemd160"===e?new s:new u(i(e))}},function(e,t,r){"use strict";var n=r(1),o=r(34),s=r(2).Buffer,i=new Array(16);function a(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(e,t){return e<>>32-t}function c(e,t,r,n,o,s,i){return u(e+(t&r|~t&n)+o+s|0,i)+t|0}function l(e,t,r,n,o,s,i){return u(e+(t&n|r&~n)+o+s|0,i)+t|0}function p(e,t,r,n,o,s,i){return u(e+(t^r^n)+o+s|0,i)+t|0}function f(e,t,r,n,o,s,i){return u(e+(r^(t|~n))+o+s|0,i)+t|0}n(a,o),a.prototype._update=function(){for(var e=i,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,o=this._c,s=this._d;r=c(r,n,o,s,e[0],3614090360,7),s=c(s,r,n,o,e[1],3905402710,12),o=c(o,s,r,n,e[2],606105819,17),n=c(n,o,s,r,e[3],3250441966,22),r=c(r,n,o,s,e[4],4118548399,7),s=c(s,r,n,o,e[5],1200080426,12),o=c(o,s,r,n,e[6],2821735955,17),n=c(n,o,s,r,e[7],4249261313,22),r=c(r,n,o,s,e[8],1770035416,7),s=c(s,r,n,o,e[9],2336552879,12),o=c(o,s,r,n,e[10],4294925233,17),n=c(n,o,s,r,e[11],2304563134,22),r=c(r,n,o,s,e[12],1804603682,7),s=c(s,r,n,o,e[13],4254626195,12),o=c(o,s,r,n,e[14],2792965006,17),r=l(r,n=c(n,o,s,r,e[15],1236535329,22),o,s,e[1],4129170786,5),s=l(s,r,n,o,e[6],3225465664,9),o=l(o,s,r,n,e[11],643717713,14),n=l(n,o,s,r,e[0],3921069994,20),r=l(r,n,o,s,e[5],3593408605,5),s=l(s,r,n,o,e[10],38016083,9),o=l(o,s,r,n,e[15],3634488961,14),n=l(n,o,s,r,e[4],3889429448,20),r=l(r,n,o,s,e[9],568446438,5),s=l(s,r,n,o,e[14],3275163606,9),o=l(o,s,r,n,e[3],4107603335,14),n=l(n,o,s,r,e[8],1163531501,20),r=l(r,n,o,s,e[13],2850285829,5),s=l(s,r,n,o,e[2],4243563512,9),o=l(o,s,r,n,e[7],1735328473,14),r=p(r,n=l(n,o,s,r,e[12],2368359562,20),o,s,e[5],4294588738,4),s=p(s,r,n,o,e[8],2272392833,11),o=p(o,s,r,n,e[11],1839030562,16),n=p(n,o,s,r,e[14],4259657740,23),r=p(r,n,o,s,e[1],2763975236,4),s=p(s,r,n,o,e[4],1272893353,11),o=p(o,s,r,n,e[7],4139469664,16),n=p(n,o,s,r,e[10],3200236656,23),r=p(r,n,o,s,e[13],681279174,4),s=p(s,r,n,o,e[0],3936430074,11),o=p(o,s,r,n,e[3],3572445317,16),n=p(n,o,s,r,e[6],76029189,23),r=p(r,n,o,s,e[9],3654602809,4),s=p(s,r,n,o,e[12],3873151461,11),o=p(o,s,r,n,e[15],530742520,16),r=f(r,n=p(n,o,s,r,e[2],3299628645,23),o,s,e[0],4096336452,6),s=f(s,r,n,o,e[7],1126891415,10),o=f(o,s,r,n,e[14],2878612391,15),n=f(n,o,s,r,e[5],4237533241,21),r=f(r,n,o,s,e[12],1700485571,6),s=f(s,r,n,o,e[3],2399980690,10),o=f(o,s,r,n,e[10],4293915773,15),n=f(n,o,s,r,e[1],2240044497,21),r=f(r,n,o,s,e[8],1873313359,6),s=f(s,r,n,o,e[15],4264355552,10),o=f(o,s,r,n,e[6],2734768916,15),n=f(n,o,s,r,e[13],1309151649,21),r=f(r,n,o,s,e[4],4149444226,6),s=f(s,r,n,o,e[11],3174756917,10),o=f(o,s,r,n,e[2],718787259,15),n=f(n,o,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+o|0,this._d=this._d+s|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=s.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},function(e,t){},function(e,t,r){"use strict";var n=r(2).Buffer,o=r(56);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,o,s=n.allocUnsafe(e>>>0),i=this.head,a=0;i;)t=i.data,r=s,o=a,t.copy(r,o),a+=i.data.length,i=i.next;return s},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function s(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new s(o.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new s(o.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(58),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(10))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,o,s,i,a,u=1,c={},l=!1,p=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){d(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){d(e.data)},n=function(e){s.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(o=p.documentElement,n=function(e){var t=p.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):n=function(e){setTimeout(d,0,e)}:(i="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(i)&&d(+t.data.slice(i.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),n=function(t){e.postMessage(i+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r>>32-t}function g(e,t,r,n,o,s,i,a){return d(e+(t^r^n)+s+i|0,a)+o|0}function m(e,t,r,n,o,s,i,a){return d(e+(t&r|~t&n)+s+i|0,a)+o|0}function b(e,t,r,n,o,s,i,a){return d(e+((t|~r)^n)+s+i|0,a)+o|0}function y(e,t,r,n,o,s,i,a){return d(e+(t&n|r&~n)+s+i|0,a)+o|0}function D(e,t,r,n,o,s,i,a){return d(e+(t^(r|~n))+s+i|0,a)+o|0}o(h,s),h.prototype._update=function(){for(var e=i,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,h=0|this._e,P=0|this._a,$=0|this._b,v=0|this._c,A=0|this._d,I=0|this._e,_=0;_<80;_+=1){var R,S;_<16?(R=g(r,n,o,s,h,e[a[_]],p[0],c[_]),S=D(P,$,v,A,I,e[u[_]],f[0],l[_])):_<32?(R=m(r,n,o,s,h,e[a[_]],p[1],c[_]),S=y(P,$,v,A,I,e[u[_]],f[1],l[_])):_<48?(R=b(r,n,o,s,h,e[a[_]],p[2],c[_]),S=b(P,$,v,A,I,e[u[_]],f[2],l[_])):_<64?(R=y(r,n,o,s,h,e[a[_]],p[3],c[_]),S=m(P,$,v,A,I,e[u[_]],f[3],l[_])):(R=D(r,n,o,s,h,e[a[_]],p[4],c[_]),S=g(P,$,v,A,I,e[u[_]],f[4],l[_])),r=h,h=s,s=d(o,10),o=n,n=R,P=I,I=A,A=d(v,10),v=$,$=S}var C=this._b+o+A|0;this._b=this._c+s+I|0,this._c=this._d+h+P|0,this._d=this._e+r+$|0,this._e=this._a+n+v|0,this._a=C},h.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=n.alloc?n.alloc(20):new n(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=h},function(e,t,r){(t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r}).sha=r(67),t.sha1=r(68),t.sha224=r(69),t.sha256=r(40),t.sha384=r(70),t.sha512=r(41)},function(e,t,r){var n=r(1),o=r(13),s=r(2).Buffer,i=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,o.call(this,64,56)}function c(e){return e<<30|e>>>2}function l(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,o),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,o=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,p=0;p<16;++p)r[p]=e.readInt32BE(4*p);for(;p<80;++p)r[p]=r[p-3]^r[p-8]^r[p-14]^r[p-16];for(var f=0;f<80;++f){var h=~~(f/20),d=0|((t=n)<<5|t>>>27)+l(h,o,s,a)+u+r[f]+i[h];u=a,a=s,s=c(o),o=n,n=d}this._a=n+this._a|0,this._b=o+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(1),o=r(13),s=r(2).Buffer,i=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,o.call(this,64,56)}function c(e){return e<<5|e>>>27}function l(e){return e<<30|e>>>2}function p(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,o),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,o=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=e.readInt32BE(4*f);for(;f<80;++f)r[f]=(t=r[f-3]^r[f-8]^r[f-14]^r[f-16])<<1|t>>>31;for(var h=0;h<80;++h){var d=~~(h/20),g=c(n)+p(d,o,s,a)+u+r[h]+i[d]|0;u=a,a=s,s=l(o),o=n,n=g}this._a=n+this._a|0,this._b=o+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(1),o=r(40),s=r(13),i=r(2).Buffer,a=new Array(64);function u(){this.init(),this._w=a,s.call(this,64,56)}n(u,o),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=i.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=u},function(e,t,r){var n=r(1),o=r(41),s=r(13),i=r(2).Buffer,a=new Array(160);function u(){this.init(),this._w=a,s.call(this,128,112)}n(u,o),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=i.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=u},function(e,t,r){var n=r(2).Buffer,o=r(35).Transform,s=r(25).StringDecoder;function i(e){o.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(1)(i,o),i.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var o=this._update(e);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},i.prototype.setAutoPadding=function(){},i.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},i.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},i.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},i.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},i.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},i.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},i.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new s(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},e.exports=i},function(e,t,r){"use strict";var n=r(73),o=r(2).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),o=e(r);if(!(n[0]^o[0]|n[1]^o[1]|n[2]^o[2]|n[3]^o[3]))return r}return{encode:function(t){var r=e(t);return n.encode(o.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){var n=r(74);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(e,t,r){"use strict";var n=r(2).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");var t=new Uint8Array(256);t.fill(255);for(var r=0;r>>0,l=new Uint8Array(c);e[r];){var p=t[e.charCodeAt(r)];if(255===p)return;for(var f=0,h=c-1;(0!==p||f>>0,l[h]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");s=f,r++}if(" "!==e[r]){for(var d=c-s;d!==c&&0===l[d];)d++;var g=n.allocUnsafe(o+(c-d));g.fill(0,0,o);for(var m=o;d!==c;)g[m++]=l[d++];return g}}}return{encode:function(t){if(!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,o=0,s=0,u=t.length;s!==u&&0===t[s];)s++,r++;for(var l=(u-s)*c+1>>>0,p=new Uint8Array(l);s!==u;){for(var f=t[s],h=0,d=l-1;(0!==f||h>>0,p[d]=f%i>>>0,f=f/i>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,s++}for(var g=l-o;g!==l&&0===p[g];)g++;for(var m=a.repeat(r);g=4294967296&&o++,e[t]=n,e[t+1]=o}function s(e,t,r,n){var o=e[t]+r;r<0&&(o+=4294967296);var s=e[t+1]+n;o>=4294967296&&s++,e[t]=o,e[t+1]=s}function i(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function a(e,t,r,n,i,a){var u=p[i],c=p[i+1],f=p[a],h=p[a+1];o(l,e,t),s(l,e,u,c);var d=l[n]^l[e],g=l[n+1]^l[e+1];l[n]=g,l[n+1]=d,o(l,r,n),d=l[t]^l[r],g=l[t+1]^l[r+1],l[t]=d>>>24^g<<8,l[t+1]=g>>>24^d<<8,o(l,e,t),s(l,e,f,h),d=l[n]^l[e],g=l[n+1]^l[e+1],l[n]=d>>>16^g<<16,l[n+1]=g>>>16^d<<16,o(l,r,n),d=l[t]^l[r],g=l[t+1]^l[r+1],l[t]=g>>>31^d<<1,l[t+1]=d>>>31^g<<1}var u=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),l=new Uint32Array(32),p=new Uint32Array(32);function f(e,t){var r=0;for(r=0;r<16;r++)l[r]=e.h[r],l[r+16]=u[r];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,t&&(l[28]=~l[28],l[29]=~l[29]),r=0;r<32;r++)p[r]=i(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,c[16*r+0],c[16*r+1]),a(2,10,18,26,c[16*r+2],c[16*r+3]),a(4,12,20,28,c[16*r+4],c[16*r+5]),a(6,14,22,30,c[16*r+6],c[16*r+7]),a(0,10,20,30,c[16*r+8],c[16*r+9]),a(2,12,22,24,c[16*r+10],c[16*r+11]),a(4,14,16,26,c[16*r+12],c[16*r+13]),a(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^l[r]^l[r+16]}function h(e,t){if(0===e||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e},n=0;n<16;n++)r.h[n]=u[n];var o=t?t.length:0;return r.h[0]^=16842752^o<<8^e,t&&(d(r,t),r.c=128),r}function d(e,t){for(var r=0;r>2]>>8*(3&r);return t}function m(e,t,r){r=r||64,e=n.normalizeInput(e);var o=h(r,t);return d(o,e),g(o)}e.exports={blake2b:m,blake2bHex:function(e,t,r){var o=m(e,t,r);return n.toHex(o)},blake2bInit:h,blake2bUpdate:d,blake2bFinal:g}},function(e,t,r){var n=r(42);function o(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function s(e,t,r,n,o,s){c[e]=c[e]+c[t]+o,c[n]=i(c[n]^c[e],16),c[r]=c[r]+c[n],c[t]=i(c[t]^c[r],12),c[e]=c[e]+c[t]+s,c[n]=i(c[n]^c[e],8),c[r]=c[r]+c[n],c[t]=i(c[t]^c[r],7)}function i(e,t){return e>>>t^e<<32-t}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),l=new Uint32Array(16);function p(e,t){var r=0;for(r=0;r<8;r++)c[r]=e.h[r],c[r+8]=a[r];for(c[12]^=e.t,c[13]^=e.t/4294967296,t&&(c[14]=~c[14]),r=0;r<16;r++)l[r]=o(e.b,4*r);for(r=0;r<10;r++)s(0,4,8,12,l[u[16*r+0]],l[u[16*r+1]]),s(1,5,9,13,l[u[16*r+2]],l[u[16*r+3]]),s(2,6,10,14,l[u[16*r+4]],l[u[16*r+5]]),s(3,7,11,15,l[u[16*r+6]],l[u[16*r+7]]),s(0,5,10,15,l[u[16*r+8]],l[u[16*r+9]]),s(1,6,11,12,l[u[16*r+10]],l[u[16*r+11]]),s(2,7,8,13,l[u[16*r+12]],l[u[16*r+13]]),s(3,4,9,14,l[u[16*r+14]],l[u[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=c[r]^c[r+8]}function f(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(h(n,t),n.c=64),n}function h(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}function g(e,t,r){r=r||32,e=n.normalizeInput(e);var o=f(r,t);return h(o,e),d(o)}e.exports={blake2s:g,blake2sHex:function(e,t,r){var o=g(e,t,r);return n.toHex(o)},blake2sInit:f,blake2sUpdate:h,blake2sFinal:d}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(21).compile({wspace:/[ \t]+/,lparen:"(",rparen:")",annot:/:[^ );]+|%[^ );]+/,parameter:"parameter",or:"or",pair:"pair",data:["bytes","int","nat","bool","string","timestamp","signature","key","key_hash","mutez","address","unit","operation","chain_id"],singleArgData:["option","list","contract","set"],doubleArgData:["lambda","map","big_map"],semicolon:";"}),o=e=>{let t=void 0,r=void 0;if(e.length>=3){const n=e[2].toString();"%"===n.charAt(0)?r=a(n):t=u(n)}if(5===e.length){const n=e[4].toString();n.startsWith("%")&&void 0===r&&(r=a(n)),n.startsWith(":")&&void 0===t&&(t=u(n))}return[{name:r,parameters:[{name:t||r,type:e[0].toString()}],structure:"$PARAM",generateInvocationString(...e){if(this.parameters.length!==e.length)throw new Error(`Incorrect number of parameters provided; expected ${this.parameters.length}, got ${e.length}`);let t=this.structure;for(let r=0;r{switch(e.type){case"string":return'"Tacos"';case"int":return-1;case"nat":return 99;case"address":return'"KT1EGbAxguaWQFkV3Egb2Z1r933MWuEYyrJS"';case"key_hash":return'"tz1SQnJaocpquTztY3zMgydTPoQBBQrDGonJ"';case"timestamp":return`"${(new Date).toISOString()}"`;case"mutez":return 5e5;case"unit":return"Unit";case"bytes":case"bool":case"signature":case"key":case"operation":case"chain_id":default:return e.type}});return this.generateInvocationString(...e)}}]},s=(...e)=>{const t=e.find(e=>e.startsWith("%"));return t?a(t):void 0},i=(...e)=>{const t=e.find(e=>e.startsWith(":"));return t?u(t):void 0},a=e=>{if(!e.startsWith("%"))throw new Error(e+" must start with '%'");return e.replace(/^%_Liq_entry_/,"").replace("%","")},u=e=>{if(!e.startsWith(":"))throw new Error(e+" must start with ':'");return e.replace(":","")},c={Lexer:n,ParserRules:[{name:"entry",symbols:[n.has("parameter")?{type:"parameter"}:parameter,"__","parameters","_",n.has("semicolon")?{type:"semicolon"}:semicolon],postprocess:e=>e[2]},{name:"parameters",symbols:[n.has("lparen")?{type:"lparen"}:lparen,"_","parameters","_",n.has("rparen")?{type:"rparen"}:rparen],postprocess:e=>e[2]},{name:"parameters",symbols:[n.has("or")?{type:"or"}:or,"_",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{e[2],e[4];const t=e[6],r=e[8],n=[];for(const e of t){const t={name:e.name,parameters:e.parameters,structure:"(Left "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};n.push(t)}for(const e of r){const t={name:e.name,parameters:e.parameters,structure:"(Right "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};n.push(t)}return n}},{name:"parameters",symbols:[n.has("or")?{type:"or"}:or,"_",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=e[6],o=[];for(const e of r){const r={name:`${t}.${e.name}`,parameters:e.parameters,structure:"(Left "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};o.push(r)}for(const e of n){const r={name:`${t}.${e.name}`,parameters:e.parameters,structure:"(Right "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};o.push(r)}return o}},{name:"parameters",symbols:[n.has("or")?{type:"or"}:or,"_","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=[];for(const e of t)1===e.parameters.length&&e.parameters[0].name===e.name&&(e.parameters[0].name=void 0),n.push(Object.assign(Object.assign({},e),{structure:`(Left ${e.structure})`}));for(const e of r)1===e.parameters.length&&e.parameters[0].name===e.name&&(e.parameters[0].name=void 0),n.push(Object.assign(Object.assign({},e),{structure:`(Right ${e.structure})`}));return n}},{name:"parameters",symbols:[n.has("pair")?{type:"pair"}:pair,"__",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=e[6],o=e[8],s=[];for(const e of n)for(const n of o){const o={name:i(t.toString(),r.toString()),parameters:e.parameters.concat(n.parameters),structure:`(Pair ${e.structure} ${n.structure})`,generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};s.push(o)}return s}},{name:"parameters",symbols:[n.has("pair")?{type:"pair"}:pair,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=e[6],o=[];for(const e of r)for(const r of n){const n={name:i(t.toString())||s(t.toString())||void 0,parameters:e.parameters.concat(r.parameters),structure:`(Pair ${e.structure} ${r.structure})`,generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};o.push(n)}return o}},{name:"parameters",symbols:[n.has("pair")?{type:"pair"}:pair,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=[];for(const e of t)for(const t of r){const r={name:void 0,parameters:e.parameters.concat(t.parameters),structure:`(Pair ${e.structure} ${t.structure})`,generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};n.push(r)}return n}},{name:"parameters",symbols:[n.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4].toString(),o=e[6];return o[0].name=s(r,n),o[0].parameters[0].constituentType=o[0].parameters[0].type,"option"===t&&(o[0].parameters[0].optional=!0),o[0].parameters[0].type=`${t} (${o[0].parameters[0].type})`,o[0].structure=`(${o[0].structure})`,o}},{name:"parameters",symbols:[n.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4];return n[0].name=s(r),n[0].parameters[0].constituentType=n[0].parameters[0].type,"option"===t&&(n[0].parameters[0].optional=!0),n[0].parameters[0].type=`${t} (${n[0].parameters[0].type})`,n[0].structure=`(${n[0].structure})`,n}},{name:"parameters",symbols:[n.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2];return r[0].parameters[0].constituentType=r[0].parameters[0].type,"option"===t&&(r[0].parameters[0].optional=!0),r[0].parameters[0].type=`${t} (${r[0].parameters[0].type})`,r[0].structure=`(${r[0].structure})`,r}},{name:"parameters",symbols:[n.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4].toString(),o=e[6],i=e[8];return o[0].name=s(r,n),o[0].parameters[0].type=`${t} (${o[0].parameters[0].type}) (${i[0].parameters[0].type})`,o[0].structure=`(${o[0].structure})`,o}},{name:"parameters",symbols:[n.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4],o=e[6];return n[0].name=s(r),n[0].parameters[0].type=`${t} (${n[0].parameters[0].type}) (${o[0].parameters[0].type})`,n[0].structure=`(${n[0].structure})`,n}},{name:"parameters",symbols:[n.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_","parameters","__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2],n=e[4];return r[0].parameters[0].type=`${t} (${r[0].parameters[0].type}) (${n[0].parameters[0].type})`,r[0].structure=`(${r[0].structure})`,r}},{name:"parameters",symbols:[n.has("data")?{type:"data"}:data,"__",n.has("annot")?{type:"annot"}:annot],postprocess:o},{name:"parameters",symbols:[n.has("data")?{type:"data"}:data,"__",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot],postprocess:o},{name:"parameters",symbols:[n.has("data")?{type:"data"}:data],postprocess:o},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1",/[\s]/],postprocess:e=>e[0].concat([e[1]])},{name:"_",symbols:["_$ebnf$1"]},{name:"__",symbols:[/[\s]/]}],ParserStart:"entry"};t.default=c},function(module,exports){var indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0;r{const r=s.get(t)||"";return e[r]>t?e:Object.assign(Object.assign({},e),{[r]:t})},new Map);!function(t){function r(e){return s.get(n.TezosMessageUtils.readInt(e))||""}function a(e){return r(e.substring(64,66))}function u(e,t,r=!0){switch(t){case"endorsement":case"seedNonceRevelation":case"doubleEndorsementEvidence":case"doubleBakingEvidence":case"accountActivation":case"proposal":throw new Error("Unsupported operation type: "+t);case"ballot":return l(e,r);case"reveal":return f(e,r);case"transaction":return d(e,r);case"origination":return m(e,r);case"delegation":return y(e,r);default:throw new Error("Unsupported operation type: "+t)}}function c(e){let t=n.TezosMessageUtils.writeInt(i.accountActivation);return t+=n.TezosMessageUtils.writeAddress(e.pkh).slice(4),t+=e.secret,t}function l(t,o=!0){if("ballot"!==r(o?t.substring(64,66):t.substring(0,2)))throw new Error("Provided operation is not a ballot");let s=0,i="";o?(i=n.TezosMessageUtils.readBranch(t.substring(s,s+64)),s+=66):s+=2;const a=n.TezosMessageUtils.readAddress(t.substring(s,s+42));s+=42;const u=parseInt(t.substring(s,s+8),16);s+=8;const c=n.TezosMessageUtils.readBufferWithHint(e.from(t.substring(s,s+64),"hex"),"p");s+=64;const l=parseInt(t.substring(s,s+1),16);let p;s+=2,t.length>s&&(p=r(t.substring(s,s+2)));return{operation:{kind:"ballot",source:a,period:u,proposal:c,vote:l},branch:i,next:p,nextoffset:p?s:-1}}function p(e){let t=n.TezosMessageUtils.writeInt(i.ballot);return t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=("00000000"+e.period.toString(16)).slice(-8),t+=n.TezosMessageUtils.writeBufferWithHint(e.proposal).toString("hex").slice(4),t+=("00"+e.vote.toString(16)).slice(-2),t}function f(e,t=!0){let o=t?e.substring(64,66):e.substring(0,2);if("reveal"!==r(o))throw new Error("Provided operation is not a reveal.");let s=0,i="";t?(i=n.TezosMessageUtils.readBranch(e.substring(s,s+64)),s+=66):s+=2;let a="";parseInt(o,16)<100?(a=n.TezosMessageUtils.readAddress(e.substring(s,s+44)),s+=44):(a=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42);let u=n.TezosMessageUtils.findInt(e,s);s+=u.length;let c=n.TezosMessageUtils.findInt(e,s);s+=c.length;let l=n.TezosMessageUtils.findInt(e,s);s+=l.length;let p=n.TezosMessageUtils.findInt(e,s);s+=p.length;let f,h=n.TezosMessageUtils.readPublicKey(e.substring(s,s+66));s+=66,e.length>s&&(f=r(e.substring(s,s+2)));return{operation:{kind:"reveal",source:a,public_key:h,fee:u.value+"",gas_limit:l.value+"",storage_limit:p.value+"",counter:c.value+""},branch:i,next:f,nextoffset:f?s:-1}}function h(e){if("reveal"!==e.kind)throw new Error("Incorrect operation type.");let t=n.TezosMessageUtils.writeInt(i.reveal);return t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),t+=n.TezosMessageUtils.writePublicKey(e.public_key),t}function d(t,s=!0){let i=s?t.substring(64,66):t.substring(0,2);if("transaction"!==r(i))throw new Error("Provided operation is not a transaction.");let a=0,u="";s?(u=n.TezosMessageUtils.readBranch(t.substring(a,a+64)),a+=66):a+=2;let c="";parseInt(i,16)<100?(c=n.TezosMessageUtils.readAddress(t.substring(a,a+44)),a+=44):(c=n.TezosMessageUtils.readAddress(t.substring(a,a+42)),a+=42);let l=n.TezosMessageUtils.findInt(t,a);a+=l.length;let p=n.TezosMessageUtils.findInt(t,a);a+=p.length;let f=n.TezosMessageUtils.findInt(t,a);a+=f.length;let h=n.TezosMessageUtils.findInt(t,a);a+=h.length;let d=n.TezosMessageUtils.findInt(t,a);a+=d.length;let g=n.TezosMessageUtils.readAddress(t.substring(a,a+44));a+=44;let m=n.TezosMessageUtils.readBoolean(t.substring(a,a+2));a+=2;let b,y="";if(m&&parseInt(i,16)<100){const e=parseInt(t.substring(a,a+8),16);a+=8;const r=o.TezosLanguageUtil.hexToMicheline(t.substring(a));if(y=r.code,r.consumed!==2*e)throw new Error("Failed to parse transaction parameters: length mismatch");a+=2*e}else if(m&&parseInt(i,16)>100){const r=parseInt(t.substring(a,a+2),16);a+=2;let n="";if(255===r){const r=parseInt(t.substring(a,a+2),16);a+=2,n=e.from(t.substring(a,a+2*r),"hex").toString(),a+=2*r}else 0===r?n="default":1===r?n="root":2===r?n="do":3===r?n="set_delegate":4===r&&(n="remove_delegate");const s=parseInt(t.substring(a,a+8),16);a+=8;const i=o.TezosLanguageUtil.hexToMicheline(t.substring(a)),u=i.code;if(i.consumed!==2*s)throw new Error("Failed to parse transaction parameters: length mismatch");a+=2*s,y={entrypoint:n,value:u}}t.length>a&&(b=r(t.substring(a,a+2)));return{operation:{kind:"transaction",source:c,destination:g,amount:d.value.toString(),fee:l.value.toString(),gas_limit:f.value.toString(),storage_limit:h.value.toString(),counter:p.value.toString(),parameters:y},branch:u,next:b,nextoffset:b?a:-1}}function g(e){if("transaction"!==e.kind)throw new Error("Incorrect operation type");let t=n.TezosMessageUtils.writeInt(i.transaction);if(t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.amount)),t+=n.TezosMessageUtils.writeAddress(e.destination),e.parameters){const r=e.parameters,n=o.TezosLanguageUtil.normalizeMichelineWhiteSpace(JSON.stringify(r.value)),s=o.TezosLanguageUtil.translateMichelineToHex(n);"default"!==r.entrypoint&&""!==r.entrypoint||"030b"!==s?(t+="ff","default"===r.entrypoint||""===r.entrypoint?t+="00":"root"===r.entrypoint?t+="01":"do"===r.entrypoint?t+="02":"set_delegate"===r.entrypoint?t+="03":"remove_delegate"===r.entrypoint?t+="04":t+="ff"+("0"+r.entrypoint.length.toString(16)).slice(-2)+r.entrypoint.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),t+="030b"===s?"00":("0000000"+(s.length/2).toString(16)).slice(-8)+s):t+="00"}else t+="00";return t}function m(e,t=!0){let s=t?e.substring(64,66):e.substring(0,2);if("origination"!==r(s))throw new Error("Provided operation is not an origination.");let i=0,a="";t?(a=n.TezosMessageUtils.readBranch(e.substring(i,i+64)),i+=66):i+=2;let u="";parseInt(s,16)<100?(u=n.TezosMessageUtils.readAddress(e.substring(i,i+44)),i+=44):(u=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let c=n.TezosMessageUtils.findInt(e,i);i+=c.length;let l=n.TezosMessageUtils.findInt(e,i);i+=l.length;let p=n.TezosMessageUtils.findInt(e,i);i+=p.length;let f=n.TezosMessageUtils.findInt(e,i);i+=f.length;let h="";parseInt(s,16)<100&&(h=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let d=n.TezosMessageUtils.findInt(e,i);i+=d.length;let g=!1,m=!1;parseInt(s,16)<100&&(g=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2,m=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2);let b=n.TezosMessageUtils.readBoolean(e.substring(i,i+2));i+=2;let y="";b&&(y=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let D=!0;parseInt(s,16)<100&&(D=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2);let P,$={};if(D){let t=parseInt(e.substring(i,i+8),16);i+=8;const r=o.TezosLanguageUtil.hexToMicheline(e.substring(i,i+2*t)).code;i+=2*t;let n=parseInt(e.substring(i,i+8),16);i+=8;const s=o.TezosLanguageUtil.hexToMicheline(e.substring(i,i+2*n)).code;i+=2*n,$=JSON.parse(`{ "script": [ ${r}, ${s} ] }`)}e.length>i&&(P=r(e.substring(i,i+2)));let v={kind:"origination",source:u,balance:d.value+"",delegate:b?y:void 0,fee:c.value+"",gas_limit:p.value+"",storage_limit:f.value+"",counter:l.value+"",script:D?$:void 0};parseInt(s,16)<100&&(v.manager_pubkey=h,v.spendable=g,v.delegatable=m);return{operation:v,branch:a,next:P,nextoffset:P?i:-1}}function b(e){if("origination"!==e.kind)throw new Error("Incorrect operation type");let t=n.TezosMessageUtils.writeInt(i.origination);if(t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.balance)),void 0!==e.delegate?(t+=n.TezosMessageUtils.writeBoolean(!0),t+=n.TezosMessageUtils.writeAddress(e.delegate).slice(2)):t+=n.TezosMessageUtils.writeBoolean(!1),e.script){let r=[];r.push(e.script.code),r.push(e.script.storage),t+=r.map(e=>o.TezosLanguageUtil.normalizeMichelineWhiteSpace(JSON.stringify(e))).map(e=>o.TezosLanguageUtil.translateMichelineToHex(e)).reduce((e,t)=>e+(("0000000"+(t.length/2).toString(16)).slice(-8)+t),"")}return t}function y(e,t=!0){let o=t?e.substring(64,66):e.substring(0,2);if("delegation"!==r(o))throw new Error("Provided operation is not a delegation.");let s=0,i="";t?(i=n.TezosMessageUtils.readBranch(e.substring(s,s+64)),s+=66):s+=2;let a="";parseInt(o,16)<100?(a=n.TezosMessageUtils.readAddress(e.substring(s,s+44)),s+=44):(a=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42);let u=n.TezosMessageUtils.findInt(e,s);s+=u.length;let c=n.TezosMessageUtils.findInt(e,s);s+=c.length;let l=n.TezosMessageUtils.findInt(e,s);s+=l.length;let p=n.TezosMessageUtils.findInt(e,s);s+=p.length;let f=n.TezosMessageUtils.readBoolean(e.substring(s,s+2));s+=2;let h,d="";f&&(d=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42),e.length>s&&(h=r(e.substring(s,s+2)));return{operation:{kind:"delegation",source:a,delegate:f?d:void 0,fee:u.value+"",gas_limit:l.value+"",storage_limit:p.value+"",counter:c.value+""},branch:i,next:h,nextoffset:h?s:-1}}function D(e){if("delegation"!==e.kind)throw new Error("Incorrect operation type");let t=n.TezosMessageUtils.writeInt(i.delegation);return t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),void 0!==e.delegate&&""!==e.delegate?(t+=n.TezosMessageUtils.writeBoolean(!0),t+=n.TezosMessageUtils.writeAddress(e.delegate).slice(2)):t+=n.TezosMessageUtils.writeBoolean(!1),t}t.getOperationType=r,t.idFirstOperation=a,t.parseOperation=u,t.encodeOperation=function(e){if(e.hasOwnProperty("pkh")&&e.hasOwnProperty("secret"))return c(e);if(e.hasOwnProperty("kind")){const t=e;if("reveal"===t.kind)return h(e);if("transaction"===t.kind)return g(e);if("origination"===t.kind)return b(e);if("delegation"===t.kind)return D(e)}if(e.hasOwnProperty("vote"))return p(e);throw new Error("Unsupported message type")},t.encodeActivation=c,t.parseBallot=l,t.encodeBallot=p,t.parseReveal=f,t.encodeReveal=h,t.parseTransaction=d,t.encodeTransaction=g,t.parseOrigination=m,t.encodeOrigination=b,t.parseDelegation=y,t.encodeDelegation=D,t.parseOperationGroup=function(e){let t=[],r=u(e,a(e));t.push(r.operation);let n=0;for(;r.next;)n+=r.nextoffset,r=u(e.substring(n),r.next,!1),t.push(r.operation);return t}}(t.TezosMessageCodec||(t.TezosMessageCodec={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(19),i=r(3),a=r(7),u=o(r(12)).default.log;class c{constructor(e,t,r,n){this.triggerTimestamp=0,this.server=e,this.keyStore=r,this.signer=t,this.delay=n,this.operations=[]}static createQueue(e,t,r,n=s.TezosConstants.DefaultBatchDelay){return new c(e,t,r,n)}addOperations(...e){0===this.operations.length&&(this.triggerTimestamp=Date.now(),setTimeout(()=>{this.sendOperations()},1e3*this.delay)),e.forEach(e=>this.operations.push(e))}getStatus(){return this.operations.length}sendOperations(){return n(this,void 0,void 0,(function*(){let e=(yield i.TezosNodeReader.getCounterForAccount(this.server,this.keyStore.publicKeyHash))+1,t=[];const r=this.operations.length;for(let n=0;n0&&(this.triggerTimestamp=Date.now(),setTimeout(()=>{this.sendOperations()},1e3*this.delay));try{yield a.TezosNodeWriter.sendOperation(this.server,t,this.signer)}catch(e){u.error("Error sending queued operations: "+e)}}))}}t.TezosOperationQueue=c},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(19),u=r(3),c=r(7),l=r(8);!function(e){function t(e,t,r,n,o,s,u){let l=`[ { "prim": "DROP" },\n { "prim": "NIL", "args": [ { "prim": "operation" } ] },\n { "prim": "PUSH", "args": [ { "prim": "key_hash" }, { "string": "${u}" } ] },\n { "prim": "IMPLICIT_ACCOUNT" },\n { "prim": "PUSH", "args": [ { "prim": "mutez" }, { "int": "${s}" } ] },\n { "prim": "UNIT" },\n { "prim": "TRANSFER_TOKENS" },\n { "prim": "CONS" } ]`;return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,0,o,a.TezosConstants.P005ManagerContractWithdrawalStorageLimit,a.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",l,i.TezosParameterFormat.Micheline)}e.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"d99cb8b4c7e40166f59c0f3c30724225")}))},e.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"a585489ffaee60d07077059539d5bfc8")},e.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{administrator:s.JSONPath({path:"$.string",json:r})[0]}}))},e.setDelegate=function(e,t,r,n,o,s){if(n.startsWith("KT1")){const u=`[{ "prim": "DROP" }, { "prim": "NIL", "args": [{ "prim": "operation" }] }, { "prim": "PUSH", "args": [{ "prim": "key_hash" }, { "string": "${o}" } ] }, { "prim": "SOME" }, { "prim": "SET_DELEGATE" }, { "prim": "CONS" } ]`;return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,0,s,0,a.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",u,i.TezosParameterFormat.Micheline)}return c.TezosNodeWriter.sendDelegationOperation(e,t,r,o,s)},e.unSetDelegate=function(e,t,r,n,o){if(n.startsWith("KT1")){const s='[{ "prim": "DROP" }, { "prim": "NIL", "args": [{ "prim": "operation" }] }, { "prim": "NONE", "args": [{ "prim": "key_hash" }] }, { "prim": "SET_DELEGATE" }, { "prim": "CONS" } ]';return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,0,o,0,a.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",s,i.TezosParameterFormat.Micheline)}return c.TezosNodeWriter.sendUndelegationOperation(e,t,r,o)},e.withdrawDelegatedFunds=function(e,r,n,o,s,i){return t(e,r,n,o,s,i,n.publicKeyHash)},e.sendDelegatedFunds=t,e.depositDelegatedFunds=function(e,t,r,n,o,s){return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,s,o,0,a.TezosConstants.P005ManagerContractDepositGasLimit,void 0,void 0)},e.deployManagerContract=function(e,t,r,n,o,s){const a=`{ "string": "${r.publicKeyHash}" }`;return c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,s,n,o,600,2e4,'[ { "prim": "parameter",\n "args":\n [ { "prim": "or",\n "args":\n [ { "prim": "lambda",\n "args":\n [ { "prim": "unit" }, { "prim": "list", "args": [ { "prim": "operation" } ] } ], "annots": [ "%do" ] },\n { "prim": "unit", "annots": [ "%default" ] } ] } ] },\n { "prim": "storage", "args": [ { "prim": "key_hash" } ] },\n { "prim": "code",\n "args":\n [ [ [ [ { "prim": "DUP" }, { "prim": "CAR" },\n { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ],\n { "prim": "IF_LEFT",\n "args":\n [ [ { "prim": "PUSH", "args": [ { "prim": "mutez" }, { "int": "0" } ] },\n { "prim": "AMOUNT" },\n [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ],\n { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" }, { "prim": "FAILWITH" } ] ] ] } ],\n [ { "prim": "DIP", "args": [ [ { "prim": "DUP" } ] ] },\n { "prim": "SWAP" } ],\n { "prim": "IMPLICIT_ACCOUNT" },\n { "prim": "ADDRESS" },\n { "prim": "SENDER" },\n [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ],\n { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" },{ "prim": "FAILWITH" } ] ] ] } ],\n { "prim": "UNIT" }, { "prim": "EXEC" },\n { "prim": "PAIR" } ],\n [ { "prim": "DROP" },\n { "prim": "NIL", "args": [ { "prim": "operation" } ] },\n { "prim": "PAIR" } ] ] } ] ] } ]',a,i.TezosParameterFormat.Micheline)}}(t.BabylonDelegationHelper||(t.BabylonDelegationHelper={}))},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(8),p=r(5);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"c020219e31ee3b462ed93c33124f117f")}))},t.commitName=function(t,r,o,s,u,f,h,d,g){return n(this,void 0,void 0,(function*(){const n=`(Pair "${u}" (Pair ${f} 0x${a.TezosMessageUtils.writeAddress(o.publicKeyHash)}))`,m=a.TezosMessageUtils.writePackedData(n,"record",p.TezosParameterFormat.Michelson),b="0x"+a.TezosMessageUtils.simpleHash(e.from(m,"hex"),32).toString("hex");if(!d||!g){const e=yield c.TezosNodeWriter.testContractInvocationOperation(t,"main",o,s,0,h,6e3,5e5,"commit",b,i.TezosParameterFormat.Michelson);d||(d=Number(e.storageCost)||0),g||(g=Number(e.gas)+300)}const y=yield c.TezosNodeWriter.sendContractInvocationOperation(t,r,o,s,0,h,6e3,3e5,"commit",b,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(y.operationGroupID)}))},t.registerName=function(e,t,r,o,s,a,u,p,f,h,d){return n(this,void 0,void 0,(function*(){const n=`(Pair ${u} (Pair "${s}" ${a}))`;if(!h||!d){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,p,f,6e3,5e5,"registerName",n,i.TezosParameterFormat.Michelson);h||(h=Number(t.storageCost)||0),d||(d=Number(t.gas)+300)}const g=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,p,f,6e3,3e5,"registerName",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(g.operationGroupID)}))},t.updateRegistrationPeriod=function(e,t,r,o,s,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Pair "${s}" ${a})`;if(!f||!h){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,u,p,1e3,1e5,"updateRegistrationPeriod",n,i.TezosParameterFormat.Michelson);f||(f=Number(t.storageCost)||0),h||(h=Number(t.gas)+300)}const d=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,u,p,f,h,"updateRegistrationPeriod",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))},t.setPrimaryName=function(e,t,r,o,s,a,u,p){return n(this,void 0,void 0,(function*(){const n=`"${s}"`;if(!u||!p){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,0,a,1e3,1e5,"setPrimaryName",n,i.TezosParameterFormat.Michelson);u||(u=Number(t.storageCost)||0),p||(p=Number(t.gas)+300)}const f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,a,u,p,"deleteName",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.deleteName=function(e,t,r,o,s,a,u,p){return n(this,void 0,void 0,(function*(){const n=`"${s}"`;if(!u||!p){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,0,a,1e3,1e5,"deleteName",n,i.TezosParameterFormat.Michelson);u||(u=Number(t.storageCost)||0),p||(p=Number(t.gas)+300)}const f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,a,u,p,"deleteName",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.getNameForAddress=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex"));try{const e=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);return s.JSONPath({path:"$.string",json:e})[0]}catch(e){}return""}))},t.getNameInfo=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"string"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);return{name:s.JSONPath({path:"$.args[0].args[1].string",json:i})[0],modified:Boolean(s.JSONPath({path:"$.args[0].args[0].prim",json:i})[0]),owner:s.JSONPath({path:"$.args[1].args[0].string",json:i})[0],registeredAt:new Date(s.JSONPath({path:"$.args[1].args[1].args[0].string",json:i})[0]),registrationPeriod:s.JSONPath({path:"$.args[1].args[1].args[1].int",json:i})[0]}}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{addressMap:Number(s.JSONPath({path:"$.args[0].args[0].args[0].int",json:r})[0]),commitmentMap:Number(s.JSONPath({path:"$.args[0].args[0].args[1].int",json:r})[0]),manager:s.JSONPath({path:"$.args[0].args[1].args[0].string",json:r})[0],interval:Number(s.JSONPath({path:"$.args[0].args[1].args[1].int",json:r})[0]),maxCommitTime:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),maxDuration:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),minCommitTime:Number(s.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),nameMap:Number(s.JSONPath({path:"$.args[1].args[1].args[1].args[0].int",json:r})[0]),intervalFee:Number(s.JSONPath({path:"$.args[1].args[1].args[1].args[1].int",json:r})[0])}}))}}(t.CryptonomicNameServiceHelper||(t.CryptonomicNameServiceHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(16)),i=r(6),a=r(4),u=r(3);!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeReader.getAccountForBlock(t,"head",r);if(!n.script)throw new Error("No code found at "+r);if("1234"!==e.from(s.blake2s(n.script.toString(),null,16)).toString("hex"))throw new Error(`Contract at ${r} does not match the expected code hash`);return!0}))},t.getBasicStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return console.log("-----"),console.log(r),console.log("-----"),{mapid:Number(i.JSONPath({path:"$.args[0].int",json:r})[0]),totalSupply:Number(i.JSONPath({path:"$.args[1].int",json:r})[0])}}))},t.getAddressRecord=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex")),s=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(s)return{allowances:i.JSONPath({path:"$.args[0]",json:s})[0],balance:Number(i.JSONPath({path:"$.args[1].int",json:s})[0])}}))},t.deployContract=function(e,t,r){return n(this,void 0,void 0,(function*(){}))}}(t.DexterTokenHelper||(t.DexterTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(3),u=r(7),c=r(8);!function(e){e.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return c.TezosContractUtils.verifyDestination(e,t,"914629850cfdad7b54a8c5a661d10bd0")}))},e.verifyScript=function(e){return c.TezosContractUtils.verifyScript(e,"ffcad1e376a6c8915780fe6676aceec6")},e.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield a.TezosNodeReader.getContractStorage(e,t);return{counter:Number(s.JSONPath({path:"$.args[0].int",json:r})[0]),threshold:Number(s.JSONPath({path:"$.args[1].args[0].int",json:r})[0]),keys:s.JSONPath({path:"$.args[1].args[1]..string",json:r})}}))},e.deployContract=function(e,t,r,o,s,a,l,p,f){return n(this,void 0,void 0,(function*(){if(p>f.length)throw new Error("Number of keys provided is lower than the threshold");const n=`(Pair ${l} (Pair ${p} { "${f.join('" ; "')}" } ) )`,h=yield u.TezosNodeWriter.sendContractOriginationOperation(e,t,r,a,o,s,5e3,12e4,"parameter (pair (pair :payload (nat %counter) (or :action (pair :transfer (mutez %amount) (contract %dest unit)) (or (option %delegate key_hash) (pair %change_keys (nat %threshold) (list %keys key))))) (list %sigs (option signature)));\n storage (pair (nat %stored_counter) (pair (nat %threshold) (list %keys key)));\n code { UNPAIR ; SWAP ; DUP ; DIP { SWAP } ; DIP { UNPAIR ; DUP ; SELF ; ADDRESS ; CHAIN_ID ; PAIR ; PAIR ; PACK ; DIP { UNPAIR @counter ; DIP { SWAP } } ; SWAP } ; UNPAIR @stored_counter; DIP { SWAP }; ASSERT_CMPEQ ; DIP { SWAP } ; UNPAIR @threshold @keys; DIP { PUSH @valid nat 0; SWAP ; ITER { DIP { SWAP } ; SWAP ; IF_CONS { IF_SOME { SWAP ; DIP { SWAP ; DIIP { DUUP } ; CHECK_SIGNATURE ; ASSERT ; PUSH nat 1 ; ADD @valid } } { SWAP ; DROP } } { FAIL } ; SWAP } } ; ASSERT_CMPLE ; DROP ; DROP ; DIP { UNPAIR ; PUSH nat 1 ; ADD @new_counter ; PAIR} ; NIL operation ; SWAP ; IF_LEFT { UNPAIR ; UNIT ; TRANSFER_TOKENS ; CONS } { IF_LEFT { SET_DELEGATE ; CONS } { DIP { SWAP ; CAR } ; SWAP ; PAIR ; SWAP }} ; PAIR }",n,i.TezosParameterFormat.Michelson);return c.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},e.changeKeys=function(){return n(this,void 0,void 0,(function*(){}))},e.transfer=function(){return n(this,void 0,void 0,(function*(){}))},e.setDelegate=function(){return n(this,void 0,void 0,(function*(){}))},e.sign=function(){return n(this,void 0,void 0,(function*(){}))}}(t.MurbardMultisigHelper||(t.MurbardMultisigHelper={}))},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(8);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"0e3e137841a959521324b4ce20ca2df7")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"b77ada691b1d630622bea243696c84d7")},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===i)throw new Error(`Map ${r} does not contain a record for ${o}`);return Number(s.JSONPath({path:"$.int",json:i})[0])}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(s.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),council:s.JSONPath({path:"$.args[0].args[0].args[1]..string",json:r}),stage:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),phase:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0])%4,supply:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),paused:s.JSONPath({path:"$.args[1].args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}}))},t.transferBalance=function(e,t,r,o,s,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Right (Left (Left (Right (Pair "${a}" (Pair "${u}" ${p}))))))`,d=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,h,f,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))}}(t.StakerDAOTokenHelper||(t.StakerDAOTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(16)),i=r(6),a=r(4),u=r(3);!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeReader.getAccountForBlock(t,"head",r);if(!n.script)throw new Error("No code found at "+r);if("1527ddf08bdf582dce0b28c051044897"!==e.from(s.blake2s(n.script.toString(),null,16)).toString("hex"))throw new Error(`Contract at ${r} does not match the expected code hash`);return!0}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{mapid:parseInt(i.JSONPath({path:"$.args[0].int",json:r})[0]),owner:i.JSONPath({path:"$.args[1].args[0].string",json:r})[0],signupFee:parseInt(i.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),updateFee:parseInt(i.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}}))},t.updateRegistration=function(e,t,r,o,s,i,a){return n(this,void 0,void 0,(function*(){}))},t.queryRegistration=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"key_hash"),"hex")),s=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(!s)return;const c=new TextDecoder,l=Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[0].args[1].int",json:s})[0]);return{name:c.decode(e.from(i.JSONPath({path:"$.args[0].args[0].args[0].args[0].args[0].args[0].bytes",json:s})[0],"hex")),isAcceptingDelegation:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[0].args[0].args[1].prim",json:s})[0]),externalDataURL:c.decode(e.from(i.JSONPath({path:"$.args[0].args[0].args[0].args[0].args[1].bytes",json:s})[0],"hex")),split:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[0].args[0].int",json:s})[0])/1e4,paymentAccounts:i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[0].args[1]..string",json:s}),minimumDelegation:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[0].args[0].int",json:s})[0]),isGreedy:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[0].args[1].prim",json:s})[0]),payoutDelay:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[1].args[0].int",json:s})[0]),payoutFrequency:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[1].args[1].args[0].int",json:s})[0]),minimumPayout:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[1].args[1].args[1].int",json:s})[0]),isCheap:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[0].args[0].prim",json:s})[0]),paymentConfig:{payForOwnBlocks:Boolean(1&l),payForEndorsements:Boolean(2&l),payGainedFees:Boolean(4&l),payForAccusationGains:Boolean(8&l),subtractLostDepositsWhenAccused:Boolean(16&l),subtractLostRewardsWhenAccused:Boolean(32&l),subtractLostFeesWhenAccused:Boolean(64&l),payForRevelation:Boolean(128&l),subtractLostRewardsWhenMissRevelation:Boolean(256&l),subtractLostFeesWhenMissRevelation:Boolean(512&l),compensateMissedBlocks:!Boolean(1024&l),payForStolenBlocks:Boolean(2048&l),compensateMissedEndorsements:!Boolean(4096&l),compensateLowPriorityEndorsementLoss:!Boolean(8192&l)},overdelegationThreshold:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[1].args[0].int",json:s})[0]),subtractRewardsFromUninvitedDelegation:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[1].args[1].prim",json:s})[0]),recordManager:i.JSONPath({path:"$.args[0].args[1].args[0].string",json:s})[0],timestamp:new Date(i.JSONPath({path:"$.args[1].string",json:s})[0])}}))}}(t.TCFBakerRegistryHelper||(t.TCFBakerRegistryHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(8);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"0e3e137841a959521324b4ce20ca2df7")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"b77ada691b1d630622bea243696c84d7")},t.deployContract=function(e,t,r,o,s,a=!0,u=0,p=15e4,f=5e3){return n(this,void 0,void 0,(function*(){const n=`Pair {} (Pair "${s}" (Pair ${a?"True":"False"} ${u}))`,h=yield c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,f,p,'parameter (or (or (or (pair %transfer (address :from) (pair (address :to) (nat :value))) (pair %approve (address :spender) (nat :value))) (or (pair %getAllowance (pair (address :owner) (address :spender)) (contract nat)) (or (pair %getBalance (address :owner) (contract nat)) (pair %getTotalSupply unit (contract nat))))) (or (or (bool %setPause) (address %setAdministrator)) (or (pair %getAdministrator unit (contract address)) (or (pair %mint (address :to) (nat :value)) (pair %burn (address :from) (nat :value))))));\n storage (pair (big_map %ledger (address :user) (pair (nat :balance) (map :approvals (address :spender) (nat :value)))) (pair (address %admin) (pair (bool %paused) (nat %totalSupply))));\n code { CAST (pair (or (or (or (pair address (pair address nat)) (pair address nat)) (or (pair (pair address address) (contract nat)) (or (pair address (contract nat)) (pair unit (contract nat))))) (or (or bool address) (or (pair unit (contract address)) (or (pair address nat) (pair address nat))))) (pair (big_map address (pair nat (map address nat))) (pair address (pair bool nat)))); DUP; CAR; DIP { CDR }; IF_LEFT { IF_LEFT { IF_LEFT { DIP { DUP; CDR; CDR; CAR; IF { UNIT; PUSH string "TokenOperationsArePaused"; PAIR; FAILWITH } { } }; DUP; DUP; CDR; CAR; DIP { CAR }; COMPARE; EQ; IF { DROP } { DUP; CAR; SENDER; COMPARE; EQ; IF { } { DUP; DIP { DUP; DIP { DIP { DUP }; CAR; SENDER; PAIR; DUP; DIP { CDR; DIP { CAR }; GET; IF_NONE { EMPTY_MAP (address) nat } { CDR } }; CAR; GET; IF_NONE { PUSH nat 0 } { } }; DUP; CAR; DIP { SENDER; DIP { DUP; CDR; CDR; DIP { DIP { DUP }; SWAP }; SWAP; SUB; ISNAT; IF_NONE { DIP { DUP }; SWAP; DIP { DUP }; SWAP; CDR; CDR; PAIR; PUSH string "NotEnoughAllowance"; PAIR; FAILWITH } { } }; PAIR }; PAIR; DIP { DROP; DROP }; DIP { DUP }; SWAP; DIP { DUP; CAR }; SWAP; DIP { CAR }; GET; IF_NONE { PUSH nat 0; DIP { EMPTY_MAP (address) nat }; PAIR; EMPTY_MAP (address) nat } { DUP; CDR }; DIP { DIP { DUP }; SWAP }; SWAP; CDR; CDR; DUP; INT; EQ; IF { DROP; NONE nat } { SOME }; DIP { DIP { DIP { DUP }; SWAP }; SWAP }; SWAP; CDR; CAR; UPDATE; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; CAR; DIP { SOME }; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CDR; CAR; DIP { CAR }; GET; IF_NONE { DUP; CDR; CDR; INT; EQ; IF { NONE (pair nat (map address nat)) } { DUP; CDR; CDR; DIP { EMPTY_MAP (address) nat }; PAIR; SOME } } { DIP { DUP }; SWAP; CDR; CDR; DIP { DUP; CAR }; ADD; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; SOME }; SWAP; DUP; DIP { CDR; CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; CDR; INT; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CAR; DIP { CAR }; GET; IF_NONE { CDR; CDR; PUSH nat 0; SWAP; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DUP; CAR; DIP { DIP { DUP }; SWAP }; SWAP; CDR; CDR; SWAP; SUB; ISNAT; IF_NONE { CAR; DIP { DUP }; SWAP; CDR; CDR; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; DIP { DUP }; SWAP; DIP { DUP; CAR; INT; EQ; IF { DUP; CDR; SIZE; INT; EQ; IF { DROP; NONE (pair nat (map address nat)) } { SOME } } { SOME }; SWAP; CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; CDR; NEG; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DROP }; NIL operation; PAIR } { SENDER; PAIR; DIP { DUP; CDR; CDR; CAR; IF { UNIT; PUSH string "TokenOperationsArePaused"; PAIR; FAILWITH } { } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; DUP; DIP { CAR; DIP { CAR }; GET; IF_NONE { EMPTY_MAP (address) nat } { CDR } }; CDR; CAR; GET; IF_NONE { PUSH nat 0 } { }; DUP; INT; EQ; IF { DROP } { DIP { DUP }; SWAP; CDR; CDR; INT; EQ; IF { DROP } { PUSH string "UnsafeAllowanceChange"; PAIR; FAILWITH } }; DIP { DUP }; SWAP; DIP { DUP; CAR }; SWAP; DIP { CAR }; GET; IF_NONE { PUSH nat 0; DIP { EMPTY_MAP (address) nat }; PAIR; EMPTY_MAP (address) nat } { DUP; CDR }; DIP { DIP { DUP }; SWAP }; SWAP; CDR; CDR; DUP; INT; EQ; IF { DROP; NONE nat } { SOME }; DIP { DIP { DIP { DUP }; SWAP }; SWAP }; SWAP; CDR; CAR; UPDATE; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; CAR; DIP { SOME }; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; NIL operation; PAIR } } { IF_LEFT { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; DUP; CAR; DIP { CDR }; DUP; DIP { CAR; DIP { CAR }; GET; IF_NONE { EMPTY_MAP (address) nat } { CDR } }; CDR; GET; IF_NONE { PUSH nat 0 } { }; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } { IF_LEFT { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; DUP; CAR; DIP { CDR }; DIP { CAR }; GET; IF_NONE { PUSH nat 0 } { CAR }; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; CDR; CDR; CDR; CDR; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } } } } { IF_LEFT { IF_LEFT { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; NIL operation; PAIR } { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP; CDR }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; NIL operation; PAIR } } { IF_LEFT { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; CDR; CDR; CAR; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } { IF_LEFT { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CAR; DIP { CAR }; GET; IF_NONE { DUP; CDR; INT; EQ; IF { NONE (pair nat (map address nat)) } { DUP; CDR; DIP { EMPTY_MAP (address) nat }; PAIR; SOME } } { DIP { DUP }; SWAP; CDR; DIP { DUP; CAR }; ADD; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; SOME }; SWAP; DUP; DIP { CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; INT; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DROP; NIL operation; PAIR } { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CAR; DIP { CAR }; GET; IF_NONE { CDR; PUSH nat 0; SWAP; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DUP; CAR; DIP { DIP { DUP }; SWAP }; SWAP; CDR; SWAP; SUB; ISNAT; IF_NONE { CAR; DIP { DUP }; SWAP; CDR; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; DIP { DUP }; SWAP; DIP { DUP; CAR; INT; EQ; IF { DUP; CDR; SIZE; INT; EQ; IF { DROP; NONE (pair nat (map address nat)) } { SOME } } { SOME }; SWAP; CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; NEG; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DROP; NIL operation; PAIR } } } } };',n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===i)throw new Error(`Map ${r} does not contain a record for ${o}`);const c=s.JSONPath({path:"$.args[0].int",json:i});return Number(c[0])}))},t.getAccountAllowance=function(t,r,o,i){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(i,"address"),"hex")),c=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===c)throw new Error(`Map ${r} does not contain a record for ${i}/${o}`);let l=new Map;return s.JSONPath({path:"$.args[1][*].args",json:c}).forEach(e=>l[e[0].string]=Number(e[1].int)),l[o]}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(s.JSONPath({path:"$.args[0].int",json:r})[0]),supply:Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0]),administrator:s.JSONPath({path:"$.args[1].args[0].string",json:r})[0],paused:s.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}}))},t.getTokenSupply=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}))},t.getAdministrator=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return s.JSONPath({path:"$.args[1].args[0].string",json:r})[0]}))},t.getPaused=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return s.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}))},t.transferBalance=function(e,t,r,o,s,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Left (Left (Left (Pair "${a}" (Pair "${u}" ${p})))))`,d=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,h,f,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))},t.approveBalance=function(e,t,r,o,s,a,u,p,f){return n(this,void 0,void 0,(function*(){const n=`(Left (Left (Right (Pair "${a}" ${u}))))`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,p,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.activateLedger=function(e,t,r,o,s,a,u){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,u,a,"","(Right (Left (Left False)))",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.deactivateLedger=function(e,t,r,o,s,a,u){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,u,a,"","(Right (Left (Left True)))",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.setAdministrator=function(e,t,r,o,s,a,u,p){return n(this,void 0,void 0,(function*(){const n=`(Right (Left (Right "${s}")))`,f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,a,p,u,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.mint=function(e,t,r,o,s,a,u,p=15e4,f=5e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Left (Pair "${a}" ${u})))))`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,p,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.burn=function(e,t,r,o,s,a,u,p,f){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Pair "${a}" ${u})))))`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,p,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))}}(t.Tzip7ReferenceTokenHelper||(t.Tzip7ReferenceTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(8);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"cdf4fb6303d606686694d80bd485b6a1")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"000")},t.deployContract=function(e,t,r,o,s,a,u,p,f,h=!0,d=0,g=8e5,m=2e4){return n(this,void 0,void 0,(function*(){const n=`( Pair ( Pair "${s}" ( Pair 0 { } ) ) ( Pair ( Pair Unit { } ) ( Pair ${h?"True":"False"} { Elt ${p} ( Pair ( Pair ${p} ( Pair "${u}" ( Pair "${a}" ( Pair ${f} { } ) ) ) ) ${d} ) } ) ) )`,b=yield c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,m,g,'parameter (or (or (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (pair %mint (pair (address %address) (nat %amount)) (pair (string %symbol) (nat %token_id)))) (or (address %set_administrator) (bool %set_pause))) (or (or (pair %token_metadata (list %token_ids nat) (lambda %handler (list (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string)))))) unit)) (contract %token_metadata_regitry address)) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (address %operator)) (pair %remove_operator (address %owner) (address %operator))))))) ;\n storage (pair (pair (address %administrator) (pair (nat %all_tokens) (big_map %ledger (pair address nat) nat))) (pair (pair (unit %version_20200615_tzip_a57dfe86_contract) (big_map %operators (pair (address %owner) (address %operator)) unit)) (pair (bool %paused) (big_map %tokens nat (pair (pair %metadata (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string))))) (nat %total_supply)))))) ;\n code { DUP ; CDR ; SWAP ; CAR ; IF_LEFT { IF_LEFT { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; NIL (pair (pair %request (address %owner) (nat %token_id)) (nat %balance)) ; SWAP ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; DIG 3 ; DUP ; DUG 4 ; { CAR ; CDR ; CDR } ; DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 3 ; DUP ; DUG 4 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 3 ; CAR ; PAIR %owner %token_id ; PAIR %request %balance ; CONS } ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CDR ; PUSH mutez 0 ; DIG 3 ; DUP ; DUG 4 ; NIL (pair (pair %request (address %owner) (nat %token_id)) (nat %balance)) ; SWAP ; ITER { CONS } ; DIG 4 ; DROP ; DIG 4 ; DROP ; TRANSFER_TOKENS ; CONS } { SWAP ; DUP ; DUG 2 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF {} { PUSH string "WrongCondition: sp.sender == self.data.administrator" ; FAILWITH } ; SWAP ; DUP ; DUG 2 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; { CDR ; CDR } ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR ; CAR } ; DUP ; PUSH nat 1 ; DIG 6 ; DUP ; DUG 7 ; { CDR ; CDR } ; ADD ; DUP ; DUG 2 ; COMPARE ; LE ; IF { DROP } { SWAP ; DROP } ; DIG 5 ; DROP ; PAIR ; SWAP ; PAIR ; PAIR ; SWAP ; SWAP ; DUP ; DUG 2 ; { CAR ; CDR ; CDR } ; SWAP ; DUP ; DUG 2 ; { CDR ; CDR } ; DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; PAIR ; MEM ; IF { SWAP ; DUP ; DUG 2 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 6 ; DUP ; DUG 7 ; { CAR ; CAR } ; PAIR ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; DROP ; DIG 5 ; DUP ; DUG 6 ; { CAR ; CDR } ; DIG 7 ; { CAR ; CDR ; CDR } ; DIG 7 ; DUP ; DUG 8 ; { CDR ; CDR } ; DIG 8 ; DUP ; DUG 9 ; { CAR ; CAR } ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; ADD ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; SWAP } { SWAP ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR } ; SOME ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 6 ; DUP ; DUG 7 ; { CAR ; CAR } ; PAIR ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; SWAP } ; SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CDR } ; SWAP ; DUP ; DUG 2 ; { CDR ; CDR } ; MEM ; IF { SWAP ; DUP ; DUG 2 ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; CAR ; DIG 6 ; DUP ; DUG 7 ; { CAR ; CDR } ; DIG 8 ; { CDR ; CDR ; CDR } ; DIG 8 ; DUP ; DUG 9 ; { CDR ; CDR } ; GET ; { IF_NONE { PUSH string "Get-item:431" ; FAILWITH } {} } ; CDR ; ADD ; SWAP ; PAIR ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP } { SWAP ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR } ; PUSH (pair (string %name) (pair (nat %decimals) (map %extras string string))) (Pair "" (Pair 0 {})) ; DIG 6 ; DUP ; DUG 7 ; { CDR ; CAR } ; PAIR %symbol ; DIG 6 ; DUP ; DUG 7 ; { CDR ; CDR } ; PAIR %token_id ; PAIR %metadata %total_supply ; SOME ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP } ; DROP ; NIL operation } } { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF {} { PUSH string "WrongCondition: sp.sender == self.data.administrator" ; FAILWITH } ; SWAP ; DUP ; CDR ; SWAP ; { CAR ; CDR } ; DIG 2 ; PAIR ; PAIR } { SWAP ; DUP ; DUG 2 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF {} { PUSH string "WrongCondition: sp.sender == self.data.administrator" ; FAILWITH } ; SWAP ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; { CDR ; CDR } ; DIG 3 ; PAIR ; SWAP ; PAIR ; SWAP ; PAIR } ; NIL operation } } { IF_LEFT { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; NIL (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string))))) ; SWAP ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; DIG 3 ; DUP ; DUG 4 ; { CDR ; CDR ; CDR } ; DIG 2 ; GET ; { IF_NONE { PUSH string "Get-item:523" ; FAILWITH } {} } ; CAR ; CONS } ; SWAP ; DUP ; DUG 2 ; CDR ; SWAP ; DUP ; DUG 2 ; NIL (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string))))) ; SWAP ; ITER { CONS } ; EXEC ; DROP 3 ; NIL operation } { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; DUP ; NIL operation ; SWAP ; PUSH mutez 0 ; SELF ; DIG 4 ; DROP ; ADDRESS ; TRANSFER_TOKENS ; CONS } } { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; DUP ; ITER { DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF { PUSH bool True } { DUP ; CAR ; SENDER ; COMPARE ; EQ } ; IF { PUSH bool True } { DIG 2 ; DUP ; DUG 3 ; { CDR ; CAR ; CDR } ; SENDER ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR %owner %operator ; MEM } ; IF {} { PUSH string "WrongCondition: ((sp.sender == self.data.administrator) | (transfer.from_ == sp.sender)) | (self.data.operators.contains(sp.record(operator = sp.sender, owner = transfer.from_)))" ; FAILWITH } ; DUP ; CDR ; ITER { DUP ; { CDR ; CDR } ; PUSH nat 0 ; COMPARE ; LT ; IF {} { PUSH string "TRANSFER_OF_ZERO" ; FAILWITH } ; DUP ; { CDR ; CDR } ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR ; CDR } ; DIG 2 ; DUP ; DUG 3 ; { CDR ; CAR } ; DIG 4 ; DUP ; DUG 5 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; COMPARE ; GE ; IF {} { PUSH string "WrongCondition: self.data.ledger[(transfer.from_, tx.token_id)].balance >= tx.amount" ; FAILWITH } ; DIG 3 ; DUP ; DUG 4 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CAR } ; DIG 7 ; DUP ; DUG 8 ; CAR ; PAIR ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; DROP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 9 ; { CAR ; CDR ; CDR } ; DIG 7 ; DUP ; DUG 8 ; { CDR ; CAR } ; DIG 9 ; DUP ; DUG 10 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; SUB ; ISNAT ; { IF_NONE { PUSH unit Unit ; FAILWITH } {} } ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; DUG 3 ; DIG 3 ; DUP ; DUG 4 ; { CAR ; CDR ; CDR } ; SWAP ; DUP ; DUG 2 ; { CDR ; CAR } ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR ; MEM ; IF { DIG 3 ; DUP ; DUG 4 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CAR } ; DIG 6 ; DUP ; DUG 7 ; CAR ; PAIR ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; DROP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 9 ; { CAR ; CDR ; CDR } ; DIG 7 ; DUP ; DUG 8 ; { CDR ; CAR } ; DIG 8 ; DUP ; DUG 9 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; ADD ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; DUG 3 } { DIG 3 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DIG 4 ; DUP ; DUG 5 ; { CDR ; CDR } ; SOME ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CAR } ; DIG 6 ; DUP ; DUG 7 ; CAR ; PAIR ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; DUG 3 } ; DROP } ; DROP } ; DROP } { DUP ; ITER { DUP ; IF_LEFT { DROP ; DUP ; SENDER ; SWAP ; IF_LEFT {} { DROP ; PUSH unit Unit ; FAILWITH } ; CAR ; COMPARE ; EQ ; IF { PUSH bool True } { DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ } ; IF {} { PUSH string "WrongCondition: (update.open_variant(\'add_operator\').owner == sp.sender) | (sp.sender == self.data.administrator)" ; FAILWITH } ; DIG 2 ; DUP ; DUG 3 ; DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; PUSH (option unit) (Some Unit) ; DIG 5 ; DUP ; DUG 6 ; IF_LEFT {} { DROP ; PUSH unit Unit ; FAILWITH } ; CDR ; DIG 6 ; DUP ; DUG 7 ; IF_LEFT {} { DROP ; PUSH unit Unit ; FAILWITH } ; DIG 9 ; DROP ; CAR ; PAIR %owner %operator ; UPDATE ; SWAP ; PAIR ; PAIR ; SWAP ; PAIR ; DUG 2 } { DROP ; DUP ; SENDER ; SWAP ; IF_LEFT { DROP ; PUSH unit Unit ; FAILWITH } {} ; CAR ; COMPARE ; EQ ; IF { PUSH bool True } { DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ } ; IF {} { PUSH string "WrongCondition: (update.open_variant(\'remove_operator\').owner == sp.sender) | (sp.sender == self.data.administrator)" ; FAILWITH } ; DIG 2 ; DUP ; DUG 3 ; DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; NONE unit ; DIG 5 ; DUP ; DUG 6 ; IF_LEFT { DROP ; PUSH unit Unit ; FAILWITH } {} ; CDR ; DIG 6 ; DUP ; DUG 7 ; IF_LEFT { DROP ; PUSH unit Unit ; FAILWITH } {} ; DIG 9 ; DROP ; CAR ; PAIR %owner %operator ; UPDATE ; SWAP ; PAIR ; PAIR ; SWAP ; PAIR ; DUG 2 } ; DROP } ; DROP } ; NIL operation } } ; PAIR } ;',n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(b.operationGroupID)}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{administrator:s.JSONPath({path:"$.args[0].args[0].string",json:r})[0],tokens:Number(s.JSONPath({path:"$.args[0].args[1].args[0].int",json:r})[0]),balanceMap:Number(s.JSONPath({path:"$.args[0].args[1].args[1].int",json:r})[0]),operatorMap:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),paused:s.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t"),metadataMap:Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}}))},t.getTokenDefinition=function(t,r,o=0){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"nat"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===i)throw new Error(`Map ${r} does not contain a record for token ${o}`);return{tokenid:Number(s.JSONPath({path:"$.args[0].args[0].int",json:i})[0]),symbol:s.JSONPath({path:"$.args[0].args[1].args[0].string",json:i})[0],name:s.JSONPath({path:"$.args[0].args[1].args[1].args[0].string",json:i})[0],scale:Number(s.JSONPath({path:"$.args[0].args[1].args[1].args[1].args[0].int",json:i})[0]),supply:Number(s.JSONPath({path:"$.args[1].int",json:i})[0])}}))},t.activate=function(e,t,r,o,s,a=8e5,u=2e4){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,u,a,"set_pause","False",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.deactivate=function(e,t,r,o,s,a=8e5,u=2e4){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,u,a,"set_pause","True",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.changeAdministrator=function(e,t,r,o,s,a,u=8e5,p=2e4){return n(this,void 0,void 0,(function*(){const n=`"${a}"`,f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,p,u,"set_administrator",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.mint=function(e,t,r,o,s,a,u,p,f,h=8e5,d=2e4){return n(this,void 0,void 0,(function*(){const n=`(Pair (Pair "${a}" ${u}) (Pair "${p}" ${f}))`,g=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,d,h,"mint",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(g.operationGroupID)}))},t.transfer=function(e,t,r,o,s,a,u,p=8e5,f=2e4){return n(this,void 0,void 0,(function*(){const n=`{ Pair "${a}" { ${u.map(e=>'( Pair "'+e.address+'" ( Pair '+e.tokenid+" "+e.balance+" ) )").join(" ; ")} } }`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,f,p,"transfer",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.getAccountBalance=function(t,r,o,c){return n(this,void 0,void 0,(function*(){const n="0x"+a.TezosMessageUtils.writeAddress(o),l=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(`(Pair ${n} ${c})`,"",i.TezosParameterFormat.Michelson),"hex")),p=yield u.TezosNodeReader.getValueForBigMapKey(t,r,l);if(void 0===p)throw new Error(`Map ${r} does not contain a record for ${o}/${c}`);const f=s.JSONPath({path:"$.int",json:p});return Number(f[0])}))}}(t.MultiAssetTokenHelper||(t.MultiAssetTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=r(4),a=r(3),u=r(7),c=o(r(5)),l=r(8);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"17aab0975df6139f4ff29be76a67f348")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"000")},t.deployContract=function(e,t,r,o,s,i,a,p,f,h=!0,d=0,g=8e5,m=2e4){return n(this,void 0,void 0,(function*(){const n=`( Pair ( Pair ( Pair "${s}" ${h?"True":"False"} ) None ) ( Pair ( Pair { } { } ) ( Pair { Elt ${p} ( Pair ${p} ( Pair "${a}" ( Pair "${i}" ( Pair ${f} { } ) ) ) ) } ${d} ) ) )`,b=yield u.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,m,g,'parameter (or (or (or %admin (or (unit %confirm_admin) (bool %pause)) (address %set_admin)) (or %assets (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (contract %token_metadata_registry address)) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (address %operator)) (pair %remove_operator (address %owner) (address %operator))))))) (or %tokens (list %burn_tokens (pair (nat %amount) (address %owner))) (list %mint_tokens (pair (nat %amount) (address %owner))))) ;\n storage (pair (pair %admin (pair (address %admin) (bool %paused)) (option %pending_admin address)) (pair %assets (pair (big_map %ledger address nat) (big_map %operators (pair address address) unit)) (pair (big_map %token_metadata nat (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string)))))) (nat %total_supply)))) ;\n code { PUSH string "FA2_TOKEN_UNDEFINED" ; PUSH string "FA2_INSUFFICIENT_BALANCE" ; LAMBDA (pair address address) (pair address address) { DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PAIR ; DIP { DROP } } ; LAMBDA (pair address (big_map address nat)) nat { DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; GET ; IF_NONE { PUSH nat 0 } { DUP ; DIP { DROP } } ; DIP { DROP } } ; DUP ; LAMBDA (pair (lambda (pair address (big_map address nat)) nat) (pair (pair address nat) (big_map address nat))) (big_map address nat) { DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 4 ; DUP ; DUG 5 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; CAR ; CDR ; DIG 1 ; DUP ; DUG 2 ; ADD ; DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; SOME ; DIG 5 ; DUP ; DUG 6 ; UPDATE ; DIP { DROP 6 } } ; SWAP ; APPLY ; DIP { DIP { DIP { DUP } ; SWAP } ; DUP ; DIP { PAIR } ; SWAP } ; SWAP ; LAMBDA (pair (pair (lambda (pair address (big_map address nat)) nat) string) (pair (pair address nat) (big_map address nat))) (big_map address nat) { DUP ; CAR ; SWAP ; CDR ; DIP { DUP ; CDR ; SWAP ; CAR } ; DUP ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 4 ; DUP ; DUG 5 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; CAR ; CDR ; DIG 1 ; DUP ; DUG 2 ; SUB ; ISNAT ; IF_NONE { DIG 5 ; DUP ; DUG 6 ; FAILWITH } { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; COMPARE ; EQ ; IF { DIG 2 ; DUP ; DUG 3 ; DIG 4 ; DUP ; DUG 5 ; NONE nat ; SWAP ; UPDATE } { DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; SOME ; DIG 5 ; DUP ; DUG 6 ; UPDATE } ; DIP { DROP } } ; DIP { DROP 6 } } ; SWAP ; APPLY ; LAMBDA (list (pair nat address)) nat { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; ITER { SWAP ; PAIR ; DUP ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ADD ; DIP { DROP } } ; DIP { DROP } } ; LAMBDA (pair (pair address bool) (option address)) unit { DUP ; CAR ; CAR ; SENDER ; COMPARE ; NEQ ; IF { PUSH string "NOT_AN_ADMIN" ; FAILWITH } { UNIT } ; DIP { DROP } } ; DIG 8 ; DUP ; DUG 9 ; CDR ; DIG 9 ; DUP ; DUG 10 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DIG 2 ; DUP ; DUG 3 ; CDR ; IF_NONE { PUSH string "NO_PENDING_ADMIN" ; FAILWITH } { DUP ; SENDER ; COMPARE ; EQ ; IF { DIG 3 ; DUP ; DUG 4 ; CAR ; NONE address ; SWAP ; PAIR ; DUP ; CDR ; SWAP ; CAR ; CDR ; SENDER ; PAIR ; PAIR } { PUSH string "NOT_AN_ADMIN" ; FAILWITH } ; DIP { DROP } } ; DUP ; NIL operation ; PAIR ; DIP { DROP 2 } } { DIG 2 ; DUP ; DUG 3 ; DIG 8 ; DUP ; DUG 9 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ; SWAP ; PAIR ; PAIR ; DIP { DROP } ; NIL operation ; PAIR ; DIP { DROP 2 } } ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; DIG 7 ; DUP ; DUG 8 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; SOME ; SWAP ; CAR ; PAIR ; DIP { DROP } ; NIL operation ; PAIR ; DIP { DROP 2 } } ; DIP { DROP 2 } ; DIG 3 ; DUP ; DUG 4 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CDR ; SWAP ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 2 } } { DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; CDR ; IF { PUSH string "PAUSED" ; FAILWITH } { UNIT } ; DIG 3 ; DUP ; DUG 4 ; CDR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PAIR ; DUP ; CDR ; MAP { DUP ; DIP { DROP } } ; DUP ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR ; DIP { DROP 2 } ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DUP ; CDR ; MAP { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; COMPARE ; NEQ ; IF { DIG 19 ; DUP ; DUG 20 ; FAILWITH } { DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIG 17 ; DUP ; DUG 18 ; SWAP ; EXEC ; DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; CDR ; DIG 1 ; DUP ; DUG 2 ; CDR ; CAR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PAIR ; DIP { DROP 3 } } ; DIP { DROP } } ; DIG 1 ; DUP ; DUG 2 ; CAR ; PUSH mutez 0 ; DIG 2 ; DUP ; DUG 3 ; TRANSFER_TOKENS ; DIP { DROP 3 } ; DIG 4 ; DUP ; DUG 5 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 3 } } { DUP ; PUSH mutez 0 ; SELF ; ADDRESS ; TRANSFER_TOKENS ; DIG 3 ; DUP ; DUG 4 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 2 } } ; DIP { DROP } } { DUP ; IF_LEFT { DUP ; MAP { DUP ; CDR ; MAP { DUP ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; CDR ; PAIR ; PAIR ; DIP { DROP } } ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP } } ; DUP ; MAP { DUP ; CDR ; MAP { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; COMPARE ; NEQ ; IF { DIG 18 ; DUP ; DUG 19 ; FAILWITH } { DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CDR ; SOME ; DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; PAIR ; PAIR } ; DIP { DROP } } ; DUP ; DIG 2 ; DUP ; DUG 3 ; CAR ; SOME ; PAIR ; DIP { DROP 2 } } ; SENDER ; DUP ; LAMBDA (pair address (pair address (big_map (pair address address) unit))) unit { DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; COMPARE ; EQ ; IF { UNIT } { DIG 1 ; DUP ; DUG 2 ; CDR ; DIG 3 ; DUP ; DUG 4 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; MEM ; IF { UNIT } { PUSH string "FA2_NOT_OPERATOR" ; FAILWITH } } ; DIP { DROP 3 } } ; SWAP ; APPLY ; DIP { DROP } ; DIG 5 ; DUP ; DUG 6 ; CAR ; CAR ; DIG 6 ; DUP ; DUG 7 ; CAR ; CDR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIG 3 ; DUP ; DUG 4 ; PAIR ; PAIR ; DUP ; CDR ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CAR ; ITER { SWAP ; PAIR ; DUP ; CDR ; DUP ; CAR ; IF_NONE { UNIT } { DIG 3 ; DUP ; DUG 4 ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DIG 4 ; DUP ; DUG 5 ; CAR ; CDR ; SWAP ; EXEC ; DIP { DROP } } ; DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; ITER { SWAP ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; COMPARE ; NEQ ; IF { DIG 25 ; DUP ; DUG 26 ; FAILWITH } { DIG 4 ; DUP ; DUG 5 ; CAR ; IF_NONE { DIG 1 ; DUP ; DUG 2 } { DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DIG 22 ; DUP ; DUG 23 ; SWAP ; EXEC ; DIP { DROP } } ; DIG 1 ; DUP ; DUG 2 ; CAR ; CDR ; IF_NONE { DUP } { DIG 1 ; DUP ; DUG 2 ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DIG 24 ; DUP ; DUG 25 ; SWAP ; EXEC ; DIP { DROP } } ; DIP { DROP } } ; DIP { DROP 3 } } ; DIP { DROP 3 } } ; DIP { DROP } ; DIG 6 ; DUP ; DUG 7 ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 5 } } { DUP ; MAP { DUP ; IF_LEFT { DUP ; LEFT (pair (address %owner) (address %operator)) ; DIP { DROP } } { DUP ; RIGHT (pair (address %owner) (address %operator)) ; DIP { DROP } } ; DUP ; IF_LEFT { DUP ; DIG 17 ; DUP ; DUG 18 ; SWAP ; EXEC ; LEFT (pair (address %operator) (address %owner)) ; DIP { DROP } } { DUP ; DIG 17 ; DUP ; DUG 18 ; SWAP ; EXEC ; RIGHT (pair (address %operator) (address %owner)) ; DIP { DROP } } ; DIP { DROP 2 } } ; SENDER ; DIG 4 ; DUP ; DUG 5 ; CAR ; CDR ; DIG 2 ; DUP ; DUG 3 ; ITER { SWAP ; PAIR ; DUP ; CDR ; DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DUP ; DIP { DROP } } { DUP ; DIP { DROP } } ; CDR ; COMPARE ; EQ ; IF { UNIT } { PUSH string "FA2_NOT_OWNER" ; FAILWITH } ; DIP { DROP } ; DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DIG 1 ; DUP ; DUG 2 ; UNIT ; SOME ; DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 3 ; DUP ; DUG 4 ; CDR ; PAIR ; UPDATE ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; PAIR ; NONE unit ; SWAP ; UPDATE ; DIP { DROP } } ; DIP { DROP 5 } } ; DIG 5 ; DUP ; DUG 6 ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ; SWAP ; PAIR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 4 } } ; DIP { DROP } } ; DIP { DROP 2 } ; DIG 4 ; DUP ; DUG 5 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CAR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 3 } } ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 3 ; DUP ; DUG 4 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; PAIR ; PAIR ; DIG 15 ; DUP ; DUG 16 ; SWAP ; EXEC ; DIP { DROP 2 } } ; DIP { DROP } ; DIG 2 ; DUP ; DUG 3 ; DIG 12 ; DUP ; DUG 13 ; SWAP ; EXEC ; DUP ; DIG 3 ; DUP ; DUG 4 ; CDR ; CDR ; SUB ; ISNAT ; DUP ; IF_NONE { DIG 18 ; DUP ; DUG 19 ; FAILWITH } { DUP ; DIP { DROP } } ; DIG 4 ; DUP ; DUG 5 ; DIG 4 ; DUP ; DUG 5 ; DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ; SWAP ; PAIR ; SWAP ; PAIR ; NIL operation ; PAIR ; DIP { DROP 8 } } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; PAIR ; PAIR ; DIG 16 ; DUP ; DUG 17 ; SWAP ; EXEC ; DIP { DROP 2 } } ; DIP { DROP } ; DIG 2 ; DUP ; DUG 3 ; DIG 12 ; DUP ; DUG 13 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIG 4 ; DUP ; DUG 5 ; CDR ; CDR ; ADD ; DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ; SWAP ; PAIR ; SWAP ; PAIR ; DUP ; NIL operation ; PAIR ; DIP { DROP 7 } } ; DIP { DROP 2 } ; DIG 3 ; DUP ; DUG 4 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CAR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 3 } } ; DIP { DROP 10 } } ; ',n,c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(b.operationGroupID)}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield a.TezosNodeReader.getContractStorage(e,t);return{administrator:s.JSONPath({path:"$.args[0].args[0].args[0].string",json:r})[0],paused:s.JSONPath({path:"$.args[0].args[0].args[1].prim",json:r})[0].toString().toLowerCase().startsWith("t"),pendingAdmin:s.JSONPath({path:"$.args[0].args[1].prim",json:r})[0],balanceMap:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),operatorMap:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),metadataMap:Number(s.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),supply:Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}}))},t.getTokenDefinition=function(t,r,o=0){return n(this,void 0,void 0,(function*(){const n=i.TezosMessageUtils.encodeBigMapKey(e.from(i.TezosMessageUtils.writePackedData(o,"nat"),"hex")),u=yield a.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===u)throw new Error(`Map ${r} does not contain a record for token ${o}`);return{tokenid:Number(s.JSONPath({path:"$.args[0].int",json:u})[0]),symbol:s.JSONPath({path:"$.args[1].args[0].string",json:u})[0],name:s.JSONPath({path:"$.args[1].args[1].args[0].string",json:u})[0],scale:Number(s.JSONPath({path:"$.args[1].args[1].args[1].args[0].int",json:u})[0])}}))},t.activate=function(e,t,r,o,s,i=8e5,a=2e4){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,a,i,"pause","False",c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.deactivate=function(e,t,r,o,s,i=8e5,a=2e4){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,a,i,"pause","True",c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.mint=function(e,t,r,o,s,i,a=8e5,p=2e4){return n(this,void 0,void 0,(function*(){const n=`{ ${i.map(e=>"( Pair "+e.balance+' "'+e.address+'" )').join(" ; ")} }`,f=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,p,a,"mint_tokens",n,c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.transfer=function(e,t,r,o,s,i,a,p=8e5,f=2e4){return n(this,void 0,void 0,(function*(){const n=`{ Pair "${i}" { ${a.map(e=>'( Pair "'+e.address+'" ( Pair '+e.tokenid+" "+e.balance+" ) )").join(" ; ")} } }`,h=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,f,p,"transfer",n,c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=i.TezosMessageUtils.encodeBigMapKey(e.from(i.TezosMessageUtils.writePackedData(o,"address"),"hex")),u=yield a.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===u)throw new Error(`Map ${r} does not contain a record for ${o}`);const c=s.JSONPath({path:"$.int",json:u});return Number(c[0])}))}}(t.SingleAssetTokenHelper||(t.SingleAssetTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(9),u=r(4),c=r(3),l=r(7),p=r(8);!function(t){function r(t,r,o){return n(this,void 0,void 0,(function*(){const n=e.from(u.TezosMessageUtils.writePackedData(o,"",i.TezosParameterFormat.Michelson),"hex"),l=u.TezosMessageUtils.writePackedData(n,"bytes"),p=u.TezosMessageUtils.encodeBigMapKey(e.from(l,"hex")),f=yield c.TezosNodeReader.getValueForBigMapKey(t,r,p);if(void 0===f)throw new Error(`Could not get data from map ${r} for '${o}'`);const h=s.JSONPath({path:"$.bytes",json:f})[0];return JSON.parse(a.TezosLanguageUtil.hexToMicheline(h.slice(2)).code)}))}t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return p.TezosContractUtils.verifyDestination(e,t,"187c967006ca95a648c770fdd76947ef")}))},t.verifyScript=function(e){return p.TezosContractUtils.verifyScript(e,"ffcad1e376a6c8915780fe6676aceec6")},t.getAccountBalance=function(e,t,o){return n(this,void 0,void 0,(function*(){const n=yield r(e,t,`(Pair "ledger" 0x${u.TezosMessageUtils.writeAddress(o)})`);return Number(s.JSONPath({path:"$.args[0].int",json:n})[0])}))},t.getOperatorList=function(e,t){return n(this,void 0,void 0,(function*(){const n=yield r(e,t,'"operators"');let o=[];for(const e of n)o.push(u.TezosMessageUtils.readAddress(e.bytes));return o}))},t.getTokenMetadata=function(e,t){return n(this,void 0,void 0,(function*(){return yield r(e,t,'"tokenMetadata"')}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield c.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(s.JSONPath({path:"$.args[0].int",json:r})[0]),scale:8}}))},t.transferBalance=function(e,t,r,o,s,a,u,c,f=25e4,h=1e3){return n(this,void 0,void 0,(function*(){const n=`(Pair "${a}" (Pair "${u}" ${c}))`,d=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,h,f,"transfer",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))},t.approveBalance=function(e,t,r,o,s,a,u,c=25e4,f=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Left (Right (Right (Right (Pair "${a}" ${u})))))))))`,h=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,c,"",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.mintBalance=function(e,t,r,o,s,a,u,c=25e4,f=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Right (Left (Left (Left (Pair "${a}" ${u})))))))))`,h=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,c,"",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.addOperator=function(e,t,r,o,s,a,u=25e4,c=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Right (Left (Right (Left "${a}" ))))))))`,f=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,c,u,"",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))}}(t.TzbtcTokenHelper||(t.TzbtcTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(29),i=o(r(14)),a=o(r(12)).default.log,u=i.default.fetch;!function(e){function t(e,t){return n(this,void 0,void 0,(function*(){return u(`${e.url}/v2/metadata/${t}`,{method:"GET",headers:{apiKey:e.apiKey}}).then(r=>{if(!r.ok)throw new s.ConseilRequestError(r.status,r.statusText,`${e.url}/v2/metadata/${t}`,null);return r}).then(r=>r.json().catch(r=>{a.error(`ConseilMetadataClient.executeMetadataQuery parsing failed for ${e.url}/v2/metadata/${t} with ${r}`)}))}))}e.executeMetadataQuery=t,e.getPlatforms=function(e){return n(this,void 0,void 0,(function*(){return t(e,"platforms")}))},e.getNetworks=function(e,r){return n(this,void 0,void 0,(function*(){return t(e,r+"/networks")}))},e.getEntities=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/entities`)}))},e.getAttributes=function(e,r,o,s){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/${s}/attributes`)}))},e.getAttributeValues=function(e,r,o,s,i){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/${s}/${i}`)}))},e.getAttributeValuesForPrefix=function(e,r,o,s,i,a){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/${s}/${i}/${encodeURIComponent(a)}`)}))}}(t.ConseilMetadataClient||(t.ConseilMetadataClient={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.STRING="String",e.INT="Int",e.DECIMAL="Decimal",e.BOOLEAN="Boolean",e.ACCOUNT_ADDRESS="AccountAddress",e.HASH="Hash",e.DATETIME="DateTime",e.CURRENCY="Currency"}(t.AttrbuteDataType||(t.AttrbuteDataType={})),function(e){e.PRIMARYKEY="PrimaryKey",e.UNIQUEKEY="UniqueKey",e.NONKEY="NonKey"}(t.AttrbuteKeyType||(t.AttrbuteKeyType={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Yay=0]="Yay",e[e.Nay=1]="Nay",e[e.Pass=2]="Pass"}(t.BallotVote||(t.BallotVote={}))}])})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.conseiljs=t():e.conseiljs=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=44)}([function(e,t,r){"use strict";(function(e){var n=r(46),o=r(47),s=r(31);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(i()=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return C(this,t,r);case"base64":return _(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,o){var s,i=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;i=2,a/=2,u/=2,r/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o){var l=-1;for(s=r;sa&&(r=a-u),s=r;s>=0;s--){for(var p=!0,f=0;fo&&(n=o):n=o;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var i=0;i>8,o=r%256,s.push(o),s.push(n);return s}(t,e.length-r),e,r,n)}function _(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function R(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+p<=r)switch(p){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[o+1]))&&(u=(31&c)<<6|63&s)>127&&(l=u);break;case 3:s=e[o+1],i=e[o+2],128==(192&s)&&128==(192&i)&&(u=(15&c)<<12|(63&s)<<6|63&i)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=e[o+1],i=e[o+2],a=e[o+3],128==(192&s)&&128==(192&i)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&i)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,p=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=p}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(n>>>=0),i=(r>>>=0)-(t>>>=0),a=Math.min(s,i),c=this.slice(n,o),l=e.slice(t,r),p=0;po)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return D(this,e,t,r);case"utf8":case"utf-8":return P(this,e,t,r);case"ascii":return $(this,e,t,r);case"latin1":case"binary":return v(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function S(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;on)&&(r=n);for(var o="",s=t;sr)throw new RangeError("Trying to access beyond buffer length")}function w(e,t,r,n,o,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,s=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function N(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,s=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function x(e,t,r,n,o,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,s){return s||x(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function F(e,t,r,n,s){return s||x(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||T(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],o=1,s=0;++s=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,o=1,s=this[e+--n];n>0&&(o*=256);)s+=this[e+--n]*o;return s>=(o*=128)&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||T(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||T(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||w(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+o]=e/s&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);w(this,e,t,r,o-1,-o)}var s=0,i=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);w(this,e,t,r,o-1,-o)}var s=r-1,i=1,a=0;for(this[t+s]=255&e;--s>=0&&(i*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/i>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||w(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return F(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return F(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function W(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(9))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){var n=r(0),o=n.Buffer;function s(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return o(e,t,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(s(n,t),t.Buffer=i),s(o,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=o(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=r(79),a=o(r(15)),u=o(r(12)).default.log,c=a.default.fetch;!function(e){function t(e,t){const r=`${e}/${t}`;return c(r,{method:"get"}).then(n=>{if(!n.ok)throw u.error(`TezosNodeReader.performGetRequest error: ${n.status} for ${t} on ${e}`),new i.TezosRequestError(n.status,n.statusText,r,null);return n}).then(r=>{const n=r.json();return u.debug(`TezosNodeReader.performGetRequest response: ${n} for ${t} on ${e}`),n})}function r(e,r="head",n="main"){return t(e,`chains/${n}/blocks/${r}`).then(e=>e)}function o(e,r,n,o="main"){return t(e,`chains/${o}/blocks/${r}/context/contracts/${n}`).then(e=>e)}function a(e,r,o,s="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${s}/blocks/${r}/context/contracts/${o}/manager_key`);return n?n.toString():""}))}e.getBlock=r,e.getBlockHead=function(e){return r(e)},e.getBlockAtOffset=function(e,o,s="main"){return n(this,void 0,void 0,(function*(){if(o<=0)return r(e);const n=yield r(e);return t(e,`chains/${s}/blocks/${Number(n.header.level)-o}`).then(e=>e)}))},e.getAccountForBlock=o,e.getCounterForAccount=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${o}/blocks/head/context/contracts/${r}/counter`).then(e=>e.toString());return parseInt(n.toString(),10)}))},e.getSpendableBalanceForAccount=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${o}/blocks/head/context/contracts/${r}`).then(e=>e);return parseInt(n.balance.toString(),10)}))},e.getAccountManagerForBlock=a,e.isImplicitAndEmpty=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield o(e,"head",t),n=t.toLowerCase().startsWith("tz"),s=0===Number(r.balance);return n&&s}))},e.isManagerKeyRevealedForAccount=function(e,t){return n(this,void 0,void 0,(function*(){return(yield a(e,"head",t)).length>0}))},e.getContractStorage=function(e,r,n="head",o="main"){return t(e,`chains/${o}/blocks/${n}/context/contracts/${r}/storage`)},e.getValueForBigMapKey=function(e,r,n,o="head",s="main"){return t(e,`chains/${s}/blocks/${o}/context/big_maps/${r}/${n}`).catch(e=>{})},e.getMempoolOperation=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){const n=yield t(e,`chains/${o}/mempool/pending_operations`).catch(()=>{});return s.JSONPath({path:`$.applied[?(@.hash=='${r}')]`,json:n})[0]}))},e.estimateBranchTimeout=function(e,t,o="main"){return n(this,void 0,void 0,(function*(){const n=r(e,t,o),s=r(e,"head",o);return 64-(yield Promise.all([n,s]).then(e=>Number(e[1].header.level)-Number(e[0].header.level)))}))},e.getMempoolOperationsForAccount=function(e,r,o="main"){return n(this,void 0,void 0,(function*(){return(yield t(e,`chains/${o}/mempool/pending_operations`).catch(()=>{})).applied.filter(e=>e.contents.some(e=>e.source===r||e.destination===r)).map(e=>(e.contents=e.contents.filter(e=>e.source===r||e.destination===r),e))}))}}(t.TezosNodeReader||(t.TezosNodeReader={}))},function(e,t,r){"use strict";(function(e){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=n(r(51)),i=n(r(32)),a=o(r(14)),u=r(8),c=r(5),l=r(43);!function(t){function r(t){if(t<0)throw new Error("Use writeSignedInt to encode negative numbers");return e.from(e.from(function(e){if(e<128)return("0"+e.toString(16)).slice(-2);let t="";if(e>2147483648){let r=i.default(e);for(;r.greater(0);)t=("0"+r.and(127).toString(16)).slice(-2)+t,r=r.shiftRight(7)}else{let r=e;for(;r>0;)t=("0"+(127&r).toString(16)).slice(-2)+t,r>>=7}return t}(t),"hex").map((e,t)=>0===t?e:128^e).reverse()).toString("hex")}function n(e){if(0===e)return"00";const t=i.default(e).abs(),r=t.bitLength().toJSNumber();let n=[],o=t;for(let t=0;t("0"+e.toString(16)).slice(-2)).join("")}function o(t){return function(e){if(2===e.length)return parseInt(e,16);if(e.length<=8){let t=parseInt(e.slice(-2),16);for(let r=1;r0===t?e:127&e)).toString("hex"))}function p(t){const r=!(64&e.from(t.slice(0,2),"hex")[0]),n=e.from(t,"hex").map((e,t)=>0===t?63&e:127&e);let o=i.default.zero;for(let e=n.length-1;e>=0;e--)o=0===e?o.or(n[e]):o.or(i.default(n[e]).shiftLeft(7*e-1));return r?o.toJSNumber():o.negate().toJSNumber()}function f(e){return D(e.length)+e.split("").map(e=>e.charCodeAt(0).toString(16)).join("")}function h(e){if(0===parseInt(e.substring(0,8),16))return"";const t=e.slice(8);let r="";for(let e=0;e0},t.writeInt=r,t.writeSignedInt=n,t.readInt=o,t.readSignedInt=p,t.findInt=function(e,t,r=!1){let n="",s=0;for(;t+2*se.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1?e.slice(0,s+1)+" return "+e.slice(s+1):" return "+e;return a(Function,l(r).concat([i])).apply(void 0,l(o))}};function g(e,t){return(e=e.slice()).push(t),e}function m(e,t){return(t=t.slice()).unshift(e),t}var b=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e);var t,r=(t=n,function(){var e,r=o(t);if(i()){var n=o(this).constructor;e=Reflect.construct(r,arguments,n)}else e=r.apply(this,arguments);return c(this,e)});function n(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=r.call(this,'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)')).avoidNew=!0,t.value=e,t.name="NewError",t}return n}(u(Error));function y(e,t,r,o,s){if(!(this instanceof y))try{return new y(e,t,r,o,s)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(s=o,o=r,r=t,t=e,e=null);var i=e&&"object"===n(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!h.call(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.preventEval=e.preventEval||!1,this.parent=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||o||null,this.otherTypeCallback=e.otherTypeCallback||s||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:i?e.path:t};i?"json"in e&&(a.json=e.json):a.json=r;var u=this.evaluate(a);if(!u||"object"!==n(u))throw new b(u);return u}}y.prototype.evaluate=function(e,t,r,o){var s=this,i=this.parent,a=this.parentProperty,u=this.flatten,c=this.wrap;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=o||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===n(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!h.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,u=h.call(e,"flatten")?e.flatten:u,this.currResultType=h.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=h.call(e,"sandbox")?e.sandbox:this.currSandbox,c=h.call(e,"wrap")?e.wrap:c,this.currPreventEval=h.call(e,"preventEval")?e.preventEval:this.currPreventEval,r=h.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=h.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,i=h.call(e,"parent")?e.parent:i,a=h.call(e,"parentProperty")?e.parentProperty:a,e=e.path}if(i=i||null,a=a||null,Array.isArray(e)&&(e=y.toPathString(e)),(e||""===e)&&t){this._obj=t;var l=y.toPathArray(e);"$"===l[0]&&l.length>1&&l.shift(),this._hasParentSelector=null;var p=this._trace(l,t,["$"],i,a,r).filter((function(e){return e&&!e.isParentSelector}));return p.length?c||1!==p.length||p[0].hasArrExpr?p.reduce((function(e,t){var r=s._getPreferredOutput(t);return u&&Array.isArray(r)?e=e.concat(r):e.push(r),e}),[]):this._getPreferredOutput(p[0]):c?[]:void 0}},y.prototype._getPreferredOutput=function(e){var t=this.currResultType;switch(t){default:throw new TypeError("Unknown result type");case"all":var r=Array.isArray(e.path)?e.path:y.toPathArray(e.path);return e.pointer=y.toPointer(r),e.path="string"==typeof e.path?e.path:y.toPathString(e.path),e;case"value":case"parent":case"parentProperty":return e[t];case"path":return y.toPathString(e[t]);case"pointer":return y.toPointer(e.path)}},y.prototype._handleCallback=function(e,t,r){if(t){var n=this._getPreferredOutput(e);e.path="string"==typeof e.path?e.path:y.toPathString(e.path),t(n,r,e)}},y.prototype._trace=function(e,t,r,o,s,i,a,u){var c,l=this;if(!e.length)return c={path:r,value:t,parent:o,parentProperty:s,hasArrExpr:a},this._handleCallback(c,i,"value"),c;var f=e[0],d=e.slice(1),b=[];function y(e){Array.isArray(e)?e.forEach((function(e){b.push(e)})):b.push(e)}if(("string"!=typeof f||u)&&t&&h.call(t,f))y(this._trace(d,t[f],g(r,f),t,f,i,a));else if("*"===f)this._walk(f,d,t,r,o,s,i,(function(e,t,r,n,o,s,i,a){y(l._trace(m(e,r),n,o,s,i,a,!0,!0))}));else if(".."===f)y(this._trace(d,t,r,o,s,i,a)),this._walk(f,d,t,r,o,s,i,(function(e,t,r,o,s,i,a,u){"object"===n(o[e])&&y(l._trace(m(t,r),o[e],g(s,e),o,e,u,!0))}));else{if("^"===f)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:d,isParentSelector:!0};if("~"===f)return c={path:g(r,f),value:s,parent:o,parentProperty:null},this._handleCallback(c,i,"property"),c;if("$"===f)y(this._trace(d,t,r,null,null,i,a));else if(/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(f))y(this._slice(f,d,t,r,o,s,i));else if(0===f.indexOf("?(")){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");this._walk(f,d,t,r,o,s,i,(function(e,t,r,n,o,s,i,a){l._eval(t.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/,"$1"),n[e],e,o,s,i)&&y(l._trace(m(e,r),n,o,s,i,a,!0))}))}else if("("===f[0]){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");y(this._trace(m(this._eval(f,t,r[r.length-1],r.slice(0,-1),o,s),d),t,r,o,s,i,a))}else if("@"===f[0]){var D=!1,P=f.slice(1,-2);switch(P){default:throw new TypeError("Unknown value type "+P);case"scalar":t&&["object","function"].includes(n(t))||(D=!0);break;case"boolean":case"string":case"undefined":case"function":n(t)===P&&(D=!0);break;case"integer":!Number.isFinite(t)||t%1||(D=!0);break;case"number":Number.isFinite(t)&&(D=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(D=!0);break;case"object":t&&n(t)===P&&(D=!0);break;case"array":Array.isArray(t)&&(D=!0);break;case"other":D=this.currOtherTypeCallback(t,r,o,s);break;case"null":null===t&&(D=!0)}if(D)return c={path:r,value:t,parent:o,parentProperty:s},this._handleCallback(c,i,"value"),c}else if("`"===f[0]&&t&&h.call(t,f.slice(1))){var $=f.slice(1);y(this._trace(d,t[$],g(r,$),t,$,i,a,!0))}else if(f.includes(",")){var v,A=function(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=p(e))){var t=0,r=function(){};return{s:r,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o,s=!0,i=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(f.split(","));try{for(A.s();!(v=A.n()).done;){var I=v.value;y(this._trace(m(I,d),t,r,o,s,i,!0))}}catch(e){A.e(e)}finally{A.f()}}else!u&&t&&h.call(t,f)&&y(this._trace(d,t[f],g(r,f),t,f,i,a,!0))}if(this._hasParentSelector)for(var _=0;_\n${n}`),g(n,{method:"post",body:o,headers:{"content-type":"application/json"}})}function o(e,t){m.debug("TezosNodeWriter.forgeOperations:"),m.debug(JSON.stringify(t));let r=f.TezosMessageUtils.writeBranch(e);return t.forEach(e=>r+=p.TezosMessageCodec.encodeOperation(e)),r}function s(e,t,o,s,i,a="main"){return n(this,void 0,void 0,(function*(){const n=[{protocol:o,branch:t,contents:s,signature:i.signature}],u=yield r(e,`chains/${a}/blocks/head/helpers/preapply/operations`,n),c=yield u.text();let l;try{m.debug("TezosNodeWriter.preapplyOperation received "+c),l=JSON.parse(c)}catch(e){throw m.error("TezosNodeWriter.preapplyOperation failed to parse response"),new Error(`Could not parse JSON from response of chains/${a}/blocks/head/helpers/preapply/operation: '${c}' for ${n}`)}return R(c),l}))}function y(e,t,o="main"){return n(this,void 0,void 0,(function*(){const n=yield r(e,"injection/operation?chain="+o,t.bytes.toString("hex")),s=yield n.text();return R(s),s}))}function D(t,r,i,a=54){return n(this,void 0,void 0,(function*(){const n=yield l.TezosNodeReader.getBlockAtOffset(t,a),c=o(n.hash,r),p=yield i.signOperation(e.from(u.TezosConstants.OperationGroupWatermark+c,"hex")),h={bytes:e.concat([e.from(c,"hex"),p]),signature:f.TezosMessageUtils.readSignatureWithHint(p,i.getSignerCurve())},d=yield s(t,n.hash,n.protocol,r,h),g=yield y(t,h);return{results:d[0],operationGroupID:g}}))}function P(e,t,r,o,s){return n(this,void 0,void 0,(function*(){if(!(yield l.TezosNodeReader.isManagerKeyRevealedForAccount(e,r))){const e={kind:"reveal",source:r,fee:"0",counter:(o+1).toString(),gas_limit:"10600",storage_limit:"0",public_key:t};return s.forEach((e,t)=>{const r=o+2+t;e.counter=r.toString()}),[e,...s]}return s}))}function $(e,t,r,o,s=u.TezosConstants.DefaultDelegationFee,i=54){return n(this,void 0,void 0,(function*(){const n=(yield l.TezosNodeReader.getCounterForAccount(e,r.publicKeyHash))+1,a={kind:"delegation",source:r.publicKeyHash,fee:s.toString(),counter:n.toString(),storage_limit:u.TezosConstants.DefaultDelegationStorageLimit+"",gas_limit:u.TezosConstants.DefaultDelegationGasLimit+"",delegate:o},c=yield P(e,r.publicKey,r.publicKeyHash,n-1,[a]);return D(e,c,t,i)}))}function v(e,t,r,n,o,s,i,u,c,l){let p=void 0,f=void 0;return c===a.TezosParameterFormat.Michelson?(p=JSON.parse(h.TezosLanguageUtil.translateMichelsonToMicheline(i)),m.debug(`TezosNodeWriter.sendOriginationOperation code translation:\n${i}\n->\n${JSON.stringify(p)}`),f=JSON.parse(h.TezosLanguageUtil.translateMichelsonToMicheline(u)),m.debug(`TezosNodeWriter.sendOriginationOperation storage translation:\n${u}\n->\n${JSON.stringify(f)}`)):c===a.TezosParameterFormat.Micheline&&(p=JSON.parse(i),f=JSON.parse(u)),{kind:"origination",source:e.publicKeyHash,fee:n.toString(),counter:l.toString(),gas_limit:s.toString(),storage_limit:o.toString(),balance:t.toString(),delegate:r,script:{code:p,storage:f}}}function A(e,t,r,o,s,i,u,c,p,f,h=a.TezosParameterFormat.Micheline,d=54){return n(this,void 0,void 0,(function*(){const n=(yield l.TezosNodeReader.getCounterForAccount(e,r.publicKeyHash))+1,a=I(r.publicKeyHash,n,o,s,i,u,c,p,f,h),g=yield P(e,r.publicKey,r.publicKeyHash,n-1,[a]);return D(e,g,t,d)}))}function I(e,t,r,n,o,s,i,u,c,l=a.TezosParameterFormat.Micheline){let p={destination:r,amount:n.toString(),storage_limit:s.toString(),gas_limit:i.toString(),counter:t.toString(),fee:o.toString(),source:e,kind:"transaction"};if(void 0!==c){if(l===a.TezosParameterFormat.Michelson){const e=h.TezosLanguageUtil.translateParameterMichelsonToMicheline(c);p.parameters={entrypoint:u||"default",value:JSON.parse(e)}}else if(l===a.TezosParameterFormat.Micheline)p.parameters={entrypoint:u||"default",value:JSON.parse(c)};else if(l===a.TezosParameterFormat.MichelsonLambda){const e=h.TezosLanguageUtil.translateMichelsonToMicheline("code "+c);p.parameters={entrypoint:u||"default",value:JSON.parse(e)}}}else void 0!==u&&(p.parameters={entrypoint:u,value:[]});return p}function _(e,t,...o){return n(this,void 0,void 0,(function*(){const n=yield r(e,`chains/${t}/blocks/head/helpers/scripts/run_operation`,{chain_id:"NetXdQprcVkpaWU",operation:{branch:"BL94i2ShahPx3BoNs6tJdXDdGeoJ9ukwujUA2P8WJwULYNdimmq",contents:o,signature:"edsigu6xFLH2NpJ1VcYshpjW99Yc1TAL1m2XBqJyXrxcZQgBMo8sszw2zm626yjpA3pWMhjpsahLrWdmvX9cqhd4ZEUchuBuFYy"}}),s=yield n.text();R(s);const i=JSON.parse(s);let a=0,u=0;for(let e of i.contents){try{a+=parseInt(e.metadata.operation_result.consumed_gas)||0,u+=parseInt(e.metadata.operation_result.paid_storage_size_diff)||0}catch(e){}const t=e.metadata.internal_operation_results;if(void 0!==t)for(const e of t){const t=e.result;a+=parseInt(t.consumed_gas)||0,u+=parseInt(t.paid_storage_size_diff)||0}}return{gas:a,storageCost:u}}))}function R(e){let t="";try{const r=JSON.parse(e),n=Array.isArray(r)?r:[r];"kind"in n[0]?t=n.map(e=>`(${e.kind}: ${e.id})`).join(""):1===n.length&&1===n[0].contents.length&&"activate_account"===n[0].contents[0].kind||(t=n.map(e=>e.contents).map(e=>e.map(e=>e.metadata.operation_result).filter(e=>"applied"!==e.status).map(e=>`${e.status}: ${e.errors.map(e=>`(${e.kind}: ${e.id})`).join(", ")}\n`)).join(""))}catch(r){if(e.startsWith("Failed to parse the request body: "))t=e.slice(34);else{const t=e.replace(/\"/g,"").replace(/\n/,"");51===t.length&&"o"===t.charAt(0)||m.error(`failed to parse errors: '${r}' from '${e}'\n, PLEASE report this to the maintainers`)}}if(t.length>0)throw m.debug("errors found in response:\n"+e),new c.ServiceResponseError(200,"","","",e)}t.forgeOperations=o,t.forgeOperationsRemotely=function(e,t,o,s="main"){return n(this,void 0,void 0,(function*(){m.debug("TezosNodeWriter.forgeOperations:"),m.debug(JSON.stringify(o)),m.warn("forgeOperationsRemotely() is not intrinsically trustless");const n=yield r(e,`chains/${s}/blocks/head/helpers/forge/operations`,{branch:t,contents:o}),i=(yield n.text()).replace(/\n/g,"").replace(/['"]+/g,"");let a=Array.from(o.map(e=>e.kind)),u=!1;for(let e of a)if(u=["reveal","transaction","delegation","origination"].includes(e),u)break;if(u){const e=p.TezosMessageCodec.parseOperationGroup(i);for(let t=0;t{t.feed(e)}),t.results[0]}function n(e,t){let r=e;e.script&&(r=e.script);for(let e=0;e`"${e}"`).join(", "),consumed:t.consumed}}function d(e){let t=new Map;t.parameter=e.search(/(^|\s+)parameter/m),t.storage=e.search(/(^|\s+)storage/m),t.code=e.search(/(^|\s+)code/m);const r=Object.values(t).sort((e,t)=>Number(e)-Number(t));t[Object.keys(t).find(e=>t[e]===r[0])+""]=e.substring(r[0],r[1]),t[Object.keys(t).find(e=>t[e]===r[1])+""]=e.substring(r[1],r[2]),t[Object.keys(t).find(e=>t[e]===r[2])+""]=e.substring(r[2]);return[t.parameter,t.storage,t.code].map(e=>e.trim().split("\n").map(e=>e.replace(/\#[\s\S]+$/,"").trim()).filter(e=>e.length>0).join(" "))}function g(e){return e.replace(/\n/g," ").replace(/ +/g," ").replace(/\[{/g,"[ {").replace(/}\]/g,"} ]").replace(/},{/g,"}, {").replace(/\]}/g,"] }").replace(/":"/g,'": "').replace(/":\[/g,'": [').replace(/{"/g,'{ "').replace(/"}/g,'" }').replace(/,"/g,', "').replace(/","/g,'", "').replace(/\[\[/g,"[ [").replace(/\]\]/g,"] ]").replace(/\["/g,'[ "').replace(/"\]/g,'" ]').replace(/\[ +\]/g,"[]").trim()}t.hexToMicheline=function e(t){if(t.length<2)throw new Error(`Malformed Micheline fragment '${t}'`);let r="",n=0,o=t.substring(n,n+2);switch(n+=2,o){case"00":{const e=a.TezosMessageUtils.findInt(t.substring(n),0,!0);r+=`{ "int": "${e.value}" }`,n+=e.length;break}case"01":{const e=l(t.substring(n));r+=`{ "string": "${e.code}" }`,n+=e.consumed;break}case"02":{const o=parseInt(t.substring(n,n+8),16);n+=8;let s=[],i=0;for(;i2&&(r+=`, "annots": [ ${e.code} ] }`),n+=e.consumed}else r+=" }",n+=8;break}case"0a":{const e=parseInt(t.substring(n,n+8),16);n+=8,r+=`{ "bytes": "${t.substring(n,n+2*e)}" }`,n+=2*e;break}default:throw new Error(`Unknown Micheline field type '${o}'`)}return{code:r,consumed:n}},t.hexToMichelson=function e(t){if(t.length<2)throw new Error(`Malformed Michelson fragment '${t}'`);let r="",n=0,o=t.substring(n,n+2);switch(n+=2,o){case"00":{const e=a.TezosMessageUtils.findInt(t.substring(n),0,!0);r+=` ${e.value} `,n+=e.length;break}case"01":{const e=l(t.substring(n));r+=` "${e.code}" `,n+=e.consumed;break}case"02":{const o=parseInt(t.substring(n,n+8),16);n+=8;let s=[],i=0;for(;i2&&(r+=` ${e.code} )`),n+=e.consumed}else r+=" )",n+=8;break}case"0a":{const e=parseInt(t.substring(n,n+8),16);n+=8,r+=` 0x${t.substring(n,n+2*e)} `,n+=2*e;break}default:throw new Error(`Unknown Micheline field type '${o}'`)}return{code:r,consumed:n}},t.translateMichelsonToMicheline=r,t.translateParameterMichelsonToMicheline=function(e){return r(e)},t.translateMichelsonToHex=function(e){return function(e){const t=JSON.parse(e);let r=[];return r.push(n(t,"code")),r.push(n(t,"storage")),r}(r(e)).map(e=>g(e)).map(e=>c(e)).reduce((e,t)=>e+("0000000"+(t.length/2).toString(16)).slice(-8)+t,"")},t.translateMichelineToHex=c,t.preProcessMichelsonScript=d,t.normalizeMichelineWhiteSpace=g,t.normalizeMichelsonWhiteSpace=function(e){return e.replace(/\s{2,}/g," ").replace(/\( /g,"(").replace(/ \)/g,")")},t.stripComments=function(e){return e.trim().split("\n").map(e=>e.replace(/\#[\s\S]+$/,"").trim()).filter(e=>e.length>0).join(" ")}}(t.TezosLanguageUtil||(t.TezosLanguageUtil={}))}).call(this,r(0).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n=r(18),o=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=p;var s=r(16);s.inherits=r(1);var i=r(36),a=r(25);s.inherits(p,i);for(var u=o(a.prototype),c=0;c=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,o=(r-n)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s},o.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=o},function(e,t,r){var n=r(75),o=r(76);e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{static setFetch(e){this.actualFetch=e}}t.default=n,n.fetch=(e,t)=>n.actualFetch(e,t)},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,r(0).Buffer)},function(e,t){var r,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var u,c=[],l=!1,p=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&h())}function h(){if(!l){var e=a(f);l=!0;for(var t=c.length;t;){for(u=c,c=[];++p1)for(var r=1;r0)throw new Error("RegExp has capture groups: "+m+"\nUse (?: … ) instead");if(!h.lineBreaks&&m.test("\n"))throw new Error("Rule should declare lineBreaks: "+m);p.push(s(g))}}var b=n&&n.fallback,y=r&&!b?"ym":"gm",D=r||b?"":"|";return{regexp:new RegExp(i(p)+D,y),groups:c,fast:o,error:n||l}}function f(e,t,r){var n=e&&(e.push||e.next);if(n&&!r[n])throw new Error("Missing state '"+n+"' (in token '"+e.defaultType+"' of state '"+t+"')");if(e&&e.pop&&1!=+e.pop)throw new Error("pop must be 1 (in token '"+e.defaultType+"' of state '"+t+"')")}var h=function(e,t){this.startState=t,this.states=e,this.buffer="",this.stack=[],this.reset()};h.prototype.reset=function(e,t){return this.buffer=e||"",this.index=0,this.line=t?t.line:1,this.col=t?t.col:1,this.queuedToken=t?t.queuedToken:null,this.queuedThrow=t?t.queuedThrow:null,this.setState(t?t.state:this.startState),this.stack=t&&t.stack?t.stack.slice():[],this},h.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},h.prototype.setState=function(e){if(e&&this.state!==e){this.state=e;var t=this.states[e];this.groups=t.groups,this.error=t.error,this.re=t.regexp,this.fast=t.fast}},h.prototype.popState=function(){this.setState(this.stack.pop())},h.prototype.pushState=function(e){this.stack.push(this.state),this.setState(e)};var d=r?function(e,t){return e.exec(t)}:function(e,t){var r=e.exec(t);return 0===r[0].length?null:r};function g(){return this.value}if(h.prototype._getGroup=function(e){for(var t=this.groups.length,r=0;r0&&i.length>o&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,a=u,console&&console.warn&&console.warn(a)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=f.bind(n);return o.listener=r,n.wrapFn=o,o}function d(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)s(u,this,t);else{var c=u.length,l=m(u,c);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return d(this,e,!0)},a.prototype.rawListeners=function(e){return d(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){(t=e.exports=r(36)).Stream=t,t.Readable=t,t.Writable=r(25),t.Duplex=r(10),t.Transform=r(39),t.PassThrough=r(60)},function(e,t,r){"use strict";(function(t,n,o){var s=r(18);function i(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var o=n.callback;t.pendingcb--,o(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=y;var a,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:s.nextTick;y.WritableState=b;var c=r(16);c.inherits=r(1);var l={deprecate:r(59)},p=r(37),f=r(2).Buffer,h=o.Uint8Array||function(){};var d,g=r(38);function m(){}function b(e,t){a=a||r(10),e=e||{};var n=t instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var o=e.highWaterMark,c=e.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:n&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var p=!1===e.decodeStrings;this.decodeStrings=!p,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,o=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,o){--t.pendingcb,r?(s.nextTick(o,n),s.nextTick(I,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(o(n),e._writableState.errorEmitted=!0,e.emit("error",n),I(e,t))}(e,r,n,t,o);else{var i=v(r);i||r.corked||r.bufferProcessing||!r.bufferedRequest||$(e,r),n?u(P,e,r,i,o):P(e,r,i,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function y(e){if(a=a||r(10),!(d.call(y,this)||this instanceof a))return new y(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),p.call(this)}function D(e,t,r,n,o,s,i){t.writelen=n,t.writecb=i,t.writing=!0,t.sync=!0,r?e._writev(o,t.onwrite):e._write(o,s,t.onwrite),t.sync=!1}function P(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),I(e,t)}function $(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,o=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)o[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;o.allBuffers=u,D(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new i(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,p=r.callback;if(D(e,t,!1,t.objectMode?1:c.length,c,l,p),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function v(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function A(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),I(e,t)}))}function I(e,t){var r=v(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,s.nextTick(A,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}c.inherits(y,p),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:l.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===y&&(e&&e._writableState instanceof b)}})):d=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,r){var n,o=this._writableState,i=!1,a=!o.objectMode&&(n=e,f.isBuffer(n)||n instanceof h);return a&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=m),o.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),s.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var o=!0,i=!1;return null===r?i=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),s.nextTick(n,i),o=!1),o}(this,o,e,r))&&(o.pendingcb++,i=function(e,t,r,n,o,s){if(!r){var i=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,r));return t}(t,n,o);n!==i&&(r=!0,o="buffer",n=i)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,I(e,t),r&&(t.finished?s.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=g.destroy,y.prototype._undestroy=g.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(17),r(57).setImmediate,r(9))},function(e,t,r){"use strict";var n=r(2).Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=p,t=3;break;default:return this.write=f,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function i(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function p(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return o>0&&(e.lastNeed=o-1),o;if(--n=0)return o>0&&(e.lastNeed=o-2),o;if(--n=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=r(28),s=r(20),i=r(29);!function(e){function t(e,t,r,o){return n(this,void 0,void 0,(function*(){return i.ConseilDataClient.executeEntityQuery(e,"tezos",t,r,o)}))}function r(e,r){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addOrdering(o.ConseilQueryBuilder.blankQuery(),"level",s.ConseilSortDirection.DESC),1);return(yield t(e,r,"blocks",n))[0]}))}function a(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"blocks",o)}))}function u(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"operations",o)}))}function c(e,t,i,a,c=60){return n(this,void 0,void 0,(function*(){if(a<=0)throw new Error("Invalid duration");const n=(yield r(e,t)).level;let l=n,p=o.ConseilQueryBuilder.blankQuery();for(p=o.ConseilQueryBuilder.addPredicate(p,"operation_group_hash",s.ConseilOperator.EQ,[i],!1),p=o.ConseilQueryBuilder.addPredicate(p,"timestamp",s.ConseilOperator.AFTER,[(new Date).getTime()-6e4],!1),p=o.ConseilQueryBuilder.setLimit(p,1);n+a>l;){const o=yield u(e,t,p);if(o.length>0)return o[0];if(l=(yield r(e,t)).level,n+asetTimeout(e,1e3*c))}throw new Error(`Did not observe ${i} on ${t} in ${a} block${a>1?"s":""} since ${n}`)}))}e.getTezosEntityData=t,e.getBlockHead=r,e.getBlock=function(e,i,a){return n(this,void 0,void 0,(function*(){if("head"===a)return r(e,i);const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"hash",s.ConseilOperator.EQ,[a],!1),1);return(yield t(e,i,"blocks",n))[0]}))},e.getBlockByLevel=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"level",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"blocks",n))[0]}))},e.getAccount=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"account_id",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"accounts",n))[0]}))},e.getOperationGroup=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"hash",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"operation_groups",n))[0]}))},e.getOperation=function(e,r,i){return n(this,void 0,void 0,(function*(){const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"operation_group_hash",s.ConseilOperator.EQ,[i],!1),1);return(yield t(e,r,"operations",n))[0]}))},e.getBlocks=a,e.getAccounts=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"accounts",o)}))},e.getOperationGroups=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"operation_groups",o)}))},e.getOperations=u,e.getFeeStatistics=function(e,r,i){return n(this,void 0,void 0,(function*(){let n=o.ConseilQueryBuilder.blankQuery();return n=o.ConseilQueryBuilder.addPredicate(n,"kind",s.ConseilOperator.EQ,[i]),n=o.ConseilQueryBuilder.addOrdering(n,"timestamp",s.ConseilSortDirection.DESC),n=o.ConseilQueryBuilder.setLimit(n,1),t(e,r,"fees",n)}))},e.getProposals=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"proposals",o)}))},e.getBakers=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"bakers",o)}))},e.getBallots=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,r,"ballots",o)}))},e.awaitOperationConfirmation=c,e.awaitOperationForkConfirmation=function(e,t,i,u,l){return n(this,void 0,void 0,(function*(){const n=yield c(e,t,i,u),p=n.block_level,f=n.block_hash;let h=p;for(yield new Promise(e=>setTimeout(e,50*l*1e3));h=p+l)break;yield new Promise(e=>setTimeout(e,6e4))}let d=o.ConseilQueryBuilder.blankQuery();d=o.ConseilQueryBuilder.addFields(d,"level","hash","predecessor"),d=o.ConseilQueryBuilder.addPredicate(d,"level",s.ConseilOperator.BETWEEN,[p-1,p+l]),d=o.ConseilQueryBuilder.setLimit(d,2*l);const g=yield a(e,t,d);return g.length===l+2?function(e,t,r){try{return e.sort((e,t)=>parseInt(e.level)-parseInt(t.level)).reduce((n,o,s)=>{if(!n)throw new Error("Block sequence mismatch");return s>1?o.predecessor===e[s-1].hash:1===s?n&&o.level===t&&o.hash===r&&o.predecessor===e[s-1].hash:0===s||void 0},!0)}catch(e){return!1}}(g,p,f):function(e,t,r,n){throw new Error("Not implemented")}()}))},e.getBigMapData=function(e,r){return n(this,void 0,void 0,(function*(){if(!r.startsWith("KT1"))throw new Error("Invalid address");const n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addFields(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"account_id",s.ConseilOperator.EQ,[r],!1),"big_map_id"),100),i=yield t(e,e.network,"originated_account_maps",n);if(i.length<1)return;const a=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"big_map_id",i.length>1?s.ConseilOperator.IN:s.ConseilOperator.EQ,i.map(e=>e.big_map_id),!1),100),u=yield t(e,e.network,"big_maps",a),c=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.addFields(o.ConseilQueryBuilder.addPredicate(o.ConseilQueryBuilder.blankQuery(),"big_map_id",i.length>1?s.ConseilOperator.IN:s.ConseilOperator.EQ,i.map(e=>e.big_map_id),!1),"big_map_id","key","value"),1e3),l=yield t(e,e.network,"big_map_contents",c);let p=[];for(const e of u){const t={index:Number(e.big_map_id),key:e.key_type,value:e.value_type};let r=[];for(const e of l.filter(e=>e.big_map_id===t.index))r.push({key:JSON.stringify(e.key),value:JSON.stringify(e.value)});p.push({definition:t,content:r})}return{contract:r,maps:p}}))},e.getBigMapValueForKey=function(e,r,i="",a=-1){return n(this,void 0,void 0,(function*(){if(!i.startsWith("KT1"))throw new Error("Invalid address");if(r.length<1)throw new Error("Invalid key");if(a<0&&0===i.length)throw new Error("One of contract or mapIndex must be specified");if(a<0&&i.length>0){let r=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.blankQuery(),1);r=o.ConseilQueryBuilder.addFields(r,"big_map_id"),r=o.ConseilQueryBuilder.addPredicate(r,"account_id",s.ConseilOperator.EQ,[i],!1),r=o.ConseilQueryBuilder.addOrdering(r,"big_map_id",s.ConseilSortDirection.DESC);const n=yield t(e,e.network,"originated_account_maps",r);if(n.length<1)throw new Error("Could not find any maps for "+i);a=n[0]}let n=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.blankQuery(),1);n=o.ConseilQueryBuilder.addFields(n,"value"),n=o.ConseilQueryBuilder.addPredicate(n,"key",s.ConseilOperator.EQ,[r],!1),n=o.ConseilQueryBuilder.addPredicate(n,"big_map_id",s.ConseilOperator.EQ,[a],!1);const u=yield t(e,e.network,"big_map_contents",n);if(u.length<1)throw new Error(`Could not a value for key ${r} in map ${a}`);return u[0]}))},e.getEntityQueryForId=function(e){let t=o.ConseilQueryBuilder.setLimit(o.ConseilQueryBuilder.blankQuery(),1);if("number"==typeof e){if(Number(e)<0)throw new Error("Invalid numeric id parameter");return{entity:"blocks",query:o.ConseilQueryBuilder.addPredicate(t,"level",s.ConseilOperator.EQ,[e],!1)}}if("string"==typeof e){const r=String(e);if(r.startsWith("tz1")||r.startsWith("tz2")||r.startsWith("tz3")||r.startsWith("KT1"))return{entity:"accounts",query:o.ConseilQueryBuilder.addPredicate(t,"account_id",s.ConseilOperator.EQ,[e],!1)};if(r.startsWith("B"))return{entity:"blocks",query:o.ConseilQueryBuilder.addPredicate(t,"hash",s.ConseilOperator.EQ,[e],!1)};if(r.startsWith("o"))return t=o.ConseilQueryBuilder.setLimit(t,1e3),{entity:"operations",query:o.ConseilQueryBuilder.addPredicate(t,"operation_group_hash",s.ConseilOperator.EQ,[e],!1)}}throw new Error("Invalid id parameter")}}(t.TezosConseilClient||(t.TezosConseilClient={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(20);!function(e){e.blankQuery=function(){return{fields:[],predicates:[],orderBy:[],aggregation:[],limit:100}},e.addFields=function(e,...t){let r=Object.assign({},e),n=new Set(e.fields);return t.forEach(e=>n.add(e)),r.fields=Array.from(n.values()),r},e.addPredicate=function(e,t,r,o,s=!1,i){if(r===n.ConseilOperator.BETWEEN&&2!==o.length)throw new Error("BETWEEN operation requires a list of two values.");if(r===n.ConseilOperator.IN&&o.length<2)throw new Error("IN operation requires a list of two or more values.");if(1!==o.length&&r!==n.ConseilOperator.IN&&r!==n.ConseilOperator.BETWEEN&&r!==n.ConseilOperator.ISNULL)throw new Error(`invalid values list for ${r}.`);let a=Object.assign({},e);return a.predicates.push({field:t,operation:r,set:o,inverse:s,group:i}),a},e.addOrdering=function(e,t,r=n.ConseilSortDirection.ASC){let o=Object.assign({},e);return o.orderBy.push({field:t,direction:r}),o},e.setLimit=function(e,t){if(t<1)throw new Error("Limit cannot be less than one.");let r=Object.assign({},e);return r.limit=t,r},e.setOutputType=function(e,t){let r=Object.assign({},e);return r.output=t,r},e.addAggregationFunction=function(e,t,r){if(!e.fields.includes(t))throw new Error("Cannot apply an aggregation function on a field not being returned.");let n=Object.assign({},e);return n.aggregation.push({field:t,function:r}),n}}(t.ConseilQueryBuilder||(t.ConseilQueryBuilder={}))},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(30),i=o(r(15)),a=o(r(12)).default.log,u=i.default.fetch;!function(e){e.executeEntityQuery=function(e,t,r,o,i){return n(this,void 0,void 0,(function*(){const n=`${e.url}/v2/data/${t}/${r}/${o}`;return a.debug(`ConseilDataClient.executeEntityQuery request: ${n}, ${JSON.stringify(i)}`),u(n,{method:"post",headers:{apiKey:e.apiKey,"Content-Type":"application/json"},body:JSON.stringify(i)}).then(e=>{if(!e.ok)throw a.error(`ConseilDataClient.executeEntityQuery request: ${n}, ${JSON.stringify(i)}, failed with ${e.statusText}(${e.status})`),new s.ConseilRequestError(e.status,e.statusText,n,i);return e}).then(e=>{const t=e.headers.get("content-type").toLowerCase().includes("application/json"),r=t?e.json():e.text();return a.debug("ConseilDataClient.executeEntityQuery response: "+(t?JSON.stringify(r):r)),r})}))}}(t.ConseilDataClient||(t.ConseilDataClient={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(21);class o extends n.ServiceRequestError{constructor(e,t,r,n){super(e,t,r,null),this.conseilQuery=n}toString(){return`ConseilRequestError for ${this.serverURL} with ${this.httpStatus} and ${this.httpMessage}`}}t.ConseilRequestError=o;class s extends n.ServiceResponseError{constructor(e,t,r,n,o){super(e,t,r,null,o),this.conseilQuery=n}}t.ConseilResponseError=s},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){(function(e){var n,o=function(e){"use strict";var t=1e7,r=9007199254740992,n=p(r),s="function"==typeof BigInt;function i(e,t,r,n){return void 0===e?i[0]:void 0!==t&&(10!=+t||r)?L(e,t,r,n):H(e)}function a(e,t){this.value=e,this.sign=t,this.isSmall=!1}function u(e){this.value=e,this.sign=e<0,this.isSmall=!0}function c(e){this.value=e}function l(e){return-r0?Math.floor(e):Math.ceil(e)}function m(e,r){var n,o,s=e.length,i=r.length,a=new Array(s),u=0,c=t;for(o=0;o=c?1:0,a[o]=n-u*c;for(;o0&&a.push(u),a}function b(e,t){return e.length>=t.length?m(e,t):m(t,e)}function y(e,r){var n,o,s=e.length,i=new Array(s),a=t;for(o=0;o0;)i[o++]=r%a,r=Math.floor(r/a);return i}function D(e,t){var r,n,o=e.length,s=t.length,i=new Array(o),a=0;for(r=0;r0;)i[o++]=u%a,u=Math.floor(u/a);return i}function A(e,t){for(var r=[];t-- >0;)r.push(0);return r.concat(e)}function I(e,r,n){return new a(e=0;--r)o=(s=1e7*o+e[r])-(n=g(s/t))*t,a[r]=0|n;return[a,0|o]}function S(e,r){var n,o=H(r);if(s)return[new c(e.value/o.value),new c(e.value%o.value)];var l,m=e.value,b=o.value;if(0===b)throw new Error("Cannot divide by zero");if(e.isSmall)return o.isSmall?[new u(g(m/b)),new u(m%b)]:[i[0],e];if(o.isSmall){if(1===b)return[e,i[0]];if(-1==b)return[e.negate(),i[0]];var y=Math.abs(b);if(y=0;o--){for(n=h-1,y[o+p]!==m&&(n=Math.floor((y[o+p]*h+y[o+p-1])/m)),s=0,i=0,u=D.length,a=0;au&&(o=1e7*(o+1)),r=Math.ceil(o/s);do{if(C(i=v(t,r),l)<=0)break;r--}while(r);c.push(r),l=D(l,i)}return c.reverse(),[f(c),f(l)]}(m,b))[0];var A=e.sign!==o.sign,I=n[1],_=e.sign;return"number"==typeof l?(A&&(l=-l),l=new u(l)):l=new a(l,A),"number"==typeof I?(_&&(I=-I),I=new u(I)):I=new a(I,_),[l,I]}function C(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var r=e.length-1;r>=0;r--)if(e[r]!==t[r])return e[r]>t[r]?1:-1;return 0}function U(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function E(e,t){for(var r,n,s,i=e.prev(),a=i,u=0;a.isEven();)a=a.divide(2),u++;e:for(n=0;n=0?n=D(e,t):(n=D(t,e),r=!r),"number"==typeof(n=f(n))?(r&&(n=-n),new u(n)):new a(n,r)}(r,n,this.sign)},a.prototype.minus=a.prototype.subtract,u.prototype.subtract=function(e){var t=H(e),r=this.value;if(r<0!==t.sign)return this.add(t.negate());var n=t.value;return t.isSmall?new u(r-n):P(n,Math.abs(r),r>=0)},u.prototype.minus=u.prototype.subtract,c.prototype.subtract=function(e){return new c(this.value-H(e).value)},c.prototype.minus=c.prototype.subtract,a.prototype.negate=function(){return new a(this.value,!this.sign)},u.prototype.negate=function(){var e=this.sign,t=new u(-this.value);return t.sign=!e,t},c.prototype.negate=function(){return new c(-this.value)},a.prototype.abs=function(){return new a(this.value,!1)},u.prototype.abs=function(){return new u(Math.abs(this.value))},c.prototype.abs=function(){return new c(this.value>=0?this.value:-this.value)},a.prototype.multiply=function(e){var r,n,o,s=H(e),u=this.value,c=s.value,l=this.sign!==s.sign;if(s.isSmall){if(0===c)return i[0];if(1===c)return this;if(-1===c)return this.negate();if((r=Math.abs(c))0?function e(t,r){var n=Math.max(t.length,r.length);if(n<=30)return $(t,r);n=Math.ceil(n/2);var o=t.slice(n),s=t.slice(0,n),i=r.slice(n),a=r.slice(0,n),u=e(s,a),c=e(o,i),l=e(b(s,o),b(a,i)),p=b(b(u,A(D(D(l,u),c),n)),A(c,2*n));return h(p),p}(u,c):$(u,c),l)},a.prototype.times=a.prototype.multiply,u.prototype._multiplyBySmall=function(e){return l(e.value*this.value)?new u(e.value*this.value):I(Math.abs(e.value),p(Math.abs(this.value)),this.sign!==e.sign)},a.prototype._multiplyBySmall=function(e){return 0===e.value?i[0]:1===e.value?this:-1===e.value?this.negate():I(Math.abs(e.value),this.value,this.sign!==e.sign)},u.prototype.multiply=function(e){return H(e)._multiplyBySmall(this)},u.prototype.times=u.prototype.multiply,c.prototype.multiply=function(e){return new c(this.value*H(e).value)},c.prototype.times=c.prototype.multiply,a.prototype.square=function(){return new a(_(this.value),!1)},u.prototype.square=function(){var e=this.value*this.value;return l(e)?new u(e):new a(_(p(Math.abs(this.value))),!1)},c.prototype.square=function(e){return new c(this.value*this.value)},a.prototype.divmod=function(e){var t=S(this,e);return{quotient:t[0],remainder:t[1]}},c.prototype.divmod=u.prototype.divmod=a.prototype.divmod,a.prototype.divide=function(e){return S(this,e)[0]},c.prototype.over=c.prototype.divide=function(e){return new c(this.value/H(e).value)},u.prototype.over=u.prototype.divide=a.prototype.over=a.prototype.divide,a.prototype.mod=function(e){return S(this,e)[1]},c.prototype.mod=c.prototype.remainder=function(e){return new c(this.value%H(e).value)},u.prototype.remainder=u.prototype.mod=a.prototype.remainder=a.prototype.mod,a.prototype.pow=function(e){var t,r,n,o=H(e),s=this.value,a=o.value;if(0===a)return i[1];if(0===s)return i[0];if(1===s)return i[1];if(-1===s)return o.isEven()?i[1]:i[-1];if(o.sign)return i[0];if(!o.isSmall)throw new Error("The exponent "+o.toString()+" is too large.");if(this.isSmall&&l(t=Math.pow(s,a)))return new u(g(t));for(r=this,n=i[1];!0&a&&(n=n.times(r),--a),0!==a;)a/=2,r=r.square();return n},u.prototype.pow=a.prototype.pow,c.prototype.pow=function(e){var t=H(e),r=this.value,n=t.value,o=BigInt(0),s=BigInt(1),a=BigInt(2);if(n===o)return i[1];if(r===o)return i[0];if(r===s)return i[1];if(r===BigInt(-1))return t.isEven()?i[1]:i[-1];if(t.isNegative())return new c(o);for(var u=this,l=i[1];(n&s)===s&&(l=l.times(u),--n),n!==o;)n/=a,u=u.square();return l},a.prototype.modPow=function(e,t){if(e=H(e),(t=H(t)).isZero())throw new Error("Cannot take modPow with modulus 0");var r=i[1],n=this.mod(t);for(e.isNegative()&&(e=e.multiply(i[-1]),n=n.modInv(t));e.isPositive();){if(n.isZero())return i[0];e.isOdd()&&(r=r.multiply(n).mod(t)),e=e.divide(2),n=n.square().mod(t)}return r},c.prototype.modPow=u.prototype.modPow=a.prototype.modPow,a.prototype.compareAbs=function(e){var t=H(e),r=this.value,n=t.value;return t.isSmall?1:C(r,n)},u.prototype.compareAbs=function(e){var t=H(e),r=Math.abs(this.value),n=t.value;return t.isSmall?r===(n=Math.abs(n))?0:r>n?1:-1:-1},c.prototype.compareAbs=function(e){var t=this.value,r=H(e).value;return(t=t>=0?t:-t)===(r=r>=0?r:-r)?0:t>r?1:-1},a.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=H(e),r=this.value,n=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:C(r,n)*(this.sign?-1:1)},a.prototype.compareTo=a.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=H(e),r=this.value,n=t.value;return t.isSmall?r==n?0:r>n?1:-1:r<0!==t.sign?r<0?-1:1:r<0?1:-1},u.prototype.compareTo=u.prototype.compare,c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,r=H(e).value;return t===r?0:t>r?1:-1},c.prototype.compareTo=c.prototype.compare,a.prototype.equals=function(e){return 0===this.compare(e)},c.prototype.eq=c.prototype.equals=u.prototype.eq=u.prototype.equals=a.prototype.eq=a.prototype.equals,a.prototype.notEquals=function(e){return 0!==this.compare(e)},c.prototype.neq=c.prototype.notEquals=u.prototype.neq=u.prototype.notEquals=a.prototype.neq=a.prototype.notEquals,a.prototype.greater=function(e){return this.compare(e)>0},c.prototype.gt=c.prototype.greater=u.prototype.gt=u.prototype.greater=a.prototype.gt=a.prototype.greater,a.prototype.lesser=function(e){return this.compare(e)<0},c.prototype.lt=c.prototype.lesser=u.prototype.lt=u.prototype.lesser=a.prototype.lt=a.prototype.lesser,a.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},c.prototype.geq=c.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals=a.prototype.geq=a.prototype.greaterOrEquals,a.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},c.prototype.leq=c.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals=a.prototype.leq=a.prototype.lesserOrEquals,a.prototype.isEven=function(){return 0==(1&this.value[0])},u.prototype.isEven=function(){return 0==(1&this.value)},c.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},a.prototype.isOdd=function(){return 1==(1&this.value[0])},u.prototype.isOdd=function(){return 1==(1&this.value)},c.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},a.prototype.isPositive=function(){return!this.sign},u.prototype.isPositive=function(){return this.value>0},c.prototype.isPositive=u.prototype.isPositive,a.prototype.isNegative=function(){return this.sign},u.prototype.isNegative=function(){return this.value<0},c.prototype.isNegative=u.prototype.isNegative,a.prototype.isUnit=function(){return!1},u.prototype.isUnit=function(){return 1===Math.abs(this.value)},c.prototype.isUnit=function(){return this.abs().value===BigInt(1)},a.prototype.isZero=function(){return!1},u.prototype.isZero=function(){return 0===this.value},c.prototype.isZero=function(){return this.value===BigInt(0)},a.prototype.isDivisibleBy=function(e){var t=H(e);return!t.isZero()&&(!!t.isUnit()||(0===t.compareAbs(2)?this.isEven():this.mod(t).isZero()))},c.prototype.isDivisibleBy=u.prototype.isDivisibleBy=a.prototype.isDivisibleBy,a.prototype.isPrime=function(e){var t=U(this);if(void 0!==t)return t;var r=this.abs(),n=r.bitLength();if(n<=64)return E(r,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var s=Math.log(2)*n.toJSNumber(),i=Math.ceil(!0===e?2*Math.pow(s,2):s),a=[],u=0;u-r?new u(e-1):new a(n,!0)},c.prototype.prev=function(){return new c(this.value-BigInt(1))};for(var T=[1];2*T[T.length-1]<=t;)T.push(2*T[T.length-1]);var w=T.length,O=T[w-1];function N(e){return Math.abs(e)<=t}function x(e,t,r){t=H(t);for(var n=e.isNegative(),s=t.isNegative(),i=n?e.not():e,a=s?t.not():t,u=0,c=0,l=null,p=null,f=[];!i.isZero()||!a.isZero();)u=(l=S(i,O))[1].toJSNumber(),n&&(u=O-1-u),c=(p=S(a,O))[1].toJSNumber(),s&&(c=O-1-c),i=l[0],a=p[0],f.push(r(u,c));for(var h=0!==r(n?1:0,s?1:0)?o(-1):o(0),d=f.length-1;d>=0;d-=1)h=h.multiply(O).add(o(f[d]));return h}a.prototype.shiftLeft=function(e){var t=H(e).toJSNumber();if(!N(t))throw new Error(String(t)+" is too large for shifting.");if(t<0)return this.shiftRight(-t);var r=this;if(r.isZero())return r;for(;t>=w;)r=r.multiply(O),t-=w-1;return r.multiply(T[t])},c.prototype.shiftLeft=u.prototype.shiftLeft=a.prototype.shiftLeft,a.prototype.shiftRight=function(e){var t,r=H(e).toJSNumber();if(!N(r))throw new Error(String(r)+" is too large for shifting.");if(r<0)return this.shiftLeft(-r);for(var n=this;r>=w;){if(n.isZero()||n.isNegative()&&n.isUnit())return n;n=(t=S(n,O))[1].isNegative()?t[0].prev():t[0],r-=w-1}return(t=S(n,T[r]))[1].isNegative()?t[0].prev():t[0]},c.prototype.shiftRight=u.prototype.shiftRight=a.prototype.shiftRight,a.prototype.not=function(){return this.negate().prev()},c.prototype.not=u.prototype.not=a.prototype.not,a.prototype.and=function(e){return x(this,e,(function(e,t){return e&t}))},c.prototype.and=u.prototype.and=a.prototype.and,a.prototype.or=function(e){return x(this,e,(function(e,t){return e|t}))},c.prototype.or=u.prototype.or=a.prototype.or,a.prototype.xor=function(e){return x(this,e,(function(e,t){return e^t}))},c.prototype.xor=u.prototype.xor=a.prototype.xor;function M(e){var r=e.value,n="number"==typeof r?r|1<<30:"bigint"==typeof r?r|BigInt(1<<30):r[0]+r[1]*t|1073758208;return n&-n}function F(e,t){return e=H(e),t=H(t),e.greater(t)?e:t}function G(e,t){return e=H(e),t=H(t),e.lesser(t)?e:t}function k(e,t){if(e=H(e).abs(),t=H(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var r,n,o=i[1];e.isEven()&&t.isEven();)r=G(M(e),M(t)),e=e.divide(r),t=t.divide(r),o=o.multiply(r);for(;e.isEven();)e=e.divide(M(e));do{for(;t.isEven();)t=t.divide(M(t));e.greater(t)&&(n=t,t=e,e=n),t=t.subtract(e)}while(!t.isZero());return o.isUnit()?e:e.multiply(o)}a.prototype.bitLength=function(){var e=this;return e.compareTo(o(0))<0&&(e=e.negate().subtract(o(1))),0===e.compareTo(o(0))?o(0):o(function e(t,r){if(r.compareTo(t)<=0){var n=e(t,r.square(r)),s=n.p,i=n.e,a=s.multiply(r);return a.compareTo(t)<=0?{p:a,e:2*i+1}:{p:s,e:2*i}}return{p:o(1),e:0}}(e,o(2)).e).add(o(1))},c.prototype.bitLength=u.prototype.bitLength=a.prototype.bitLength;var L=function(e,t,r,n){r=r||"0123456789abcdefghijklmnopqrstuvwxyz",e=String(e),n||(e=e.toLowerCase(),r=r.toLowerCase());var o,s=e.length,i=Math.abs(t),a={};for(o=0;o=i)){if("1"===l&&1===i)continue;throw new Error(l+" is not a valid digit in base "+t+".")}}t=H(t);var u=[],c="-"===e[0];for(o=c?1:0;o"!==e[o]&&o=0;n--)o=o.add(e[n].times(s)),s=s.times(t);return r?o.negate():o}function B(e,t){if((t=o(t)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var n=!1;if(e.isNegative()&&t.isPositive()&&(n=!0,e=e.abs()),t.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:n};for(var s,i=[],a=e;a.isNegative()||a.compareAbs(t)>=0;){s=a.divmod(t),a=s.quotient;var u=s.remainder;u.isNegative()&&(u=t.minus(u).abs(),a=a.next()),i.push(u.toJSNumber())}return i.push(a.toJSNumber()),{value:i.reverse(),isNegative:n}}function z(e,t,r){var n=B(e,t);return(n.isNegative?"-":"")+n.value.map((function(e){return function(e,t){return e<(t=t||"0123456789abcdefghijklmnopqrstuvwxyz").length?t[e]:"<"+e+">"}(e,r)})).join("")}function j(e){if(l(+e)){var t=+e;if(t===g(t))return s?new c(BigInt(t)):new u(t);throw new Error("Invalid integer: "+e)}var r="-"===e[0];r&&(e=e.slice(1));var n=e.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var o=n[1];if("+"===o[0]&&(o=o.slice(1)),(o=+o)!==g(o)||!l(o))throw new Error("Invalid integer: "+o+" is not a valid exponent.");var i=n[0],p=i.indexOf(".");if(p>=0&&(o-=i.length-p-1,i=i.slice(0,p)+i.slice(p+1)),o<0)throw new Error("Cannot include negative exponent part for integers");e=i+=new Array(o+1).join("0")}if(!/^([0-9][0-9]*)$/.test(e))throw new Error("Invalid integer: "+e);if(s)return new c(BigInt(r?"-"+e:e));for(var f=[],d=e.length,m=d-7;d>0;)f.push(+e.slice(m,d)),(m-=7)<0&&(m=0),d-=7;return h(f),new a(f,r)}function H(e){return"number"==typeof e?function(e){if(s)return new c(BigInt(e));if(l(e)){if(e!==g(e))throw new Error(e+" is not an integer.");return new u(e)}return j(e.toString())}(e):"string"==typeof e?j(e):"bigint"==typeof e?new c(e):e}a.prototype.toArray=function(e){return B(this,e)},u.prototype.toArray=function(e){return B(this,e)},c.prototype.toArray=function(e){return B(this,e)},a.prototype.toString=function(e,t){if(void 0===e&&(e=10),10!==e)return z(this,e,t);for(var r,n=this.value,o=n.length,s=String(n[--o]);--o>=0;)r=String(n[o]),s+="0000000".slice(r.length)+r;return(this.sign?"-":"")+s},u.prototype.toString=function(e,t){return void 0===e&&(e=10),10!=e?z(this,e,t):String(this.value)},c.prototype.toString=u.prototype.toString,c.prototype.toJSON=a.prototype.toJSON=u.prototype.toJSON=function(){return this.toString()},a.prototype.valueOf=function(){return parseInt(this.toString(),10)},a.prototype.toJSNumber=a.prototype.valueOf,u.prototype.valueOf=function(){return this.value},u.prototype.toJSNumber=u.prototype.valueOf,c.prototype.valueOf=c.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var Q=0;Q<1e3;Q++)i[Q]=H(Q),Q>0&&(i[-Q]=H(-Q));return i.one=i[1],i.zero=i[0],i.minusOne=i[-1],i.max=F,i.min=G,i.gcd=k,i.lcm=function(e,t){return e=H(e).abs(),t=H(t).abs(),e.divide(k(e,t)).multiply(t)},i.isInstance=function(e){return e instanceof a||e instanceof u||e instanceof c},i.randBetween=function(e,r,n){e=H(e),r=H(r);var o=n||Math.random,s=G(e,r),a=F(e,r).subtract(s).add(1);if(a.isSmall)return s.add(Math.floor(o()*a));for(var u=B(a,t).value,c=[],l=!0,p=0;p0&&t.push(" ⬆ ︎"+n+" more lines identical to this"),n=0,t.push(" "+i)),r=i}},s.prototype.getSymbolDisplay=function(e){var t=typeof e;if("string"===t)return e;if("object"===t&&e.literal)return JSON.stringify(e.literal);if("object"===t&&e instanceof RegExp)return"character matching "+e;if("object"===t&&e.type)return e.type+" token";throw new Error("Unknown symbol type: "+e)},s.prototype.buildFirstStateStack=function(e,t){if(-1!==t.indexOf(e))return null;if(0===e.wantedBy.length)return[e];var r=e.wantedBy[0],n=[e].concat(t),o=this.buildFirstStateStack(r,n);return null===o?null:[e].concat(o)},s.prototype.save=function(){var e=this.table[this.current];return e.lexerState=this.lexerState,e},s.prototype.restore=function(e){var t=e.index;this.current=t,this.table[t]=e,this.table.splice(t+1),this.lexerState=e.lexerState,this.results=this.finish()},s.prototype.rewind=function(e){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[e])},s.prototype.finish=function(){var e=[],t=this.grammar.start;return this.table[this.table.length-1].states.forEach((function(r){r.rule.name===t&&r.dot===r.rule.symbols.length&&0===r.reference&&r.data!==s.fail&&e.push(r)})),e.map((function(e){return e.data}))},{Parser:s,Grammar:n,Rule:e}},e.exports?e.exports=o():n.nearley=o()},function(e,t,r){"use strict";var n=r(2).Buffer,o=r(35).Transform;function s(e){o.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(1)(s,o),s.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},s.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},s.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,o=0;this._blockOffset+e.length-o>=this._blockSize;){for(var s=this._blockOffset;s0;++i)this._length[i]+=a,(a=this._length[i]/4294967296|0)>0&&(this._length[i]-=4294967296*a);return this},s.prototype._update=function(){throw new Error("_update is not implemented")},s.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},s.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=s},function(e,t,r){e.exports=o;var n=r(23).EventEmitter;function o(){n.call(this)}r(1)(o,n),o.Readable=r(24),o.Writable=r(61),o.Duplex=r(62),o.Transform=r(63),o.PassThrough=r(64),o.Stream=o,o.prototype.pipe=function(e,t){var r=this;function o(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",o),e.on("drain",s),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",u));var i=!1;function a(){i||(i=!0,e.end())}function u(){i||(i=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(l(),0===n.listenerCount(this,"error"))throw e}function l(){r.removeListener("data",o),e.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("error",c),e.on("error",c),r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}},function(e,t,r){"use strict";(function(t,n){var o=r(18);e.exports=D;var s,i=r(31);D.ReadableState=y;r(23).EventEmitter;var a=function(e,t){return e.listeners(t).length},u=r(37),c=r(2).Buffer,l=t.Uint8Array||function(){};var p=r(16);p.inherits=r(1);var f=r(54),h=void 0;h=f&&f.debuglog?f.debuglog("stream"):function(){};var d,g=r(55),m=r(38);p.inherits(D,u);var b=["error","close","destroy","pause","resume"];function y(e,t){e=e||{};var n=t instanceof(s=s||r(10));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var o=e.highWaterMark,i=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:n&&(i||0===i)?i:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=r(26).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function D(e){if(s=s||r(10),!(this instanceof D))return new D(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function P(e,t,r,n,o){var s,i=e._readableState;null===t?(i.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,A(e)}(e,i)):(o||(s=function(e,t){var r;n=t,c.isBuffer(n)||n instanceof l||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(i,t)),s?e.emit("error",s):i.objectMode||t&&t.length>0?("string"==typeof t||i.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?i.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):$(e,i,t,!0):i.ended?e.emit("error",new Error("stream.push() after EOF")):(i.reading=!1,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?$(e,i,t,!1):_(e,i)):$(e,i,t,!1))):n||(i.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function A(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?o.nextTick(I,e):I(e))}function I(e){h("emit readable"),e.emit("readable"),U(e)}function _(e,t){t.readingMore||(t.readingMore=!0,o.nextTick(R,e,t))}function R(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;es.length?s.length:e;if(i===s.length?o+=s:o+=s.slice(0,e),0===(e-=i)){i===s.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(i));break}++n}return t.length-=n,o}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,o=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var s=n.data,i=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,i),0===(e-=i)){i===s.length?(++o,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(i));break}++o}return t.length-=o,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function T(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,o.nextTick(w,t,e))}function w(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function O(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):A(this),null;if(0===(e=v(e,t))&&t.ended)return 0===t.length&&T(this),null;var n,o=t.needReadable;return h("need readable",o),(0===t.length||t.length-e0?E(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&T(this)),null!==n&&this.emit("data",n),n},D.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},D.prototype.pipe=function(e,t){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,h("pipe count=%d opts=%j",s.pipesCount,t);var u=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?l:D;function c(t,n){h("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,h("cleanup"),e.removeListener("close",b),e.removeListener("finish",y),e.removeListener("drain",p),e.removeListener("error",m),e.removeListener("unpipe",c),r.removeListener("end",l),r.removeListener("end",D),r.removeListener("data",g),f=!0,!s.awaitDrain||e._writableState&&!e._writableState.needDrain||p())}function l(){h("onend"),e.end()}s.endEmitted?o.nextTick(u):r.once("end",u),e.on("unpipe",c);var p=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,U(e))}}(r);e.on("drain",p);var f=!1;var d=!1;function g(t){h("ondata"),d=!1,!1!==e.write(t)||d||((1===s.pipesCount&&s.pipes===e||s.pipesCount>1&&-1!==O(s.pipes,e))&&!f&&(h("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function m(t){h("onerror",t),D(),e.removeListener("error",m),0===a(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",y),D()}function y(){h("onfinish"),e.removeListener("close",b),D()}function D(){h("unpipe"),r.unpipe(e)}return r.on("data",g),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?i(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",m),e.once("close",b),e.once("finish",y),e.emit("pipe",r),s.flowing||(h("pipe resume"),r.resume()),e},D.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function f(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function h(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,o),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,o=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,d=0|this._f,g=0|this._g,m=0|this._h,b=0;b<16;++b)r[b]=e.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((t=r[b-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[b-7]+h(r[b-15])+r[b-16];for(var y=0;y<64;++y){var D=m+f(u)+c(u,d,g)+i[y]+r[y]|0,P=p(n)+l(n,o,s)|0;m=g,g=d,d=u,u=a+D|0,a=s,s=o,o=n,n=D+P|0}this._a=n+this._a|0,this._b=o+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=g+this._g|0,this._h=m+this._h|0},u.prototype._hash=function(){var e=s.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=u},function(e,t,r){var n=r(1),o=r(13),s=r(2).Buffer,i=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function l(e,t,r){return e&t|r&(e|t)}function p(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function f(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function b(e,t){return e>>>0>>0?1:0}n(u,o),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,o=0|this._ch,s=0|this._dh,a=0|this._eh,u=0|this._fh,y=0|this._gh,D=0|this._hh,P=0|this._al,$=0|this._bl,v=0|this._cl,A=0|this._dl,I=0|this._el,_=0|this._fl,R=0|this._gl,S=0|this._hl,C=0;C<32;C+=2)t[C]=e.readInt32BE(4*C),t[C+1]=e.readInt32BE(4*C+4);for(;C<160;C+=2){var U=t[C-30],E=t[C-30+1],T=h(U,E),w=d(E,U),O=g(U=t[C-4],E=t[C-4+1]),N=m(E,U),x=t[C-14],M=t[C-14+1],F=t[C-32],G=t[C-32+1],k=w+M|0,L=T+x+b(k,w)|0;L=(L=L+O+b(k=k+N|0,N)|0)+F+b(k=k+G|0,G)|0,t[C]=L,t[C+1]=k}for(var W=0;W<160;W+=2){L=t[W],k=t[W+1];var B=l(r,n,o),z=l(P,$,v),j=p(r,P),H=p(P,r),Q=f(a,I),J=f(I,a),q=i[W],K=i[W+1],Y=c(a,u,y),V=c(I,_,R),Z=S+J|0,X=D+Q+b(Z,S)|0;X=(X=(X=X+Y+b(Z=Z+V|0,V)|0)+q+b(Z=Z+K|0,K)|0)+L+b(Z=Z+k|0,k)|0;var ee=H+z|0,te=j+B+b(ee,H)|0;D=y,S=R,y=u,R=_,u=a,_=I,a=s+X+b(I=A+Z|0,A)|0,s=o,A=v,o=n,v=$,n=r,$=P,r=X+te+b(P=Z+ee|0,Z)|0}this._al=this._al+P|0,this._bl=this._bl+$|0,this._cl=this._cl+v|0,this._dl=this._dl+A|0,this._el=this._el+I|0,this._fl=this._fl+_|0,this._gl=this._gl+R|0,this._hl=this._hl+S|0,this._ah=this._ah+r+b(this._al,P)|0,this._bh=this._bh+n+b(this._bl,$)|0,this._ch=this._ch+o+b(this._cl,v)|0,this._dh=this._dh+s+b(this._dl,A)|0,this._eh=this._eh+a+b(this._el,I)|0,this._fh=this._fh+u+b(this._fl,_)|0,this._gh=this._gh+y+b(this._gl,R)|0,this._hh=this._hh+D+b(this._hl,S)|0},u.prototype._hash=function(){var e=s.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=u},function(e,t,r){(function(t){function r(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){var r;if(e instanceof Uint8Array)r=e;else if(e instanceof t)r=new Uint8Array(e);else{if("string"!=typeof e)throw new Error("Input must be an string, Buffer or Uint8Array");r=new Uint8Array(t.from(e,"utf8"))}return r},toHex:function(e){return Array.prototype.map.call(e,(function(e){return(e<16?"0":"")+e.toString(16)})).join("")},debugPrint:function(e,t,n){for(var o="\n"+e+" = ",s=0;s0?i-4:i;for(r=0;r>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,s=[],i=0,a=r-o;ia?a:i+16383));1===o?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return s.join("")};for(var n=[],o=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=i.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var o,s,i=[],a=t;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,o){var s,i,a=8*o-n-1,u=(1<>1,l=-7,p=r?o-1:0,f=r?-1:1,h=e[t+p];for(p+=f,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+p],p+=f,l-=8);for(i=s&(1<<-l)-1,s>>=-l,l+=n;l>0;i=256*i+e[t+p],p+=f,l-=8);if(0===s)s=1-c;else{if(s===u)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,n),s-=c}return(h?-1:1)*i*Math.pow(2,s-n)},t.write=function(e,t,r,n,o,s){var i,a,u,c=8*s-o-1,l=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:s-1,d=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),(t+=i+p>=1?f/u:f*Math.pow(2,1-p))*u>=2&&(i++,u/=2),i+p>=l?(a=0,i=l):i+p>=1?(a=(t*u-1)*Math.pow(2,o),i+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),i=0));o>=8;e[r+h]=255&a,h+=d,a/=256,o-=8);for(i=i<0;e[r+h]=255&i,h+=d,i/=256,c-=8);e[r+h-d]|=128*g}},function(e,t,r){"use strict";function n(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0});const o=r(22),s=r(32),i=['"parameter"','"storage"','"code"','"False"','"Elt"','"Left"','"None"','"Pair"','"Right"','"Some"','"True"','"Unit"','"PACK"','"UNPACK"','"BLAKE2B"','"SHA256"','"SHA512"','"ABS"','"ADD"','"AMOUNT"','"AND"','"BALANCE"','"CAR"','"CDR"','"CHECK_SIGNATURE"','"COMPARE"','"CONCAT"','"CONS"','"CREATE_ACCOUNT"','"CREATE_CONTRACT"','"IMPLICIT_ACCOUNT"','"DIP"','"DROP"','"DUP"','"EDIV"','"EMPTY_MAP"','"EMPTY_SET"','"EQ"','"EXEC"','"FAILWITH"','"GE"','"GET"','"GT"','"HASH_KEY"','"IF"','"IF_CONS"','"IF_LEFT"','"IF_NONE"','"INT"','"LAMBDA"','"LE"','"LEFT"','"LOOP"','"LSL"','"LSR"','"LT"','"MAP"','"MEM"','"MUL"','"NEG"','"NEQ"','"NIL"','"NONE"','"NOT"','"NOW"','"OR"','"PAIR"','"PUSH"','"RIGHT"','"SIZE"','"SOME"','"SOURCE"','"SENDER"','"SELF"','"STEPS_TO_QUOTA"','"SUB"','"SWAP"','"TRANSFER_TOKENS"','"SET_DELEGATE"','"UNIT"','"UPDATE"','"XOR"','"ITER"','"LOOP_LEFT"','"ADDRESS"','"CONTRACT"','"ISNAT"','"CAST"','"RENAME"','"bool"','"contract"','"int"','"key"','"key_hash"','"lambda"','"list"','"map"','"big_map"','"nat"','"option"','"or"','"pair"','"set"','"signature"','"string"','"bytes"','"mutez"','"timestamp"','"unit"','"operation"','"address"','"SLICE"','"DIG"','"DUG"','"EMPTY_BIG_MAP"','"APPLY"','"chain_id"','"CHAIN_ID"'],a=o.compile({keyword:i,lbrace:"{",rbrace:"}",lbracket:"[",rbracket:"]",colon:":",comma:",",_:/[ \t]+/,quotedValue:/\"[\S\s]*?\"/}),u=e=>("00"+i.indexOf(e).toString(16)).slice(-2),c=e=>("0000000"+e.toString(16)).slice(-8),l=e=>{if(0===e)return"00";const t=s(e).abs(),r=t.bitLength().toJSNumber();let n=[],o=t;for(let t=0;t("0"+e.toString(16)).slice(-2)).join("")},p={Lexer:a,ParserRules:[{name:"main",symbols:["staticObject"],postprocess:n},{name:"main",symbols:["primBare"],postprocess:n},{name:"main",symbols:["primArg"],postprocess:n},{name:"main",symbols:["primAnn"],postprocess:n},{name:"main",symbols:["primArgAnn"],postprocess:n},{name:"main",symbols:["anyArray"],postprocess:n},{name:"staticInt$ebnf$1",symbols:[]},{name:"staticInt$ebnf$1",symbols:["staticInt$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"staticInt",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"int"'},"staticInt$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("quotedValue")?{type:"quotedValue"}:quotedValue,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{const t=e[6].toString();return"00"+l(parseInt(t.substring(1,t.length-1)))}},{name:"staticString$ebnf$1",symbols:[]},{name:"staticString$ebnf$1",symbols:["staticString$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"staticString",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"string"'},"staticString$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("quotedValue")?{type:"quotedValue"}:quotedValue,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t=e[6].toString();t=t.substring(1,t.length-1);const r=c(t.length);return t=t.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),"01"+r+t}},{name:"staticBytes$ebnf$1",symbols:[]},{name:"staticBytes$ebnf$1",symbols:["staticBytes$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"staticBytes",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"bytes"'},"staticBytes$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("quotedValue")?{type:"quotedValue"}:quotedValue,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t=e[6].toString();t=t.substring(1,t.length-1);return"0a"+c(t.length/2)+t}},{name:"staticObject",symbols:["staticInt"],postprocess:n},{name:"staticObject",symbols:["staticString"],postprocess:n},{name:"staticObject",symbols:["staticBytes"],postprocess:n},{name:"primBare$ebnf$1",symbols:[]},{name:"primBare$ebnf$1",symbols:["primBare$ebnf$1",a.has("_")?{type:"_"}:_],postprocess:e=>e[0].concat([e[1]])},{name:"primBare",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primBare$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"03"+u(e[6].toString())},{name:"primArg$ebnf$1",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArg$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$3$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$1",symbols:["any","primArg$ebnf$3$subexpression$1$ebnf$1","primArg$ebnf$3$subexpression$1$ebnf$2"]},{name:"primArg$ebnf$3",symbols:["primArg$ebnf$3$subexpression$1"]},{name:"primArg$ebnf$3$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArg$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArg$ebnf$3$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArg$ebnf$3$subexpression$2",symbols:["any","primArg$ebnf$3$subexpression$2$ebnf$1","primArg$ebnf$3$subexpression$2$ebnf$2"]},{name:"primArg$ebnf$3",symbols:["primArg$ebnf$3","primArg$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primArg",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primArg$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"args"'},"primArg$ebnf$2",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primArg$ebnf$3",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t="05";2==e[15].length?t="07":e[15].length>2&&(t="09");const r=u(e[6].toString());let n=e[15].map(e=>e[0]).join("");return"09"===t&&(n=("0000000"+(n.length/2).toString(16)).slice(-8)+n,n+="00000000"),t+r+n}},{name:"primAnn$ebnf$1",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$1",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$2",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$1",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primAnn$ebnf$3$subexpression$1$ebnf$1","primAnn$ebnf$3$subexpression$1$ebnf$2"]},{name:"primAnn$ebnf$3",symbols:["primAnn$ebnf$3$subexpression$1"]},{name:"primAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primAnn$ebnf$3$subexpression$2",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primAnn$ebnf$3$subexpression$2$ebnf$1","primAnn$ebnf$3$subexpression$2$ebnf$2"]},{name:"primAnn$ebnf$3",symbols:["primAnn$ebnf$3","primAnn$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primAnn",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primAnn$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"annots"'},"primAnn$ebnf$2",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primAnn$ebnf$3",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{const t=u(e[6].toString());let r=e[15].map(e=>{let t=e[0].toString();return t=t.substring(1,t.length-1),t}).join(" ");return r=r.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),r=c(r.length/2)+r,"04"+t+r}},{name:"primArgAnn$ebnf$1",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$1",symbols:["any","primArgAnn$ebnf$3$subexpression$1$ebnf$1","primArgAnn$ebnf$3$subexpression$1$ebnf$2"]},{name:"primArgAnn$ebnf$3",symbols:["primArgAnn$ebnf$3$subexpression$1"]},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$3$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$3$subexpression$2",symbols:["any","primArgAnn$ebnf$3$subexpression$2$ebnf$1","primArgAnn$ebnf$3$subexpression$2$ebnf$2"]},{name:"primArgAnn$ebnf$3",symbols:["primArgAnn$ebnf$3","primArgAnn$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primArgAnn$ebnf$4",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$4",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$1",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primArgAnn$ebnf$5$subexpression$1$ebnf$1","primArgAnn$ebnf$5$subexpression$1$ebnf$2"]},{name:"primArgAnn$ebnf$5",symbols:["primArgAnn$ebnf$5$subexpression$1"]},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"primArgAnn$ebnf$5$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"primArgAnn$ebnf$5$subexpression$2",symbols:[a.has("quotedValue")?{type:"quotedValue"}:quotedValue,"primArgAnn$ebnf$5$subexpression$2$ebnf$1","primArgAnn$ebnf$5$subexpression$2$ebnf$2"]},{name:"primArgAnn$ebnf$5",symbols:["primArgAnn$ebnf$5","primArgAnn$ebnf$5$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"primArgAnn",symbols:[a.has("lbrace")?{type:"lbrace"}:lbrace,a.has("_")?{type:"_"}:_,{literal:'"prim"'},"primArgAnn$ebnf$1",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("keyword")?{type:"keyword"}:keyword,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"args"'},"primArgAnn$ebnf$2",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primArgAnn$ebnf$3",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("comma")?{type:"comma"}:comma,a.has("_")?{type:"_"}:_,{literal:'"annots"'},"primArgAnn$ebnf$4",a.has("colon")?{type:"colon"}:colon,a.has("_")?{type:"_"}:_,a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"primArgAnn$ebnf$5",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket,a.has("_")?{type:"_"}:_,a.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>{let t="06";2==e[15].length?t="08":e[15].length>2&&(t="09");const r=u(e[6].toString());let n=e[15].map(e=>e[0]).join(""),o=e[26].map(e=>{let t=e[0].toString();return t=t.substring(1,t.length-1),t}).join(" ");return o=o.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),o=c(o.length/2)+o,"09"===t&&(n=("0000000"+(n.length/2).toString(16)).slice(-8)+n),t+r+n+o}},{name:"primAny",symbols:["primBare"],postprocess:n},{name:"primAny",symbols:["primArg"],postprocess:n},{name:"primAny",symbols:["primAnn"],postprocess:n},{name:"primAny",symbols:["primArgAnn"],postprocess:n},{name:"any",symbols:["primAny"],postprocess:n},{name:"any",symbols:["staticObject"],postprocess:n},{name:"any",symbols:["anyArray"],postprocess:n},{name:"anyArray",symbols:[a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("rbracket")?{type:"rbracket"}:rbracket],postprocess:function(e){return"0200000000"}},{name:"anyArray$ebnf$1$subexpression$1$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"anyArray$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$1$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"anyArray$ebnf$1$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$1",symbols:["any","anyArray$ebnf$1$subexpression$1$ebnf$1","anyArray$ebnf$1$subexpression$1$ebnf$2"]},{name:"anyArray$ebnf$1",symbols:["anyArray$ebnf$1$subexpression$1"]},{name:"anyArray$ebnf$1$subexpression$2$ebnf$1",symbols:[a.has("comma")?{type:"comma"}:comma],postprocess:n},{name:"anyArray$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$2$ebnf$2",symbols:[a.has("_")?{type:"_"}:_],postprocess:n},{name:"anyArray$ebnf$1$subexpression$2$ebnf$2",symbols:[],postprocess:()=>null},{name:"anyArray$ebnf$1$subexpression$2",symbols:["any","anyArray$ebnf$1$subexpression$2$ebnf$1","anyArray$ebnf$1$subexpression$2$ebnf$2"]},{name:"anyArray$ebnf$1",symbols:["anyArray$ebnf$1","anyArray$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"anyArray",symbols:[a.has("lbracket")?{type:"lbracket"}:lbracket,a.has("_")?{type:"_"}:_,"anyArray$ebnf$1",a.has("_")?{type:"_"}:_,a.has("rbracket")?{type:"rbracket"}:rbracket],postprocess:e=>{const t=e[2].map(e=>e[0]).join("");return"02"+c(t.length/2)+t}}],ParserStart:"main"};t.default=p},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";function n(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0});const o=r(22),s=/SET_C[AD]+R/,i=/DII+P/,a=/DUU+P/,u=new RegExp(i),c=new RegExp(a),l=["ASSERT","ASSERT_EQ","ASSERT_NEQ","ASSERT_GT","ASSERT_LT","ASSERT_GE","ASSERT_LE","ASSERT_NONE","ASSERT_SOME","ASSERT_LEFT","ASSERT_RIGHT","ASSERT_CMPEQ","ASSERT_CMPNEQ","ASSERT_CMPGT","ASSERT_CMPLT","ASSERT_CMPGE","ASSERT_CMPLE"],p=["IFCMPEQ","IFCMPNEQ","IFCMPLT","IFCMPGT","IFCMPLE","IFCMPGE"],f=["CMPEQ","CMPNEQ","CMPLT","CMPGT","CMPLE","CMPGE"],h=["IFEQ","IFNEQ","IFLT","IFGT","IFLE","IFGE"],d=o.compile({annot:/[\@\%\:][a-z_A-Z0-9]+/,lparen:"(",rparen:")",lbrace:"{",rbrace:"}",ws:/[ \t]+/,semicolon:";",bytes:/0x[0-9a-fA-F]+/,number:/-?[0-9]+(?!x)/,parameter:["parameter","Parameter"],storage:["Storage","storage"],code:["Code","code"],comparableType:["int","nat","string","bytes","mutez","bool","key_hash","timestamp","chain_id"],constantType:["key","unit","signature","operation","address"],singleArgType:["option","list","set","contract"],doubleArgType:["pair","or","lambda","map","big_map"],baseInstruction:["ABS","ADD","ADDRESS","AMOUNT","AND","BALANCE","BLAKE2B","CAR","CAST","CDR","CHECK_SIGNATURE","COMPARE","CONCAT","CONS","CONTRACT","DIP","EDIV","EMPTY_SET","EQ","EXEC","FAIL","FAILWITH","GE","GET","GT","HASH_KEY","IF","IF_CONS","IF_LEFT","IF_NONE","IF_RIGHT","IMPLICIT_ACCOUNT","INT","ISNAT","ITER","LAMBDA","LE","LEFT","LOOP","LOOP_LEFT","LSL","LSR","LT","MAP","MEM","MUL","NEG","NEQ","NIL","NONE","NOT","NOW","OR","PACK","PAIR","REDUCE","RENAME","RIGHT","SELF","SENDER","SET_DELEGATE","SHA256","SHA512","SIZE","SLICE","SOME","SOURCE","STEPS_TO_QUOTA","SUB","SWAP","TRANSFER_TOKENS","UNIT","UNPACK","UPDATE","XOR","UNPAIR","UNPAPAIR","IF_SOME","IFCMPEQ","IFCMPNEQ","IFCMPLT","IFCMPGT","IFCMPLE","IFCMPGE","CMPEQ","CMPNEQ","CMPLT","CMPGT","CMPLE","CMPGE","IFEQ","NEQ","IFLT","IFGT","IFLE","IFGE","EMPTY_BIG_MAP","APPLY","CHAIN_ID"],macroCADR:/C[AD]+R/,macroDIP:i,macroDUP:a,macroSETCADR:s,macroASSERTlist:l,constantData:["Unit","True","False","None","instruction"],singleArgData:["Left","Right","Some"],doubleArgData:["Pair"],elt:"Elt",word:/[a-zA-Z_0-9]+/,string:/"(?:\\["\\]|[^\n"\\])*"/}),g=e=>new RegExp("^C(A|D)(A|D)+R$").test(e),m=e=>f.includes(e),b=e=>c.test(e),y=e=>l.includes(e),D=e=>"FAIL"===e,P=e=>p.includes(e)||h.includes(e)||"IF_SOME"===e,$=(e,t,r,n)=>{const o=n?`, "annots": [${n}]`:"";switch(e){case"IFCMPEQ":return`[{"prim":"COMPARE"},{"prim":"EQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPGE":return`[{"prim":"COMPARE"},{"prim":"GE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPGT":return`[{"prim":"COMPARE"},{"prim":"GT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPLE":return`[{"prim":"COMPARE"},{"prim":"LE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPLT":return`[{"prim":"COMPARE"},{"prim":"LT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFCMPNEQ":return`[{"prim":"COMPARE"},{"prim":"NEQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFEQ":return`[{"prim":"EQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFGE":return`[{"prim":"GE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFGT":return`[{"prim":"GT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFLE":return`[{"prim":"LE"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFLT":return`[{"prim":"LT"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IFNEQ":return`[{"prim":"NEQ"},{"prim":"IF","args":[ [${t}] , [${r}]]${o}}]`;case"IF_SOME":return`[{"prim":"IF_NONE","args":[ [${r}], [${t}]]${o}}]`;default:throw new Error("Could not process "+e)}},v=e=>u.test(e),A=(e,t,r)=>{let n="";if(u.test(e)){const o=e.length-2;for(let e=0;e"UNPAIR"==e||"UNPAPAIR"==e,_=e=>s.test(e),R=e=>{if(0===e.length)return"";const t=e.charAt(0);if(1===e.length){if("A"===t)return'[{"prim": "CDR","annots":["@%%"]}, {"prim": "SWAP"}, {"prim": "PAIR","annots":["%","%@"]}]';if("D"===t)return'[{"prim": "CAR","annots":["@%%"]}, {"prim": "PAIR","annots":["%@","%"]}]'}return"A"===t?`[{"prim": "DUP"}, {"prim": "DIP", "args": [[{"prim": "CAR","annots":["@%%"]}, ${R(e.slice(1))}]]}, {"prim": "CDR","annots":["@%%"]}, {"prim": "SWAP"}, {"prim": "PAIR","annots":["%@","%@"]}]`:"D"===t?`[{"prim": "DUP"}, {"prim": "DIP", "args": [[{"prim": "CDR","annots":["@%%"]}, ${R(e.slice(1))}]]}, {"prim": "CAR","annots":["@%%"]}, {"prim": "PAIR","annots":["%@","%@"]}]`:void 0},S=e=>!!y(e)||(!!m(e)||(!!v(e)||(!!b(e)||(!!D(e)||(!!P(e)||(!!g(e)||(!!I(e)||(!!_(e)||void 0)))))))),C=(e,t)=>g(e)?((e,t)=>{var r=e.slice(1,-1).split("").map(e=>"A"===e?'{ "prim": "CAR" }':'{ "prim": "CDR" }');if(null!=t){const n=e.slice(-2,-1);"A"===n?r[r.length-1]=`{ "prim": "CAR", "annots": [${t}] }`:"D"===n&&(r[r.length-1]=`{ "prim": "CDR", "annots": [${t}] }`)}return`[${r.join(", ")}]`})(e,t):y(e)?((e,t)=>{const r=t?`, "annots": [${t}]`:"";switch(e){case"ASSERT":return`[{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPEQ":return`[[{"prim":"COMPARE"},{"prim":"EQ"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPGE":return`[[{"prim":"COMPARE"},{"prim":"GE"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPGT":return`[[{"prim":"COMPARE"},{"prim":"GT"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPLE":return`[[{"prim":"COMPARE"},{"prim":"LE"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPLT":return`[[{"prim":"COMPARE"},{"prim":"LT"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_CMPNEQ":return`[[{"prim":"COMPARE"},{"prim":"NEQ"}],{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_EQ":return`[{"prim":"EQ"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]]`;case"ASSERT_GE":return`[{"prim":"GE"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_GT":return`[{"prim":"GT"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_LE":return`[{"prim":"LE"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_LT":return`[{"prim":"LT"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_NEQ":return`[{"prim":"NEQ"},{"prim":"IF","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"${r}}]]]}]`;case"ASSERT_NONE":return'[{"prim":"IF_NONE","args":[[],[[{"prim":"UNIT"},{"prim":"FAILWITH"}]]]}]';case"ASSERT_SOME":return'[{"prim":"IF_NONE","args":[[[{"prim":"UNIT"},{"prim":"FAILWITH"}]],[]]}]';case"ASSERT_LEFT":case"ASSERT_RIGHT":return"";default:throw new Error("Could not process "+e)}})(e,t):m(e)?((e,t)=>{var r=e.substring(3),n=T([""+r]);return null!=t&&(n=`{ "prim": "${r}", "annots": [${t}] }`),`[${T(["COMPARE"])}, ${n}]`})(e,t):v(e)?A(e,t):b(e)?((e,t)=>{let r="";if(c.test(e)){const n=e.length-3;for(let e=0;enull==t?'[ { "prim": "UNIT" }, { "prim": "FAILWITH" } ]':`[ { "prim": "UNIT" }, { "prim": "FAILWITH", "annots": [${t}] } ]`)(0,t):P(e)?$(e,t):I(e)?((e,t)=>"UNPAIR"==e?null==t?'[ [ { "prim": "DUP" }, { "prim": "CAR" }, { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ]':1==t.length?`[ [ { "prim": "DUP" }, { "prim": "CAR", "annots": [${t}] }, { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ]`:2==t.length?`[ [ { "prim": "DUP" }, { "prim": "CAR", "annots": [${t[0]}] }, { "prim": "DIP", "args": [ [ { "prim": "CDR", "annots": [${t[1]}] } ] ] } ] ]`:"":"UNPAPAIR"==e?null==t?'[ [ { "prim": "DUP" },\n { "prim": "CAR" },\n { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ],\n {"prim":"DIP","args":[[[{"prim":"DUP"},{"prim":"CAR"},{"prim":"DIP","args":[[{"prim":"CDR"}]]}]]]}]':`[ [ { "prim": "DUP" },\n { "prim": "CAR" },\n { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ],\n {"prim":"DIP","args":[[[{"prim":"DUP"},{"prim":"CAR"},{"prim":"DIP","args":[[{"prim":"CDR"}]],"annots": [${t}]}]]]}]`:void 0)(e,t):_(e)?((e,t)=>R(e.slice(5,-1)))(e):void 0,U=e=>`{ "int": "${parseInt(e[0])}" }`,E=e=>`{ "string": ${e[0]} }`,T=e=>{const t=e[0].toString();if(1==e.length)return S(t)?[C(t,null)]:`{ "prim": "${e[0]}" }`;{const r=e[1].map(e=>`"${e[1]}"`);return S(t)?[C(t,r)]:`{ "prim": "${e[0]}", "annots": [${r}] }`}},w=e=>`{ "prim": "${e[0]}", "args": [ ${e[2]} ] }`,O=e=>{const t=e[3].map(e=>`"${e[1]}"`);return`{ "prim": "${e[2]}", "annots": [${t}] }`},N=e=>{const t=""+e[0].toString(),r=e[1].map(e=>`"${e[1]}"`);return v(t)?A(t,e[2],r):`{ "prim": "${e[0]}", "args": [ ${e[3]} ], "annots": [${r}] }`},x=e=>`{ "prim": "${e[2]}", "args": [ ${e[4+(7===e.length?0:2)]} ] }`,M=e=>`{ "prim": "${e[0]}", "args": [ ${e[2]}, ${e[4]} ] }`,F=e=>`{ "prim": "${e[2]}", "args": [ ${e[4]}, ${e[6]} ] }`,G=e=>Array.isArray(e)&&Array.isArray(e[0])?e[0]:e,k=e=>""+e[2].map(e=>e[0]).map(e=>G(e)),L=e=>`[ ${e[2].map(e=>e[0]).map(e=>G(e))} ]`,W=e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "${e[0]}", "args": [ ${e[4]}, ${e[6]} ], "annots": [${t}] }`},B=e=>`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" } ] }`,z={Lexer:d,ParserRules:[{name:"main",symbols:["instruction"],postprocess:n},{name:"main",symbols:["data"],postprocess:n},{name:"main",symbols:["type"],postprocess:n},{name:"main",symbols:["parameter"],postprocess:n},{name:"main",symbols:["storage"],postprocess:n},{name:"main",symbols:["code"],postprocess:n},{name:"main",symbols:["script"],postprocess:n},{name:"main",symbols:["parameterValue"],postprocess:n},{name:"main",symbols:["storageValue"],postprocess:n},{name:"main",symbols:["typeData"],postprocess:n},{name:"script",symbols:["parameter","_","storage","_","code"],postprocess:e=>`[ ${e[0]}, ${e[2]}, { "prim": "code", "args": [ [ ${e[4]} ] ] } ]`},{name:"parameterValue",symbols:[d.has("parameter")?{type:"parameter"}:parameter,"_","typeData","_","semicolons"],postprocess:w},{name:"storageValue",symbols:[d.has("storage")?{type:"storage"}:storage,"_","typeData","_","semicolons"],postprocess:w},{name:"parameter",symbols:[d.has("parameter")?{type:"parameter"}:parameter,"_","type","_","semicolons"],postprocess:w},{name:"storage",symbols:[d.has("storage")?{type:"storage"}:storage,"_","type","_","semicolons"],postprocess:w},{name:"code",symbols:[d.has("code")?{type:"code"}:code,"_","subInstruction","_","semicolons","_"],postprocess:e=>e[2]},{name:"code",symbols:[d.has("code")?{type:"code"}:code,"_",{literal:"{};"}],postprocess:e=>"code {}"},{name:"type",symbols:[d.has("comparableType")?{type:"comparableType"}:comparableType],postprocess:T},{name:"type",symbols:[d.has("constantType")?{type:"constantType"}:constantType],postprocess:T},{name:"type",symbols:[d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","type"],postprocess:w},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","type","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:x},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_",d.has("lparen")?{type:"lparen"}:lparen,"_","type","_",d.has("rparen")?{type:"rparen"}:rparen,"_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:x},{name:"type",symbols:[d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","type","_","type"],postprocess:M},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","type","_","type","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:F},{name:"type$ebnf$1$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$1",symbols:["type$ebnf$1$subexpression$1"]},{name:"type$ebnf$1$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$1",symbols:["type$ebnf$1","type$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("comparableType")?{type:"comparableType"}:comparableType,"type$ebnf$1"],postprocess:T},{name:"type$ebnf$2$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$2",symbols:["type$ebnf$2$subexpression$1"]},{name:"type$ebnf$2$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$2",symbols:["type$ebnf$2","type$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("constantType")?{type:"constantType"}:constantType,"type$ebnf$2"],postprocess:T},{name:"type$ebnf$3$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$3",symbols:["type$ebnf$3$subexpression$1"]},{name:"type$ebnf$3$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$3",symbols:["type$ebnf$3","type$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("comparableType")?{type:"comparableType"}:comparableType,"type$ebnf$3","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:O},{name:"type$ebnf$4$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$4",symbols:["type$ebnf$4$subexpression$1"]},{name:"type$ebnf$4$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$4",symbols:["type$ebnf$4","type$ebnf$4$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("constantType")?{type:"constantType"}:constantType,"type$ebnf$4","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:O},{name:"type$ebnf$5$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$5",symbols:["type$ebnf$5$subexpression$1"]},{name:"type$ebnf$5$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$5",symbols:["type$ebnf$5","type$ebnf$5$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"type$ebnf$5","_","type",d.has("rparen")?{type:"rparen"}:rparen],postprocess:e=>{const t=e[3].map(e=>`"${e[1]}"`);return`{ "prim": "${e[2]}", "args": [ ${e[5]} ], "annots": [${t}] }`}},{name:"type$ebnf$6$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$6",symbols:["type$ebnf$6$subexpression$1"]},{name:"type$ebnf$6$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"type$ebnf$6",symbols:["type$ebnf$6","type$ebnf$6$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"type",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"type$ebnf$6","_","type","_","type",d.has("rparen")?{type:"rparen"}:rparen],postprocess:e=>{const t=e[3].map(e=>`"${e[1]}"`);return`{ "prim": "${e[2]}", "args": [ ${e[5]}, ${e[7]} ], "annots": [${t}] }`}},{name:"typeData",symbols:[d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","typeData"],postprocess:w},{name:"typeData",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","typeData","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:x},{name:"typeData",symbols:[d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","typeData","_","typeData"],postprocess:M},{name:"typeData",symbols:[d.has("lparen")?{type:"lparen"}:lparen,"_",d.has("doubleArgType")?{type:"doubleArgType"}:doubleArgType,"_","typeData","_","typeData","_",d.has("rparen")?{type:"rparen"}:rparen],postprocess:F},{name:"typeData",symbols:["subTypeData"],postprocess:n},{name:"typeData",symbols:["subTypeElt"],postprocess:n},{name:"typeData",symbols:[d.has("number")?{type:"number"}:number],postprocess:U},{name:"typeData",symbols:[d.has("string")?{type:"string"}:string],postprocess:E},{name:"typeData",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>[]},{name:"data",symbols:[d.has("constantData")?{type:"constantData"}:constantData],postprocess:T},{name:"data",symbols:[d.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_","data"],postprocess:w},{name:"data",symbols:[d.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_","data","_","data"],postprocess:M},{name:"data",symbols:["subData"],postprocess:n},{name:"data",symbols:["subElt"],postprocess:n},{name:"data",symbols:[d.has("string")?{type:"string"}:string],postprocess:E},{name:"data",symbols:[d.has("bytes")?{type:"bytes"}:bytes],postprocess:e=>`{ "bytes": "${e[0].toString().slice(2)}" }`},{name:"data",symbols:[d.has("number")?{type:"number"}:number],postprocess:U},{name:"subData",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subData$ebnf$1$subexpression$1",symbols:["data","_"]},{name:"subData$ebnf$1",symbols:["subData$ebnf$1$subexpression$1"]},{name:"subData$ebnf$1$subexpression$2",symbols:["data","_"]},{name:"subData$ebnf$1",symbols:["subData$ebnf$1","subData$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subData",symbols:[{literal:"("},"_","subData$ebnf$1",{literal:")"}],postprocess:k},{name:"subData$ebnf$2$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subData$ebnf$2$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subData$ebnf$2$subexpression$1",symbols:["data","_","subData$ebnf$2$subexpression$1$ebnf$1","_"]},{name:"subData$ebnf$2",symbols:["subData$ebnf$2$subexpression$1"]},{name:"subData$ebnf$2$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subData$ebnf$2$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subData$ebnf$2$subexpression$2",symbols:["data","_","subData$ebnf$2$subexpression$2$ebnf$1","_"]},{name:"subData$ebnf$2",symbols:["subData$ebnf$2","subData$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subData",symbols:[{literal:"{"},"_","subData$ebnf$2",{literal:"}"}],postprocess:L},{name:"subElt",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subElt$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subElt$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subElt$ebnf$1$subexpression$1",symbols:["elt","subElt$ebnf$1$subexpression$1$ebnf$1","_"]},{name:"subElt$ebnf$1",symbols:["subElt$ebnf$1$subexpression$1"]},{name:"subElt$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subElt$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subElt$ebnf$1$subexpression$2",symbols:["elt","subElt$ebnf$1$subexpression$2$ebnf$1","_"]},{name:"subElt$ebnf$1",symbols:["subElt$ebnf$1","subElt$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subElt",symbols:[{literal:"{"},"_","subElt$ebnf$1",{literal:"}"}],postprocess:L},{name:"elt",symbols:[d.has("elt")?{type:"elt"}:elt,"_","data","_","data"],postprocess:M},{name:"subTypeData",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subTypeData$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$1$subexpression$1",symbols:["data","subTypeData$ebnf$1$subexpression$1$ebnf$1","_"]},{name:"subTypeData$ebnf$1",symbols:["subTypeData$ebnf$1$subexpression$1"]},{name:"subTypeData$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$1$subexpression$2",symbols:["data","subTypeData$ebnf$1$subexpression$2$ebnf$1","_"]},{name:"subTypeData$ebnf$1",symbols:["subTypeData$ebnf$1","subTypeData$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeData",symbols:[{literal:"{"},"_","subTypeData$ebnf$1",{literal:"}"}],postprocess:k},{name:"subTypeData$ebnf$2$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$2$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$2$subexpression$1",symbols:["data","subTypeData$ebnf$2$subexpression$1$ebnf$1","_"]},{name:"subTypeData$ebnf$2",symbols:["subTypeData$ebnf$2$subexpression$1"]},{name:"subTypeData$ebnf$2$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeData$ebnf$2$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeData$ebnf$2$subexpression$2",symbols:["data","subTypeData$ebnf$2$subexpression$2$ebnf$1","_"]},{name:"subTypeData$ebnf$2",symbols:["subTypeData$ebnf$2","subTypeData$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeData",symbols:[{literal:"("},"_","subTypeData$ebnf$2",{literal:")"}],postprocess:k},{name:"subTypeElt",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>"[]"},{name:"subTypeElt$ebnf$1$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$1$subexpression$1",symbols:["typeElt","subTypeElt$ebnf$1$subexpression$1$ebnf$1","_"]},{name:"subTypeElt$ebnf$1",symbols:["subTypeElt$ebnf$1$subexpression$1"]},{name:"subTypeElt$ebnf$1$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$1$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$1$subexpression$2",symbols:["typeElt","subTypeElt$ebnf$1$subexpression$2$ebnf$1","_"]},{name:"subTypeElt$ebnf$1",symbols:["subTypeElt$ebnf$1","subTypeElt$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeElt",symbols:[{literal:"[{"},"_","subTypeElt$ebnf$1",{literal:"}]"}],postprocess:k},{name:"subTypeElt$ebnf$2$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$2$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$2$subexpression$1",symbols:["typeElt","_","subTypeElt$ebnf$2$subexpression$1$ebnf$1","_"]},{name:"subTypeElt$ebnf$2",symbols:["subTypeElt$ebnf$2$subexpression$1"]},{name:"subTypeElt$ebnf$2$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$2$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$2$subexpression$2",symbols:["typeElt","_","subTypeElt$ebnf$2$subexpression$2$ebnf$1","_"]},{name:"subTypeElt$ebnf$2",symbols:["subTypeElt$ebnf$2","subTypeElt$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeElt",symbols:[{literal:"[{"},"_","subTypeElt$ebnf$2",{literal:"}]"}],postprocess:k},{name:"typeElt",symbols:[d.has("elt")?{type:"elt"}:elt,"_","typeData","_","typeData"],postprocess:M},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>""},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_","instruction","_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>e[2]},{name:"subInstruction$ebnf$1$subexpression$1",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$1",symbols:["subInstruction$ebnf$1$subexpression$1"]},{name:"subInstruction$ebnf$1$subexpression$2",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$1",symbols:["subInstruction$ebnf$1","subInstruction$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_","subInstruction$ebnf$1","instruction","_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>e[2].map(e=>e[0]).concat(e[3]).map(e=>G(e))},{name:"subInstruction$ebnf$2$subexpression$1",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$2",symbols:["subInstruction$ebnf$2$subexpression$1"]},{name:"subInstruction$ebnf$2$subexpression$2",symbols:["instruction","_",d.has("semicolon")?{type:"semicolon"}:semicolon,"_"]},{name:"subInstruction$ebnf$2",symbols:["subInstruction$ebnf$2","subInstruction$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subInstruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_","subInstruction$ebnf$2",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:k},{name:"instructions",symbols:[d.has("baseInstruction")?{type:"baseInstruction"}:baseInstruction]},{name:"instructions",symbols:[d.has("macroCADR")?{type:"macroCADR"}:macroCADR]},{name:"instructions",symbols:[d.has("macroDIP")?{type:"macroDIP"}:macroDIP]},{name:"instructions",symbols:[d.has("macroDUP")?{type:"macroDUP"}:macroDUP]},{name:"instructions",symbols:[d.has("macroSETCADR")?{type:"macroSETCADR"}:macroSETCADR]},{name:"instructions",symbols:[d.has("macroASSERTlist")?{type:"macroASSERTlist"}:macroASSERTlist]},{name:"instruction",symbols:["instructions"],postprocess:T},{name:"instruction",symbols:["subInstruction"],postprocess:n},{name:"instruction$ebnf$1$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$1",symbols:["instruction$ebnf$1$subexpression$1"]},{name:"instruction$ebnf$1$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$1",symbols:["instruction$ebnf$1","instruction$ebnf$1$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$1","_"],postprocess:T},{name:"instruction",symbols:["instructions","_","subInstruction"],postprocess:e=>{const t=""+e[0].toString();return v(t)?A(t,e[2]):`{ "prim": "${e[0]}", "args": [ [ ${e[2]} ] ] }`}},{name:"instruction$ebnf$2$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$2",symbols:["instruction$ebnf$2$subexpression$1"]},{name:"instruction$ebnf$2$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$2",symbols:["instruction$ebnf$2","instruction$ebnf$2$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$2","_","subInstruction"],postprocess:N},{name:"instruction",symbols:["instructions","_","type"],postprocess:w},{name:"instruction$ebnf$3$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$3",symbols:["instruction$ebnf$3$subexpression$1"]},{name:"instruction$ebnf$3$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$3",symbols:["instruction$ebnf$3","instruction$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$3","_","type"],postprocess:N},{name:"instruction",symbols:["instructions","_","data"],postprocess:w},{name:"instruction$ebnf$4$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$4",symbols:["instruction$ebnf$4$subexpression$1"]},{name:"instruction$ebnf$4$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$4",symbols:["instruction$ebnf$4","instruction$ebnf$4$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$4","_","data"],postprocess:N},{name:"instruction",symbols:["instructions","_","type","_","type","_","subInstruction"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ ${e[2]}, ${e[4]}, [${e[6]}] ] }`},{name:"instruction$ebnf$5$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$5",symbols:["instruction$ebnf$5$subexpression$1"]},{name:"instruction$ebnf$5$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$5",symbols:["instruction$ebnf$5","instruction$ebnf$5$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$5","_","type","_","type","_","subInstruction"],postprocess:e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "${e[0]}", "args": [ ${e[3]}, ${e[5]}, ${e[7]} ], "annots": [${t}] }`}},{name:"instruction",symbols:["instructions","_","subInstruction","_","subInstruction"],postprocess:e=>{const t=""+e[0].toString();return P(t)?$(t,e[2],e[4]):`{ "prim": "${e[0]}", "args": [ [${e[2]}], [${e[4]}] ] }`}},{name:"instruction$ebnf$6$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$6",symbols:["instruction$ebnf$6$subexpression$1"]},{name:"instruction$ebnf$6$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$6",symbols:["instruction$ebnf$6","instruction$ebnf$6$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$6","_","subInstruction","_","subInstruction"],postprocess:W},{name:"instruction",symbols:["instructions","_","type","_","type"],postprocess:M},{name:"instruction$ebnf$7$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$7",symbols:["instruction$ebnf$7$subexpression$1"]},{name:"instruction$ebnf$7$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$7",symbols:["instruction$ebnf$7","instruction$ebnf$7$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:["instructions","instruction$ebnf$7","_","type","_","type"],postprocess:W},{name:"instruction",symbols:[{literal:"PUSH"},"_","type","_","data"],postprocess:M},{name:"instruction",symbols:[{literal:"PUSH"},"_","type","_",d.has("lbrace")?{type:"lbrace"}:lbrace,d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>`{ "prim": "${e[0]}", "args": [${e[2]}, []] }`},{name:"instruction$ebnf$8$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$8",symbols:["instruction$ebnf$8$subexpression$1"]},{name:"instruction$ebnf$8$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$8",symbols:["instruction$ebnf$8","instruction$ebnf$8$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"PUSH"},"instruction$ebnf$8","_","type","_","data"],postprocess:e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "PUSH", "args": [ ${e[3]}, ${e[5]} ], "annots": [${t}] }`}},{name:"instruction$ebnf$9",symbols:[/[0-9]/]},{name:"instruction$ebnf$9",symbols:["instruction$ebnf$9",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DIP"},"_","instruction$ebnf$9","_","subInstruction"],postprocess:e=>e.length>4?`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" }, [ ${e[4]} ] ] }`:`{ "prim": "${e[0]}", "args": [ ${e[2]} ] }`},{name:"instruction$ebnf$10",symbols:[/[0-9]/]},{name:"instruction$ebnf$10",symbols:["instruction$ebnf$10",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DUP"},"_","instruction$ebnf$10"],postprocess:e=>{const t=Number(e[2]);return 1===t?'{ "prim": "DUP" }':2===t?'[{ "prim": "DIP", "args": [[ {"prim": "DUP"} ]] }, { "prim": "SWAP" }]':`[{ "prim": "DIP", "args": [ {"int": "${t-1}"}, [{ "prim": "DUP" }] ] }, { "prim": "DIG", "args": [ {"int": "${t}"} ] }]`}},{name:"instruction",symbols:[{literal:"DUP"}],postprocess:T},{name:"instruction$ebnf$11$subexpression$1",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$11",symbols:["instruction$ebnf$11$subexpression$1"]},{name:"instruction$ebnf$11$subexpression$2",symbols:["_",d.has("annot")?{type:"annot"}:annot]},{name:"instruction$ebnf$11",symbols:["instruction$ebnf$11","instruction$ebnf$11$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DUP"},"instruction$ebnf$11","_"],postprocess:T},{name:"instruction$ebnf$12",symbols:[/[0-9]/]},{name:"instruction$ebnf$12",symbols:["instruction$ebnf$12",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DIG"},"_","instruction$ebnf$12"],postprocess:B},{name:"instruction$ebnf$13",symbols:[/[0-9]/]},{name:"instruction$ebnf$13",symbols:["instruction$ebnf$13",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DUG"},"_","instruction$ebnf$13"],postprocess:B},{name:"instruction$ebnf$14",symbols:[/[0-9]/]},{name:"instruction$ebnf$14",symbols:["instruction$ebnf$14",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DROP"},"_","instruction$ebnf$14"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" } ] }`},{name:"instruction",symbols:[{literal:"DROP"}],postprocess:T},{name:"instruction",symbols:[{literal:"CREATE_CONTRACT"},"_",d.has("lbrace")?{type:"lbrace"}:lbrace,"_","parameter","_","storage","_","code","_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>`{ "prim":"CREATE_CONTRACT", "args": [ [ ${e[4]}, ${e[6]}, {"prim": "code" , "args":[ [ ${e[8]} ] ] } ] ] }`},{name:"instruction",symbols:[{literal:"EMPTY_MAP"},"_","type","_","type"],postprocess:M},{name:"instruction",symbols:[{literal:"EMPTY_MAP"},"_",d.has("lparen")?{type:"lparen"}:lparen,"_","type","_",d.has("rparen")?{type:"rparen"}:rparen,"_","type"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ ${e[4]}, ${e[8]} ] }`},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1",/[\s]/],postprocess:e=>e[0].concat([e[1]])},{name:"_",symbols:["_$ebnf$1"]},{name:"semicolons$ebnf$1",symbols:[/[;]/],postprocess:n},{name:"semicolons$ebnf$1",symbols:[],postprocess:()=>null},{name:"semicolons",symbols:["semicolons$ebnf$1"]}],ParserStart:"main"};t.default=z},function(e,t,r){"use strict";var n=r(52),o=r(72);e.exports=o((function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}))},function(e,t,r){"use strict";var n=r(1),o=r(53),s=r(65),i=r(66),a=r(71);function u(e){a.call(this,"digest"),this._hash=e}n(u,a),u.prototype._update=function(e){this._hash.update(e)},u.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new o:"rmd160"===e||"ripemd160"===e?new s:new u(i(e))}},function(e,t,r){"use strict";var n=r(1),o=r(34),s=r(2).Buffer,i=new Array(16);function a(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(e,t){return e<>>32-t}function c(e,t,r,n,o,s,i){return u(e+(t&r|~t&n)+o+s|0,i)+t|0}function l(e,t,r,n,o,s,i){return u(e+(t&n|r&~n)+o+s|0,i)+t|0}function p(e,t,r,n,o,s,i){return u(e+(t^r^n)+o+s|0,i)+t|0}function f(e,t,r,n,o,s,i){return u(e+(r^(t|~n))+o+s|0,i)+t|0}n(a,o),a.prototype._update=function(){for(var e=i,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,o=this._c,s=this._d;r=c(r,n,o,s,e[0],3614090360,7),s=c(s,r,n,o,e[1],3905402710,12),o=c(o,s,r,n,e[2],606105819,17),n=c(n,o,s,r,e[3],3250441966,22),r=c(r,n,o,s,e[4],4118548399,7),s=c(s,r,n,o,e[5],1200080426,12),o=c(o,s,r,n,e[6],2821735955,17),n=c(n,o,s,r,e[7],4249261313,22),r=c(r,n,o,s,e[8],1770035416,7),s=c(s,r,n,o,e[9],2336552879,12),o=c(o,s,r,n,e[10],4294925233,17),n=c(n,o,s,r,e[11],2304563134,22),r=c(r,n,o,s,e[12],1804603682,7),s=c(s,r,n,o,e[13],4254626195,12),o=c(o,s,r,n,e[14],2792965006,17),r=l(r,n=c(n,o,s,r,e[15],1236535329,22),o,s,e[1],4129170786,5),s=l(s,r,n,o,e[6],3225465664,9),o=l(o,s,r,n,e[11],643717713,14),n=l(n,o,s,r,e[0],3921069994,20),r=l(r,n,o,s,e[5],3593408605,5),s=l(s,r,n,o,e[10],38016083,9),o=l(o,s,r,n,e[15],3634488961,14),n=l(n,o,s,r,e[4],3889429448,20),r=l(r,n,o,s,e[9],568446438,5),s=l(s,r,n,o,e[14],3275163606,9),o=l(o,s,r,n,e[3],4107603335,14),n=l(n,o,s,r,e[8],1163531501,20),r=l(r,n,o,s,e[13],2850285829,5),s=l(s,r,n,o,e[2],4243563512,9),o=l(o,s,r,n,e[7],1735328473,14),r=p(r,n=l(n,o,s,r,e[12],2368359562,20),o,s,e[5],4294588738,4),s=p(s,r,n,o,e[8],2272392833,11),o=p(o,s,r,n,e[11],1839030562,16),n=p(n,o,s,r,e[14],4259657740,23),r=p(r,n,o,s,e[1],2763975236,4),s=p(s,r,n,o,e[4],1272893353,11),o=p(o,s,r,n,e[7],4139469664,16),n=p(n,o,s,r,e[10],3200236656,23),r=p(r,n,o,s,e[13],681279174,4),s=p(s,r,n,o,e[0],3936430074,11),o=p(o,s,r,n,e[3],3572445317,16),n=p(n,o,s,r,e[6],76029189,23),r=p(r,n,o,s,e[9],3654602809,4),s=p(s,r,n,o,e[12],3873151461,11),o=p(o,s,r,n,e[15],530742520,16),r=f(r,n=p(n,o,s,r,e[2],3299628645,23),o,s,e[0],4096336452,6),s=f(s,r,n,o,e[7],1126891415,10),o=f(o,s,r,n,e[14],2878612391,15),n=f(n,o,s,r,e[5],4237533241,21),r=f(r,n,o,s,e[12],1700485571,6),s=f(s,r,n,o,e[3],2399980690,10),o=f(o,s,r,n,e[10],4293915773,15),n=f(n,o,s,r,e[1],2240044497,21),r=f(r,n,o,s,e[8],1873313359,6),s=f(s,r,n,o,e[15],4264355552,10),o=f(o,s,r,n,e[6],2734768916,15),n=f(n,o,s,r,e[13],1309151649,21),r=f(r,n,o,s,e[4],4149444226,6),s=f(s,r,n,o,e[11],3174756917,10),o=f(o,s,r,n,e[2],718787259,15),n=f(n,o,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+o|0,this._d=this._d+s|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=s.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},function(e,t){},function(e,t,r){"use strict";var n=r(2).Buffer,o=r(56);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,o,s=n.allocUnsafe(e>>>0),i=this.head,a=0;i;)t=i.data,r=s,o=a,t.copy(r,o),a+=i.data.length,i=i.next;return s},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function s(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new s(o.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new s(o.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(58),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(9))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,o,s,i,a,u=1,c={},l=!1,p=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){d(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){d(e.data)},n=function(e){s.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(o=p.documentElement,n=function(e){var t=p.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):n=function(e){setTimeout(d,0,e)}:(i="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(i)&&d(+t.data.slice(i.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),n=function(t){e.postMessage(i+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r>>32-t}function g(e,t,r,n,o,s,i,a){return d(e+(t^r^n)+s+i|0,a)+o|0}function m(e,t,r,n,o,s,i,a){return d(e+(t&r|~t&n)+s+i|0,a)+o|0}function b(e,t,r,n,o,s,i,a){return d(e+((t|~r)^n)+s+i|0,a)+o|0}function y(e,t,r,n,o,s,i,a){return d(e+(t&n|r&~n)+s+i|0,a)+o|0}function D(e,t,r,n,o,s,i,a){return d(e+(t^(r|~n))+s+i|0,a)+o|0}o(h,s),h.prototype._update=function(){for(var e=i,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,h=0|this._e,P=0|this._a,$=0|this._b,v=0|this._c,A=0|this._d,I=0|this._e,_=0;_<80;_+=1){var R,S;_<16?(R=g(r,n,o,s,h,e[a[_]],p[0],c[_]),S=D(P,$,v,A,I,e[u[_]],f[0],l[_])):_<32?(R=m(r,n,o,s,h,e[a[_]],p[1],c[_]),S=y(P,$,v,A,I,e[u[_]],f[1],l[_])):_<48?(R=b(r,n,o,s,h,e[a[_]],p[2],c[_]),S=b(P,$,v,A,I,e[u[_]],f[2],l[_])):_<64?(R=y(r,n,o,s,h,e[a[_]],p[3],c[_]),S=m(P,$,v,A,I,e[u[_]],f[3],l[_])):(R=D(r,n,o,s,h,e[a[_]],p[4],c[_]),S=g(P,$,v,A,I,e[u[_]],f[4],l[_])),r=h,h=s,s=d(o,10),o=n,n=R,P=I,I=A,A=d(v,10),v=$,$=S}var C=this._b+o+A|0;this._b=this._c+s+I|0,this._c=this._d+h+P|0,this._d=this._e+r+$|0,this._e=this._a+n+v|0,this._a=C},h.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=n.alloc?n.alloc(20):new n(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=h},function(e,t,r){(t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r}).sha=r(67),t.sha1=r(68),t.sha224=r(69),t.sha256=r(40),t.sha384=r(70),t.sha512=r(41)},function(e,t,r){var n=r(1),o=r(13),s=r(2).Buffer,i=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,o.call(this,64,56)}function c(e){return e<<30|e>>>2}function l(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,o),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,o=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,p=0;p<16;++p)r[p]=e.readInt32BE(4*p);for(;p<80;++p)r[p]=r[p-3]^r[p-8]^r[p-14]^r[p-16];for(var f=0;f<80;++f){var h=~~(f/20),d=0|((t=n)<<5|t>>>27)+l(h,o,s,a)+u+r[f]+i[h];u=a,a=s,s=c(o),o=n,n=d}this._a=n+this._a|0,this._b=o+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(1),o=r(13),s=r(2).Buffer,i=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,o.call(this,64,56)}function c(e){return e<<5|e>>>27}function l(e){return e<<30|e>>>2}function p(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,o),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,o=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=e.readInt32BE(4*f);for(;f<80;++f)r[f]=(t=r[f-3]^r[f-8]^r[f-14]^r[f-16])<<1|t>>>31;for(var h=0;h<80;++h){var d=~~(h/20),g=c(n)+p(d,o,s,a)+u+r[h]+i[d]|0;u=a,a=s,s=l(o),o=n,n=g}this._a=n+this._a|0,this._b=o+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(1),o=r(40),s=r(13),i=r(2).Buffer,a=new Array(64);function u(){this.init(),this._w=a,s.call(this,64,56)}n(u,o),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=i.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=u},function(e,t,r){var n=r(1),o=r(41),s=r(13),i=r(2).Buffer,a=new Array(160);function u(){this.init(),this._w=a,s.call(this,128,112)}n(u,o),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=i.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=u},function(e,t,r){var n=r(2).Buffer,o=r(35).Transform,s=r(26).StringDecoder;function i(e){o.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(1)(i,o),i.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var o=this._update(e);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},i.prototype.setAutoPadding=function(){},i.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},i.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},i.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},i.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},i.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},i.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},i.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new s(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},e.exports=i},function(e,t,r){"use strict";var n=r(73),o=r(2).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),o=e(r);if(!(n[0]^o[0]|n[1]^o[1]|n[2]^o[2]|n[3]^o[3]))return r}return{encode:function(t){var r=e(t);return n.encode(o.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){var n=r(74);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(e,t,r){"use strict";var n=r(2).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");var t=new Uint8Array(256);t.fill(255);for(var r=0;r>>0,l=new Uint8Array(c);e[r];){var p=t[e.charCodeAt(r)];if(255===p)return;for(var f=0,h=c-1;(0!==p||f>>0,l[h]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");s=f,r++}if(" "!==e[r]){for(var d=c-s;d!==c&&0===l[d];)d++;var g=n.allocUnsafe(o+(c-d));g.fill(0,0,o);for(var m=o;d!==c;)g[m++]=l[d++];return g}}}return{encode:function(t){if(!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,o=0,s=0,u=t.length;s!==u&&0===t[s];)s++,r++;for(var l=(u-s)*c+1>>>0,p=new Uint8Array(l);s!==u;){for(var f=t[s],h=0,d=l-1;(0!==f||h>>0,p[d]=f%i>>>0,f=f/i>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,s++}for(var g=l-o;g!==l&&0===p[g];)g++;for(var m=a.repeat(r);g=4294967296&&o++,e[t]=n,e[t+1]=o}function s(e,t,r,n){var o=e[t]+r;r<0&&(o+=4294967296);var s=e[t+1]+n;o>=4294967296&&s++,e[t]=o,e[t+1]=s}function i(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function a(e,t,r,n,i,a){var u=p[i],c=p[i+1],f=p[a],h=p[a+1];o(l,e,t),s(l,e,u,c);var d=l[n]^l[e],g=l[n+1]^l[e+1];l[n]=g,l[n+1]=d,o(l,r,n),d=l[t]^l[r],g=l[t+1]^l[r+1],l[t]=d>>>24^g<<8,l[t+1]=g>>>24^d<<8,o(l,e,t),s(l,e,f,h),d=l[n]^l[e],g=l[n+1]^l[e+1],l[n]=d>>>16^g<<16,l[n+1]=g>>>16^d<<16,o(l,r,n),d=l[t]^l[r],g=l[t+1]^l[r+1],l[t]=g>>>31^d<<1,l[t+1]=d>>>31^g<<1}var u=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),l=new Uint32Array(32),p=new Uint32Array(32);function f(e,t){var r=0;for(r=0;r<16;r++)l[r]=e.h[r],l[r+16]=u[r];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,t&&(l[28]=~l[28],l[29]=~l[29]),r=0;r<32;r++)p[r]=i(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,c[16*r+0],c[16*r+1]),a(2,10,18,26,c[16*r+2],c[16*r+3]),a(4,12,20,28,c[16*r+4],c[16*r+5]),a(6,14,22,30,c[16*r+6],c[16*r+7]),a(0,10,20,30,c[16*r+8],c[16*r+9]),a(2,12,22,24,c[16*r+10],c[16*r+11]),a(4,14,16,26,c[16*r+12],c[16*r+13]),a(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^l[r]^l[r+16]}function h(e,t){if(0===e||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e},n=0;n<16;n++)r.h[n]=u[n];var o=t?t.length:0;return r.h[0]^=16842752^o<<8^e,t&&(d(r,t),r.c=128),r}function d(e,t){for(var r=0;r>2]>>8*(3&r);return t}function m(e,t,r){r=r||64,e=n.normalizeInput(e);var o=h(r,t);return d(o,e),g(o)}e.exports={blake2b:m,blake2bHex:function(e,t,r){var o=m(e,t,r);return n.toHex(o)},blake2bInit:h,blake2bUpdate:d,blake2bFinal:g}},function(e,t,r){var n=r(42);function o(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function s(e,t,r,n,o,s){c[e]=c[e]+c[t]+o,c[n]=i(c[n]^c[e],16),c[r]=c[r]+c[n],c[t]=i(c[t]^c[r],12),c[e]=c[e]+c[t]+s,c[n]=i(c[n]^c[e],8),c[r]=c[r]+c[n],c[t]=i(c[t]^c[r],7)}function i(e,t){return e>>>t^e<<32-t}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),l=new Uint32Array(16);function p(e,t){var r=0;for(r=0;r<8;r++)c[r]=e.h[r],c[r+8]=a[r];for(c[12]^=e.t,c[13]^=e.t/4294967296,t&&(c[14]=~c[14]),r=0;r<16;r++)l[r]=o(e.b,4*r);for(r=0;r<10;r++)s(0,4,8,12,l[u[16*r+0]],l[u[16*r+1]]),s(1,5,9,13,l[u[16*r+2]],l[u[16*r+3]]),s(2,6,10,14,l[u[16*r+4]],l[u[16*r+5]]),s(3,7,11,15,l[u[16*r+6]],l[u[16*r+7]]),s(0,5,10,15,l[u[16*r+8]],l[u[16*r+9]]),s(1,6,11,12,l[u[16*r+10]],l[u[16*r+11]]),s(2,7,8,13,l[u[16*r+12]],l[u[16*r+13]]),s(3,4,9,14,l[u[16*r+14]],l[u[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=c[r]^c[r+8]}function f(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(h(n,t),n.c=64),n}function h(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}function g(e,t,r){r=r||32,e=n.normalizeInput(e);var o=f(r,t);return h(o,e),d(o)}e.exports={blake2s:g,blake2sHex:function(e,t,r){var o=g(e,t,r);return n.toHex(o)},blake2sInit:f,blake2sUpdate:h,blake2sFinal:d}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(22).compile({wspace:/[ \t]+/,lparen:"(",rparen:")",annot:/:[^ );]+|%[^ );]+/,parameter:"parameter",or:"or",pair:"pair",data:["bytes","int","nat","bool","string","timestamp","signature","key","key_hash","mutez","address","unit","operation","chain_id"],singleArgData:["option","list","contract","set"],doubleArgData:["lambda","map","big_map"],semicolon:";"}),o=e=>{let t=void 0,r=void 0;if(e.length>=3){const n=e[2].toString();"%"===n.charAt(0)?r=a(n):t=u(n)}if(5===e.length){const n=e[4].toString();n.startsWith("%")&&void 0===r&&(r=a(n)),n.startsWith(":")&&void 0===t&&(t=u(n))}return[{name:r,parameters:[{name:t||r,type:e[0].toString()}],structure:"$PARAM",generateInvocationString(...e){if(this.parameters.length!==e.length)throw new Error(`Incorrect number of parameters provided; expected ${this.parameters.length}, got ${e.length}`);let t=this.structure;for(let r=0;r{switch(e.type){case"string":return'"Tacos"';case"int":return-1;case"nat":return 99;case"address":return'"KT1EGbAxguaWQFkV3Egb2Z1r933MWuEYyrJS"';case"key_hash":return'"tz1SQnJaocpquTztY3zMgydTPoQBBQrDGonJ"';case"timestamp":return`"${(new Date).toISOString()}"`;case"mutez":return 5e5;case"unit":return"Unit";case"bytes":case"bool":case"signature":case"key":case"operation":case"chain_id":default:return e.type}});return this.generateInvocationString(...e)}}]},s=(...e)=>{const t=e.find(e=>e.startsWith("%"));return t?a(t):void 0},i=(...e)=>{const t=e.find(e=>e.startsWith(":"));return t?u(t):void 0},a=e=>{if(!e.startsWith("%"))throw new Error(e+" must start with '%'");return e.replace(/^%_Liq_entry_/,"").replace("%","")},u=e=>{if(!e.startsWith(":"))throw new Error(e+" must start with ':'");return e.replace(":","")},c={Lexer:n,ParserRules:[{name:"entry",symbols:[n.has("parameter")?{type:"parameter"}:parameter,"__","parameters","_",n.has("semicolon")?{type:"semicolon"}:semicolon],postprocess:e=>e[2]},{name:"parameters",symbols:[n.has("lparen")?{type:"lparen"}:lparen,"_","parameters","_",n.has("rparen")?{type:"rparen"}:rparen],postprocess:e=>e[2]},{name:"parameters",symbols:[n.has("or")?{type:"or"}:or,"_",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{e[2],e[4];const t=e[6],r=e[8],n=[];for(const e of t){const t={name:e.name,parameters:e.parameters,structure:"(Left "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};n.push(t)}for(const e of r){const t={name:e.name,parameters:e.parameters,structure:"(Right "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};n.push(t)}return n}},{name:"parameters",symbols:[n.has("or")?{type:"or"}:or,"_",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=e[6],o=[];for(const e of r){const r={name:`${t}.${e.name}`,parameters:e.parameters,structure:"(Left "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};o.push(r)}for(const e of n){const r={name:`${t}.${e.name}`,parameters:e.parameters,structure:"(Right "+e.structure+")",generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};o.push(r)}return o}},{name:"parameters",symbols:[n.has("or")?{type:"or"}:or,"_","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=[];for(const e of t)1===e.parameters.length&&e.parameters[0].name===e.name&&(e.parameters[0].name=void 0),n.push(Object.assign(Object.assign({},e),{structure:`(Left ${e.structure})`}));for(const e of r)1===e.parameters.length&&e.parameters[0].name===e.name&&(e.parameters[0].name=void 0),n.push(Object.assign(Object.assign({},e),{structure:`(Right ${e.structure})`}));return n}},{name:"parameters",symbols:[n.has("pair")?{type:"pair"}:pair,"__",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=e[6],o=e[8],s=[];for(const e of n)for(const n of o){const o={name:i(t.toString(),r.toString()),parameters:e.parameters.concat(n.parameters),structure:`(Pair ${e.structure} ${n.structure})`,generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};s.push(o)}return s}},{name:"parameters",symbols:[n.has("pair")?{type:"pair"}:pair,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=e[6],o=[];for(const e of r)for(const r of n){const n={name:i(t.toString())||s(t.toString())||void 0,parameters:e.parameters.concat(r.parameters),structure:`(Pair ${e.structure} ${r.structure})`,generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};o.push(n)}return o}},{name:"parameters",symbols:[n.has("pair")?{type:"pair"}:pair,"__","parameters","__","parameters"],postprocess:e=>{const t=e[2],r=e[4],n=[];for(const e of t)for(const t of r){const r={name:void 0,parameters:e.parameters.concat(t.parameters),structure:`(Pair ${e.structure} ${t.structure})`,generateInvocationString:e.generateInvocationString,generateInvocationPair:e.generateInvocationPair,generateSampleInvocation:e.generateSampleInvocation};n.push(r)}return n}},{name:"parameters",symbols:[n.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4].toString(),o=e[6];return o[0].name=s(r,n),o[0].parameters[0].constituentType=o[0].parameters[0].type,"option"===t&&(o[0].parameters[0].optional=!0),o[0].parameters[0].type=`${t} (${o[0].parameters[0].type})`,o[0].structure=`(${o[0].structure})`,o}},{name:"parameters",symbols:[n.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4];return n[0].name=s(r),n[0].parameters[0].constituentType=n[0].parameters[0].type,"option"===t&&(n[0].parameters[0].optional=!0),n[0].parameters[0].type=`${t} (${n[0].parameters[0].type})`,n[0].structure=`(${n[0].structure})`,n}},{name:"parameters",symbols:[n.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2];return r[0].parameters[0].constituentType=r[0].parameters[0].type,"option"===t&&(r[0].parameters[0].optional=!0),r[0].parameters[0].type=`${t} (${r[0].parameters[0].type})`,r[0].structure=`(${r[0].structure})`,r}},{name:"parameters",symbols:[n.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4].toString(),o=e[6],i=e[8];return o[0].name=s(r,n),o[0].parameters[0].type=`${t} (${o[0].parameters[0].type}) (${i[0].parameters[0].type})`,o[0].structure=`(${o[0].structure})`,o}},{name:"parameters",symbols:[n.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_",n.has("annot")?{type:"annot"}:annot,"__","parameters","__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2].toString(),n=e[4],o=e[6];return n[0].name=s(r),n[0].parameters[0].type=`${t} (${n[0].parameters[0].type}) (${o[0].parameters[0].type})`,n[0].structure=`(${n[0].structure})`,n}},{name:"parameters",symbols:[n.has("doubleArgData")?{type:"doubleArgData"}:doubleArgData,"_","parameters","__","parameters"],postprocess:e=>{const t=e[0].toString(),r=e[2],n=e[4];return r[0].parameters[0].type=`${t} (${r[0].parameters[0].type}) (${n[0].parameters[0].type})`,r[0].structure=`(${r[0].structure})`,r}},{name:"parameters",symbols:[n.has("data")?{type:"data"}:data,"__",n.has("annot")?{type:"annot"}:annot],postprocess:o},{name:"parameters",symbols:[n.has("data")?{type:"data"}:data,"__",n.has("annot")?{type:"annot"}:annot,"__",n.has("annot")?{type:"annot"}:annot],postprocess:o},{name:"parameters",symbols:[n.has("data")?{type:"data"}:data],postprocess:o},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1",/[\s]/],postprocess:e=>e[0].concat([e[1]])},{name:"_",symbols:["_$ebnf$1"]},{name:"__",symbols:[/[\s]/]}],ParserStart:"entry"};t.default=c},function(module,exports){var indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0;r{const r=s.get(t)||"";return e[r]>t?e:Object.assign(Object.assign({},e),{[r]:t})},new Map);!function(t){function r(e){return s.get(n.TezosMessageUtils.readInt(e))||""}function a(e){return r(e.substring(64,66))}function u(e,t,r=!0){switch(t){case"endorsement":case"seedNonceRevelation":case"doubleEndorsementEvidence":case"doubleBakingEvidence":case"accountActivation":case"proposal":throw new Error("Unsupported operation type: "+t);case"ballot":return l(e,r);case"reveal":return f(e,r);case"transaction":return d(e,r);case"origination":return m(e,r);case"delegation":return y(e,r);default:throw new Error("Unsupported operation type: "+t)}}function c(e){let t=n.TezosMessageUtils.writeInt(i.accountActivation);return t+=n.TezosMessageUtils.writeAddress(e.pkh).slice(4),t+=e.secret,t}function l(t,o=!0){if("ballot"!==r(o?t.substring(64,66):t.substring(0,2)))throw new Error("Provided operation is not a ballot");let s=0,i="";o?(i=n.TezosMessageUtils.readBranch(t.substring(s,s+64)),s+=66):s+=2;const a=n.TezosMessageUtils.readAddress(t.substring(s,s+42));s+=42;const u=parseInt(t.substring(s,s+8),16);s+=8;const c=n.TezosMessageUtils.readBufferWithHint(e.from(t.substring(s,s+64),"hex"),"p");s+=64;const l=parseInt(t.substring(s,s+1),16);let p;s+=2,t.length>s&&(p=r(t.substring(s,s+2)));return{operation:{kind:"ballot",source:a,period:u,proposal:c,vote:l},branch:i,next:p,nextoffset:p?s:-1}}function p(e){let t=n.TezosMessageUtils.writeInt(i.ballot);return t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=("00000000"+e.period.toString(16)).slice(-8),t+=n.TezosMessageUtils.writeBufferWithHint(e.proposal).toString("hex").slice(4),t+=("00"+e.vote.toString(16)).slice(-2),t}function f(e,t=!0){let o=t?e.substring(64,66):e.substring(0,2);if("reveal"!==r(o))throw new Error("Provided operation is not a reveal.");let s=0,i="";t?(i=n.TezosMessageUtils.readBranch(e.substring(s,s+64)),s+=66):s+=2;let a="";parseInt(o,16)<100?(a=n.TezosMessageUtils.readAddress(e.substring(s,s+44)),s+=44):(a=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42);let u=n.TezosMessageUtils.findInt(e,s);s+=u.length;let c=n.TezosMessageUtils.findInt(e,s);s+=c.length;let l=n.TezosMessageUtils.findInt(e,s);s+=l.length;let p=n.TezosMessageUtils.findInt(e,s);s+=p.length;let f,h=n.TezosMessageUtils.readPublicKey(e.substring(s,s+66));s+=66,e.length>s&&(f=r(e.substring(s,s+2)));return{operation:{kind:"reveal",source:a,public_key:h,fee:u.value+"",gas_limit:l.value+"",storage_limit:p.value+"",counter:c.value+""},branch:i,next:f,nextoffset:f?s:-1}}function h(e){if("reveal"!==e.kind)throw new Error("Incorrect operation type.");let t=n.TezosMessageUtils.writeInt(i.reveal);return t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),t+=n.TezosMessageUtils.writePublicKey(e.public_key),t}function d(t,s=!0){let i=s?t.substring(64,66):t.substring(0,2);if("transaction"!==r(i))throw new Error("Provided operation is not a transaction.");let a=0,u="";s?(u=n.TezosMessageUtils.readBranch(t.substring(a,a+64)),a+=66):a+=2;let c="";parseInt(i,16)<100?(c=n.TezosMessageUtils.readAddress(t.substring(a,a+44)),a+=44):(c=n.TezosMessageUtils.readAddress(t.substring(a,a+42)),a+=42);let l=n.TezosMessageUtils.findInt(t,a);a+=l.length;let p=n.TezosMessageUtils.findInt(t,a);a+=p.length;let f=n.TezosMessageUtils.findInt(t,a);a+=f.length;let h=n.TezosMessageUtils.findInt(t,a);a+=h.length;let d=n.TezosMessageUtils.findInt(t,a);a+=d.length;let g=n.TezosMessageUtils.readAddress(t.substring(a,a+44));a+=44;let m=n.TezosMessageUtils.readBoolean(t.substring(a,a+2));a+=2;let b,y="";if(m&&parseInt(i,16)<100){const e=parseInt(t.substring(a,a+8),16);a+=8;const r=o.TezosLanguageUtil.hexToMicheline(t.substring(a));if(y=r.code,r.consumed!==2*e)throw new Error("Failed to parse transaction parameters: length mismatch");a+=2*e}else if(m&&parseInt(i,16)>100){const r=parseInt(t.substring(a,a+2),16);a+=2;let n="";if(255===r){const r=parseInt(t.substring(a,a+2),16);a+=2,n=e.from(t.substring(a,a+2*r),"hex").toString(),a+=2*r}else 0===r?n="default":1===r?n="root":2===r?n="do":3===r?n="set_delegate":4===r&&(n="remove_delegate");const s=parseInt(t.substring(a,a+8),16);a+=8;const i=o.TezosLanguageUtil.hexToMicheline(t.substring(a)),u=i.code;if(i.consumed!==2*s)throw new Error("Failed to parse transaction parameters: length mismatch");a+=2*s,y={entrypoint:n,value:u}}t.length>a&&(b=r(t.substring(a,a+2)));return{operation:{kind:"transaction",source:c,destination:g,amount:d.value.toString(),fee:l.value.toString(),gas_limit:f.value.toString(),storage_limit:h.value.toString(),counter:p.value.toString(),parameters:y},branch:u,next:b,nextoffset:b?a:-1}}function g(e){if("transaction"!==e.kind)throw new Error("Incorrect operation type");let t=n.TezosMessageUtils.writeInt(i.transaction);if(t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.amount)),t+=n.TezosMessageUtils.writeAddress(e.destination),e.parameters){const r=e.parameters,n=o.TezosLanguageUtil.normalizeMichelineWhiteSpace(JSON.stringify(r.value)),s=o.TezosLanguageUtil.translateMichelineToHex(n);"default"!==r.entrypoint&&""!==r.entrypoint||"030b"!==s?(t+="ff","default"===r.entrypoint||""===r.entrypoint?t+="00":"root"===r.entrypoint?t+="01":"do"===r.entrypoint?t+="02":"set_delegate"===r.entrypoint?t+="03":"remove_delegate"===r.entrypoint?t+="04":t+="ff"+("0"+r.entrypoint.length.toString(16)).slice(-2)+r.entrypoint.split("").map(e=>e.charCodeAt(0).toString(16)).join(""),t+="030b"===s?"00":("0000000"+(s.length/2).toString(16)).slice(-8)+s):t+="00"}else t+="00";return t}function m(e,t=!0){let s=t?e.substring(64,66):e.substring(0,2);if("origination"!==r(s))throw new Error("Provided operation is not an origination.");let i=0,a="";t?(a=n.TezosMessageUtils.readBranch(e.substring(i,i+64)),i+=66):i+=2;let u="";parseInt(s,16)<100?(u=n.TezosMessageUtils.readAddress(e.substring(i,i+44)),i+=44):(u=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let c=n.TezosMessageUtils.findInt(e,i);i+=c.length;let l=n.TezosMessageUtils.findInt(e,i);i+=l.length;let p=n.TezosMessageUtils.findInt(e,i);i+=p.length;let f=n.TezosMessageUtils.findInt(e,i);i+=f.length;let h="";parseInt(s,16)<100&&(h=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let d=n.TezosMessageUtils.findInt(e,i);i+=d.length;let g=!1,m=!1;parseInt(s,16)<100&&(g=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2,m=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2);let b=n.TezosMessageUtils.readBoolean(e.substring(i,i+2));i+=2;let y="";b&&(y=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let D=!0;parseInt(s,16)<100&&(D=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2);let P,$={};if(D){let t=parseInt(e.substring(i,i+8),16);i+=8;const r=o.TezosLanguageUtil.hexToMicheline(e.substring(i,i+2*t)).code;i+=2*t;let n=parseInt(e.substring(i,i+8),16);i+=8;const s=o.TezosLanguageUtil.hexToMicheline(e.substring(i,i+2*n)).code;i+=2*n,$=JSON.parse(`{ "script": [ ${r}, ${s} ] }`)}e.length>i&&(P=r(e.substring(i,i+2)));let v={kind:"origination",source:u,balance:d.value+"",delegate:b?y:void 0,fee:c.value+"",gas_limit:p.value+"",storage_limit:f.value+"",counter:l.value+"",script:D?$:void 0};parseInt(s,16)<100&&(v.manager_pubkey=h,v.spendable=g,v.delegatable=m);return{operation:v,branch:a,next:P,nextoffset:P?i:-1}}function b(e){if("origination"!==e.kind)throw new Error("Incorrect operation type");let t=n.TezosMessageUtils.writeInt(i.origination);if(t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.balance)),void 0!==e.delegate?(t+=n.TezosMessageUtils.writeBoolean(!0),t+=n.TezosMessageUtils.writeAddress(e.delegate).slice(2)):t+=n.TezosMessageUtils.writeBoolean(!1),e.script){let r=[];r.push(e.script.code),r.push(e.script.storage),t+=r.map(e=>o.TezosLanguageUtil.normalizeMichelineWhiteSpace(JSON.stringify(e))).map(e=>o.TezosLanguageUtil.translateMichelineToHex(e)).reduce((e,t)=>e+("0000000"+(t.length/2).toString(16)).slice(-8)+t,"")}return t}function y(e,t=!0){let o=t?e.substring(64,66):e.substring(0,2);if("delegation"!==r(o))throw new Error("Provided operation is not a delegation.");let s=0,i="";t?(i=n.TezosMessageUtils.readBranch(e.substring(s,s+64)),s+=66):s+=2;let a="";parseInt(o,16)<100?(a=n.TezosMessageUtils.readAddress(e.substring(s,s+44)),s+=44):(a=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42);let u=n.TezosMessageUtils.findInt(e,s);s+=u.length;let c=n.TezosMessageUtils.findInt(e,s);s+=c.length;let l=n.TezosMessageUtils.findInt(e,s);s+=l.length;let p=n.TezosMessageUtils.findInt(e,s);s+=p.length;let f=n.TezosMessageUtils.readBoolean(e.substring(s,s+2));s+=2;let h,d="";f&&(d=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42),e.length>s&&(h=r(e.substring(s,s+2)));return{operation:{kind:"delegation",source:a,delegate:f?d:void 0,fee:u.value+"",gas_limit:l.value+"",storage_limit:p.value+"",counter:c.value+""},branch:i,next:h,nextoffset:h?s:-1}}function D(e){if("delegation"!==e.kind)throw new Error("Incorrect operation type");let t=n.TezosMessageUtils.writeInt(i.delegation);return t+=n.TezosMessageUtils.writeAddress(e.source).slice(2),t+=n.TezosMessageUtils.writeInt(parseInt(e.fee)),t+=n.TezosMessageUtils.writeInt(parseInt(e.counter)),t+=n.TezosMessageUtils.writeInt(parseInt(e.gas_limit)),t+=n.TezosMessageUtils.writeInt(parseInt(e.storage_limit)),void 0!==e.delegate&&""!==e.delegate?(t+=n.TezosMessageUtils.writeBoolean(!0),t+=n.TezosMessageUtils.writeAddress(e.delegate).slice(2)):t+=n.TezosMessageUtils.writeBoolean(!1),t}t.getOperationType=r,t.idFirstOperation=a,t.parseOperation=u,t.encodeOperation=function(e){if(e.hasOwnProperty("pkh")&&e.hasOwnProperty("secret"))return c(e);if(e.hasOwnProperty("kind")){const t=e;if("reveal"===t.kind)return h(e);if("transaction"===t.kind)return g(e);if("origination"===t.kind)return b(e);if("delegation"===t.kind)return D(e)}if(e.hasOwnProperty("vote"))return p(e);throw new Error("Unsupported message type")},t.encodeActivation=c,t.parseBallot=l,t.encodeBallot=p,t.parseReveal=f,t.encodeReveal=h,t.parseTransaction=d,t.encodeTransaction=g,t.parseOrigination=m,t.encodeOrigination=b,t.parseDelegation=y,t.encodeDelegation=D,t.parseOperationGroup=function(e){let t=[],r=u(e,a(e));t.push(r.operation);let n=0;for(;r.next;)n+=r.nextoffset,r=u(e.substring(n),r.next,!1),t.push(r.operation);return t}}(t.TezosMessageCodec||(t.TezosMessageCodec={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(19),i=r(3),a=r(7),u=o(r(12)).default.log;class c{constructor(e,t,r,n){this.triggerTimestamp=0,this.server=e,this.keyStore=r,this.signer=t,this.delay=n,this.operations=[]}static createQueue(e,t,r,n=s.TezosConstants.DefaultBatchDelay){return new c(e,t,r,n)}addOperations(...e){0===this.operations.length&&(this.triggerTimestamp=Date.now(),setTimeout(()=>{this.sendOperations()},1e3*this.delay)),e.forEach(e=>this.operations.push(e))}getStatus(){return this.operations.length}sendOperations(){return n(this,void 0,void 0,(function*(){let e=(yield i.TezosNodeReader.getCounterForAccount(this.server,this.keyStore.publicKeyHash))+1,t=[];const r=this.operations.length;for(let n=0;n0&&(this.triggerTimestamp=Date.now(),setTimeout(()=>{this.sendOperations()},1e3*this.delay));try{yield a.TezosNodeWriter.sendOperation(this.server,t,this.signer)}catch(e){u.error("Error sending queued operations: "+e)}}))}}t.TezosOperationQueue=c},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(19),u=r(3),c=r(7),l=r(11);!function(e){function t(e,t,r,n,o,s,u){let l=`[ { "prim": "DROP" },\n { "prim": "NIL", "args": [ { "prim": "operation" } ] },\n { "prim": "PUSH", "args": [ { "prim": "key_hash" }, { "string": "${u}" } ] },\n { "prim": "IMPLICIT_ACCOUNT" },\n { "prim": "PUSH", "args": [ { "prim": "mutez" }, { "int": "${s}" } ] },\n { "prim": "UNIT" },\n { "prim": "TRANSFER_TOKENS" },\n { "prim": "CONS" } ]`;return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,0,o,a.TezosConstants.P005ManagerContractWithdrawalStorageLimit,a.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",l,i.TezosParameterFormat.Micheline)}e.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"d99cb8b4c7e40166f59c0f3c30724225")}))},e.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"a585489ffaee60d07077059539d5bfc8")},e.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{administrator:s.JSONPath({path:"$.string",json:r})[0]}}))},e.setDelegate=function(e,t,r,n,o,s){if(n.startsWith("KT1")){const u=`[{ "prim": "DROP" }, { "prim": "NIL", "args": [{ "prim": "operation" }] }, { "prim": "PUSH", "args": [{ "prim": "key_hash" }, { "string": "${o}" } ] }, { "prim": "SOME" }, { "prim": "SET_DELEGATE" }, { "prim": "CONS" } ]`;return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,0,s,0,a.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",u,i.TezosParameterFormat.Micheline)}return c.TezosNodeWriter.sendDelegationOperation(e,t,r,o,s)},e.unSetDelegate=function(e,t,r,n,o){if(n.startsWith("KT1")){const s='[{ "prim": "DROP" }, { "prim": "NIL", "args": [{ "prim": "operation" }] }, { "prim": "NONE", "args": [{ "prim": "key_hash" }] }, { "prim": "SET_DELEGATE" }, { "prim": "CONS" } ]';return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,0,o,0,a.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",s,i.TezosParameterFormat.Micheline)}return c.TezosNodeWriter.sendUndelegationOperation(e,t,r,o)},e.withdrawDelegatedFunds=function(e,r,n,o,s,i){return t(e,r,n,o,s,i,n.publicKeyHash)},e.sendDelegatedFunds=t,e.depositDelegatedFunds=function(e,t,r,n,o,s){return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,s,o,0,a.TezosConstants.P005ManagerContractDepositGasLimit,void 0,void 0)},e.deployManagerContract=function(e,t,r,n,o,s){const a=`{ "string": "${r.publicKeyHash}" }`;return c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,s,n,o,600,2e4,'[ { "prim": "parameter",\n "args":\n [ { "prim": "or",\n "args":\n [ { "prim": "lambda",\n "args":\n [ { "prim": "unit" }, { "prim": "list", "args": [ { "prim": "operation" } ] } ], "annots": [ "%do" ] },\n { "prim": "unit", "annots": [ "%default" ] } ] } ] },\n { "prim": "storage", "args": [ { "prim": "key_hash" } ] },\n { "prim": "code",\n "args":\n [ [ [ [ { "prim": "DUP" }, { "prim": "CAR" },\n { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ],\n { "prim": "IF_LEFT",\n "args":\n [ [ { "prim": "PUSH", "args": [ { "prim": "mutez" }, { "int": "0" } ] },\n { "prim": "AMOUNT" },\n [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ],\n { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" }, { "prim": "FAILWITH" } ] ] ] } ],\n [ { "prim": "DIP", "args": [ [ { "prim": "DUP" } ] ] },\n { "prim": "SWAP" } ],\n { "prim": "IMPLICIT_ACCOUNT" },\n { "prim": "ADDRESS" },\n { "prim": "SENDER" },\n [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ],\n { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" },{ "prim": "FAILWITH" } ] ] ] } ],\n { "prim": "UNIT" }, { "prim": "EXEC" },\n { "prim": "PAIR" } ],\n [ { "prim": "DROP" },\n { "prim": "NIL", "args": [ { "prim": "operation" } ] },\n { "prim": "PAIR" } ] ] } ] ] } ]',a,i.TezosParameterFormat.Micheline)}}(t.BabylonDelegationHelper||(t.BabylonDelegationHelper={}))},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(11),p=r(5);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"c020219e31ee3b462ed93c33124f117f")}))},t.commitName=function(t,r,o,s,u,f,h,d,g){return n(this,void 0,void 0,(function*(){const n=`(Pair "${u}" (Pair ${f} 0x${a.TezosMessageUtils.writeAddress(o.publicKeyHash)}))`,m=a.TezosMessageUtils.writePackedData(n,"record",p.TezosParameterFormat.Michelson),b="0x"+a.TezosMessageUtils.simpleHash(e.from(m,"hex"),32).toString("hex");if(!d||!g){const e=yield c.TezosNodeWriter.testContractInvocationOperation(t,"main",o,s,0,h,6e3,5e5,"commit",b,i.TezosParameterFormat.Michelson);d||(d=Number(e.storageCost)||0),g||(g=Number(e.gas)+300)}const y=yield c.TezosNodeWriter.sendContractInvocationOperation(t,r,o,s,0,h,d,g,"commit",b,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(y.operationGroupID)}))},t.registerName=function(e,t,r,o,s,a,u,p,f,h,d){return n(this,void 0,void 0,(function*(){const n=`(Pair ${u} (Pair "${s}" ${a}))`;if(!h||!d){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,p,f,6e3,5e5,"registerName",n,i.TezosParameterFormat.Michelson);h||(h=Number(t.storageCost)||0),d||(d=Number(t.gas)+300)}const g=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,p,f,h,d,"registerName",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(g.operationGroupID)}))},t.updateRegistrationPeriod=function(e,t,r,o,s,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Pair "${s}" ${a})`;if(!f||!h){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,u,p,1e3,1e5,"updateRegistrationPeriod",n,i.TezosParameterFormat.Michelson);f||(f=Number(t.storageCost)||0),h||(h=Number(t.gas)+300)}const d=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,u,p,f,h,"updateRegistrationPeriod",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))},t.setPrimaryName=function(e,t,r,o,s,a,u,p){return n(this,void 0,void 0,(function*(){const n=`"${s}"`;if(!u||!p){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,0,a,1e3,1e5,"setPrimaryName",n,i.TezosParameterFormat.Michelson);u||(u=Number(t.storageCost)||0),p||(p=Number(t.gas)+300)}const f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,a,u,p,"deleteName",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.deleteName=function(e,t,r,o,s,a,u,p){return n(this,void 0,void 0,(function*(){const n=`"${s}"`;if(!u||!p){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",r,o,0,a,1e3,1e5,"deleteName",n,i.TezosParameterFormat.Michelson);u||(u=Number(t.storageCost)||0),p||(p=Number(t.gas)+300)}const f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,a,u,p,"deleteName",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.getNameForAddress=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex"));try{const e=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);return s.JSONPath({path:"$.string",json:e})[0]}catch(e){}return""}))},t.getNameInfo=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"string"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);return{name:s.JSONPath({path:"$.args[0].args[1].string",json:i})[0],modified:Boolean(s.JSONPath({path:"$.args[0].args[0].prim",json:i})[0]),owner:s.JSONPath({path:"$.args[1].args[0].string",json:i})[0],registeredAt:new Date(s.JSONPath({path:"$.args[1].args[1].args[0].string",json:i})[0]),registrationPeriod:s.JSONPath({path:"$.args[1].args[1].args[1].int",json:i})[0]}}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{addressMap:Number(s.JSONPath({path:"$.args[0].args[0].args[0].int",json:r})[0]),commitmentMap:Number(s.JSONPath({path:"$.args[0].args[0].args[1].int",json:r})[0]),manager:s.JSONPath({path:"$.args[0].args[1].args[0].string",json:r})[0],interval:Number(s.JSONPath({path:"$.args[0].args[1].args[1].int",json:r})[0]),maxCommitTime:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),maxDuration:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),minCommitTime:Number(s.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),nameMap:Number(s.JSONPath({path:"$.args[1].args[1].args[1].args[0].int",json:r})[0]),intervalFee:Number(s.JSONPath({path:"$.args[1].args[1].args[1].args[1].int",json:r})[0])}}))}}(t.CryptonomicNameServiceHelper||(t.CryptonomicNameServiceHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(14)),i=r(6),a=r(4),u=r(3);!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeReader.getAccountForBlock(t,"head",r);if(!n.script)throw new Error("No code found at "+r);if("1234"!==e.from(s.blake2s(n.script.toString(),null,16)).toString("hex"))throw new Error(`Contract at ${r} does not match the expected code hash`);return!0}))},t.getBasicStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return console.log("-----"),console.log(r),console.log("-----"),{mapid:Number(i.JSONPath({path:"$.args[0].int",json:r})[0]),totalSupply:Number(i.JSONPath({path:"$.args[1].int",json:r})[0])}}))},t.getAddressRecord=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex")),s=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(s)return{allowances:i.JSONPath({path:"$.args[0]",json:s})[0],balance:Number(i.JSONPath({path:"$.args[1].int",json:s})[0])}}))},t.deployContract=function(e,t,r){return n(this,void 0,void 0,(function*(){}))}}(t.DexterTokenHelper||(t.DexterTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(14)),i=r(6),a=r(8),u=r(3),c=r(7),l=o(r(5));!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeReader.getAccountForBlock(t,"head",r);if(!n.script)throw new Error("No code found at "+r);const o=e.from(s.blake2s(JSON.stringify(n.script.code),null,16)).toString("hex");if("914629850cfdad7b54a8c5a661d10bd0"!==o)throw new Error(`Contract does not match the expected code hash: ${o}, '914629850cfdad7b54a8c5a661d10bd0'`);return!0}))},t.verifyScript=function(t){const r=e.from(s.blake2s(a.TezosLanguageUtil.preProcessMichelsonScript(t).join("\n"),null,16)).toString("hex");if("ffcad1e376a6c8915780fe6676aceec6"!==r)throw new Error(`Contract does not match the expected code hash: ${r}, 'ffcad1e376a6c8915780fe6676aceec6'`);return!0},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{counter:Number(i.JSONPath({path:"$.args[0].int",json:r})[0]),threshold:Number(i.JSONPath({path:"$.args[1].args[0].int",json:r})[0]),keys:i.JSONPath({path:"$.args[1].args[1]..string",json:r})}}))},t.deployContract=function(e,t,r,o,s,i,a,u,p){return n(this,void 0,void 0,(function*(){if(u>p.length)throw new Error("Number of keys provided is lower than the threshold");const n=`(Pair ${a} (Pair ${u} { "${p.join('" ; "')}" } ) )`,f=yield c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,i,o,s,5e3,12e4,"parameter (pair (pair :payload (nat %counter) (or :action (pair :transfer (mutez %amount) (contract %dest unit)) (or (option %delegate key_hash) (pair %change_keys (nat %threshold) (list %keys key))))) (list %sigs (option signature)));\n storage (pair (nat %stored_counter) (pair (nat %threshold) (list %keys key)));\n code\n {\n UNPAIR ; SWAP ; DUP ; DIP { SWAP } ;\n DIP\n {\n UNPAIR ;\n DUP ; SELF ; ADDRESS ; CHAIN_ID ; PAIR ; PAIR ;\n PACK ;\n DIP { UNPAIR @counter ; DIP { SWAP } } ; SWAP\n } ;\n UNPAIR @stored_counter; DIP { SWAP };\n ASSERT_CMPEQ ;\n DIP { SWAP } ; UNPAIR @threshold @keys;\n DIP\n {\n PUSH @valid nat 0; SWAP ;\n ITER\n {\n DIP { SWAP } ; SWAP ;\n IF_CONS\n {\n IF_SOME\n { SWAP ;\n DIP\n {\n SWAP ; DIIP { DUUP } ;\n CHECK_SIGNATURE ; ASSERT ;\n PUSH nat 1 ; ADD @valid } }\n { SWAP ; DROP }\n }\n {\n FAIL\n } ;\n SWAP\n }\n } ;\n ASSERT_CMPLE ;\n DROP ; DROP ;\n DIP { UNPAIR ; PUSH nat 1 ; ADD @new_counter ; PAIR} ;\n NIL operation ; SWAP ;\n IF_LEFT\n {\n UNPAIR ; UNIT ; TRANSFER_TOKENS ; CONS }\n { IF_LEFT {\n SET_DELEGATE ; CONS }\n {\n DIP { SWAP ; CAR } ; SWAP ; PAIR ; SWAP }} ;\n PAIR }",n,l.TezosParameterFormat.Michelson);return f.operationGroupID.replace(/\"/g,"").replace(/\n/,"")}))}}(t.MurbardMultisigHelper||(t.MurbardMultisigHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(11);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"0e3e137841a959521324b4ce20ca2df7")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"b77ada691b1d630622bea243696c84d7")},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===i)throw new Error(`Map ${r} does not contain a record for ${o}`);return Number(s.JSONPath({path:"$.int",json:i})[0])}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(s.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),council:s.JSONPath({path:"$.args[0].args[0].args[1]..string",json:r}),stage:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),phase:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0])%4,supply:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),paused:s.JSONPath({path:"$.args[1].args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}}))},t.transferBalance=function(e,t,r,o,s,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Right (Left (Left (Right (Pair "${a}" (Pair "${u}" ${p}))))))`,d=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,h,f,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))}}(t.StakerDAOTokenHelper||(t.StakerDAOTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(14)),i=r(6),a=r(4),u=r(3);!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeReader.getAccountForBlock(t,"head",r);if(!n.script)throw new Error("No code found at "+r);if("1527ddf08bdf582dce0b28c051044897"!==e.from(s.blake2s(n.script.toString(),null,16)).toString("hex"))throw new Error(`Contract at ${r} does not match the expected code hash`);return!0}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{mapid:parseInt(i.JSONPath({path:"$.args[0].int",json:r})[0]),owner:i.JSONPath({path:"$.args[1].args[0].string",json:r})[0],signupFee:parseInt(i.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),updateFee:parseInt(i.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}}))},t.updateRegistration=function(e,t,r,o,s,i,a){return n(this,void 0,void 0,(function*(){}))},t.queryRegistration=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"key_hash"),"hex")),s=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(!s)return;const c=new TextDecoder,l=Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[0].args[1].int",json:s})[0]);return{name:c.decode(e.from(i.JSONPath({path:"$.args[0].args[0].args[0].args[0].args[0].args[0].bytes",json:s})[0],"hex")),isAcceptingDelegation:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[0].args[0].args[1].prim",json:s})[0]),externalDataURL:c.decode(e.from(i.JSONPath({path:"$.args[0].args[0].args[0].args[0].args[1].bytes",json:s})[0],"hex")),split:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[0].args[0].int",json:s})[0])/1e4,paymentAccounts:i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[0].args[1]..string",json:s}),minimumDelegation:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[0].args[0].int",json:s})[0]),isGreedy:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[0].args[1].prim",json:s})[0]),payoutDelay:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[1].args[0].int",json:s})[0]),payoutFrequency:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[1].args[1].args[0].int",json:s})[0]),minimumPayout:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[0].args[1].args[1].args[1].int",json:s})[0]),isCheap:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[0].args[0].prim",json:s})[0]),paymentConfig:{payForOwnBlocks:Boolean(1&l),payForEndorsements:Boolean(2&l),payGainedFees:Boolean(4&l),payForAccusationGains:Boolean(8&l),subtractLostDepositsWhenAccused:Boolean(16&l),subtractLostRewardsWhenAccused:Boolean(32&l),subtractLostFeesWhenAccused:Boolean(64&l),payForRevelation:Boolean(128&l),subtractLostRewardsWhenMissRevelation:Boolean(256&l),subtractLostFeesWhenMissRevelation:Boolean(512&l),compensateMissedBlocks:!Boolean(1024&l),payForStolenBlocks:Boolean(2048&l),compensateMissedEndorsements:!Boolean(4096&l),compensateLowPriorityEndorsementLoss:!Boolean(8192&l)},overdelegationThreshold:Number(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[1].args[0].int",json:s})[0]),subtractRewardsFromUninvitedDelegation:Boolean(i.JSONPath({path:"$.args[0].args[0].args[0].args[1].args[1].args[1].args[1].args[1].prim",json:s})[0]),recordManager:i.JSONPath({path:"$.args[0].args[1].args[0].string",json:s})[0],timestamp:new Date(i.JSONPath({path:"$.args[1].string",json:s})[0])}}))}}(t.TCFBakerRegistryHelper||(t.TCFBakerRegistryHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(11);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"0e3e137841a959521324b4ce20ca2df7")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"b77ada691b1d630622bea243696c84d7")},t.deployContract=function(e,t,r,o,s,a=!0,u=0,p=15e4,f=5e3){return n(this,void 0,void 0,(function*(){const n=`Pair {} (Pair "${s}" (Pair ${a?"True":"False"} ${u}))`,h=yield c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,f,p,'parameter (or (or (or (pair %transfer (address :from) (pair (address :to) (nat :value))) (pair %approve (address :spender) (nat :value))) (or (pair %getAllowance (pair (address :owner) (address :spender)) (contract nat)) (or (pair %getBalance (address :owner) (contract nat)) (pair %getTotalSupply unit (contract nat))))) (or (or (bool %setPause) (address %setAdministrator)) (or (pair %getAdministrator unit (contract address)) (or (pair %mint (address :to) (nat :value)) (pair %burn (address :from) (nat :value))))));\n storage (pair (big_map %ledger (address :user) (pair (nat :balance) (map :approvals (address :spender) (nat :value)))) (pair (address %admin) (pair (bool %paused) (nat %totalSupply))));\n code { CAST (pair (or (or (or (pair address (pair address nat)) (pair address nat)) (or (pair (pair address address) (contract nat)) (or (pair address (contract nat)) (pair unit (contract nat))))) (or (or bool address) (or (pair unit (contract address)) (or (pair address nat) (pair address nat))))) (pair (big_map address (pair nat (map address nat))) (pair address (pair bool nat)))); DUP; CAR; DIP { CDR }; IF_LEFT { IF_LEFT { IF_LEFT { DIP { DUP; CDR; CDR; CAR; IF { UNIT; PUSH string "TokenOperationsArePaused"; PAIR; FAILWITH } { } }; DUP; DUP; CDR; CAR; DIP { CAR }; COMPARE; EQ; IF { DROP } { DUP; CAR; SENDER; COMPARE; EQ; IF { } { DUP; DIP { DUP; DIP { DIP { DUP }; CAR; SENDER; PAIR; DUP; DIP { CDR; DIP { CAR }; GET; IF_NONE { EMPTY_MAP (address) nat } { CDR } }; CAR; GET; IF_NONE { PUSH nat 0 } { } }; DUP; CAR; DIP { SENDER; DIP { DUP; CDR; CDR; DIP { DIP { DUP }; SWAP }; SWAP; SUB; ISNAT; IF_NONE { DIP { DUP }; SWAP; DIP { DUP }; SWAP; CDR; CDR; PAIR; PUSH string "NotEnoughAllowance"; PAIR; FAILWITH } { } }; PAIR }; PAIR; DIP { DROP; DROP }; DIP { DUP }; SWAP; DIP { DUP; CAR }; SWAP; DIP { CAR }; GET; IF_NONE { PUSH nat 0; DIP { EMPTY_MAP (address) nat }; PAIR; EMPTY_MAP (address) nat } { DUP; CDR }; DIP { DIP { DUP }; SWAP }; SWAP; CDR; CDR; DUP; INT; EQ; IF { DROP; NONE nat } { SOME }; DIP { DIP { DIP { DUP }; SWAP }; SWAP }; SWAP; CDR; CAR; UPDATE; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; CAR; DIP { SOME }; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CDR; CAR; DIP { CAR }; GET; IF_NONE { DUP; CDR; CDR; INT; EQ; IF { NONE (pair nat (map address nat)) } { DUP; CDR; CDR; DIP { EMPTY_MAP (address) nat }; PAIR; SOME } } { DIP { DUP }; SWAP; CDR; CDR; DIP { DUP; CAR }; ADD; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; SOME }; SWAP; DUP; DIP { CDR; CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; CDR; INT; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CAR; DIP { CAR }; GET; IF_NONE { CDR; CDR; PUSH nat 0; SWAP; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DUP; CAR; DIP { DIP { DUP }; SWAP }; SWAP; CDR; CDR; SWAP; SUB; ISNAT; IF_NONE { CAR; DIP { DUP }; SWAP; CDR; CDR; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; DIP { DUP }; SWAP; DIP { DUP; CAR; INT; EQ; IF { DUP; CDR; SIZE; INT; EQ; IF { DROP; NONE (pair nat (map address nat)) } { SOME } } { SOME }; SWAP; CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; CDR; NEG; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DROP }; NIL operation; PAIR } { SENDER; PAIR; DIP { DUP; CDR; CDR; CAR; IF { UNIT; PUSH string "TokenOperationsArePaused"; PAIR; FAILWITH } { } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; DUP; DIP { CAR; DIP { CAR }; GET; IF_NONE { EMPTY_MAP (address) nat } { CDR } }; CDR; CAR; GET; IF_NONE { PUSH nat 0 } { }; DUP; INT; EQ; IF { DROP } { DIP { DUP }; SWAP; CDR; CDR; INT; EQ; IF { DROP } { PUSH string "UnsafeAllowanceChange"; PAIR; FAILWITH } }; DIP { DUP }; SWAP; DIP { DUP; CAR }; SWAP; DIP { CAR }; GET; IF_NONE { PUSH nat 0; DIP { EMPTY_MAP (address) nat }; PAIR; EMPTY_MAP (address) nat } { DUP; CDR }; DIP { DIP { DUP }; SWAP }; SWAP; CDR; CDR; DUP; INT; EQ; IF { DROP; NONE nat } { SOME }; DIP { DIP { DIP { DUP }; SWAP }; SWAP }; SWAP; CDR; CAR; UPDATE; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; CAR; DIP { SOME }; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; NIL operation; PAIR } } { IF_LEFT { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; DUP; CAR; DIP { CDR }; DUP; DIP { CAR; DIP { CAR }; GET; IF_NONE { EMPTY_MAP (address) nat } { CDR } }; CDR; GET; IF_NONE { PUSH nat 0 } { }; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } { IF_LEFT { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; DUP; CAR; DIP { CDR }; DIP { CAR }; GET; IF_NONE { PUSH nat 0 } { CAR }; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; CDR; CDR; CDR; CDR; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } } } } { IF_LEFT { IF_LEFT { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; NIL operation; PAIR } { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP; CDR }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; NIL operation; PAIR } } { IF_LEFT { DUP; CAR; DIP { CDR }; DIP { DIP { DUP }; SWAP }; PAIR; CDR; CDR; CAR; DIP { AMOUNT }; TRANSFER_TOKENS; NIL operation; SWAP; CONS; PAIR } { IF_LEFT { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CAR; DIP { CAR }; GET; IF_NONE { DUP; CDR; INT; EQ; IF { NONE (pair nat (map address nat)) } { DUP; CDR; DIP { EMPTY_MAP (address) nat }; PAIR; SOME } } { DIP { DUP }; SWAP; CDR; DIP { DUP; CAR }; ADD; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; SOME }; SWAP; DUP; DIP { CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; INT; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DROP; NIL operation; PAIR } { DIP { DUP; CDR; CAR; SENDER; COMPARE; EQ; IF { } { UNIT; PUSH string "SenderIsNotAdmin"; PAIR; FAILWITH } }; DIP { DUP }; SWAP; DIP { DUP }; SWAP; CAR; DIP { CAR }; GET; IF_NONE { CDR; PUSH nat 0; SWAP; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DUP; CAR; DIP { DIP { DUP }; SWAP }; SWAP; CDR; SWAP; SUB; ISNAT; IF_NONE { CAR; DIP { DUP }; SWAP; CDR; PAIR; PUSH string "NotEnoughBalance"; PAIR; FAILWITH } { }; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR; DIP { DUP }; SWAP; DIP { DUP; CAR; INT; EQ; IF { DUP; CDR; SIZE; INT; EQ; IF { DROP; NONE (pair nat (map address nat)) } { SOME } } { SOME }; SWAP; CAR; DIP { DIP { DUP; CAR } }; UPDATE; DIP { DUP; DIP { CDR }; CAR }; DIP { DROP }; PAIR }; DUP; DIP { CDR; NEG; DIP { DUP; CDR; CDR; CDR }; ADD; ISNAT; IF_NONE { PUSH string "Internal: Negative total supply"; FAILWITH } { }; DIP { DUP; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR; SWAP; PAIR; DIP { DUP; DIP { CAR }; CDR }; DIP { DROP }; SWAP; PAIR }; DROP; NIL operation; PAIR } } } } };',n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"address"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===i)throw new Error(`Map ${r} does not contain a record for ${o}`);const c=s.JSONPath({path:"$.args[0].int",json:i});return Number(c[0])}))},t.getAccountAllowance=function(t,r,o,i){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(i,"address"),"hex")),c=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===c)throw new Error(`Map ${r} does not contain a record for ${i}/${o}`);let l=new Map;return s.JSONPath({path:"$.args[1][*].args",json:c}).forEach(e=>l[e[0].string]=Number(e[1].int)),l[o]}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(s.JSONPath({path:"$.args[0].int",json:r})[0]),supply:Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0]),administrator:s.JSONPath({path:"$.args[1].args[0].string",json:r})[0],paused:s.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}}))},t.getTokenSupply=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}))},t.getAdministrator=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return s.JSONPath({path:"$.args[1].args[0].string",json:r})[0]}))},t.getPaused=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return s.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}))},t.transferBalance=function(e,t,r,o,s,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Left (Left (Left (Pair "${a}" (Pair "${u}" ${p})))))`,d=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,h,f,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))},t.approveBalance=function(e,t,r,o,s,a,u,p,f){return n(this,void 0,void 0,(function*(){const n=`(Left (Left (Right (Pair "${a}" ${u}))))`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,p,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.activateLedger=function(e,t,r,o,s,a,u){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,u,a,"","(Right (Left (Left False)))",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.deactivateLedger=function(e,t,r,o,s,a,u){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,u,a,"","(Right (Left (Left True)))",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.setAdministrator=function(e,t,r,o,s,a,u,p){return n(this,void 0,void 0,(function*(){const n=`(Right (Left (Right "${s}")))`,f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,a,p,u,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.mint=function(e,t,r,o,s,a,u,p=15e4,f=5e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Left (Pair "${a}" ${u})))))`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,p,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.burn=function(e,t,r,o,s,a,u,p,f){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Pair "${a}" ${u})))))`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,p,"",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))}}(t.Tzip7ReferenceTokenHelper||(t.Tzip7ReferenceTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(4),u=r(3),c=r(7),l=r(11);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"cdf4fb6303d606686694d80bd485b6a1")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"000")},t.deployContract=function(e,t,r,o,s,a,u,p,f,h=!0,d=0,g=8e5,m=2e4){return n(this,void 0,void 0,(function*(){const n=`( Pair ( Pair "${s}" ( Pair 0 { } ) ) ( Pair ( Pair Unit { } ) ( Pair ${h?"True":"False"} { Elt ${p} ( Pair ( Pair ${p} ( Pair "${u}" ( Pair "${a}" ( Pair ${f} { } ) ) ) ) ${d} ) } ) ) )`,b=yield c.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,m,g,'parameter (or (or (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (pair %mint (pair (address %address) (nat %amount)) (pair (string %symbol) (nat %token_id)))) (or (address %set_administrator) (bool %set_pause))) (or (or (pair %token_metadata (list %token_ids nat) (lambda %handler (list (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string)))))) unit)) (contract %token_metadata_regitry address)) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (address %operator)) (pair %remove_operator (address %owner) (address %operator))))))) ;\n storage (pair (pair (address %administrator) (pair (nat %all_tokens) (big_map %ledger (pair address nat) nat))) (pair (pair (unit %version_20200615_tzip_a57dfe86_contract) (big_map %operators (pair (address %owner) (address %operator)) unit)) (pair (bool %paused) (big_map %tokens nat (pair (pair %metadata (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string))))) (nat %total_supply)))))) ;\n code { DUP ; CDR ; SWAP ; CAR ; IF_LEFT { IF_LEFT { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; NIL (pair (pair %request (address %owner) (nat %token_id)) (nat %balance)) ; SWAP ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; DIG 3 ; DUP ; DUG 4 ; { CAR ; CDR ; CDR } ; DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 3 ; DUP ; DUG 4 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 3 ; CAR ; PAIR %owner %token_id ; PAIR %request %balance ; CONS } ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CDR ; PUSH mutez 0 ; DIG 3 ; DUP ; DUG 4 ; NIL (pair (pair %request (address %owner) (nat %token_id)) (nat %balance)) ; SWAP ; ITER { CONS } ; DIG 4 ; DROP ; DIG 4 ; DROP ; TRANSFER_TOKENS ; CONS } { SWAP ; DUP ; DUG 2 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF {} { PUSH string "WrongCondition: sp.sender == self.data.administrator" ; FAILWITH } ; SWAP ; DUP ; DUG 2 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; { CDR ; CDR } ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR ; CAR } ; DUP ; PUSH nat 1 ; DIG 6 ; DUP ; DUG 7 ; { CDR ; CDR } ; ADD ; DUP ; DUG 2 ; COMPARE ; LE ; IF { DROP } { SWAP ; DROP } ; DIG 5 ; DROP ; PAIR ; SWAP ; PAIR ; PAIR ; SWAP ; SWAP ; DUP ; DUG 2 ; { CAR ; CDR ; CDR } ; SWAP ; DUP ; DUG 2 ; { CDR ; CDR } ; DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; PAIR ; MEM ; IF { SWAP ; DUP ; DUG 2 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 6 ; DUP ; DUG 7 ; { CAR ; CAR } ; PAIR ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; DROP ; DIG 5 ; DUP ; DUG 6 ; { CAR ; CDR } ; DIG 7 ; { CAR ; CDR ; CDR } ; DIG 7 ; DUP ; DUG 8 ; { CDR ; CDR } ; DIG 8 ; DUP ; DUG 9 ; { CAR ; CAR } ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; ADD ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; SWAP } { SWAP ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR } ; SOME ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 6 ; DUP ; DUG 7 ; { CAR ; CAR } ; PAIR ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; SWAP } ; SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CDR } ; SWAP ; DUP ; DUG 2 ; { CDR ; CDR } ; MEM ; IF { SWAP ; DUP ; DUG 2 ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; CAR ; DIG 6 ; DUP ; DUG 7 ; { CAR ; CDR } ; DIG 8 ; { CDR ; CDR ; CDR } ; DIG 8 ; DUP ; DUG 9 ; { CDR ; CDR } ; GET ; { IF_NONE { PUSH string "Get-item:431" ; FAILWITH } {} } ; CDR ; ADD ; SWAP ; PAIR ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP } { SWAP ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR } ; PUSH (pair (string %name) (pair (nat %decimals) (map %extras string string))) (Pair "" (Pair 0 {})) ; DIG 6 ; DUP ; DUG 7 ; { CDR ; CAR } ; PAIR %symbol ; DIG 6 ; DUP ; DUG 7 ; { CDR ; CDR } ; PAIR %token_id ; PAIR %metadata %total_supply ; SOME ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP ; PAIR ; SWAP } ; DROP ; NIL operation } } { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF {} { PUSH string "WrongCondition: sp.sender == self.data.administrator" ; FAILWITH } ; SWAP ; DUP ; CDR ; SWAP ; { CAR ; CDR } ; DIG 2 ; PAIR ; PAIR } { SWAP ; DUP ; DUG 2 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF {} { PUSH string "WrongCondition: sp.sender == self.data.administrator" ; FAILWITH } ; SWAP ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; { CDR ; CDR } ; DIG 3 ; PAIR ; SWAP ; PAIR ; SWAP ; PAIR } ; NIL operation } } { IF_LEFT { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; NIL (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string))))) ; SWAP ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; DIG 3 ; DUP ; DUG 4 ; { CDR ; CDR ; CDR } ; DIG 2 ; GET ; { IF_NONE { PUSH string "Get-item:523" ; FAILWITH } {} } ; CAR ; CONS } ; SWAP ; DUP ; DUG 2 ; CDR ; SWAP ; DUP ; DUG 2 ; NIL (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string))))) ; SWAP ; ITER { CONS } ; EXEC ; DROP 3 ; NIL operation } { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; DUP ; NIL operation ; SWAP ; PUSH mutez 0 ; SELF ; DIG 4 ; DROP ; ADDRESS ; TRANSFER_TOKENS ; CONS } } { IF_LEFT { SWAP ; DUP ; DUG 2 ; { CDR ; CDR ; CAR } ; IF { PUSH string "WrongCondition: ~ self.data.paused" ; FAILWITH } {} ; DUP ; ITER { DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ ; IF { PUSH bool True } { DUP ; CAR ; SENDER ; COMPARE ; EQ } ; IF { PUSH bool True } { DIG 2 ; DUP ; DUG 3 ; { CDR ; CAR ; CDR } ; SENDER ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR %owner %operator ; MEM } ; IF {} { PUSH string "WrongCondition: ((sp.sender == self.data.administrator) | (transfer.from_ == sp.sender)) | (self.data.operators.contains(sp.record(operator = sp.sender, owner = transfer.from_)))" ; FAILWITH } ; DUP ; CDR ; ITER { DUP ; { CDR ; CDR } ; PUSH nat 0 ; COMPARE ; LT ; IF {} { PUSH string "TRANSFER_OF_ZERO" ; FAILWITH } ; DUP ; { CDR ; CDR } ; DIG 4 ; DUP ; DUG 5 ; { CAR ; CDR ; CDR } ; DIG 2 ; DUP ; DUG 3 ; { CDR ; CAR } ; DIG 4 ; DUP ; DUG 5 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; COMPARE ; GE ; IF {} { PUSH string "WrongCondition: self.data.ledger[(transfer.from_, tx.token_id)].balance >= tx.amount" ; FAILWITH } ; DIG 3 ; DUP ; DUG 4 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CAR } ; DIG 7 ; DUP ; DUG 8 ; CAR ; PAIR ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; DROP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 9 ; { CAR ; CDR ; CDR } ; DIG 7 ; DUP ; DUG 8 ; { CDR ; CAR } ; DIG 9 ; DUP ; DUG 10 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; SUB ; ISNAT ; { IF_NONE { PUSH unit Unit ; FAILWITH } {} } ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; DUG 3 ; DIG 3 ; DUP ; DUG 4 ; { CAR ; CDR ; CDR } ; SWAP ; DUP ; DUG 2 ; { CDR ; CAR } ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR ; MEM ; IF { DIG 3 ; DUP ; DUG 4 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DUP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CAR } ; DIG 6 ; DUP ; DUG 7 ; CAR ; PAIR ; DUP ; DUG 2 ; GET ; { IF_NONE { PUSH string "set_in_top-any" ; FAILWITH } {} } ; DROP ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CDR } ; DIG 9 ; { CAR ; CDR ; CDR } ; DIG 7 ; DUP ; DUG 8 ; { CDR ; CAR } ; DIG 8 ; DUP ; DUG 9 ; CAR ; PAIR ; GET ; { IF_NONE { PUSH string "Get-item:190" ; FAILWITH } {} } ; ADD ; SOME ; SWAP ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; DUG 3 } { DIG 3 ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; SWAP ; CDR ; DIG 4 ; DUP ; DUG 5 ; { CDR ; CDR } ; SOME ; DIG 5 ; DUP ; DUG 6 ; { CDR ; CAR } ; DIG 6 ; DUP ; DUG 7 ; CAR ; PAIR ; UPDATE ; SWAP ; PAIR ; SWAP ; PAIR ; PAIR ; DUG 3 } ; DROP } ; DROP } ; DROP } { DUP ; ITER { DUP ; IF_LEFT { DROP ; DUP ; SENDER ; SWAP ; IF_LEFT {} { DROP ; PUSH unit Unit ; FAILWITH } ; CAR ; COMPARE ; EQ ; IF { PUSH bool True } { DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ } ; IF {} { PUSH string "WrongCondition: (update.open_variant(\'add_operator\').owner == sp.sender) | (sp.sender == self.data.administrator)" ; FAILWITH } ; DIG 2 ; DUP ; DUG 3 ; DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; PUSH (option unit) (Some Unit) ; DIG 5 ; DUP ; DUG 6 ; IF_LEFT {} { DROP ; PUSH unit Unit ; FAILWITH } ; CDR ; DIG 6 ; DUP ; DUG 7 ; IF_LEFT {} { DROP ; PUSH unit Unit ; FAILWITH } ; DIG 9 ; DROP ; CAR ; PAIR %owner %operator ; UPDATE ; SWAP ; PAIR ; PAIR ; SWAP ; PAIR ; DUG 2 } { DROP ; DUP ; SENDER ; SWAP ; IF_LEFT { DROP ; PUSH unit Unit ; FAILWITH } {} ; CAR ; COMPARE ; EQ ; IF { PUSH bool True } { DIG 2 ; DUP ; DUG 3 ; { CAR ; CAR } ; SENDER ; COMPARE ; EQ } ; IF {} { PUSH string "WrongCondition: (update.open_variant(\'remove_operator\').owner == sp.sender) | (sp.sender == self.data.administrator)" ; FAILWITH } ; DIG 2 ; DUP ; DUG 3 ; DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; NONE unit ; DIG 5 ; DUP ; DUG 6 ; IF_LEFT { DROP ; PUSH unit Unit ; FAILWITH } {} ; CDR ; DIG 6 ; DUP ; DUG 7 ; IF_LEFT { DROP ; PUSH unit Unit ; FAILWITH } {} ; DIG 9 ; DROP ; CAR ; PAIR %owner %operator ; UPDATE ; SWAP ; PAIR ; PAIR ; SWAP ; PAIR ; DUG 2 } ; DROP } ; DROP } ; NIL operation } } ; PAIR } ;',n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(b.operationGroupID)}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{administrator:s.JSONPath({path:"$.args[0].args[0].string",json:r})[0],tokens:Number(s.JSONPath({path:"$.args[0].args[1].args[0].int",json:r})[0]),balanceMap:Number(s.JSONPath({path:"$.args[0].args[1].args[1].int",json:r})[0]),operatorMap:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),paused:s.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t"),metadataMap:Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}}))},t.getTokenDefinition=function(t,r,o=0){return n(this,void 0,void 0,(function*(){const n=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(o,"nat"),"hex")),i=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===i)throw new Error(`Map ${r} does not contain a record for token ${o}`);return{tokenid:Number(s.JSONPath({path:"$.args[0].args[0].int",json:i})[0]),symbol:s.JSONPath({path:"$.args[0].args[1].args[0].string",json:i})[0],name:s.JSONPath({path:"$.args[0].args[1].args[1].args[0].string",json:i})[0],scale:Number(s.JSONPath({path:"$.args[0].args[1].args[1].args[1].args[0].int",json:i})[0]),supply:Number(s.JSONPath({path:"$.args[1].int",json:i})[0])}}))},t.activate=function(e,t,r,o,s,a=8e5,u=2e4){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,u,a,"set_pause","False",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.deactivate=function(e,t,r,o,s,a=8e5,u=2e4){return n(this,void 0,void 0,(function*(){const n=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,u,a,"set_pause","True",i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.changeAdministrator=function(e,t,r,o,s,a,u=8e5,p=2e4){return n(this,void 0,void 0,(function*(){const n=`"${a}"`,f=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,p,u,"set_administrator",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.mint=function(e,t,r,o,s,a,u,p,f,h=8e5,d=2e4){return n(this,void 0,void 0,(function*(){const n=`(Pair (Pair "${a}" ${u}) (Pair "${p}" ${f}))`,g=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,d,h,"mint",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(g.operationGroupID)}))},t.transfer=function(e,t,r,o,s,a,u,p=8e5,f=2e4){return n(this,void 0,void 0,(function*(){const n=`{ Pair "${a}" { ${u.map(e=>'( Pair "'+e.address+'" ( Pair '+e.tokenid+" "+e.balance+" ) )").join(" ; ")} } }`,h=yield c.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,f,p,"transfer",n,i.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.getAccountBalance=function(t,r,o,c){return n(this,void 0,void 0,(function*(){const n="0x"+a.TezosMessageUtils.writeAddress(o),l=a.TezosMessageUtils.encodeBigMapKey(e.from(a.TezosMessageUtils.writePackedData(`(Pair ${n} ${c})`,"",i.TezosParameterFormat.Michelson),"hex")),p=yield u.TezosNodeReader.getValueForBigMapKey(t,r,l);if(void 0===p)throw new Error(`Map ${r} does not contain a record for ${o}/${c}`);const f=s.JSONPath({path:"$.int",json:p});return Number(f[0])}))}}(t.MultiAssetTokenHelper||(t.MultiAssetTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=r(4),a=r(3),u=r(7),c=o(r(5)),l=r(11);!function(t){t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return l.TezosContractUtils.verifyDestination(e,t,"17aab0975df6139f4ff29be76a67f348")}))},t.verifyScript=function(e){return l.TezosContractUtils.verifyScript(e,"000")},t.deployContract=function(e,t,r,o,s,i,a,p,f,h=!0,d=0,g=8e5,m=2e4){return n(this,void 0,void 0,(function*(){const n=`( Pair ( Pair ( Pair "${s}" ${h?"True":"False"} ) None ) ( Pair ( Pair { } { } ) ( Pair { Elt ${p} ( Pair ${p} ( Pair "${a}" ( Pair "${i}" ( Pair ${f} { } ) ) ) ) } ${d} ) ) )`,b=yield u.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,m,g,'parameter (or (or (or %admin (or (unit %confirm_admin) (bool %pause)) (address %set_admin)) (or %assets (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (contract %token_metadata_registry address)) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (address %operator)) (pair %remove_operator (address %owner) (address %operator))))))) (or %tokens (list %burn_tokens (pair (nat %amount) (address %owner))) (list %mint_tokens (pair (nat %amount) (address %owner))))) ;\n storage (pair (pair %admin (pair (address %admin) (bool %paused)) (option %pending_admin address)) (pair %assets (pair (big_map %ledger address nat) (big_map %operators (pair address address) unit)) (pair (big_map %token_metadata nat (pair (nat %token_id) (pair (string %symbol) (pair (string %name) (pair (nat %decimals) (map %extras string string)))))) (nat %total_supply)))) ;\n code { PUSH string "FA2_TOKEN_UNDEFINED" ; PUSH string "FA2_INSUFFICIENT_BALANCE" ; LAMBDA (pair address address) (pair address address) { DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PAIR ; DIP { DROP } } ; LAMBDA (pair address (big_map address nat)) nat { DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; GET ; IF_NONE { PUSH nat 0 } { DUP ; DIP { DROP } } ; DIP { DROP } } ; DUP ; LAMBDA (pair (lambda (pair address (big_map address nat)) nat) (pair (pair address nat) (big_map address nat))) (big_map address nat) { DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 4 ; DUP ; DUG 5 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; CAR ; CDR ; DIG 1 ; DUP ; DUG 2 ; ADD ; DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; SOME ; DIG 5 ; DUP ; DUG 6 ; UPDATE ; DIP { DROP 6 } } ; SWAP ; APPLY ; DIP { DIP { DIP { DUP } ; SWAP } ; DUP ; DIP { PAIR } ; SWAP } ; SWAP ; LAMBDA (pair (pair (lambda (pair address (big_map address nat)) nat) string) (pair (pair address nat) (big_map address nat))) (big_map address nat) { DUP ; CAR ; SWAP ; CDR ; DIP { DUP ; CDR ; SWAP ; CAR } ; DUP ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 4 ; DUP ; DUG 5 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; CAR ; CDR ; DIG 1 ; DUP ; DUG 2 ; SUB ; ISNAT ; IF_NONE { DIG 5 ; DUP ; DUG 6 ; FAILWITH } { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; COMPARE ; EQ ; IF { DIG 2 ; DUP ; DUG 3 ; DIG 4 ; DUP ; DUG 5 ; NONE nat ; SWAP ; UPDATE } { DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; SOME ; DIG 5 ; DUP ; DUG 6 ; UPDATE } ; DIP { DROP } } ; DIP { DROP 6 } } ; SWAP ; APPLY ; LAMBDA (list (pair nat address)) nat { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; ITER { SWAP ; PAIR ; DUP ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ADD ; DIP { DROP } } ; DIP { DROP } } ; LAMBDA (pair (pair address bool) (option address)) unit { DUP ; CAR ; CAR ; SENDER ; COMPARE ; NEQ ; IF { PUSH string "NOT_AN_ADMIN" ; FAILWITH } { UNIT } ; DIP { DROP } } ; DIG 8 ; DUP ; DUG 9 ; CDR ; DIG 9 ; DUP ; DUG 10 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DIG 2 ; DUP ; DUG 3 ; CDR ; IF_NONE { PUSH string "NO_PENDING_ADMIN" ; FAILWITH } { DUP ; SENDER ; COMPARE ; EQ ; IF { DIG 3 ; DUP ; DUG 4 ; CAR ; NONE address ; SWAP ; PAIR ; DUP ; CDR ; SWAP ; CAR ; CDR ; SENDER ; PAIR ; PAIR } { PUSH string "NOT_AN_ADMIN" ; FAILWITH } ; DIP { DROP } } ; DUP ; NIL operation ; PAIR ; DIP { DROP 2 } } { DIG 2 ; DUP ; DUG 3 ; DIG 8 ; DUP ; DUG 9 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ; SWAP ; PAIR ; PAIR ; DIP { DROP } ; NIL operation ; PAIR ; DIP { DROP 2 } } ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; DIG 7 ; DUP ; DUG 8 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; SOME ; SWAP ; CAR ; PAIR ; DIP { DROP } ; NIL operation ; PAIR ; DIP { DROP 2 } } ; DIP { DROP 2 } ; DIG 3 ; DUP ; DUG 4 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CDR ; SWAP ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 2 } } { DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; CDR ; IF { PUSH string "PAUSED" ; FAILWITH } { UNIT } ; DIG 3 ; DUP ; DUG 4 ; CDR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PAIR ; DUP ; CDR ; MAP { DUP ; DIP { DROP } } ; DUP ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR ; DIP { DROP 2 } ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DUP ; CDR ; MAP { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; COMPARE ; NEQ ; IF { DIG 19 ; DUP ; DUG 20 ; FAILWITH } { DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIG 17 ; DUP ; DUG 18 ; SWAP ; EXEC ; DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; CDR ; DIG 1 ; DUP ; DUG 2 ; CDR ; CAR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PAIR ; DIP { DROP 3 } } ; DIP { DROP } } ; DIG 1 ; DUP ; DUG 2 ; CAR ; PUSH mutez 0 ; DIG 2 ; DUP ; DUG 3 ; TRANSFER_TOKENS ; DIP { DROP 3 } ; DIG 4 ; DUP ; DUG 5 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 3 } } { DUP ; PUSH mutez 0 ; SELF ; ADDRESS ; TRANSFER_TOKENS ; DIG 3 ; DUP ; DUG 4 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 2 } } ; DIP { DROP } } { DUP ; IF_LEFT { DUP ; MAP { DUP ; CDR ; MAP { DUP ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; CDR ; PAIR ; PAIR ; DIP { DROP } } ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP } } ; DUP ; MAP { DUP ; CDR ; MAP { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; COMPARE ; NEQ ; IF { DIG 18 ; DUP ; DUG 19 ; FAILWITH } { DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CDR ; SOME ; DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; PAIR ; PAIR } ; DIP { DROP } } ; DUP ; DIG 2 ; DUP ; DUG 3 ; CAR ; SOME ; PAIR ; DIP { DROP 2 } } ; SENDER ; DUP ; LAMBDA (pair address (pair address (big_map (pair address address) unit))) unit { DUP ; CAR ; SWAP ; CDR ; DUP ; CAR ; DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; COMPARE ; EQ ; IF { UNIT } { DIG 1 ; DUP ; DUG 2 ; CDR ; DIG 3 ; DUP ; DUG 4 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; MEM ; IF { UNIT } { PUSH string "FA2_NOT_OPERATOR" ; FAILWITH } } ; DIP { DROP 3 } } ; SWAP ; APPLY ; DIP { DROP } ; DIG 5 ; DUP ; DUG 6 ; CAR ; CAR ; DIG 6 ; DUP ; DUG 7 ; CAR ; CDR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIG 3 ; DUP ; DUG 4 ; PAIR ; PAIR ; DUP ; CDR ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CAR ; ITER { SWAP ; PAIR ; DUP ; CDR ; DUP ; CAR ; IF_NONE { UNIT } { DIG 3 ; DUP ; DUG 4 ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DIG 4 ; DUP ; DUG 5 ; CAR ; CDR ; SWAP ; EXEC ; DIP { DROP } } ; DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; ITER { SWAP ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; COMPARE ; NEQ ; IF { DIG 25 ; DUP ; DUG 26 ; FAILWITH } { DIG 4 ; DUP ; DUG 5 ; CAR ; IF_NONE { DIG 1 ; DUP ; DUG 2 } { DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DIG 22 ; DUP ; DUG 23 ; SWAP ; EXEC ; DIP { DROP } } ; DIG 1 ; DUP ; DUG 2 ; CAR ; CDR ; IF_NONE { DUP } { DIG 1 ; DUP ; DUG 2 ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DIG 24 ; DUP ; DUG 25 ; SWAP ; EXEC ; DIP { DROP } } ; DIP { DROP } } ; DIP { DROP 3 } } ; DIP { DROP 3 } } ; DIP { DROP } ; DIG 6 ; DUP ; DUG 7 ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 5 } } { DUP ; MAP { DUP ; IF_LEFT { DUP ; LEFT (pair (address %owner) (address %operator)) ; DIP { DROP } } { DUP ; RIGHT (pair (address %owner) (address %operator)) ; DIP { DROP } } ; DUP ; IF_LEFT { DUP ; DIG 17 ; DUP ; DUG 18 ; SWAP ; EXEC ; LEFT (pair (address %operator) (address %owner)) ; DIP { DROP } } { DUP ; DIG 17 ; DUP ; DUG 18 ; SWAP ; EXEC ; RIGHT (pair (address %operator) (address %owner)) ; DIP { DROP } } ; DIP { DROP 2 } } ; SENDER ; DIG 4 ; DUP ; DUG 5 ; CAR ; CDR ; DIG 2 ; DUP ; DUG 3 ; ITER { SWAP ; PAIR ; DUP ; CDR ; DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DUP ; DIP { DROP } } { DUP ; DIP { DROP } } ; CDR ; COMPARE ; EQ ; IF { UNIT } { PUSH string "FA2_NOT_OWNER" ; FAILWITH } ; DIP { DROP } ; DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DIG 1 ; DUP ; DUG 2 ; UNIT ; SOME ; DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 3 ; DUP ; DUG 4 ; CDR ; PAIR ; UPDATE ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; PAIR ; NONE unit ; SWAP ; UPDATE ; DIP { DROP } } ; DIP { DROP 5 } } ; DIG 5 ; DUP ; DUG 6 ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ; SWAP ; PAIR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 4 } } ; DIP { DROP } } ; DIP { DROP 2 } ; DIG 4 ; DUP ; DUG 5 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CAR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 3 } } ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 3 ; DUP ; DUG 4 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; IF_LEFT { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; PAIR ; PAIR ; DIG 15 ; DUP ; DUG 16 ; SWAP ; EXEC ; DIP { DROP 2 } } ; DIP { DROP } ; DIG 2 ; DUP ; DUG 3 ; DIG 12 ; DUP ; DUG 13 ; SWAP ; EXEC ; DUP ; DIG 3 ; DUP ; DUG 4 ; CDR ; CDR ; SUB ; ISNAT ; DUP ; IF_NONE { DIG 18 ; DUP ; DUG 19 ; FAILWITH } { DUP ; DIP { DROP } } ; DIG 4 ; DUP ; DUG 5 ; DIG 4 ; DUP ; DUG 5 ; DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ; SWAP ; PAIR ; SWAP ; PAIR ; NIL operation ; PAIR ; DIP { DROP 8 } } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; DIG 2 ; DUP ; DUG 3 ; CDR ; PAIR ; PAIR ; DIG 16 ; DUP ; DUG 17 ; SWAP ; EXEC ; DIP { DROP 2 } } ; DIP { DROP } ; DIG 2 ; DUP ; DUG 3 ; DIG 12 ; DUP ; DUG 13 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIG 4 ; DUP ; DUG 5 ; CDR ; CDR ; ADD ; DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ; SWAP ; PAIR ; SWAP ; PAIR ; DUP ; NIL operation ; PAIR ; DIP { DROP 7 } } ; DIP { DROP 2 } ; DIG 3 ; DUP ; DUG 4 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CAR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 3 } } ; DIP { DROP 10 } } ; ',n,c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(b.operationGroupID)}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield a.TezosNodeReader.getContractStorage(e,t);return{administrator:s.JSONPath({path:"$.args[0].args[0].args[0].string",json:r})[0],paused:s.JSONPath({path:"$.args[0].args[0].args[1].prim",json:r})[0].toString().toLowerCase().startsWith("t"),pendingAdmin:s.JSONPath({path:"$.args[0].args[1].prim",json:r})[0],balanceMap:Number(s.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),operatorMap:Number(s.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),metadataMap:Number(s.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),supply:Number(s.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0])}}))},t.getTokenDefinition=function(t,r,o=0){return n(this,void 0,void 0,(function*(){const n=i.TezosMessageUtils.encodeBigMapKey(e.from(i.TezosMessageUtils.writePackedData(o,"nat"),"hex")),u=yield a.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===u)throw new Error(`Map ${r} does not contain a record for token ${o}`);return{tokenid:Number(s.JSONPath({path:"$.args[0].int",json:u})[0]),symbol:s.JSONPath({path:"$.args[1].args[0].string",json:u})[0],name:s.JSONPath({path:"$.args[1].args[1].args[0].string",json:u})[0],scale:Number(s.JSONPath({path:"$.args[1].args[1].args[1].args[0].int",json:u})[0])}}))},t.activate=function(e,t,r,o,s,i=8e5,a=2e4){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,a,i,"pause","False",c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.deactivate=function(e,t,r,o,s,i=8e5,a=2e4){return n(this,void 0,void 0,(function*(){const n=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,a,i,"pause","True",c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(n.operationGroupID)}))},t.mint=function(e,t,r,o,s,i,a=8e5,p=2e4){return n(this,void 0,void 0,(function*(){const n=`{ ${i.map(e=>"( Pair "+e.balance+' "'+e.address+'" )').join(" ; ")} }`,f=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,p,a,"mint_tokens",n,c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))},t.transfer=function(e,t,r,o,s,i,a,p=8e5,f=2e4){return n(this,void 0,void 0,(function*(){const n=`{ Pair "${i}" { ${a.map(e=>'( Pair "'+e.address+'" ( Pair '+e.tokenid+" "+e.balance+" ) )").join(" ; ")} } }`,h=yield u.TezosNodeWriter.sendContractInvocationOperation(e,r,o,t,0,s,f,p,"transfer",n,c.TezosParameterFormat.Michelson);return l.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=i.TezosMessageUtils.encodeBigMapKey(e.from(i.TezosMessageUtils.writePackedData(o,"address"),"hex")),u=yield a.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===u)throw new Error(`Map ${r} does not contain a record for ${o}`);const c=s.JSONPath({path:"$.int",json:u});return Number(c[0])}))}}(t.SingleAssetTokenHelper||(t.SingleAssetTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6),i=o(r(5)),a=r(8),u=r(4),c=r(3),l=r(7),p=r(11);!function(t){function r(t,r,o){return n(this,void 0,void 0,(function*(){const n=e.from(u.TezosMessageUtils.writePackedData(o,"",i.TezosParameterFormat.Michelson),"hex"),l=u.TezosMessageUtils.writePackedData(n,"bytes"),p=u.TezosMessageUtils.encodeBigMapKey(e.from(l,"hex")),f=yield c.TezosNodeReader.getValueForBigMapKey(t,r,p);if(void 0===f)throw new Error(`Could not get data from map ${r} for '${o}'`);const h=s.JSONPath({path:"$.bytes",json:f})[0];return JSON.parse(a.TezosLanguageUtil.hexToMicheline(h.slice(2)).code)}))}t.verifyDestination=function(e,t){return n(this,void 0,void 0,(function*(){return p.TezosContractUtils.verifyDestination(e,t,"187c967006ca95a648c770fdd76947ef")}))},t.verifyScript=function(e){return p.TezosContractUtils.verifyScript(e,"ffcad1e376a6c8915780fe6676aceec6")},t.getAccountBalance=function(e,t,o){return n(this,void 0,void 0,(function*(){const n=yield r(e,t,`(Pair "ledger" 0x${u.TezosMessageUtils.writeAddress(o)})`);return Number(s.JSONPath({path:"$.args[0].int",json:n})[0])}))},t.getOperatorList=function(e,t){return n(this,void 0,void 0,(function*(){const n=yield r(e,t,'"operators"');let o=[];for(const e of n)o.push(u.TezosMessageUtils.readAddress(e.bytes));return o}))},t.getTokenMetadata=function(e,t){return n(this,void 0,void 0,(function*(){return yield r(e,t,'"tokenMetadata"')}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield c.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(s.JSONPath({path:"$.args[0].int",json:r})[0]),scale:8}}))},t.transferBalance=function(e,t,r,o,s,a,u,c,f=25e4,h=1e3){return n(this,void 0,void 0,(function*(){const n=`(Pair "${a}" (Pair "${u}" ${c}))`,d=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,h,f,"transfer",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(d.operationGroupID)}))},t.approveBalance=function(e,t,r,o,s,a,u,c=25e4,f=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Left (Right (Right (Right (Pair "${a}" ${u})))))))))`,h=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,c,"",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.mintBalance=function(e,t,r,o,s,a,u,c=25e4,f=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Right (Left (Left (Left (Pair "${a}" ${u})))))))))`,h=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,c,"",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(h.operationGroupID)}))},t.addOperator=function(e,t,r,o,s,a,u=25e4,c=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Right (Left (Right (Left "${a}" ))))))))`,f=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,c,u,"",n,i.TezosParameterFormat.Michelson);return p.TezosContractUtils.clearRPCOperationGroupHash(f.operationGroupID)}))}}(t.TzbtcTokenHelper||(t.TzbtcTokenHelper={}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(30),i=o(r(15)),a=o(r(12)).default.log,u=i.default.fetch;!function(e){function t(e,t){return n(this,void 0,void 0,(function*(){return u(`${e.url}/v2/metadata/${t}`,{method:"GET",headers:{apiKey:e.apiKey}}).then(r=>{if(!r.ok)throw new s.ConseilRequestError(r.status,r.statusText,`${e.url}/v2/metadata/${t}`,null);return r}).then(r=>r.json().catch(r=>{a.error(`ConseilMetadataClient.executeMetadataQuery parsing failed for ${e.url}/v2/metadata/${t} with ${r}`)}))}))}e.executeMetadataQuery=t,e.getPlatforms=function(e){return n(this,void 0,void 0,(function*(){return t(e,"platforms")}))},e.getNetworks=function(e,r){return n(this,void 0,void 0,(function*(){return t(e,r+"/networks")}))},e.getEntities=function(e,r,o){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/entities`)}))},e.getAttributes=function(e,r,o,s){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/${s}/attributes`)}))},e.getAttributeValues=function(e,r,o,s,i){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/${s}/${i}`)}))},e.getAttributeValuesForPrefix=function(e,r,o,s,i,a){return n(this,void 0,void 0,(function*(){return t(e,`${r}/${o}/${s}/${i}/${encodeURIComponent(a)}`)}))}}(t.ConseilMetadataClient||(t.ConseilMetadataClient={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.STRING="String",e.INT="Int",e.DECIMAL="Decimal",e.BOOLEAN="Boolean",e.ACCOUNT_ADDRESS="AccountAddress",e.HASH="Hash",e.DATETIME="DateTime",e.CURRENCY="Currency"}(t.AttrbuteDataType||(t.AttrbuteDataType={})),function(e){e.PRIMARYKEY="PrimaryKey",e.UNIQUEKEY="UniqueKey",e.NONKEY="NonKey"}(t.AttrbuteKeyType||(t.AttrbuteKeyType={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Yay=0]="Yay",e[e.Nay=1]="Nay",e[e.Pass=2]="Pass"}(t.BallotVote||(t.BallotVote={}))}])})); \ No newline at end of file From 42548df15f932947f7c41fe6caef857af6bb9429 Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Mon, 3 Aug 2020 00:52:06 -0400 Subject: [PATCH 6/9] - add ability to override keyword translation --- grammar/tezos/Micheline.ne | 26 +++++++++++++++++++------- src/chain/tezos/TezosLanguageUtil.ts | 18 +++++++++++++----- src/chain/tezos/lexer/Micheline.ts | 27 +++++++++++++++++++-------- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/grammar/tezos/Micheline.ne b/grammar/tezos/Micheline.ne index a8194db1..c008af64 100644 --- a/grammar/tezos/Micheline.ne +++ b/grammar/tezos/Micheline.ne @@ -5,10 +5,22 @@ const moo = require("moo"); const bigInt = require("big-integer"); // taken from https://gitlab.com/nomadic-labs/tezos, lib_protocol/michelson_v1_primitives.ml, prim_encoding enum -const MichelineKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DIG"', '"DUG"', '"EMPTY_BIG_MAP"', '"APPLY"', '"chain_id"', '"CHAIN_ID"']; +export const DefaultMichelsonKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DIG"', '"DUG"', '"EMPTY_BIG_MAP"', '"APPLY"', '"chain_id"', '"CHAIN_ID"']; +let _languageKeywords = [...DefaultMichelsonKeywords]; + +export const setKeywordList = list => { + _languageKeywords = list; +} + +export const getCodeForKeyword = word => { + return _languageKeywords.indexOf(word); +} + +export const getKeywordForCode = code => { + return _languageKeywords[code]; +} const lexer = moo.compile({ - keyword: MichelineKeywords, lbrace: '{', rbrace: '}', lbracket: '[', @@ -31,10 +43,10 @@ staticString -> %lbrace %_ "\"string\"" %_:* %colon %_ %quotedValue %_ %rbrace { staticBytes -> %lbrace %_ "\"bytes\"" %_:* %colon %_ %quotedValue %_ %rbrace {% staticBytesToHex %} staticObject -> staticInt {% id %} | staticString {% id %} | staticBytes {% id %} -primBare -> %lbrace %_ "\"prim\"" %_:* %colon %_ %keyword %_ %rbrace {% primBareToHex %} -primArg -> %lbrace %_ "\"prim\"" %_:? %colon %_ %keyword %comma %_ "\"args\"" %_:? %colon %_ %lbracket %_ (any %comma:? %_:?):+ %_ %rbracket %_ %rbrace {% primArgToHex %} -primAnn -> %lbrace %_ "\"prim\"" %_:? %colon %_ %keyword %comma %_ "\"annots\"" %_:? %colon %_ %lbracket %_ (%quotedValue %comma:? %_:?):+ %_ %rbracket %_ %rbrace {% primAnnToHex %} -primArgAnn -> %lbrace %_ "\"prim\"" %_:? %colon %_ %keyword %comma %_ "\"args\"" %_:? %colon %_ %lbracket %_ (any %comma:? %_:?):+ %_ %rbracket %comma %_ "\"annots\"" %_:? %colon %_ %lbracket %_ (%quotedValue %comma:? %_:?):+ %_ %rbracket %_ %rbrace {% primArgAnnToHex %} +primBare -> %lbrace %_ "\"prim\"" %_:* %colon %_ %quotedValue %_ %rbrace {% primBareToHex %} +primArg -> %lbrace %_ "\"prim\"" %_:? %colon %_ %quotedValue %comma %_ "\"args\"" %_:? %colon %_ %lbracket %_ (any %comma:? %_:?):+ %_ %rbracket %_ %rbrace {% primArgToHex %} +primAnn -> %lbrace %_ "\"prim\"" %_:? %colon %_ %quotedValue %comma %_ "\"annots\"" %_:? %colon %_ %lbracket %_ (%quotedValue %comma:? %_:?):+ %_ %rbracket %_ %rbrace {% primAnnToHex %} +primArgAnn -> %lbrace %_ "\"prim\"" %_:? %colon %_ %quotedValue %comma %_ "\"args\"" %_:? %colon %_ %lbracket %_ (any %comma:? %_:?):+ %_ %rbracket %comma %_ "\"annots\"" %_:? %colon %_ %lbracket %_ (%quotedValue %comma:? %_:?):+ %_ %rbracket %_ %rbrace {% primArgAnnToHex %} primAny -> primBare {% id %} | primArg {% id %} | primAnn {% id %} | primArgAnn {% id %} any -> primAny {% id %} | staticObject {% id %} | anyArray {% id %} @@ -177,7 +189,7 @@ const primArgAnnToHex = d => { } const encodePrimitive = p => { - return ('00' + MichelineKeywords.indexOf(p).toString(16)).slice(-2); + return ('00' + getCodeForKeyword(p).toString(16)).slice(-2); } const encodeLength = l => { diff --git a/src/chain/tezos/TezosLanguageUtil.ts b/src/chain/tezos/TezosLanguageUtil.ts index 44176447..cdcbca5b 100644 --- a/src/chain/tezos/TezosLanguageUtil.ts +++ b/src/chain/tezos/TezosLanguageUtil.ts @@ -4,9 +4,6 @@ import * as nearley from 'nearley'; import { TezosMessageUtils } from './TezosMessageUtil'; -// TODO: share this with the parser somehow -const MichelineKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DEFAULT_ACCOUNT"', '"tez"']; - /** * A collection of functions to encode and decode Michelson and Micheline code */ @@ -370,11 +367,11 @@ export namespace TezosLanguageUtil { * @returns {string} Michelson/Micheline keyword */ function hexToMichelineKeyword(hex: string, offset: number): string { - return MichelineKeywords[parseInt(hex.substring(offset, offset + 2), 16)]; + return Micheline.getKeywordForCode(parseInt(hex.substring(offset, offset + 2), 16)); } function hexToMichelsonKeyword(hex: string, offset: number): string { - return MichelineKeywords[parseInt(hex.substring(offset, offset + 2), 16)].slice(1, -1); + return hexToMichelineKeyword(hex, offset).slice(1, -1); } /** @@ -389,6 +386,17 @@ export namespace TezosLanguageUtil { return { code: stringEnvelope.code.split(' ').map(s => `"${s}"`).join(', '), consumed: stringEnvelope.consumed }; } + /** + * This function is undocumented, if you're using it, please know what you're doing. + */ + export function overrideKeywordList(list: string[]) { + Micheline.setKeywordList(list); + } + + export function restoreKeywordList() { + Micheline.setKeywordList(Micheline.DefaultMichelsonKeywords); + } + /** * Reformats the Michelson code into the order the parser will understand. Input is expected to contains parameter, storage and code sections. */ diff --git a/src/chain/tezos/lexer/Micheline.ts b/src/chain/tezos/lexer/Micheline.ts index 5ade39e9..be3fe0d6 100644 --- a/src/chain/tezos/lexer/Micheline.ts +++ b/src/chain/tezos/lexer/Micheline.ts @@ -8,7 +8,6 @@ declare var _: any; declare var colon: any; declare var quotedValue: any; declare var rbrace: any; -declare var keyword: any; declare var comma: any; declare var lbracket: any; declare var rbracket: any; @@ -17,10 +16,22 @@ const moo = require("moo"); const bigInt = require("big-integer"); // taken from https://gitlab.com/nomadic-labs/tezos, lib_protocol/michelson_v1_primitives.ml, prim_encoding enum -const MichelineKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DIG"', '"DUG"', '"EMPTY_BIG_MAP"', '"APPLY"', '"chain_id"', '"CHAIN_ID"']; +export const DefaultMichelsonKeywords = ['"parameter"', '"storage"', '"code"', '"False"', '"Elt"', '"Left"', '"None"', '"Pair"', '"Right"', '"Some"', '"True"', '"Unit"', '"PACK"', '"UNPACK"', '"BLAKE2B"', '"SHA256"', '"SHA512"', '"ABS"', '"ADD"', '"AMOUNT"', '"AND"', '"BALANCE"', '"CAR"', '"CDR"', '"CHECK_SIGNATURE"', '"COMPARE"', '"CONCAT"', '"CONS"', '"CREATE_ACCOUNT"', '"CREATE_CONTRACT"', '"IMPLICIT_ACCOUNT"', '"DIP"', '"DROP"', '"DUP"', '"EDIV"', '"EMPTY_MAP"', '"EMPTY_SET"', '"EQ"', '"EXEC"', '"FAILWITH"', '"GE"', '"GET"', '"GT"', '"HASH_KEY"', '"IF"', '"IF_CONS"', '"IF_LEFT"', '"IF_NONE"', '"INT"', '"LAMBDA"', '"LE"', '"LEFT"', '"LOOP"', '"LSL"', '"LSR"', '"LT"', '"MAP"', '"MEM"', '"MUL"', '"NEG"', '"NEQ"', '"NIL"', '"NONE"', '"NOT"', '"NOW"', '"OR"', '"PAIR"', '"PUSH"', '"RIGHT"', '"SIZE"', '"SOME"', '"SOURCE"', '"SENDER"', '"SELF"', '"STEPS_TO_QUOTA"', '"SUB"', '"SWAP"', '"TRANSFER_TOKENS"', '"SET_DELEGATE"', '"UNIT"', '"UPDATE"', '"XOR"', '"ITER"', '"LOOP_LEFT"', '"ADDRESS"', '"CONTRACT"', '"ISNAT"', '"CAST"', '"RENAME"', '"bool"', '"contract"', '"int"', '"key"', '"key_hash"', '"lambda"', '"list"', '"map"', '"big_map"', '"nat"', '"option"', '"or"', '"pair"', '"set"', '"signature"', '"string"', '"bytes"', '"mutez"', '"timestamp"', '"unit"', '"operation"', '"address"', '"SLICE"', '"DIG"', '"DUG"', '"EMPTY_BIG_MAP"', '"APPLY"', '"chain_id"', '"CHAIN_ID"']; +let _languageKeywords = [...DefaultMichelsonKeywords]; + +export const setKeywordList = list => { + _languageKeywords = list; +} + +export const getCodeForKeyword = word => { + return _languageKeywords.indexOf(word); +} + +export const getKeywordForCode = code => { + return _languageKeywords[code]; +} const lexer = moo.compile({ - keyword: MichelineKeywords, lbrace: '{', rbrace: '}', lbracket: '[', @@ -167,7 +178,7 @@ const primArgAnnToHex = d => { } const encodePrimitive = p => { - return ('00' + MichelineKeywords.indexOf(p).toString(16)).slice(-2); + return ('00' + getCodeForKeyword(p).toString(16)).slice(-2); } const encodeLength = l => { @@ -255,7 +266,7 @@ const grammar: Grammar = { {"name": "staticObject", "symbols": ["staticBytes"], "postprocess": id}, {"name": "primBare$ebnf$1", "symbols": []}, {"name": "primBare$ebnf$1", "symbols": ["primBare$ebnf$1", (lexer.has("_") ? {type: "_"} : _)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "primBare", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primBare$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("keyword") ? {type: "keyword"} : keyword), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primBareToHex}, + {"name": "primBare", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primBare$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("quotedValue") ? {type: "quotedValue"} : quotedValue), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primBareToHex}, {"name": "primArg$ebnf$1", "symbols": [(lexer.has("_") ? {type: "_"} : _)], "postprocess": id}, {"name": "primArg$ebnf$1", "symbols": [], "postprocess": () => null}, {"name": "primArg$ebnf$2", "symbols": [(lexer.has("_") ? {type: "_"} : _)], "postprocess": id}, @@ -272,7 +283,7 @@ const grammar: Grammar = { {"name": "primArg$ebnf$3$subexpression$2$ebnf$2", "symbols": [], "postprocess": () => null}, {"name": "primArg$ebnf$3$subexpression$2", "symbols": ["any", "primArg$ebnf$3$subexpression$2$ebnf$1", "primArg$ebnf$3$subexpression$2$ebnf$2"]}, {"name": "primArg$ebnf$3", "symbols": ["primArg$ebnf$3", "primArg$ebnf$3$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "primArg", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primArg$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("keyword") ? {type: "keyword"} : keyword), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"args\""}, "primArg$ebnf$2", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primArg$ebnf$3", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primArgToHex}, + {"name": "primArg", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primArg$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("quotedValue") ? {type: "quotedValue"} : quotedValue), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"args\""}, "primArg$ebnf$2", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primArg$ebnf$3", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primArgToHex}, {"name": "primAnn$ebnf$1", "symbols": [(lexer.has("_") ? {type: "_"} : _)], "postprocess": id}, {"name": "primAnn$ebnf$1", "symbols": [], "postprocess": () => null}, {"name": "primAnn$ebnf$2", "symbols": [(lexer.has("_") ? {type: "_"} : _)], "postprocess": id}, @@ -289,7 +300,7 @@ const grammar: Grammar = { {"name": "primAnn$ebnf$3$subexpression$2$ebnf$2", "symbols": [], "postprocess": () => null}, {"name": "primAnn$ebnf$3$subexpression$2", "symbols": [(lexer.has("quotedValue") ? {type: "quotedValue"} : quotedValue), "primAnn$ebnf$3$subexpression$2$ebnf$1", "primAnn$ebnf$3$subexpression$2$ebnf$2"]}, {"name": "primAnn$ebnf$3", "symbols": ["primAnn$ebnf$3", "primAnn$ebnf$3$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "primAnn", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primAnn$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("keyword") ? {type: "keyword"} : keyword), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"annots\""}, "primAnn$ebnf$2", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primAnn$ebnf$3", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primAnnToHex}, + {"name": "primAnn", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primAnn$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("quotedValue") ? {type: "quotedValue"} : quotedValue), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"annots\""}, "primAnn$ebnf$2", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primAnn$ebnf$3", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primAnnToHex}, {"name": "primArgAnn$ebnf$1", "symbols": [(lexer.has("_") ? {type: "_"} : _)], "postprocess": id}, {"name": "primArgAnn$ebnf$1", "symbols": [], "postprocess": () => null}, {"name": "primArgAnn$ebnf$2", "symbols": [(lexer.has("_") ? {type: "_"} : _)], "postprocess": id}, @@ -320,7 +331,7 @@ const grammar: Grammar = { {"name": "primArgAnn$ebnf$5$subexpression$2$ebnf$2", "symbols": [], "postprocess": () => null}, {"name": "primArgAnn$ebnf$5$subexpression$2", "symbols": [(lexer.has("quotedValue") ? {type: "quotedValue"} : quotedValue), "primArgAnn$ebnf$5$subexpression$2$ebnf$1", "primArgAnn$ebnf$5$subexpression$2$ebnf$2"]}, {"name": "primArgAnn$ebnf$5", "symbols": ["primArgAnn$ebnf$5", "primArgAnn$ebnf$5$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "primArgAnn", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primArgAnn$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("keyword") ? {type: "keyword"} : keyword), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"args\""}, "primArgAnn$ebnf$2", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primArgAnn$ebnf$3", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"annots\""}, "primArgAnn$ebnf$4", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primArgAnn$ebnf$5", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primArgAnnToHex}, + {"name": "primArgAnn", "symbols": [(lexer.has("lbrace") ? {type: "lbrace"} : lbrace), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"prim\""}, "primArgAnn$ebnf$1", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("quotedValue") ? {type: "quotedValue"} : quotedValue), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"args\""}, "primArgAnn$ebnf$2", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primArgAnn$ebnf$3", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("comma") ? {type: "comma"} : comma), (lexer.has("_") ? {type: "_"} : _), {"literal":"\"annots\""}, "primArgAnn$ebnf$4", (lexer.has("colon") ? {type: "colon"} : colon), (lexer.has("_") ? {type: "_"} : _), (lexer.has("lbracket") ? {type: "lbracket"} : lbracket), (lexer.has("_") ? {type: "_"} : _), "primArgAnn$ebnf$5", (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbracket") ? {type: "rbracket"} : rbracket), (lexer.has("_") ? {type: "_"} : _), (lexer.has("rbrace") ? {type: "rbrace"} : rbrace)], "postprocess": primArgAnnToHex}, {"name": "primAny", "symbols": ["primBare"], "postprocess": id}, {"name": "primAny", "symbols": ["primArg"], "postprocess": id}, {"name": "primAny", "symbols": ["primAnn"], "postprocess": id}, From b3639e7efc58deb91c56fe1a5d965e72bc55fa7c Mon Sep 17 00:00:00 2001 From: anonymoussprocket Date: Mon, 3 Aug 2020 12:25:46 -0400 Subject: [PATCH 7/9] - updated web-dist --- README.md | 2 +- dist-web/conseiljs.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae03df4e..20c22495 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ TBD