>>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,$=0|this._hh,D=0|this._al,P=0|this._bl,_=0|this._cl,v=0|this._dl,I=0|this._el,A=0|this._fl,w=0|this._gl,E=0|this._hl,S=0;S<32;S+=2)t[S]=e.readInt32BE(4*S),t[S+1]=e.readInt32BE(4*S+4);for(;S<160;S+=2){var R=t[S-30],T=t[S-30+1],C=h(R,T),U=d(T,R),O=b(R=t[S-4],T=t[S-4+1]),N=m(T,R),x=t[S-14],M=t[S-14+1],k=t[S-32],F=t[S-32+1],L=U+M|0,G=C+x+g(L,U)|0;G=(G=G+O+g(L=L+N|0,N)|0)+k+g(L=L+F|0,F)|0,t[S]=G,t[S+1]=L}for(var B=0;B<160;B+=2){G=t[B],L=t[B+1];var z=l(r,n,o),j=l(D,P,_),W=p(r,D),H=p(D,r),Q=f(a,I),q=f(I,a),J=i[B],K=i[B+1],Y=c(a,u,y),V=c(I,A,w),Z=E+q|0,X=$+Q+g(Z,E)|0;X=(X=(X=X+Y+g(Z=Z+V|0,V)|0)+J+g(Z=Z+K|0,K)|0)+G+g(Z=Z+L|0,L)|0;var ee=H+j|0,te=W+z+g(ee,H)|0;$=y,E=w,y=u,w=A,u=a,A=I,a=s+X+g(I=v+Z|0,v)|0,s=o,v=_,o=n,_=P,n=r,P=D,r=X+te+g(D=Z+ee|0,Z)|0}this._al=this._al+D|0,this._bl=this._bl+P|0,this._cl=this._cl+_|0,this._dl=this._dl+v|0,this._el=this._el+I|0,this._fl=this._fl+A|0,this._gl=this._gl+w|0,this._hl=this._hl+E|0,this._ah=this._ah+r+g(this._al,D)|0,this._bh=this._bh+n+g(this._bl,P)|0,this._ch=this._ch+o+g(this._cl,_)|0,this._dh=this._dh+s+g(this._dl,v)|0,this._eh=this._eh+a+g(this._el,I)|0,this._fh=this._fh+u+g(this._fl,A)|0,this._gh=this._gh+y+g(this._gl,w)|0,this._hh=this._hh+$+g(this._hl,E)|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,b=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*b}},function(e,t,r){"use strict";function n(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0});const o=r(19),s=r(31),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();return t=t.substring(1,t.length-1),"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(19),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","DUP","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"\\])*"/}),b=e=>new RegExp("^C(A|D)(A|D)+R$").test(e),m=e=>f.includes(e),g=e=>c.test(e),y=e=>l.includes(e),$=e=>"FAIL"===e,D=e=>p.includes(e)||h.includes(e)||"IF_SOME"===e,P=(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:return""}},_=e=>u.test(e),v=(e,t,r)=>{let n="";if(u.test(e)){const o=e.length-2;for(let e=0;e"UNPAIR"==e||"UNPAPAIR"==e,A=e=>s.test(e),w=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":["@%%"]}, ${w(e.slice(1))}]]}, {"prim": "CDR","annots":["@%%"]}, {"prim": "SWAP"}, {"prim": "PAIR","annots":["%@","%@"]}]`:"D"===t?`[{"prim": "DUP"}, {"prim": "DIP", "args": [[{"prim": "CDR","annots":["@%%"]}, ${w(e.slice(1))}]]}, {"prim": "CAR","annots":["@%%"]}, {"prim": "PAIR","annots":["%@","%@"]}]`:void 0},E=e=>!!y(e)||(!!m(e)||(!!_(e)||(!!g(e)||(!!$(e)||(!!D(e)||(!!b(e)||(!!I(e)||(!!A(e)||void 0)))))))),S=(e,t)=>b(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}}]]]}]`;default:return""}})(e,t):m(e)?((e,t)=>{var r=e.substring(3),n=C([`${r}`]);return null!=t&&(n=`{ "prim": "${r}", "annots": [${t}] }`),`[${C(["COMPARE"])}, ${n}]`})(e,t):_(e)?v(e,t):g(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):D(e)?P(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):A(e)?((e,t)=>w(e.slice(5,-1)))(e):void 0,R=e=>`{ "int": "${parseInt(e[0])}" }`,T=e=>`{ "string": ${e[0]} }`,C=e=>{const t=e[0].toString();if(1==e.length)return E(t)?[S(t,null)]:`{ "prim": "${e[0]}" }`;{const r=e[1].map(e=>`"${e[1]}"`);return E(t)?[S(t,r)]:`{ "prim": "${e[0]}", "annots": [${r}] }`}},U=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 _(t)?v(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]} ] }`,k=e=>`{ "prim": "${e[2]}", "args": [ ${e[4]}, ${e[6]} ] }`,F=e=>Array.isArray(e)&&Array.isArray(e[0])?e[0]:e,L=e=>`${e[2].map(e=>e[0]).map(e=>F(e))}`,G=e=>`[ ${e[2].map(e=>e[0]).map(e=>F(e))} ]`,B=e=>{const t=e[1].map(e=>`"${e[1]}"`);return`{ "prim": "${e[0]}", "args": [ ${e[4]}, ${e[6]} ], "annots": [${t}] }`},z=e=>e.length>4?`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" }, [ ${e[4]} ] ] }`:`{ "prim": "${e[0]}", "args": [ ${e[2]} ] }`,j=e=>`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" } ] }`,W={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:U},{name:"storageValue",symbols:[d.has("storage")?{type:"storage"}:storage,"_","typeData","_","semicolons"],postprocess:U},{name:"parameter",symbols:[d.has("parameter")?{type:"parameter"}:parameter,"_","type","_","semicolons"],postprocess:U},{name:"storage",symbols:[d.has("storage")?{type:"storage"}:storage,"_","type","_","semicolons"],postprocess:U},{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:C},{name:"type",symbols:[d.has("constantType")?{type:"constantType"}:constantType],postprocess:C},{name:"type",symbols:[d.has("singleArgType")?{type:"singleArgType"}:singleArgType,"_","type"],postprocess:U},{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:k},{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:C},{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:C},{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:U},{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:k},{name:"typeData",symbols:["subTypeData"],postprocess:n},{name:"typeData",symbols:["subTypeElt"],postprocess:n},{name:"typeData",symbols:[d.has("number")?{type:"number"}:number],postprocess:R},{name:"typeData",symbols:[d.has("string")?{type:"string"}:string],postprocess:T},{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:C},{name:"data",symbols:[d.has("singleArgData")?{type:"singleArgData"}:singleArgData,"_","data"],postprocess:U},{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:T},{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:R},{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:L},{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:G},{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:G},{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:L},{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:L},{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:L},{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:L},{name:"subTypeElt$ebnf$3$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$3$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$3$subexpression$1",symbols:["typeElt","_","subTypeElt$ebnf$3$subexpression$1$ebnf$1","_"]},{name:"subTypeElt$ebnf$3",symbols:["subTypeElt$ebnf$3$subexpression$1"]},{name:"subTypeElt$ebnf$3$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$3$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$3$subexpression$2",symbols:["typeElt","_","subTypeElt$ebnf$3$subexpression$2$ebnf$1","_"]},{name:"subTypeElt$ebnf$3",symbols:["subTypeElt$ebnf$3","subTypeElt$ebnf$3$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeElt",symbols:[{literal:"{"},"_","subTypeElt$ebnf$3",{literal:"}"}],postprocess:L},{name:"subTypeElt$ebnf$4$subexpression$1$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$4$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$4$subexpression$1",symbols:["typeElt","_","subTypeElt$ebnf$4$subexpression$1$ebnf$1","_"]},{name:"subTypeElt$ebnf$4",symbols:["subTypeElt$ebnf$4$subexpression$1"]},{name:"subTypeElt$ebnf$4$subexpression$2$ebnf$1",symbols:[{literal:";"}],postprocess:n},{name:"subTypeElt$ebnf$4$subexpression$2$ebnf$1",symbols:[],postprocess:()=>null},{name:"subTypeElt$ebnf$4$subexpression$2",symbols:["typeElt","_","subTypeElt$ebnf$4$subexpression$2$ebnf$1","_"]},{name:"subTypeElt$ebnf$4",symbols:["subTypeElt$ebnf$4","subTypeElt$ebnf$4$subexpression$2"],postprocess:e=>e[0].concat([e[1]])},{name:"subTypeElt",symbols:[{literal:"("},"_","subTypeElt$ebnf$4",{literal:")"}],postprocess:L},{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=>F(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:L},{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:C},{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:C},{name:"instruction",symbols:["instructions","_","subInstruction"],postprocess:e=>{const t=`${e[0].toString()}`;return _(t)?v(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:U},{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:U},{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 D(t)?P(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:B},{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:B},{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:z},{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","_","subInstruction"],postprocess:z},{name:"instruction$ebnf$11",symbols:[/[0-9]/]},{name:"instruction$ebnf$11",symbols:["instruction$ebnf$11",/[0-9]/],postprocess:e=>e[0].concat([e[1]])},{name:"instruction",symbols:[{literal:"DIG"},"_","instruction$ebnf$11"],postprocess:j},{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:"DUG"},"_","instruction$ebnf$12"],postprocess:j},{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:"DROP"},"_","instruction$ebnf$13"],postprocess:e=>`{ "prim": "${e[0]}", "args": [ { "int": "${e[2]}" } ] }`},{name:"instruction",symbols:[{literal:"DROP"}],postprocess:C},{name:"instruction",symbols:[d.has("lbrace")?{type:"lbrace"}:lbrace,"_",d.has("rbrace")?{type:"rbrace"}:rbrace],postprocess:e=>""},{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=W},function(e,t,r){"use strict";var n=r(50),o=r(70);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(51),s=r(63),i=r(64),a=r(69);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(33),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(54);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(56),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 b(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 g(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 $(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,D=0|this._a,P=0|this._b,_=0|this._c,v=0|this._d,I=0|this._e,A=0;A<80;A+=1){var w,E;A<16?(w=b(r,n,o,s,h,e[a[A]],p[0],c[A]),E=$(D,P,_,v,I,e[u[A]],f[0],l[A])):A<32?(w=m(r,n,o,s,h,e[a[A]],p[1],c[A]),E=y(D,P,_,v,I,e[u[A]],f[1],l[A])):A<48?(w=g(r,n,o,s,h,e[a[A]],p[2],c[A]),E=g(D,P,_,v,I,e[u[A]],f[2],l[A])):A<64?(w=y(r,n,o,s,h,e[a[A]],p[3],c[A]),E=m(D,P,_,v,I,e[u[A]],f[3],l[A])):(w=$(r,n,o,s,h,e[a[A]],p[4],c[A]),E=b(D,P,_,v,I,e[u[A]],f[4],l[A])),r=h,h=s,s=d(o,10),o=n,n=w,D=I,I=v,v=d(_,10),_=P,P=E}var S=this._b+o+v|0;this._b=this._c+s+I|0,this._c=this._d+h+D|0,this._d=this._e+r+P|0,this._e=this._a+n+_|0,this._a=S},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(65),t.sha1=r(66),t.sha224=r(67),t.sha256=r(39),t.sha384=r(68),t.sha512=r(40)},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),b=c(n)+p(d,o,s,a)+u+r[h]+i[d]|0;u=a,a=s,s=l(o),o=n,n=b}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(39),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(40),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(34).Transform,s=r(23).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(71),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(72);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 b=n.allocUnsafe(o+(c-d));b.fill(0,0,o);for(var m=o;d!==c;)b[m++]=l[d++];return b}}}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 b=l-o;b!==l&&0===p[b];)b++;for(var m=a.repeat(r);b=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],b=l[n+1]^l[e+1];l[n]=b,l[n+1]=d,o(l,r,n),d=l[t]^l[r],b=l[t+1]^l[r+1],l[t]=d>>>24^b<<8,l[t+1]=b>>>24^d<<8,o(l,e,t),s(l,e,f,h),d=l[n]^l[e],b=l[n+1]^l[e+1],l[n]=d>>>16^b<<16,l[n+1]=b>>>16^d<<16,o(l,r,n),d=l[t]^l[r],b=l[t+1]^l[r+1],l[t]=b>>>31^d<<1,l[t+1]=d>>>31^b<<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),b(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:b}},function(e,t,r){var n=r(41);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 b(e,t,r){r=r||32,e=n.normalizeInput(e);var o=f(r,t);return h(o,e),d(o)}e.exports={blake2s:b,blake2sHex:function(e,t,r){var o=b(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(19).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;return s+=2,t.length>s&&(p=r(t.substring(s,s+2))),{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));return s+=66,e.length>s&&(f=r(e.substring(s,s+2))),{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 b=n.TezosMessageUtils.readAddress(t.substring(a,a+44));a+=44;let m=n.TezosMessageUtils.readBoolean(t.substring(a,a+2));a+=2;let g,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}}return t.length>a&&(g=r(t.substring(a,a+2))),{operation:{kind:"transaction",source:c,destination:b,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:g,nextoffset:g?a:-1}}function b(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 b=!1,m=!1;parseInt(s,16)<100&&(b=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2,m=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2);let g=n.TezosMessageUtils.readBoolean(e.substring(i,i+2));i+=2;let y="";g&&(y=n.TezosMessageUtils.readAddress(e.substring(i,i+42)),i+=42);let $=!0;parseInt(s,16)<100&&($=n.TezosMessageUtils.readBoolean(e.substring(i,i+2)),i+=2);let D,P={};if($){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,P=JSON.parse(`{ "script": [ ${r}, ${s} ] }`)}e.length>i&&(D=r(e.substring(i,i+2)));let _={kind:"origination",source:u,balance:d.value+"",delegate:g?y:void 0,fee:c.value+"",gas_limit:p.value+"",storage_limit:f.value+"",counter:l.value+"",script:$?P:void 0};return parseInt(s,16)<100&&(_.manager_pubkey=h,_.spendable=b,_.delegatable=m),{operation:_,branch:a,next:D,nextoffset:D?i:-1}}function g(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="";return f&&(d=n.TezosMessageUtils.readAddress(e.substring(s,s+42)),s+=42),e.length>s&&(h=r(e.substring(s,s+2))),{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 $(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 b(e);if("origination"===t.kind)return g(e);if("delegation"===t.kind)return $(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=b,t.parseOrigination=m,t.encodeOrigination=g,t.parseDelegation=y,t.encodeDelegation=$,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(24),i=r(3),a=r(9),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";(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(5)),i=r(8),a=r(4),u=r(3),c=r(9),l=o(r(7)),p=r(24);!function(t){function r(e,t,r,n,o,s,i){let a=`[ { "prim": "DROP" },\n { "prim": "NIL", "args": [ { "prim": "operation" } ] },\n { "prim": "PUSH", "args": [ { "prim": "key_hash" }, { "string": "${i}" } ] },\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,p.TezosConstants.P005ManagerContractWithdrawalStorageLimit,p.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",a,l.TezosParameterFormat.Micheline)}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("d99cb8b4c7e40166f59c0f3c30724225"!==o)throw new Error(`Contract does not match the expected code hash: ${o}, 'd99cb8b4c7e40166f59c0f3c30724225'`);return!0}))},t.verifyScript=function(t){const r=e.from(s.blake2s(a.TezosLanguageUtil.preProcessMichelsonScript(t).join("\n"),null,16)).toString("hex");if("a585489ffaee60d07077059539d5bfc8"!==r)throw new Error(`Contract does not match the expected code hash: ${r}, 'a585489ffaee60d07077059539d5bfc8'`);return!0},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield u.TezosNodeReader.getContractStorage(e,t);return{administrator:i.JSONPath({path:"$.string",json:r})[0]}}))},t.setDelegate=function(e,t,r,n,o,s){if(n.startsWith("KT1")){const i=`[{ "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,p.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",i,l.TezosParameterFormat.Micheline)}return c.TezosNodeWriter.sendDelegationOperation(e,t,r,o,s)},t.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,p.TezosConstants.P005ManagerContractWithdrawalGasLimit,"do",s,l.TezosParameterFormat.Micheline)}return c.TezosNodeWriter.sendUndelegationOperation(e,t,r,o)},t.withdrawDelegatedFunds=function(e,t,n,o,s,i){return r(e,t,n,o,s,i,n.publicKeyHash)},t.sendDelegatedFunds=r,t.depositDelegatedFunds=function(e,t,r,n,o,s){return c.TezosNodeWriter.sendContractInvocationOperation(e,t,r,n,s,o,0,p.TezosConstants.P005ManagerContractDepositGasLimit,void 0,void 0)},t.deployManagerContract=function(e,t,r,n,o,s){const i=`{ "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" } ] ] } ] ] } ]',i,l.TezosParameterFormat.Micheline)}}(t.BabylonDelegationHelper||(t.BabylonDelegationHelper={}))}).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(5)),i=r(8),a=r(6),u=r(3),c=r(9),l=o(r(7));!function(t){function r(e){return e.replace(/\"/g,"").replace(/\n/,"")}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(n.script.toString(),null,16)).toString("hex");if("c020219e31ee3b462ed93c33124f117f"!==o)throw new Error(`Contract at ${r} does not match the expected code hash: ${o}, 'c020219e31ee3b462ed93c33124f117f'`);return!0}))},t.registerName=function(e,t,o,s,i,a,u,p,f,h,d){return n(this,void 0,void 0,(function*(){const n=`(Pair ${u} (Pair "${i}" "${a}"))`;if(!h||!d){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",o,s,p,f,6e3,5e5,"registerName",n,l.TezosParameterFormat.Michelson);h||(h=Number(t.storageCost)||0),d||(d=Number(t.gas)+300)}return r((yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,p,f,6e3,3e5,"registerName",n,l.TezosParameterFormat.Michelson)).operationGroupID)}))},t.transferNameOwnership=function(e,t,o,s,i,a,u,p,f){return n(this,void 0,void 0,(function*(){const n=`(Pair "${i}" "${a}")`;if(!p||!f){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",o,s,0,u,1e3,1e5,"transferNameOwnership",n,l.TezosParameterFormat.Michelson);p||(p=Number(t.storageCost)||0),f||(f=Number(t.gas)+300)}return r((yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,u,p,f,"transferNameOwnership",n,l.TezosParameterFormat.Michelson)).operationGroupID)}))},t.updateResolver=function(e,t,o,s,i,a,u,p,f){return n(this,void 0,void 0,(function*(){const n=`(Pair "${i}" "${a}")`;if(!p||!f){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",o,s,0,u,1e3,1e5,"updateResolver",n,l.TezosParameterFormat.Michelson);p||(p=Number(t.storageCost)||0),f||(f=Number(t.gas)+300)}return r((yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,u,p,f,"updateResolver",n,l.TezosParameterFormat.Michelson)).operationGroupID)}))},t.updateRegistrationPeriod=function(e,t,o,s,i,a,u,p,f,h){return n(this,void 0,void 0,(function*(){const n=`(Pair "${i}" ${a})`;if(!f||!h){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",o,s,u,p,1e3,1e5,"updateRegistrationPeriod",n,l.TezosParameterFormat.Michelson);f||(f=Number(t.storageCost)||0),h||(h=Number(t.gas)+300)}return r((yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,u,p,f,h,"updateRegistrationPeriod",n,l.TezosParameterFormat.Michelson)).operationGroupID)}))},t.deleteName=function(e,t,o,s,i,a,u,p){return n(this,void 0,void 0,(function*(){const n=`"${i}"`;if(!u||!p){const t=yield c.TezosNodeWriter.testContractInvocationOperation(e,"main",o,s,0,a,1e3,1e5,"deleteName",n,l.TezosParameterFormat.Michelson);u||(u=Number(t.storageCost)||0),p||(p=Number(t.gas)+300)}return r((yield c.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,a,u,p,"deleteName",n,l.TezosParameterFormat.Michelson)).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")),s=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);return i.JSONPath({path:"$.string",json:s})[0]}))},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")),s=yield u.TezosNodeReader.getValueForBigMapKey(t,r,n);return{name:o,owner:i.JSONPath({path:"$.args[0].args[1].args[1].string",json:s})[0],resolver:i.JSONPath({path:"$.args[1].args[1].args[1].string",json:s})[0],registeredAt:new Date(i.JSONPath({path:"$.args[1].args[0].string",json:s})[0]),registrationPeriod:i.JSONPath({path:"$.args[1].args[1].args[0].int",json:s})[0],modified:Boolean(i.JSONPath({path:"$.args[0].args[0].prim",json:s})[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(i.JSONPath({path:"$.args[0].args[0].int",json:r})[0]),nameMap:Number(i.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),manager:i.JSONPath({path:"$.args[0].args[1].args[0].string",json:r})[0],interval:Number(i.JSONPath({path:"$.args[0].args[1].args[1].int",json:r})[0]),maxDuration:Number(i.JSONPath({path:"$.args[1].args[0].int",json:r})[0]),intervalFee:Number(i.JSONPath({path:"$.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(5)),i=r(8),a=r(6),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(5)),i=r(8),a=r(4),u=r(3),c=r(9),l=o(r(7));!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=o(r(5)),i=r(8),a=r(4),u=r(6),c=r(3),l=r(9),p=o(r(7));!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield c.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("0e3e137841a959521324b4ce20ca2df7"!==o)throw new Error(`Contract does not match the expected code hash: ${o}, '0e3e137841a959521324b4ce20ca2df7'`);return!0}))},t.verifyScript=function(t){const r=e.from(s.blake2s(a.TezosLanguageUtil.preProcessMichelsonScript(t).join("\n"),null,16)).toString("hex");if("b77ada691b1d630622bea243696c84d7"!==r)throw new Error(`Contract does not match the expected code hash: ${r}, 'b77ada691b1d630622bea243696c84d7'`);return!0},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=u.TezosMessageUtils.encodeBigMapKey(e.from(u.TezosMessageUtils.writePackedData(o,"address"),"hex")),s=yield c.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===s)throw new Error(`Map ${r} does not contain a record for ${o}`);return Number(i.JSONPath({path:"$.int",json:s})[0])}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){const r=yield c.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(i.JSONPath({path:"$.args[1].args[1].args[0].int",json:r})[0]),council:i.JSONPath({path:"$.args[0].args[0].args[1]..string",json:r}),stage:Number(i.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0]),phase:Number(i.JSONPath({path:"$.args[1].args[0].args[0].int",json:r})[0])%4,supply:Number(i.JSONPath({path:"$.args[1].args[0].args[1].int",json:r})[0]),paused:i.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,i,a,u,c,f){return n(this,void 0,void 0,(function*(){const n=`(Right (Left (Left (Right (Pair "${i}" (Pair "${a}" ${u}))))))`,h=yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,o,0,s,f,c,"",n,p.TezosParameterFormat.Michelson);return h.operationGroupID.replace(/\"/g,"").replace(/\n/,"")}))}}(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(5)),i=r(8),a=r(6),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=o(r(5)),i=r(8),a=r(4),u=r(6),c=r(3),l=r(9),p=o(r(7));!function(t){function r(e){return e.replace(/\"/g,"").replace(/\n/,"")}t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield c.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("0e3e137841a959521324b4ce20ca2df7"!==o)throw new Error(`Contract does not match the expected code hash: ${o}, '0e3e137841a959521324b4ce20ca2df7'`);return!0}))},t.verifyScript=function(t){const r=e.from(s.blake2s(a.TezosLanguageUtil.preProcessMichelsonScript(t).join("\n"),null,16)).toString("hex");if("b77ada691b1d630622bea243696c84d7"!==r)throw new Error(`Contract does not match the expected code hash: ${r}, 'b77ada691b1d630622bea243696c84d7'`);return!0},t.deployContract=function(e,t,o,s,i,a=!0,u=0,c=15e4,f=5e3){return n(this,void 0,void 0,(function*(){const n=`Pair {} (Pair "${i}" (Pair ${a?"True":"False"} ${u}))`;return r((yield l.TezosNodeWriter.sendContractOriginationOperation(e,t,o,0,void 0,s,f,c,'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,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.getAccountBalance=function(t,r,o){return n(this,void 0,void 0,(function*(){const n=u.TezosMessageUtils.encodeBigMapKey(e.from(u.TezosMessageUtils.writePackedData(o,"address"),"hex")),s=yield c.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===s)throw new Error(`Map ${r} does not contain a record for ${o}`);const a=i.JSONPath({path:"$.args[0].int",json:s});return Number(a[0])}))},t.getAccountAllowance=function(t,r,o,s){return n(this,void 0,void 0,(function*(){const n=u.TezosMessageUtils.encodeBigMapKey(e.from(u.TezosMessageUtils.writePackedData(s,"address"),"hex")),a=yield c.TezosNodeReader.getValueForBigMapKey(t,r,n);if(void 0===a)throw new Error(`Map ${r} does not contain a record for ${s}/${o}`);let l=new Map;return i.JSONPath({path:"$.args[1][*].args",json:a}).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 c.TezosNodeReader.getContractStorage(e,t);return{mapid:Number(i.JSONPath({path:"$.args[0].int",json:r})[0]),supply:Number(i.JSONPath({path:"$.args[1].args[1].args[1].int",json:r})[0]),administrator:i.JSONPath({path:"$.args[1].args[0].string",json:r})[0],paused:i.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 c.TezosNodeReader.getContractStorage(e,t);return Number(i.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 c.TezosNodeReader.getContractStorage(e,t);return i.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 c.TezosNodeReader.getContractStorage(e,t);return i.JSONPath({path:"$.args[1].args[1].args[0].prim",json:r})[0].toString().toLowerCase().startsWith("t")}))},t.transferBalance=function(e,t,o,s,i,a,u,c,f,h){return n(this,void 0,void 0,(function*(){const n=`(Left (Left (Left (Pair "${a}" (Pair "${u}" ${c})))))`;return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,i,h,f,"",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.approveBalance=function(e,t,o,s,i,a,u,c,f){return n(this,void 0,void 0,(function*(){const n=`(Left (Left (Right (Pair "${a}" ${u}))))`;return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,i,f,c,"",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.activateLedger=function(e,t,o,s,i,a,u){return n(this,void 0,void 0,(function*(){return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,i,u,a,"","(Right (Left (Left False)))",p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.deactivateLedger=function(e,t,o,s,i,a,u){return n(this,void 0,void 0,(function*(){return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,i,u,a,"","(Right (Left (Left True)))",p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.setAdministrator=function(e,t,o,s,i,a,u,c){return n(this,void 0,void 0,(function*(){const n=`(Right (Left (Right "${i}")))`;return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,a,c,u,"",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.mint=function(e,t,o,s,i,a,u,c=15e4,f=5e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Left (Pair "${a}" ${u})))))`;return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,i,f,c,"",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.burn=function(e,t,o,s,i,a,u,c,f){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Pair "${a}" ${u})))))`;return r((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,o,s,0,i,f,c,"",n,p.TezosParameterFormat.Michelson)).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=o(r(5)),i=r(4),a=r(3),u=r(9),c=o(r(7));!function(t){t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield a.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("0e3e137841a959521324b4ce20ca2df7"!==o)throw new Error(`Contract does not match the expected code hash: ${o}, '0e3e137841a959521324b4ce20ca2df7'`);return!0}))},t.verifyScript=function(t){const r=e.from(s.blake2s(i.TezosLanguageUtil.preProcessMichelsonScript(t).join("\n"),null,16)).toString("hex");if("b77ada691b1d630622bea243696c84d7"!==r)throw new Error(`Contract does not match the expected code hash: ${r}, 'b77ada691b1d630622bea243696c84d7'`);return!0},t.deployContract=function(e,t,r,o,s,i,a,l,p,f=!0,h=0,d=4e5,b=8e3){return n(this,void 0,void 0,(function*(){const n=`(Pair (Pair "${s}" ${f?"True":"False"}) (Pair (Pair (Pair { } (Pair (Pair (Pair ${p} { }) (Pair "${i}" "${a}")) ${l})) (Pair { } (Pair (Pair None (Right Unit)) (Pair (Right Unit) (Right Unit))))) ${h}))`,m=yield u.TezosNodeWriter.sendContractOriginationOperation(e,t,r,0,void 0,o,b,d,'{ parameter (or (or (or %admin (bool %pause) (address %set_admin)) (or %assets (or (or (pair %balance_of (contract %callback (list (pair (nat %balance) (pair %request (address %owner) (nat %token_id))))) (list %requests (pair (address %owner) (nat %token_id)))) (pair %is_operator (contract %callback (pair (bool %is_operator) (pair %operator (pair (address %operator) (address %owner)) (or %tokens (unit %all_tokens) (set %some_tokens nat))))) (pair %operator (pair (address %operator) (address %owner)) (or %tokens (unit %all_tokens) (set %some_tokens nat))))) (or (contract %permissions_descriptor (pair (pair (option %custom (pair (option %config_api address) (string %tag))) (or %operator (or (unit %no_transfer) (unit %owner_or_operator_transfer)) (unit %owner_transfer))) (pair (or %receiver (or (unit %optional_owner_hook) (unit %owner_no_op)) (unit %required_owner_hook)) (or %sender (or (unit %optional_owner_hook) (unit %owner_no_op)) (unit %required_owner_hook))))) (pair %token_metadata (contract %callback (list (pair (pair (pair (nat %decimals) (map %extras string string)) (pair (string %name) (string %symbol))) (nat %token_id)))) (list %token_ids nat)))) (or (or (pair %total_supply (contract %callback (list (pair (nat %token_id) (nat %total_supply)))) (list %token_ids nat)) (list %transfer (pair (pair (nat %amount) (address %from_)) (pair (address %to_) (nat %token_id))))) (list %update_operators (or (pair %add_operator (pair (address %operator) (address %owner)) (or %tokens (unit %all_tokens) (set %some_tokens nat))) (pair %remove_operator (pair (address %operator) (address %owner)) (or %tokens (unit %all_tokens) (set %some_tokens nat)))))))) (or %tokens (list %burn_tokens (pair (nat %amount) (address %owner))) (list %mint_tokens (pair (nat %amount) (address %owner))))) ;\n storage (pair (pair %admin (address %admin) (bool %paused)) (pair %assets (pair (pair (big_map %ledger address nat) (pair %metadata (pair (pair (nat %decimals) (map %extras string string)) (pair (string %name) (string %symbol))) (nat %token_id))) (pair (big_map %operators (pair address address) bool) (pair %permissions_descriptor (pair (option %custom (pair (option %config_api address) (string %tag))) (or %operator (or (unit %no_transfer) (unit %owner_or_operator_transfer)) (unit %owner_transfer))) (pair (or %receiver (or (unit %optional_owner_hook) (unit %owner_no_op)) (unit %required_owner_hook)) (or %sender (or (unit %optional_owner_hook) (unit %owner_no_op)) (unit %required_owner_hook)))))) (nat %total_supply))) ;\n code { 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 (list (pair (pair (nat %amount) (option %from_ address)) (pair (option %to_ address) (nat %token_id)))) (big_map address nat))) (big_map address nat) { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; CAR ; CDR ; 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 ; DUP ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 9 ; DUP ; DUG 10 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; CAR ; CDR ; DIG 1 ; DUP ; DUG 2 ; SUB ; ISNAT ; IF_NONE { PUSH string "INSUFFICIENT_BALANCE" ; 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 5 } } ; DIG 1 ; DUP ; DUG 2 ; CDR ; CAR ; IF_NONE { DUP } { DIG 1 ; DUP ; DUG 2 ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DUP ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DUP ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 10 ; DUP ; DUG 11 ; 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 } } ; DUP ; DIP { DROP 5 } } ; DIP { DROP 2 } } ; SWAP ; APPLY ; LAMBDA (or (unit %all_tokens) (set %some_tokens nat)) unit { DUP ; IF_LEFT { DROP ; UNIT } { PUSH nat 1 ; DIG 1 ; DUP ; DUG 2 ; SIZE ; COMPARE ; NEQ ; IF { PUSH string "TOKEN_UNDEFINED" ; FAILWITH } { DUP ; PUSH nat 0 ; MEM ; IF { UNIT } { PUSH string "TOKEN_UNDEFINED" ; FAILWITH } } ; DIP { DROP } } ; DIP { DROP } } ; LAMBDA (list nat) unit { DUP ; IF_CONS { PUSH nat 0 ; DIG 2 ; DUP ; DUG 3 ; SIZE ; COMPARE ; NEQ ; IF { PUSH string "TOKEN_UNDEFINED" ; FAILWITH } { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; COMPARE ; EQ ; IF { UNIT } { PUSH string "TOKEN_UNDEFINED" ; FAILWITH } } ; DIP { DROP 2 } } { PUSH string "NO_TOKEN_ID" ; FAILWITH } ; DIP { DROP } } ; LAMBDA (list (pair (nat %amount) (address %owner))) 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 (address %admin) (bool %paused)) unit { DUP ; CAR ; SENDER ; COMPARE ; NEQ ; IF { PUSH string "NOT_AN_ADMIN" ; FAILWITH } { UNIT } ; DIP { DROP } } ; DIG 6 ; DUP ; DUG 7 ; CDR ; DIG 7 ; DUP ; DUG 8 ; CAR ; IF_LEFT { DUP ; IF_LEFT { DIG 2 ; DUP ; DUG 3 ; CAR ; DIG 4 ; DUP ; DUG 5 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; CAR ; 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 ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; SWAP ; CAR ; PAIR ; DIP { DROP } ; NIL operation ; PAIR ; DIP { DROP } } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; SWAP ; CDR ; SWAP ; PAIR ; DIP { DROP } ; NIL operation ; PAIR ; DIP { DROP } } ; DIP { DROP 2 } ; DIG 4 ; DUP ; DUG 5 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SWAP ; CDR ; SWAP ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIP { DROP 3 } } { DIG 2 ; DUP ; DUG 3 ; 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 ; IF_LEFT { DIG 3 ; DUP ; DUG 4 ; CAR ; 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 { PUSH string "TOKEN_UNDEFINED" ; FAILWITH } { DIG 2 ; DUP ; DUG 3 ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; PAIR ; DIG 18 ; DUP ; DUG 19 ; SWAP ; EXEC ; DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DIP { DROP } } ; 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 2 } } { DUP ; CDR ; CDR ; DIG 13 ; DUP ; DUG 14 ; SWAP ; EXEC ; DIG 1 ; DUP ; DUG 2 ; CAR ; PUSH mutez 0 ; DIG 3 ; DUP ; DUG 4 ; CDR ; DIG 7 ; DUP ; DUG 8 ; CAR ; CDR ; CAR ; DIG 5 ; DUP ; DUG 6 ; CDR ; CAR ; CAR ; DIG 6 ; DUP ; DUG 7 ; CDR ; CAR ; CDR ; PAIR ; GET ; IF_NONE { PUSH bool False } { DUP ; DIP { DROP } } ; PAIR ; TRANSFER_TOKENS ; DIG 5 ; DUP ; DUG 6 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 3 } } ; DIP { DROP } } { DUP ; IF_LEFT { DUP ; PUSH mutez 0 ; DIG 5 ; DUP ; DUG 6 ; CAR ; CDR ; CDR ; TRANSFER_TOKENS ; DIG 4 ; DUP ; DUG 5 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 2 } } { DUP ; CDR ; DIG 12 ; DUP ; DUG 13 ; SWAP ; EXEC ; DIG 1 ; DUP ; DUG 2 ; CAR ; PUSH mutez 0 ; NIL (pair (pair (pair (nat %decimals) (map %extras string string)) (pair (string %name) (string %symbol))) (nat %token_id)) ; DIG 7 ; DUP ; DUG 8 ; CAR ; CAR ; CDR ; CONS ; TRANSFER_TOKENS ; DIG 5 ; DUP ; DUG 6 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 3 } } ; DIP { DROP } } ; DIP { DROP } } { DUP ; IF_LEFT { DUP ; IF_LEFT { DUP ; CDR ; DIG 12 ; DUP ; DUG 13 ; SWAP ; EXEC ; DIG 1 ; DUP ; DUG 2 ; CAR ; PUSH mutez 0 ; NIL (pair (nat %token_id) (nat %total_supply)) ; DIG 7 ; DUP ; DUG 8 ; CDR ; PUSH nat 0 ; PAIR ; CONS ; TRANSFER_TOKENS ; DIG 5 ; DUP ; DUG 6 ; NIL operation ; DIG 2 ; DUP ; DUG 3 ; CONS ; PAIR ; DIP { DROP 3 } } { DUP ; MAP { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; CDR ; COMPARE ; NEQ ; IF { PUSH string "TOKEN_UNDEFINED" ; FAILWITH } { DUP ; CDR ; CDR ; DIG 1 ; DUP ; DUG 2 ; CDR ; CAR ; SOME ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CDR ; SOME ; DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; PAIR ; PAIR } ; DIP { DROP } } ; DIG 4 ; DUP ; DUG 5 ; CAR ; CDR ; CAR ; DIG 5 ; DUP ; DUG 6 ; CAR ; CDR ; CDR ; CAR ; CDR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DUP ; CAR ; CDR ; IF_LEFT { DUP ; IF_LEFT { PUSH string "TX_DENIED" ; FAILWITH } { PUSH bool True ; PUSH bool True ; PAIR ; DIP { DROP } } ; DIP { DROP } } { PUSH bool False ; PUSH bool True ; PAIR ; DIP { DROP } } ; SENDER ; EMPTY_SET address ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; ITER { SWAP ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; CAR ; CDR ; IF_NONE { DUP } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PUSH bool True ; SWAP ; UPDATE ; DIP { DROP } } ; DIP { DROP 2 } } ; DUP ; ITER { DIG 2 ; DUP ; DUG 3 ; DIG 1 ; DUP ; DUG 2 ; COMPARE ; EQ ; DIG 4 ; DUP ; DUG 5 ; CAR ; AND ; IF { UNIT } { DIG 3 ; DUP ; DUG 4 ; CDR ; NOT ; IF { PUSH string "NOT_OWNER" ; FAILWITH } { DIG 4 ; DUP ; DUG 5 ; CDR ; DIG 3 ; DUP ; DUG 4 ; DIG 2 ; DUP ; DUG 3 ; PAIR ; GET ; IF_NONE { PUSH string "NOT_OPERATOR" ; FAILWITH } { DROP ; UNIT } } } ; DROP 2 } ; DROP 4 ; PUSH unit Unit ; DIG 5 ; DUP ; DUG 6 ; CAR ; CAR ; CAR ; DIG 2 ; DUP ; DUG 3 ; PAIR ; DIG 16 ; DUP ; DUG 17 ; SWAP ; EXEC ; DIG 6 ; DUP ; DUG 7 ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 4 } } ; DIP { DROP } } { DIG 2 ; DUP ; DUG 3 ; CAR ; CDR ; CAR ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CDR ; DIG 1 ; DUP ; DUG 2 ; CAR ; ITER { SWAP ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; IF_LEFT { DUP ; CDR ; DIG 16 ; DUP ; DUG 17 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; PUSH bool True ; SOME ; DIG 3 ; DUP ; DUG 4 ; CAR ; CAR ; DIG 4 ; DUP ; DUG 5 ; CAR ; CDR ; PAIR ; UPDATE ; DIP { DROP 2 } } { DUP ; CDR ; DIG 16 ; DUP ; DUG 17 ; SWAP ; EXEC ; DIG 2 ; DUP ; DUG 3 ; DIG 2 ; DUP ; DUG 3 ; CAR ; CAR ; DIG 3 ; DUP ; DUG 4 ; CAR ; CDR ; PAIR ; NONE bool ; SWAP ; UPDATE ; DIP { DROP 2 } } ; DIP { DROP 2 } } ; DIP { DROP } ; DIG 3 ; DUP ; DUG 4 ; DIG 1 ; DUP ; DUG 2 ; DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CDR } ; PAIR ; SWAP ; PAIR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 2 } } ; 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 ; DIG 1 ; DUP ; DUG 2 ; MAP { PUSH nat 0 ; NONE address ; PAIR ; DIG 1 ; DUP ; DUG 2 ; CDR ; SOME ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR ; PAIR ; DIP { DROP } } ; SENDER ; SELF ; ADDRESS ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DIP { DROP } ; DIG 1 ; DUP ; DUG 2 ; CAR ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CAR ; PAIR ; DIG 15 ; DUP ; DUG 16 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; DIG 13 ; DUP ; DUG 14 ; SWAP ; EXEC ; DUP ; DIG 4 ; DUP ; DUG 5 ; CDR ; SUB ; ISNAT ; DUP ; IF_NONE { PUSH string "INSUFFICIENT_BALANCE" ; FAILWITH } { DUP ; DIP { DROP } } ; DIG 5 ; DUP ; DUG 6 ; DIG 4 ; DUP ; DUG 5 ; DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; SWAP ; CAR ; PAIR ; NIL operation ; PAIR ; DIP { DROP 9 } } { DIG 1 ; DUP ; DUG 2 ; DIG 1 ; DUP ; DUG 2 ; PAIR ; DUP ; CAR ; DIG 1 ; DUP ; DUG 2 ; CDR ; DIG 1 ; DUP ; DUG 2 ; MAP { PUSH nat 0 ; DIG 1 ; DUP ; DUG 2 ; CDR ; SOME ; PAIR ; NONE address ; DIG 2 ; DUP ; DUG 3 ; CAR ; PAIR ; PAIR ; DIP { DROP } } ; SENDER ; SELF ; ADDRESS ; DIG 2 ; DUP ; DUG 3 ; PAIR ; PAIR ; DIP { DROP } ; DIG 1 ; DUP ; DUG 2 ; CAR ; CAR ; CAR ; DIG 1 ; DUP ; DUG 2 ; CAR ; CAR ; PAIR ; DIG 15 ; DUP ; DUG 16 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; DIG 13 ; DUP ; DUG 14 ; SWAP ; EXEC ; DIG 3 ; DUP ; DUG 4 ; DIG 2 ; DUP ; DUG 3 ; DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CDR ; SWAP ; CAR ; CDR } ; PAIR ; PAIR ; PAIR ; DIG 1 ; DUP ; DUG 2 ; DIG 5 ; DUP ; DUG 6 ; CDR ; ADD ; SWAP ; CAR ; PAIR ; DUP ; NIL operation ; PAIR ; DIP { DROP 8 } } ; 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 8 } } ;',n,c.TezosParameterFormat.Michelson);return m.operationGroupID.replace(/\"/g,"").replace(/\n/,"")}))},t.getSimpleStorage=function(e,t){return n(this,void 0,void 0,(function*(){return null}))},t.getAccountBalance=function(e,t,r){return n(this,void 0,void 0,(function*(){return 0}))}}(t.Tzip12ReferenceTokenHelper||(t.Tzip12ReferenceTokenHelper={}))}).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(5)),i=r(8),a=r(4),u=r(6),c=r(3),l=r(9),p=o(r(7));!function(t){function r(t,r,o){return n(this,void 0,void 0,(function*(){const n=e.from(u.TezosMessageUtils.writePackedData(o,"",p.TezosParameterFormat.Michelson),"hex"),s=u.TezosMessageUtils.writePackedData(n,"bytes"),l=u.TezosMessageUtils.encodeBigMapKey(e.from(s,"hex")),f=yield c.TezosNodeReader.getValueForBigMapKey(t,r,l);if(void 0===f)throw new Error(`Could not get data from map ${r} for '${o}'`);const h=i.JSONPath({path:"$.bytes",json:f})[0];return JSON.parse(a.TezosLanguageUtil.hexToMicheline(h.slice(2)).code)}))}function o(e){return e.replace(/\"/g,"").replace(/\n/,"")}t.verifyDestination=function(t,r){return n(this,void 0,void 0,(function*(){const n=yield c.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("187c967006ca95a648c770fdd76947ef"!==o)throw new Error(`Contract does not match the expected code hash: ${o}, '187c967006ca95a648c770fdd76947ef'`);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.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(i.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(i.JSONPath({path:"$.args[0].int",json:r})[0]),scale:8}}))},t.transferBalance=function(e,t,r,s,i,a,u,c,f=25e4,h=1e3){return n(this,void 0,void 0,(function*(){const n=`(Pair "${a}" (Pair "${u}" ${c}))`;return o((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,s,0,i,h,f,"transfer",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.approveBalance=function(e,t,r,s,i,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})))))))))`;return o((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,s,0,i,f,c,"",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.mintBalance=function(e,t,r,s,i,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})))))))))`;return o((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,s,0,i,f,c,"",n,p.TezosParameterFormat.Michelson)).operationGroupID)}))},t.addOperator=function(e,t,r,s,i,a,u=25e4,c=1e3){return n(this,void 0,void 0,(function*(){const n=`(Right (Right (Right (Right (Right (Left (Right (Left "${a}" ))))))))`;return o((yield l.TezosNodeWriter.sendContractInvocationOperation(e,t,r,s,0,i,c,u,"",n,p.TezosParameterFormat.Michelson)).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(28),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={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Mnemonic=0]="Mnemonic",e[e.Fundraiser=1]="Fundraiser",e[e.Hardware=2]="Hardware"}(t.KeyStoreType||(t.KeyStoreType={})),function(e){e[e.ED25519=0]="ED25519",e[e.SECP256K1=1]="SECP256K1",e[e.SECP256R1=2]="SECP256R1"}(t.KeyStoreCurve||(t.KeyStoreCurve={}))}])}));
\ No newline at end of file
diff --git a/docs/.nojekyll b/ConseilJS-core/docs/.nojekyll
similarity index 100%
rename from docs/.nojekyll
rename to ConseilJS-core/docs/.nojekyll
diff --git a/ConseilJS-core/docs/README.md b/ConseilJS-core/docs/README.md
new file mode 100644
index 00000000..b2dfba28
--- /dev/null
+++ b/ConseilJS-core/docs/README.md
@@ -0,0 +1,1851 @@
+
+# ConseilJS
+
+[![npm version](https://img.shields.io/npm/v/conseiljs.svg)](https://www.npmjs.com/package/conseiljs)
+[![npm](https://img.shields.io/npm/dm/conseiljs.svg)](https://www.npmjs.com/package/conseiljs)
+[![Build Status](https://travis-ci.org/Cryptonomic/ConseilJS.svg?branch=master)](https://travis-ci.org/Cryptonomic/ConseilJS)
+[![Coverage Status](https://coveralls.io/repos/github/Cryptonomic/ConseilJS/badge.svg?branch=master)](https://coveralls.io/github/Cryptonomic/ConseilJS?branch=master)
+[![dependencies](https://david-dm.org/Cryptonomic/ConseilJS/status.svg)](https://david-dm.org/Cryptonomic/ConseilJS)
+
+A library for building decentralized applications in Typescript and Javascript, currently focused on the [Tezos](http://tezos.com/) platform.
+
+ConseilJS connects to Tezos nodes for live chain data and operations and to [Conseil](https://github.com/Cryptonomic/Conseil) servers for high-performance analytics on blockchain data. Internally, Cryptonomic uses [Nautilus](https://github.com/Cryptonomic/Nautilus) for infrastructure deployments of these services. This is the library at the core of our products, [Arronax](https://arronax.io), [Mininax](https://mininax.io) and certainly [Galleon](https://galleon-wallet.tech). There are [ReasonML bindings](https://github.com/Cryptonomic/ConseilJS-ReasonML-Bindings) as well.
+
+Cryptonomic offers an infrastructure service - [Nautilus Cloud](https://nautilus.cloud) which enables quick access to the Tezos platform along with products that make it easier build on it.
+
+## Other Resources
+
+In addition to these materials, there is an [automated walk-through for common Tezos workflows](https://gist.github.com/anonymoussprocket/148d82fc9bf6c413be04155a90d57be6) available. The [mininax](https://mininax.io) block explorer is handy for viewing operations submitted during that run. Cryptonomic holds regular dApp development workshops internationally, if you are interested in one, reach out to organize it. The materials for these events are continuously updated and [are available](https://medium.com/the-cryptonomic-aperiodical/blockchain-development-with-tezos-698aa930e50f) on [Medium](https://medium.com/the-cryptonomic-aperiodical).
+
+## Use with Nodejs
+
+Add our [NPM package](https://www.npmjs.com/package/conseiljs) to your project.
+
+```bash
+npm i conseiljs
+```
+
+If you are using webpack in your project, add below lines to your `webpack.config.js` file:
+
+```javascript
+node: { fs: 'empty' }
+```
+
+We have a complete [React application example](https://github.com/Cryptonomic/ConseilJS-Tutorials) for you to check out.
+
+## Use with Web
+
+```html
+
+```
+
+A fully functional sample [webpage example](https://github.com/Cryptonomic/ConseilJS-HTML-Example) is available too.
+
+## API Overview and Examples
+
+### Logs
+
+When using ConseilJS in the context of Nodejs, it's possible to control how verbose the logs are.
+
+
+#### **Typescript**
+
+```typescript
+import { setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+```
+
+#### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+
+conseiljs.setLogLevel('debug');
+```
+
+
+Default log level is 'error', the library used internally for logging is [loglevel](https://www.npmjs.com/package/loglevel). For more verbose logs, set it to 'info'.
+
+### Contract Development Lightning Route
+
+If you want to skip straight to working on Michelson smart contracts simply follow these instructions in the following order:
+
+1. [Create node project](https://nodejs.org/en/docs/guides/getting-started-guide/)
+2. [Install ConseilJS](#Use-with-Nodejs)
+3. [Get an API key](#API-Key)
+4. [Create a Tezos testnet account](#Create-an-Tezos-testnet-account)
+5. [Initialize the account](#Initialize-the-account)
+6. [Deploy a contract](#Deploy-a-Contract)
+7. [Invoke a contract](#Invoke-a-Contract)
+
+### Blockchain Analytics Lightning Route
+
+If your interests lay in statistics and business intelligence, ConseilJS has tools for that as well. While for heavier data extraction using [Conseil](https://cryptonomic.github.io/Conseil) directly may make more sense, if you are building user tools like dashboards ConseilJS will make the process vastly easier.
+
+1. [Create node project](https://nodejs.org/en/docs/guides/getting-started-guide/)
+1. [Install ConseilJS](#Use-with-Nodejs)
+1. [Get an API key](#API-Key)
+1. [Run reports](#reporting--analytics-functions)
+
+### API Key
+
+Some ConseilJS functions require an API key for a Conseil service instance. While direct chain interactions happen via a Tezos node, Conseil read operations like those in `TezosConseilClient` namespace do require an API key however.
+
+Obtaining a development key is easy. Cryptonomic offers an infrastructure service - [Nautilus Cloud](https://nautilus.cloud) which enables quick access to the Tezos platform along with products that make it easier build on it.
+
+### Tezos Chain Operations
+
+To execute operations on the Tezos chain a link to a Tezos node is required. One can be found after logging into [Nautilus Cloud](https://nautilus.cloud) for both testnet and mainnet. Be sure to initialize the `tezosNode` variable accordingly. Interface to this functionality is in the `TezosNodeWriter` namespace.
+
+#### Create a Tezos testnet account
+
+Visit the [Faucet](https://faucet.tzalpha.net) to get a test account with a healthy balance of fake XTZ to play with. With this information we can create the public and private keys necessary to participate in one of the test networks. Cryptnomic provides access to the Tezos **mainnet** and **carthagenet** networks via [Nautilus Cloud](https://nautilus.cloud). In the below examples, `faucetAccount` is assigned the contents of the file the faucet produces.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosWalletUtil } from 'conseiljs';
+
+const faucetAccount = {
+ "mnemonic": [ "letter", "pair", "shuffle", "exotic", "sword", "west", "build", "monster", "future", "senior", "salt", "satisfy", "knock", "alert", "gorilla"],
+ "secret": "0a09075426ab2658814c1faf101f53e5209a62f5",
+ "amount": "5652123072",
+ "pkh": "tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy",
+ "password": "VvLbJMu1fF",
+ "email": "yoyhmapi.ugewcsiv@tezos.example.org"
+}
+
+async function initAccount() {
+ const keystore = await TezosWalletUtil.unlockFundraiserIdentity(faucetAccount.mnemonic.join(' '), faucetAccount.email, faucetAccount.password, faucetAccount.pkh);
+ console.log(`public key: ${keystore.publicKey}`);
+ console.log(`secret key: ${keystore.privateKey}`);
+}
+
+initAccount();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const faucetAccount = {
+ "mnemonic": [ "letter", "pair", "shuffle", "exotic", "sword", "west", "build", "monster", "future", "senior", "salt", "satisfy", "knock", "alert", "gorilla"],
+ "secret": "0a09075426ab2658814c1faf101f53e5209a62f5",
+ "amount": "5652123072",
+ "pkh": "tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy",
+ "password": "VvLbJMu1fF",
+ "email": "yoyhmapi.ugewcsiv@tezos.example.org"
+}
+
+async function initAccount() {
+ const keystore = await conseiljs.TezosWalletUtil.unlockFundraiserIdentity(faucetAccount.mnemonic.join(' '), faucetAccount.email, faucetAccount.password, faucetAccount.pkh);
+ console.log(`public key: ${keystore.publicKey}`);
+ console.log(`secret key: ${keystore.privateKey}`);
+}
+
+initAccount();
+```
+
+
+This produces a public key of `edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj` and secret key of `edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH`. **Secret keys must be kept secure!**
+
+#### Create an empty Tezos account
+
+It is also possible to create unattached accounts on the chain. This would be the process for making accounts on mainnet that are not fundraiser accounts. Note that `unlockIdentityWithMnemonic` takes an optional password. This is not the same password that may have been used to encrypt the `TezosFileWallet` file. Presenting the intermediate mnemonic to the user may aid in key recovery.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosWalletUtil } from 'conseiljs';
+
+async function createAccount() {
+ const mnemonic = TezosWalletUtil.generateMnemonic();
+ console.log(`mnemonic: ${mnemonic}`);
+ const keystore = await TezosWalletUtil.unlockIdentityWithMnemonic(mnemonic, '');
+ console.log(`account id: ${keystore.publicKeyHash}`);
+ console.log(`public key: ${keystore.publicKey}`);
+ console.log(`secret key: ${keystore.privateKey}`);
+}
+
+createAccount();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+
+async function createAccount() {
+ const mnemonic = conseiljs.TezosWalletUtil.generateMnemonic();
+ console.log(`mnemonic: ${mnemonic}`);
+ const keystore = await conseiljs.TezosWalletUtil.unlockIdentityWithMnemonic(mnemonic, '');
+ console.log(`account id: ${keystore.publicKeyHash}`);
+ console.log(`public key: ${keystore.publicKey}`);
+ console.log(`secret key: ${keystore.privateKey}`);
+}
+
+createAccount();
+```
+
+
+#### Initialize the account
+
+An account must be activated on the chain before it can be used. With the combination of the faucet output and the keys generated in the step above we can send an account activation operation.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosNodeWriter, StoreType } from 'conseiljs';
+
+const tezosNode = '';
+
+async function activateAccount() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const result = await TezosNodeWriter.sendIdentityActivationOperation(tezosNode, keystore, '0a09075426ab2658814c1faf101f53e5209a62f5');
+ console.log(`Injected operation group id ${result.operationGroupID}`)
+}
+
+activateAccount();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+async function activateAccount() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const result = await conseiljs.TezosNodeWriter.sendIdentityActivationOperation(tezosNode, keystore, '0a09075426ab2658814c1faf101f53e5209a62f5');
+ console.log(`Injected operation group id ${result.operationGroupID}`)
+}
+
+activateAccount();
+
+```
+
+
+The next step on Tezos is an account revelation.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosNodeWriter, StoreType } from 'conseiljs';
+
+const tezosNode = '';
+
+async function revealAccount() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+
+ const result = await TezosNodeWriter.sendKeyRevealOperation(tezosNode, keystore);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+revealAccount();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+async function revealAccount() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+
+ const result = await conseiljs.TezosNodeWriter.sendKeyRevealOperation(tezosNode, keystore);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+revealAccount();
+```
+
+
+#### Transfer value
+
+The most basic operation on the chain is the transfer of value between two accounts. In this example we have the account we activated above: `tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy` and some random carthagenet address to test with: `tz1RVcUP9nUurgEJMDou8eW3bVDs6qmP5Lnc`. Note all amounts are in µtz, as in micro-tez, hence 0.5tz is represented as `500000`.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosNodeWriter, StoreType } from 'conseiljs';
+
+const tezosNode = '';
+
+async function sendTransaction() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+
+ const result = await TezosNodeWriter.sendTransactionOperation(tezosNode, keystore, 'tz1RVcUP9nUurgEJMDou8eW3bVDs6qmP5Lnc', 500000, 1500, '');
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+sendTransaction();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+async function sendTransaction() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+
+ const result = await conseiljs.TezosNodeWriter.sendTransactionOperation(tezosNode, keystore, 'tz1RVcUP9nUurgEJMDou8eW3bVDs6qmP5Lnc', 500000, 1500, '');
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+sendTransaction();
+```
+
+
+#### Delegate
+
+One of the most exciting features of Tezos is delegation. This is a means for non-baker accounts to participate in the on-chain governance process and receive staking rewards. It is possible to delegate both implicit and originated accounts. For implicit addresses, those starting with tz1, tz2 and tz3, simply call `sendDelegationOperation`. Originated accounts, that is smart contracts, must explicitly support delegate setting, but can be deployed with a delegate already set.
+
+Note that calling `sendDelegationOperation` will change an existing delegation if one is set. To cancel delegation use `sendUndelegationOperation`.
+
+Another important point is that delegation is applied per account for the full balance of that account. To delegate to multiple bakers from a single address, use `BabylonDelegationHelper`.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosNodeWriter, StoreType } from 'conseiljs';
+
+const tezosNode = '';
+
+async function delegateAccount() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+
+ const result = await TezosNodeWriter.sendDelegationOperation(tezosNode, keystore, keystore.publicKeyHash, 'tz1LhS2WFCinpwUTdUb991ocL2D9Uk6FJGJK', 10000);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+delegateAccount();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+async function delegateAccount() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+
+ const result = await conseiljs.TezosNodeWriter.sendDelegationOperation(tezosNode, keystore, keystore.publicKeyHash, 'tz1LhS2WFCinpwUTdUb991ocL2D9Uk6FJGJK', 10000);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+delegateAccount();
+```
+
+
+### Smart Contract Interactions
+
+Tezos smart contracts are natively executed in a stack-based type-safe language called Michelson. As of version 0.2.7, ConseilJS is able to deploy a large portion of contracts written in that language. Rather than compose contracts directly in Michelson, we encourage you to look at more developer-friendly options like [SmartPy](http://smartpy.io/demo/).
+
+#### Deploy a Contract
+
+A note of warning, as of Tezos Protocol 4, deployed in the spring of 2019, originated accounts with code (smart contracts) are no longer 'spendable'. What this means is, deploying a contract with an initial balance that does not have functionality internally that enables transfer of this balance, will permanently lock that amount of XTZ.
+
+One of the more existing features of ConseilJS is that it allow for trustless chain interactions, including contract deployment directly from Michelson. For the curious the language parsing and transformation code lives inside the following: [`Michelson.ne`](https://github.com/Cryptonomic/ConseilJS/blob/master/grammar/tezos/Michelson.ne), [`Micheline.ne`](https://github.com/Cryptonomic/ConseilJS/blob/master/grammar/tezos/Micheline.ne), [`TezosLanguageUtil`](https://github.com/Cryptonomic/ConseilJS/blob/master/src/chain/tezos/TezosLanguageUtil.ts)), [`TezosMessageCodec`](https://github.com/Cryptonomic/ConseilJS/blob/master/src/chain/tezos/TezosMessageCodec.ts), [`TezosMessageUtil`](https://github.com/Cryptonomic/ConseilJS/blob/master/src/chain/tezos/TezosMessageUtil.ts). To find out more about the Michelson language, visit [the guide](https://michelson.nomadic-labs.com) from Nomadic Labs and the [Tezos platform documentation](https://tezos.gitlab.io/whitedoc/michelson.html).
+
+
+##### **Typescript**
+
+```typescript
+import { StoreType, TezosNodeWriter, TezosParameterFormat, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function deployContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const contract = `[
+ {
+ "prim":"parameter",
+ "args":[ { "prim":"string" } ]
+ },
+ {
+ "prim":"storage",
+ "args":[ { "prim":"string" } ]
+ },
+ {
+ "prim":"code",
+ "args":[
+ [
+ { "prim":"CAR" },
+ { "prim":"NIL", "args":[ { "prim":"operation" } ] },
+ { "prim":"PAIR" }
+ ]
+ ]
+ }
+ ]`;
+ const storage = '{"string": "Sample"}';
+
+ const result = await TezosNodeWriter.sendContractOriginationOperation(tezosNode, keystore, 0, undefined, 100000, '', 1000, 100000, contract, storage, TezosParameterFormat.Micheline);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+deployContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+setLogLevel('debug');
+
+async function deployContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const contract = `[
+ {
+ "prim":"parameter",
+ "args":[ { "prim":"string" } ]
+ },
+ {
+ "prim":"storage",
+ "args":[ { "prim":"string" } ]
+ },
+ {
+ "prim":"code",
+ "args":[
+ [
+ { "prim":"CAR" },
+ { "prim":"NIL", "args":[ { "prim":"operation" } ] },
+ { "prim":"PAIR" }
+ ]
+ ]
+ }
+ ]`;
+ const storage = '{"string": "Sample"}';
+
+ const result = await conseiljs.TezosNodeWriter.sendContractOriginationOperation(tezosNode, keystore, 0, undefined, 100000, '', 1000, 100000, contract, storage, conseiljs.TezosParameterFormat.Micheline);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+deployContract();
+
+```
+
+
+It's possible to deploy a contract with Michelson code on an experimental basis with local forging as of ConseilJS 0.2.7. Another important feature introduced in that release was `awaitOperationConfirmation(...)` which will monitor the chain via Conseil waiting for the specified operation to appear, and then return the result set from Conseil for that operation. This can be used to ensure that the requested transaction has occured, it will also produce an updated account counter. The example below originates a contract and then waits for it to be recorded so the address of the new contract can be extracted.
+
+
+##### **Typescript**
+
+```typescript
+import { StoreType, TezosNodeWriter, TezosParameterFormat, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function deployContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const contract = `parameter string;
+ storage string;
+ code { DUP;
+ DIP { CDR ; NIL string ; SWAP ; CONS } ;
+ CAR ; CONS ;
+ CONCAT;
+ NIL operation; PAIR}`;
+ const storage = '"Sample"';
+
+ const nodeResult = await TezosNodeWriter.sendContractOriginationOperation(tezosNode, keystore, 0, undefined, 100000, '', 1000, 100000, contract, storage, TezosParameterFormat.Michelson);
+
+ const groupid = nodeResult['operationGroupID'].replace(/\"/g, '').replace(/\n/, ''); // clean up RPC output
+ console.log(`Injected operation group id ${groupid}`);
+ const conseilResult = await TezosConseilClient.awaitOperationConfirmation(conseilServer, 'carthagenet', groupid, 5);
+ console.log(`Originated contract at ${conseilResult[0].originated_contracts}`);
+}
+
+deployContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+const network = 'carthagenet';
+const conseilServer = { url: '', apiKey: '', network };
+
+conseiljs.setLogLevel('debug');
+
+async function deployContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const contract = `parameter string;
+ storage string;
+ code { DUP;
+ DIP { CDR ; NIL string ; SWAP ; CONS } ;
+ CAR ; CONS ;
+ CONCAT;
+ NIL operation; PAIR}`;
+ const storage = '"Sample"';
+
+ const nodeResult = await conseiljs.TezosNodeWriter.sendContractOriginationOperation(tezosNode, keystore, 0, undefined, 100000, '', 1000, 100000, contract, storage, conseiljs.TezosParameterFormat.Michelson);
+
+ const groupid = nodeResult['operationGroupID'].replace(/\"/g, '').replace(/\n/, ''); // clean up RPC output
+ console.log(`Injected operation group id ${groupid}`);
+ const conseilResult = await conseiljs.TezosConseilClient.awaitOperationConfirmation(conseilServer, 'carthagenet', groupid, 5);
+ console.log(`Originated contract at ${conseilResult[0].originated_accounts}`);
+}
+
+deployContract();
+
+```
+
+
+#### Invoke a Contract
+
+Similarly to contract deployment, contract invocation can happen either with Michelson or Micheline format. There is also a convenience function for safety, `sendContractPing` that allows calling a contract with a 0 amount and no parameters. This was the invocation pattern for the Tezos Foundation [Ledger Nano S giveaway](https://tezos.foundation/news/tezos-foundation-to-give-away-ledger-nano-s-hardware-wallets-to-celebrate-one-year-since-betanet-launch) [registry contract](https://arronax.io?e=Tezos%20Mainnet/operations&q=eyJmaWVsZHMiOlsidGltZXN0YW1wIiwiYmxvY2tfbGV2ZWwiLCJzb3VyY2UiLCJkZXN0aW5hdGlvbiIsImFtb3VudCIsImtpbmQiLCJmZWUiLCJvcGVyYXRpb25fZ3JvdXBfaGFzaCJdLCJwcmVkaWNhdGVzIjpbeyJmaWVsZCI6ImtpbmQiLCJvcGVyYXRpb24iOiJlcSIsInNldCI6WyJ0cmFuc2FjdGlvbiJdLCJpbnZlcnNlIjpmYWxzZX0seyJmaWVsZCI6InRpbWVzdGFtcCIsIm9wZXJhdGlvbiI6ImFmdGVyIiwic2V0IjpbMTU1OTM2MTYwMDAwMF0sImludmVyc2UiOmZhbHNlfSx7ImZpZWxkIjoiZGVzdGluYXRpb24iLCJvcGVyYXRpb24iOiJlcSIsInNldCI6WyJLVDFCUnVkRlpFWExZQU5nbVpUa2ExeENETjVuV1RNV1k3U1oiXSwiaW52ZXJzZSI6ZmFsc2V9LHsiZmllbGQiOiJ0aW1lc3RhbXAiLCJvcGVyYXRpb24iOiJiZWZvcmUiLCJzZXQiOlsxNTYzMjQ5NjAwMDAwXSwiaW52ZXJzZSI6ZmFsc2V9LHsiZmllbGQiOiJzdGF0dXMiLCJvcGVyYXRpb24iOiJlcSIsInNldCI6WyJhcHBsaWVkIl0sImludmVyc2UiOmZhbHNlfV0sIm9yZGVyQnkiOlt7ImZpZWxkIjoidGltZXN0YW1wIiwiZGlyZWN0aW9uIjoiYXNjIn1dLCJsaW1pdCI6NTAwMH0).
+
+
+##### **Typescript**
+
+```typescript
+import { StoreType, TezosNodeWriter, TezosParameterFormat, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function invokeContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
+
+ const result = await TezosNodeWriter.sendContractInvocationOperation(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000, '"Cryptonomicon"', TezosParameterFormat.Michelson);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+invokeContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+conseiljs.setLogLevel('debug');
+
+async function invokeContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
+
+ const result = await conseiljs.TezosNodeWriter.sendContractInvocationOperation(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000, '"Cryptonomicon"', conseiljs.TezosParameterFormat.Michelson);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+invokeContract();
+```
+
+
+
+##### **Typescript**
+
+```typescript
+import { StoreType, TezosNodeWriter, TezosParameterFormat, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function invokeContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
+
+ const result = await TezosNodeWriter.sendContractInvocationOperation(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000, '', '{"string": "Cryptonomicon"}', TezosParameterFormat.Micheline);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+invokeContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+conseiljs.setLogLevel('debug');
+
+async function invokeContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
+
+ const result = await conseiljs.TezosNodeWriter.sendContractInvocationOperation(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000, '', '{"string": "Cryptonomicon"}', conseiljs.TezosParameterFormat.Micheline);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+invokeContract();
+```
+
+
+
+##### **Typescript**
+
+```typescript
+import { StoreType, TezosNodeWriter, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function pingContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
+
+ const result = await TezosNodeWriter.sendContractPing(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+pingContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+conseiljs.setLogLevel('debug');
+
+async function pingContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
+
+ const result = await conseiljs.TezosNodeWriter.sendContractPing(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+pingContract();
+```
+
+
+#### Extract Entry Points
+
+Michelson contract are single-entry, meaning unlike other smart contract languages it only has one function that can be called externally. The work-around for this limitation is to create a tree of `if` statements inside that method that perform different operations. This results in a somewhat unintuitive invocation pattern. To help with this, ConseilJS provide contract introspection functions that can not only extract the entry points given a contract, but also generate the invocation parameter object for them. This functionality resides in the `TezosContractIntrospector` namespace which has several methods for parsing the interface given a contract address, full contract code or just the `parameter` portion of the contract: `generateEntryPointsFromAddress`, `generateEntryPointsFromCode`, `generateEntryPointsFromParams` respectively. Examples below use a version the proposed Tezos token standard, [FA1.2](https://gitlab.com/tzip/tzip/blob/master/A/FA1.2.md) deployed on alphanet at [KT1XFXwWCDMLkgWjhfqKUpDtBYWf3ZdUdKC3](https://arronax.io?e=Tezos%20Alphanet/accounts&m=true&q=eyJmaWVsZHMiOlsiYWNjb3VudF9pZCIsIm1hbmFnZXIiLCJiYWxhbmNlIiwic2NyaXB0Iiwic3RvcmFnZSIsImJsb2NrX2xldmVsIl0sInByZWRpY2F0ZXMiOlt7ImZpZWxkIjoiYWNjb3VudF9pZCIsIm9wZXJhdGlvbiI6ImVxIiwic2V0IjpbIktUMVhGWHdXQ0RNTGtnV2poZnFLVXBEdEJZV2YzWmRVZEtDMyJdLCJpbnZlcnNlIjpmYWxzZX1dLCJvcmRlckJ5IjpbeyJmaWVsZCI6ImJsb2NrX2xldmVsIiwiZGlyZWN0aW9uIjoiZGVzYyJ9XSwiYWdncmVnYXRpb24iOltdLCJsaW1pdCI6MTAwMH0).
+
+
+##### **Typescript**
+
+```typescript
+import { TezosContractIntrospector, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function interrogateContract() {
+ const contractParameters = `parameter (or (or (or (pair %transfer (address :from) (pair (address :to) (nat :value))) (or (pair %transferViaProxy (address :sender) (pair (address :from) (pair (address :to) (nat :value)))) (pair %approve (address :spender) (nat :value)))) (or (pair %approveViaProxy (address :sender) (pair (address :spender) (nat :value))) (or (pair %getAllowance (pair (address :owner) (address :spender)) (contract nat)) (pair %getBalance (address :owner) (contract nat))))) (or (or (pair %getTotalSupply unit (contract nat)) (or (bool %setPause) (address %setAdministrator))) (or (or (pair %getAdministrator unit (contract address)) (pair %mint (address :to) (nat :value))) (or (pair %burn (address :from) (nat :value)) (address %setProxy)))));`;
+
+ const entryPoints = await TezosContractIntrospector.generateEntryPointsFromParams(contractParameters);
+ entryPoints.forEach(p => {
+ console.log(`${p.name}(${p.parameters.map(pp => (pp.name || 'unnamed') + '/' + pp.type).join(', ')})`);
+ });
+
+ console.log(entryPoints[0].generateParameter('', '', 999));
+}
+
+interrogateContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+conseiljs.setLogLevel('debug');
+
+async function interrogateContract() {
+ const contractParameters = `parameter (or (or (or (pair %transfer (address :from) (pair (address :to) (nat :value))) (or (pair %transferViaProxy (address :sender) (pair (address :from) (pair (address :to) (nat :value)))) (pair %approve (address :spender) (nat :value)))) (or (pair %approveViaProxy (address :sender) (pair (address :spender) (nat :value))) (or (pair %getAllowance (pair (address :owner) (address :spender)) (contract nat)) (pair %getBalance (address :owner) (contract nat))))) (or (or (pair %getTotalSupply unit (contract nat)) (or (bool %setPause) (address %setAdministrator))) (or (or (pair %getAdministrator unit (contract address)) (pair %mint (address :to) (nat :value))) (or (pair %burn (address :from) (nat :value)) (address %setProxy)))));`;
+
+ const entryPoints = await conseiljs.TezosContractIntrospector.generateEntryPointsFromParams(contractParameters);
+ entryPoints.forEach(p => {
+ console.log(`${p.name}(${p.parameters.map(pp => (pp.name || 'unnamed') + '/' + pp.type).join(', ')})`);
+ });
+
+ console.log(entryPoints[0].generateParameter('', '', 999));
+}
+
+interrogateContract();
+```
+
+
+The output of the entry point iteration and a sample invocation pattern are below.
+
+```text
+%transfer(:from/address, :to/address, :value/nat)
+%transferViaProxy(:sender/address, :from/address, :to/address, :value/nat)
+%approve(:spender/address, :value/nat)
+%approveViaProxy(:sender/address, :spender/address, :value/nat)
+%getAllowance(:owner/address, :spender/address, unnamed/contract (nat))
+%getBalance(:owner/address, unnamed/contract (nat))
+%getTotalSupply(unnamed/unit, unnamed/contract (nat))
+%setPause(unnamed/bool)
+%setAdministrator(unnamed/address)
+%getAdministrator(unnamed/unit, unnamed/contract (address))
+%mint(:to/address, :value/nat)
+%burn(:from/address, :value/nat)
+%setProxy(unnamed/address)
+
+(Left (Left (Left (Pair source-address (Pair destination-address 999)))))
+```
+
+Invoking this contract is now obvious! Don't forget that the make this call correctly, you'll need to substitue 'source-address' and 'destination-address' values for proper addresses, futhermore there are restrictions in the contract on who can execute various methods. In this case it must be either the token manager or the 'source-address' account.
+
+
+##### **Typescript**
+
+```typescript
+import { StoreType, TezosNodeWriter, TezosParameterFormat, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+const tezosNode = '';
+
+async function invokeContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1XFXwWCDMLkgWjhfqKUpDtBYWf3ZdUdKC3';
+
+ const result = await TezosNodeWriter.sendContractInvocationOperation(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000, '(Left (Left (Left (Pair source-address (Pair destination-address 999)))))', , TezosParameterFormat.Michelson);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+invokeContract();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+conseiljs.setLogLevel('debug');
+
+async function invokeContract() {
+ const keystore = {
+ publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
+ privateKey: 'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
+ publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
+ seed: '',
+ storeType: conseiljs.StoreType.Fundraiser
+ };
+ const contractAddress = 'KT1XFXwWCDMLkgWjhfqKUpDtBYWf3ZdUdKC3';
+
+ const result = await conseiljs.TezosNodeWriter.sendContractInvocationOperation(tezosNode, keystore, contractAddress, 10000, 100000, '', 1000, 100000, '(Left (Left (Left (Pair source-address (Pair destination-address 999)))))', , conseiljs.TezosParameterFormat.Michelson);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+invokeContract();
+```
+
+
+### Tezos Chain Operations with Hardware Devices
+
+ConseilJS supports operation signing with [Ledger Nano S](https://shop.ledger.com/products/ledger-nano-s) devices. The interactions are largely the same as with software-signed operations. This functionality is encapsulated in the `TezosLedgerWallet` namespace. Before a Ledger-bound account can be used, it must be unlocked as described below. After that, retrieve and cache the account address, finally to sign transactions with the Ledger, pass the `derivationPath` parameter to the various interaction functions. Remember that the private key never leaves the device, hence the `KeyStore` object returned by `unlockAddress` will not have that field populated.
+
+#### Unlock an Account
+
+
+##### **Typescript**
+
+```typescript
+import { HardwareDeviceType, TezosLedgerWallet, setLogLevel } from 'conseiljs';
+
+setLogLevel('debug');
+
+async function unlockAccount(derivationPath) {
+ const keyStore = await TezosLedgerWallet.unlockAddress(HardwareDeviceType.LedgerNanoS, derivationPath);
+
+ console.log(`Unlocked Ledger account at ${derivationPath} as ${keyStore.publicKeyHash}`);
+}
+
+unlockAccount("44'/1729'/0'/0'/0'");
+```
+
+##### **JavaScript (node)**
+
+```javascript
+const conseiljs = require('conseiljs');
+
+conseiljs.setLogLevel('debug');
+
+async function unlockAccount(derivationPath) {
+ const keyStore = await conseiljs.TezosLedgerWallet.unlockAddress(conseiljs.HardwareDeviceType.LedgerNanoS, derivationPath);
+
+ console.log(`Unlocked Ledger account at ${derivationPath} as ${keyStore.publicKeyHash}`);
+}
+
+unlockAccount("44'/1729'/0'/0'/0'");
+```
+
+
+#### Transfer Value
+
+The difference between the code below and what was described earlier is the last parameter of the `sendTransactionOperation` function. The derivation path that needs to be invoked on the Ledger device to sign the transaction. The code also unlocks the account in this example. It is not necessary to do this every time an operation is sent to the chain, it's listed below for completeness. This is just one operation sample, all chain interactions with a Ledger device require a `derivationPath` parameter to be provided.
+
+
+##### **Typescript**
+
+```typescript
+import { TezosNodeWriter, StoreType } from 'conseiljs';
+
+const tezosNode = '';
+
+async function sendTransaction(derivationPath: string) {
+ const keyStore = await TezosLedgerWallet.unlockAddress(HardwareDeviceType.LedgerNanoS, derivationPath);
+
+ const result = await TezosNodeWriter.sendTransactionOperation(tezosNode, keyStore, 'tz1RVcUP9nUurgEJMDou8eW3bVDs6qmP5Lnc', 500000, 1500, derivationPath);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+sendTransaction("44'/1729'/0'/0'/0'");
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const tezosNode = '';
+
+async function sendTransaction(derivationPath) {
+ const keyStore = await TezosLedgerWallet.unlockAddress(HardwareDeviceType.LedgerNanoS, derivationPath);
+
+ const result = await conseiljs.TezosNodeWriter.sendTransactionOperation(tezosNode, keyStore, 'tz1RVcUP9nUurgEJMDou8eW3bVDs6qmP5Lnc', 500000, 1500, derivationPath);
+ console.log(`Injected operation group id ${result.operationGroupID}`);
+}
+
+sendTransaction("44'/1729'/0'/0'/0'");
+```
+
+
+### Metadata Discovery Functions
+
+[Conseil](https://github.com/Cryptonomic/Conseil) blockchain indexer service is metadata-driven. Reports can be constructed in a fully dynamic fashion by discovering what a particular Conseil node has available. Unless you are running your own [Nautilus](https://github.com/Cryptonomic/Nautilus) instance, you'll need access to an existing one. Cryptonomic provides an infrastructure service for Tezos – [Nautilus Cloud](https://nautilus.cloud).
+
+All metadata functions are in the `ConseilMetadataClient` namespace. Internally all of these are REST GET requests. An `apiKey` header is required. The ConseilJS api takes care of these details. Each successive request relies on the results of the previous one. Using the information provide by this service it's possible to construct data queries discussed in the next section.
+
+#### Platforms
+
+Query for available platforms.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilMetadataClient } from 'conseiljs';
+import * as util from 'util';
+
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listPlatforms() {
+ const platforms = await ConseilMetadataClient.getPlatforms(conseilServerInfo);
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listPlatforms();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listPlatforms() {
+ const platforms = await conseiljs.ConseilMetadataClient.getPlatforms(conseilServerInfo);
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listPlatforms();
+```
+
+
+A result set may look like this:
+
+```json
+[ { "name": "tezos", "displayName": "Tezos" } ]
+```
+
+#### Networks
+
+Query for networks under the `Tezos` platform.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilMetadataClient } from 'conseiljs';
+import * as util from 'util';
+
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listNetworks() {
+ const platforms = await ConseilMetadataClient.getNetworks(conseilServerInfo, 'tezos');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listNetworks();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listNetworks() {
+ const platforms = await conseiljs.ConseilMetadataClient.getNetworks(conseilServerInfo, 'tezos');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listNetworks();
+```
+
+
+The service might return:
+
+```json
+[ { "name": "zeronet", "displayName": "Zeronet", "platform": "tezos", "network": "zeronet" },
+ { "name": "carthagenet", "displayName": "carthagenet", "platform": "tezos", "network": "carthagenet" } ]
+```
+
+#### Entities
+
+Query for available chain entities on `Tezos` `carthagenet`.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilMetadataClient } from 'conseiljs';
+import * as util from 'util';
+
+const conseilServerInfo = { url: '', apiKey: '', network: 'carthagenet' };
+
+async function listEntities() {
+ const platforms = await ConseilMetadataClient.getEntities(conseilServerInfo, 'tezos', 'carthagenet');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listEntities();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listEntities() {
+ const platforms = await conseiljs.ConseilMetadataClient.getEntities(conseilServerInfo, 'tezos', 'carthagenet');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listEntities();
+```
+
+
+We might get:
+
+```json
+[ { "name": "accounts", "displayName": "Accounts", "count": 18782 },
+ { "name": "accounts_checkpoint", "displayName": "Accounts checkpoint", "count": 15 },
+ { "name": "bakers", "displayName": "Bakers", "count": 7588390 },
+ { "name": "balance_updates", "displayName": "Balance updates", "count": 7352650 },
+ { "name": "ballots", "displayName": "Ballots", "count": 0 },
+ { "name": "blocks", "displayName": "Blocks", "count": 288222 },
+ { "name": "fees", "displayName": "Fees", "count": 1183 },
+ { "name": "operation_groups", "displayName": "Operation groups", "count": 2156141 },
+ { "name": "operations", "displayName": "Operations", "count": 2179936 },
+ { "name": "proposals", "displayName": "Proposals", "count": 0 } ]
+```
+
+#### Entity Attributes
+
+Entities can be queried for their properties as follows.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilMetadataClient } from 'conseiljs';
+import * as util from 'util';
+
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listAttributes() {
+ const platforms = await ConseilMetadataClient.getAttributes(conseilServerInfo, 'tezos', 'carthagenet', 'operations');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listAttributes();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listAttributes() {
+ const platforms = await conseiljs.ConseilMetadataClient.getAttributes(conseilServerInfo, 'tezos', 'carthagenet', 'operations');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listAttributes();
+```
+
+
+A result may look like this. The sample has been truncated for size.
+
+```json
+[ { "name": "operation_id", "displayName": "Operation id", "dataType": "Int", "keyType": "UniqueKey", "entity": "operations" },
+ { "name": "operation_group_hash", "displayName": "Operation group hash", "dataType": "String", "cardinality": 2147676, "keyType": "NonKey", "entity": "operations" },
+ { "name": "kind", "displayName": "Kind", "dataType": "String", "cardinality": 8, "keyType": "NonKey", "entity": "operations" },
+ { "name": "level", "displayName": "Level", "dataType": "Int", "keyType": "NonKey", "entity": "operations" },
+ { "name": "delegate", "displayName": "Delegate", "dataType": "String", "cardinality": 133, "keyType": "NonKey", "entity": "operations" },
+ { "name": "slots", "displayName": "Slots", "dataType": "String", "cardinality": 690305, "keyType": "NonKey", "entity": "operations" },
+ { "name": "nonce", "displayName": "Nonce", "dataType": "String", "cardinality": 8889, "keyType": "NonKey", "entity": "operations" },
+ { "name": "pkh", "displayName": "Pkh", "dataType": "String", "cardinality": 1532, "keyType": "NonKey", "entity": "operations" },
+ { "name": "secret", "displayName": "Secret", "dataType": "String", "cardinality": 1532, "keyType": "NonKey", "entity": "operations" },
+ { "name": "source", "displayName": "Source", "dataType": "String", "cardinality": 2254, "keyType": "UniqueKey", "entity": "operations" },
+ { "name": "fee", "displayName": "Fee", "dataType": "Decimal", "keyType": "NonKey", "entity": "operations" }
+ ...
+]
+```
+
+#### Attribute Values
+
+The metadata services provides distinct values for some low-cardinality fields. In this case we're querying for `operation` `kind` on `Tezos` `carthagenet`.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilMetadataClient } from 'conseiljs';
+import * as util from 'util';
+
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listAttributeValues() {
+ const platforms = await ConseilMetadataClient.getAttributeValues(conseilServerInfo, 'tezos', 'carthagenet', 'operations', 'kind');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listAttributeValues();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+const conseilServerInfo = { url: '', apiKey: '' };
+
+async function listAttributeValues() {
+ const platforms = await conseiljs.ConseilMetadataClient.getAttributeValues(conseilServerInfo, 'tezos', 'carthagenet', 'operations', 'kind');
+ console.log(`${util.inspect(platforms, false, 2, false)}`);
+}
+
+listAttributeValues();
+```
+
+
+Result here is:
+
+```json
+[ "seed_nonce_revelation", "delegation", "transaction", "activate_account", "origination", "reveal", "double_baking_evidence", "endorsement" ]
+```
+
+This information can be used to create a drop-down list in some UI, or allow for type-ahead-autocomplete, etc. If the returned list is too long to be useful, or to get partial matches on high-cardinality fields, see getAttributeValuesForPrefix.
+
+#### Attribute Values for Prefix
+
+For long lists that may not be practical to display in a UI for auto-complete or for fields that the server will not provide attribute lists due to limits on cardinality, use `getAttributeValuesForPrefix(serverInfo, platform, network, entity, attribute, prefix)`. The last parameter of this call should be a few characters long to be effective.
+
+### Reporting & Analytics Functions
+
+For the Tezos chain these methods are in the `TezosConseilClient` namespace, in addition to `apiKey`, `Content-Type=application/json` header must be present. All data requests are REST POST.
+
+#### List transactions for an address
+
+Notice that it is possible to sort on and filter by fields that are not returned in the result set. Sent and received transactions must be queried for separately. Same address is used as an example: `tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy`.
+
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilDataClient, ConseilQueryBuilder, ConseilSortDirection, ConseilOperator } from 'conseiljs';
+import * as util from 'util';
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'operations';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function listAccountTransactions() {
+ let sendQuery = ConseilQueryBuilder.blankQuery();
+ sendQuery = ConseilQueryBuilder.addFields(sendQuery, 'block_level', 'timestamp', 'source', 'destination', 'amount', 'fee', 'counter');
+ sendQuery = ConseilQueryBuilder.addPredicate(sendQuery, 'kind', ConseilOperator.EQ, ['transaction'], false);
+ sendQuery = ConseilQueryBuilder.addPredicate(sendQuery, 'source', ConseilOperator.EQ, ['tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy'], false);
+ sendQuery = ConseilQueryBuilder.addPredicate(sendQuery, 'status', ConseilOperator.EQ, ['applied'], false);
+ sendQuery = ConseilQueryBuilder.addOrdering(sendQuery, 'block_level', ConseilSortDirection.DESC);
+ sendQuery = ConseilQueryBuilder.setLimit(sendQuery, 100);
+
+ let receiveQuery = ConseilQueryBuilder.blankQuery();
+ receiveQuery = ConseilQueryBuilder.addFields(receiveQuery, 'block_level', 'timestamp', 'source', 'destination', 'amount', 'fee', 'counter');
+ receiveQuery = ConseilQueryBuilder.addPredicate(receiveQuery, 'kind', ConseilOperator.EQ, ['transaction'], false);
+ receiveQuery = ConseilQueryBuilder.addPredicate(receiveQuery, 'destination', ConseilOperator.EQ, ['tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy'], false);
+ receiveQuery = ConseilQueryBuilder.addPredicate(receiveQuery, 'status', ConseilOperator.EQ, ['applied'], false);
+ receiveQuery = ConseilQueryBuilder.addOrdering(receiveQuery, 'block_level', ConseilSortDirection.DESC);
+ receiveQuery = ConseilQueryBuilder.setLimit(receiveQuery, 100);
+
+ const sendResult = await ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, sendQuery);
+ const receiveResult = await ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, receiveQuery);
+ const transactions = sendResult.concat(receiveResult).sort((a, b) => { return a['timestamp'] - b['timestamp'] });
+
+ console.log(`${util.inspect(transactions, false, 2, false)}`);
+}
+
+listAccountTransactions();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'operations';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function listAccountTransactions() {
+ let sendQuery = conseiljs.ConseilQueryBuilder.blankQuery();
+ sendQuery = conseiljs.ConseilQueryBuilder.addFields(sendQuery, 'block_level', 'timestamp', 'source', 'destination', 'amount', 'fee', 'counter');
+ sendQuery = conseiljs.ConseilQueryBuilder.addPredicate(sendQuery, 'kind', conseiljs.ConseilOperator.EQ, ['transaction'], false);
+ sendQuery = conseiljs.ConseilQueryBuilder.addPredicate(sendQuery, 'source', conseiljs.ConseilOperator.EQ, ['tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy'], false);
+ sendQuery = conseiljs.ConseilQueryBuilder.addPredicate(sendQuery, 'status', conseiljs.ConseilOperator.EQ, ['applied'], false);
+ sendQuery = conseiljs.ConseilQueryBuilder.addOrdering(sendQuery, 'block_level', conseiljs.ConseilSortDirection.DESC);
+ sendQuery = conseiljs.ConseilQueryBuilder.setLimit(sendQuery, 100);
+
+ let receiveQuery = conseiljs.ConseilQueryBuilder.blankQuery();
+ receiveQuery = conseiljs.ConseilQueryBuilder.addFields(receiveQuery, 'block_level', 'timestamp', 'source', 'destination', 'amount', 'fee', 'counter');
+ receiveQuery = conseiljs.ConseilQueryBuilder.addPredicate(receiveQuery, 'kind', conseiljs.ConseilOperator.EQ, ['transaction'], false);
+ receiveQuery = conseiljs.ConseilQueryBuilder.addPredicate(receiveQuery, 'destination', conseiljs.ConseilOperator.EQ, ['tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy'], false);
+ receiveQuery = conseiljs.ConseilQueryBuilder.addPredicate(receiveQuery, 'status', conseiljs.ConseilOperator.EQ, ['applied'], false);
+ receiveQuery = conseiljs.ConseilQueryBuilder.addOrdering(receiveQuery, 'block_level', conseiljs.ConseilSortDirection.DESC);
+ receiveQuery = conseiljs.ConseilQueryBuilder.setLimit(receiveQuery, 100);
+
+ const sendResult = await conseiljs.ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, sendQuery);
+ const receiveResult = await conseiljs.ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, receiveQuery);
+ const transactions = sendResult.concat(receiveResult).sort((a, b) => { return a['timestamp'] - b['timestamp'] });
+
+ console.log(`${util.inspect(transactions, false, 2, false)}`);
+}
+
+listAccountTransactions();
+```
+
+
+A result of that request might look like this.
+
+```json
+[ { "source": "tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy",
+ "timestamp": 1554614628000,
+ "block_level": 286240,
+ "amount": 500000,
+ "counter": 36041,
+ "destination": "tz1RVcUP9nUurgEJMDou8eW3bVDs6qmP5Lnc",
+ "fee": 1500 } ]
+```
+
+#### List transactions within a date range
+
+This query will return all successful transactions in the last four hours.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilDataClient, ConseilQueryBuilder, ConseilSortDirection, ConseilOperator } from 'conseiljs';
+import * as util from 'util';
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'operations';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function listTransactions() {
+ let transactionQuery = ConseilQueryBuilder.blankQuery();
+ transactionQuery = ConseilQueryBuilder.addFields(transactionQuery, 'block_level', 'timestamp', 'source', 'destination', 'amount', 'fee', 'counter');
+ transactionQuery = ConseilQueryBuilder.addPredicate(transactionQuery, 'kind', ConseilOperator.EQ, ['transaction'], false);
+ transactionQuery = ConseilQueryBuilder.addPredicate(transactionQuery, 'timestamp', ConseilOperator.BETWEEN, [Date.now() - 3600 * 48, Date.now()], false);
+ transactionQuery = ConseilQueryBuilder.addPredicate(transactionQuery, 'status', ConseilOperator.EQ, ['applied'], false);
+ transactionQuery = ConseilQueryBuilder.addOrdering(transactionQuery, 'block_level', ConseilSortDirection.DESC);
+ transactionQuery = ConseilQueryBuilder.setLimit(transactionQuery, 5000);
+
+ const result = await ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, transactionQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+listTransactions();
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'operations';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function listTransactions() {
+ let transactionQuery = conseiljs.ConseilQueryBuilder.blankQuery();
+ transactionQuery = conseiljs.ConseilQueryBuilder.addFields(transactionQuery, 'block_level', 'timestamp', 'source', 'destination', 'amount', 'fee', 'counter');
+ transactionQuery = conseiljs.ConseilQueryBuilder.addPredicate(transactionQuery, 'kind', conseiljs.ConseilOperator.EQ, ['transaction'], false);
+ transactionQuery = conseiljs.ConseilQueryBuilder.addPredicate(transactionQuery, 'timestamp', conseiljs.ConseilOperator.BETWEEN, [Date.now() - 3600 * 48, Date.now()], false);
+ transactionQuery = conseiljs.ConseilQueryBuilder.addPredicate(transactionQuery, 'status', conseiljs.ConseilOperator.EQ, ['applied'], false);
+ transactionQuery = conseiljs.ConseilQueryBuilder.addOrdering(transactionQuery, 'block_level', conseiljs.ConseilSortDirection.DESC);
+ transactionQuery = conseiljs.ConseilQueryBuilder.setLimit(transactionQuery, 5000);
+
+ const result = await conseiljs.ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, transactionQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+listTransactions();
+```
+
+
+#### List all originated accounts
+
+#### List all managed accounts
+
+#### List all smart contracts
+
+#### List top-10 bakers by balance
+
+#### List top-10 bakers by delegator count
+
+#### Export a large dataset to csv
+
+### Common Wallet Queries
+
+#### Tezos Implicit Account Information
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilDataClient, ConseilQueryBuilder, ConseilSortDirection, ConseilOperator } from 'conseiljs';
+import * as util from 'util';
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'accounts';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function accountInfo(address: string) {
+ let accountQuery = ConseilQueryBuilder.blankQuery();
+ accountQuery = ConseilQueryBuilder.addFields(accountQuery, 'account_id', 'delegate_value', 'balance', 'block_level');
+ accountQuery = ConseilQueryBuilder.addPredicate(accountQuery, 'account_id', ConseilOperator.EQ, [address], false);
+ accountQuery = ConseilQueryBuilder.setLimit(accountQuery, 1);
+
+ const result = await ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, accountQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+accountInfo('tz3WXYtyDUNL91qfiCJtVUX746QpNv5i5ve5');
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'accounts';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function accountInfo(address: string) {
+ let accountQuery = conseiljs.ConseilQueryBuilder.blankQuery();
+ accountQuery = conseiljs.ConseilQueryBuilder.addFields(accountQuery, 'account_id', 'delegate_value', 'balance', 'block_level');
+ accountQuery = conseiljs.ConseilQueryBuilder.addPredicate(accountQuery, 'account_id', conseiljs.ConseilOperator.EQ, [address], false);
+ accountQuery = conseiljs.ConseilQueryBuilder.setLimit(accountQuery, 1);
+
+ const result = await conseiljs.ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, accountQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+accountInfo('tz3WXYtyDUNL91qfiCJtVUX746QpNv5i5ve5');
+```
+
+
+#### Delegated Accounts with non-zero Balances
+
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilDataClient, ConseilQueryBuilder, ConseilSortDirection, ConseilOperator } from 'conseiljs';
+import * as util from 'util';
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'accounts';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function accountInfo(address: string) {
+ let accountQuery = ConseilQueryBuilder.blankQuery();
+ accountQuery = ConseilQueryBuilder.addFields(accountQuery, 'account_id');
+ accountQuery = ConseilQueryBuilder.addPredicate(accountQuery, 'manager', ConseilOperator.EQ, [address]);
+ accountQuery = ConseilQueryBuilder.addPredicate(accountQuery, 'delegate_value', ConseilOperator.ISNULL, [], true);
+ accountQuery = ConseilQueryBuilder.addPredicate(accountQuery, 'balance', ConseilOperator.GT, [0]);
+ accountQuery = ConseilQueryBuilder.setLimit(accountQuery, 100);
+
+ const result = await ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, accountQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+accountInfo('tz1PziRyFwu96Rw1vqgzEdd7SqMuT4hQaggz');
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'accounts';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function accountInfo(address: string) {
+ let accountQuery = conseiljs.ConseilQueryBuilder.blankQuery();
+ accountQuery = conseiljs.ConseilQueryBuilder.addFields(accountQuery, 'account_id');
+ accountQuery = conseiljs.ConseilQueryBuilder.addPredicate(accountQuery, 'manager', conseiljs.ConseilOperator.EQ, [address]);
+ accountQuery = conseiljs.ConseilQueryBuilder.addPredicate(accountQuery, 'delegate_value', conseiljs.ConseilOperator.ISNULL, [], true);
+ accountQuery = conseiljs.ConseilQueryBuilder.addPredicate(accountQuery, 'balance', conseiljs.ConseilOperator.GT, [0]);
+ accountQuery = conseiljs.ConseilQueryBuilder.setLimit(accountQuery, 100);
+
+ const result = await conseiljs.ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, accountQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+accountInfo('tz1PziRyFwu96Rw1vqgzEdd7SqMuT4hQaggz');
+```
+
+
+#### Total Balance for an Account
+
+This query returns the complete holdings under the control of the provided account.
+
+
+##### **Typescript**
+
+```typescript
+import { ConseilDataClient, ConseilQueryBuilder, ConseilSortDirection, ConseilOperator } from 'conseiljs';
+import * as util from 'util';
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'accounts';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function accountBalance(address: string) {
+ let accountQuery = ConseilQueryBuilder.blankQuery();
+ accountQuery = ConseilQueryBuilder.addFields(accountQuery, 'manager', 'balance');
+ accountQuery = ConseilQueryBuilder.addPredicate(accountQuery, 'manager', ConseilOperator.EQ, [address]);
+ accountQuery = ConseilQueryBuilder.addPredicate(accountQuery, 'balance', ConseilOperator.GT, [0]);
+ accountQuery = ConseilQueryBuilder.addAggregationFunction(accountQuery, 'balance', ConseilFunction.sum);
+ accountQuery = ConseilQueryBuilder.setLimit(accountQuery, 1);
+
+ const result = await ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, accountQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+accountBalance('tz1aQuhhKCvjFZ4XbnvTU5BjaBiz3ceoMNag');
+```
+
+##### **JavaScript**
+
+```javascript
+const conseiljs = require('conseiljs');
+const util = require('util');
+
+const platform = 'tezos';
+const network = 'carthagenet';
+const entity = 'accounts';
+
+const conseilServer = { url: '', apiKey: '', network };
+
+async function accountBalance(address) {
+ let accountQuery = conseiljs.ConseilQueryBuilder.blankQuery();
+ accountQuery = conseiljs.ConseilQueryBuilder.addFields(accountQuery, 'manager', 'balance');
+ accountQuery = conseiljs.ConseilQueryBuilder.addPredicate(accountQuery, 'manager', conseiljs.ConseilOperator.EQ, [address]);
+ accountQuery = conseiljs.ConseilQueryBuilder.addPredicate(accountQuery, 'balance', conseiljs.ConseilOperator.GT, [0]);
+ accountQuery = conseiljs.ConseilQueryBuilder.addAggregationFunction(accountQuery, 'balance', conseiljs.ConseilFunction.sum);
+ accountQuery = conseiljs.ConseilQueryBuilder.setLimit(accountQuery, 1);
+
+ const result = await conseiljs.ConseilDataClient.executeEntityQuery(conseilServer, platform, network, entity, accountQuery);
+
+ console.log(`${util.inspect(result, false, 2, false)}`);
+}
+
+accountBalance('tz1aQuhhKCvjFZ4XbnvTU5BjaBiz3ceoMNag');
+
+```
+
+
+### Namespaces
+
+#### ConseilQueryBuilder
+
+This collection of methods for creating entity queries.
+
+##### addAggregationFunction(query, field, aggregationFunction)
+
+It is possible to apply an aggregation function to a field in the query. This field must be present in the `fields` collection. The aggregation function is one of `avg`, `count`, `max`, `min`, `sum` as defined in the `ConseilFunction` enum. `count` can be applied to any field type; `max`, `min` can be applied to a datetime or numeric fields, while `avg` and `sum` are only valid on numeric fields.
+
+##### addFields(query, ...fields)
+
+By default, all fields are returned, but using the information from the ConseilMetadataClient for the appropriate platform/network/entity combination.
+
+##### addOrdering(query, field, direction)
+
+One or more ordering instructions can be added to a query and they may be applied on fields that are not part of the result set.
+
+The default direction is `ASC`. Direction values are in the `ConseilSortDirection` enum.
+
+##### addPredicate(query, field, operation, values, invert, group)
+
+Several predicate operations are supported. For string values: `EQ`, `IN`, `LIKE`, `STARTSWITH`, `ENDSWITH`, `ISNULL`. For numbers and dates: `EQ`, `IN`, `BETWEEN`, `LT` or `BEFORE`, `GT` or `AFTER`, `ISNULL`. The operation values are located in the `ConseilOperator` enum. The difference between `LIKE` and `STARTSWITH` and `ENDSWITH`, is that the former will do a match at any point in the text.
+
+There are limitations on the contents of the values array depending on the supplied operation. `EQ` requires a single value, `IN` an contain multiple, `BETWEEN` only accepts two.
+
+The `invert` parameter is to allow for queries like `not in`, or `is not null`, `!=`. Default is `false`.
+
+Lastly, the optional `group` parameter allows to associated predicates into groups so they can be applied with and OR condition instead of AND.
+
+##### blankQuery()
+
+This method creates a minimum viable query that can be sent a Conseil data service like `TezosConseilClient`.
+
+##### setLimit(query, limit)
+
+The default record set is 100 rows. This can be changed using this method, however the server may override the request.
+
+##### setOutputType(query, outputType)
+
+By default, the service will return json data. For large datasets this is suboptimal. This function sets the output parameter of the ConseilQuery to one of 'json' or 'csv' as defined in `ConseilOutput` enum.
+
+#### ConseilMetadataClient
+
+For details, see [API Examples](#metadata-discovery-functions) below.
+
+#### ConseilDataClient
+
+#### executeEntityQuery(serverInfo, platform, network, entity, query)
+
+The single method of this namespace submits queries from the `ConseilQueryBuilder` to the Conseil service endpoint.
+
+#### TezosConseilClient
+
+Functions for querying the Conseil back-end REST API v2 for Tezos. This functionality is offered by wrapping ConseilDataClient for Tezos-specific entities.
+
+All of these methods require Conseil connection object which is a URL and API key. The `serverInfo` parameter below is of type `ConseilServerInfo`. Some of the methods also take a `query` parameter of type `ConseilQuery`, these are best constructed with `ConseilQueryBuilder` described [earlier](#ConseilQueryBuilder).
+
+##### awaitOperationConfirmation(serverInfo, network, hash, duration, blocktime)
+
+This function will monitor the chain for an operation with the given `hash` for up a `duration` blocks on some `network`. If the operation is found, it will be returned, otherwise an `Error` is thrown.
+
+##### awaitOperationForkConfirmation(serverInfo, network, hash, duration, depth)
+
+##### getAccount(serverInfo, network, accountID)
+
+Returns a specific account on the given `network` with the provided `accountID`. In Tezos account id, account address, public key hash (phk) all refer to the same thing. All account entity fields are returned. To get just a subset of fields, use `getAccounts(serverInfo, network, query)`.
+
+##### getAccounts(serverInfo, network, query)
+
+Returns account information subject to the provided `query` on a given `network`.
+
+##### getBakers(serverInfo, network, query)
+
+Returns baker information subject to the provided `query` on a given `network`.
+
+##### getBallots(serverInfo, network, query)
+
+Returns ballot information subject to the provided `query` on a given `network`.
+
+##### getBlock(serverInfo, network, hash)
+
+Returns a specific block with the given `hash` and `network`. All block entity fields are returned. To get just a subset of fields, use `getBlocks(serverInfo, network, query)`.
+
+##### getBlockByLevel(serverInfo, network level)
+
+Returns a specific block at the provided `level` from the `network`. All block entity fields are returned.
+
+##### getBlockHead(serverInfo, network)
+
+Returns the most recent block on the chain for a given `network`. Internally this is implemented with a `ConseilQuery` ordered by block level with limit 1. All block entity fields are returned. To get just a subset of fields, use `getBlocks(serverInfo, network, query)`.
+
+##### getBlocks(serverInfo, network, query)
+
+Returns block information subject to the provided `query` on a given `network`.
+
+##### getEntityQueryForId(id)
+
+A conveniences function that enabled dynamic id-based search. For a specified `id`, it returns the entity type and a query necessary to get it from the service. Numeric ids are assumed to be block level.
+
+##### getFeeStatistics(serverInfo, network, operationType)
+
+Conseil indexer calculates running average fees by operation type. This is a convenience method to get that information. [Tezori](https://github.com/Cryptonomic/Tezori/blob/master/app/utils/general.js#L168) for example uses this information to suggest an appropriate fee to the user via a drop-down.
+
+##### getOperationGroup(serverInfo, network, operationGroupID)
+
+Returns a specific operation group on the given `network` with the provided `operationGroupID`. In Tezos individual operations are not keyed. All operation group entity fields are returned. To get just a subset of fields, use `getOperationGroups(serverInfo, network, query)`.
+
+##### getOperationGroups(serverInfo, network, query)
+
+Returns operation group information subject to the provided `query` on a given `network`.
+
+##### getOperations(serverInfo, network, query)
+
+Returns operation information subject to the provided `query` on a given `network`.
+
+##### getProposals(serverInfo, network, query)
+
+Returns proposal information subject to the provided `query` on a given `network`.
+
+##### getTezosEntityData(serverInfo, network, entity, query)
+
+Returns a record set for a specific entity of the Tezos platform. Entity list and metadata can be retrieved using `ConseilMetadataClient`.
+
+#### TezosLedgerWallet
+
+Identity management and signing functions to enable Tezos node interactions with the Ledger Nano S hardware wallet.
+
+##### initLedgerTransport
+
+Before the Ledger device can be used, the connection must be initialized with this call.
+
+##### unlockAddress(deviceType, derivationPath)
+
+Returns a partial `KeyStore` container public key and public key hash (address) for a given `derivationPath`. The private key does not leave the device. `deviceType` must be `HardwareDeviceType.LedgerNanoS`.
+
+##### getTezosPublicKey(derivationPath: string): Promise<string>
+
+Returns just the public key for a given `derivationPath`.
+
+##### signTezosOperation(derivationPath, watermarkedOpInHex)
+
+Returns signature bytes resulting from signing the provided transaction expressed in bytes using the private key at the specified `derivationPath`.
+
+#### TezosMessageCodec
+
+A collection of functions to encode and decode various Tezos P2P message components
+
+#### TezosNodeReader
+
+Utility functions for interacting with the Tezos node.
+
+##### getBlock(server: string, hash: string)
+
+Gets a block directly from the specified Tezos node by block hash.
+
+##### getBlockHead(server: string)
+
+Gets the most-recent block.
+
+##### getAccountForBlock(server: string, blockHash: string, accountHash: string)
+
+Returns account status as of a specific block.
+
+##### getCounterForAccount(server: string, accountHash: string)
+
+Gets the current account operation counter. This index must be incremented with each successive operation being submitted by the account.
+
+##### getAccountManagerForBlock(server: string, blockHash: string, accountHash: string)
+
+Retrieves the account manager information as of a given block.
+
+##### isImplicitAndEmpty(server: string, accountHash: string)
+
+Identifies the account as implicit and empty - 0 balance. This has bearing on the cost of certain transactions.
+
+##### isManagerKeyRevealedForAccount(server: string, accountHash: string)
+
+A key reveal operation is required, this verifies if the account has already sent one.
+
+#### TezosNodeWriter
+
+Functions for sending operations on the Tezos network via a node. Most of these methods take many parameters that include server URL, key pair and address structure, and fee, among other things. Parameters have been omitted for brevity, but all of these methods and more are documented in the code using TSDoc.
+
+Several of these functions accept an optional derivation path parameter that is defaulted to blank for signing with a Ledger device.
+
+The various send functions return an operation group hash which can be passed to [TezosConseilClient.awaitOperationConfirmation(...)](#awaitOperationConfirmationserverInfo-network-hash-duration) to await its appearance on the chain.
+
+##### signOperationGroup
+
+Generates a signature for the hex representation of the proposed operation group based on account keys.
+
+##### forgeOperations
+
+Forges an operation group - converts it to hex in preparation for inclusion on the chain. This function will encode operations locally.
+
+##### forgeOperationsRemotely
+
+ConseilJS is able to encode locally operations in many cases, for the occasions where that fails, this function will forge an operation remotely on the specified Tezos node. This operation is not trustless.
+
+##### applyOperation
+
+Sends the operation group to the Tezos node for validation. The RPC payload is JSON, but the attached signature is based on the (potentially) locally created hex equivalent.
+
+##### injectOperation
+
+Submits the binary content of the operation group for inclusion on the chain.
+
+##### sendOperation
+
+Assembles, signs, forges, validates and submits an operation group to the chain.
+
+##### appendRevealOperation
+
+Account public key must be revealed for it to participate in transactions. This method will check the account status and add a Reveal operation to the operation group going out.
+
+##### sendTransactionOperation
+
+Sends the basic value transfer operation.
+
+##### sendDelegationOperation
+
+Updates the account's delegate.
+
+##### sendUndelegationOperation
+
+A convenience function to remove the delegate from an account. Calls [sendDelegationOperation](#sendDelegationOperation) internally
+
+##### sendAccountOriginationOperation
+
+Creates an originated account (KT1), without a script. These types of accounts allow participation in the delegation process.
+
+##### sendContractOriginationOperation
+
+Attempts to deploy a contract on the chain. `code` and initial `storage` are required parameters the content of which is specified by `codeFormat`. For operation submission Tezos converts the Michelson code into a JSON format known as Micheline before finally writing it as hex. Setting `codeFormat` to 'Micheline' will skip the Michelson-Micheline conversion.
+
+##### sendContractInvocationOperation
+
+Like [sendContractOriginationOperation](#sendContractOriginationOperation), parameters can be in Michelson or Micheline. It's possible to pass undefined or blank parameters.
+
+##### sendContractPing
+
+Invokes a contract with a 0 transaction amount and no parameters.
+
+##### sendKeyRevealOperation
+
+A key reveal operation can be sent separately as well. For a more efficient way to reveal an account, see [appendRevealOperation](#appendRevealOperation).
+
+##### sendIdentityActivationOperation
+
+Sends an account activation operation. These are preformed for fundraiser accounts.
+
+#### TezosFileWallet
+
+Functions for Tezos wallet functionality.
+
+#### TezosChainTypes
+
+#### TezosP2PMessageTypes
+
+JSON message definitions for operation submission.
+
+#### TezosRPCResponseTypes
+
+JSON message definitions for RPC service responses.
+
+## Contribute
+
+There are many ways to contribute to this project. You can develop applications or dApps with it. You can submit bug reports or feature requests. You can ask questions about it on [r/Tezos](http://reddit.com/r/tezos/) or the [Tezos StackExchange](https://tezos.stackexchange.com). We certainly welcome pull requests as well.
+
+### NPM Target Overview
+
+#### `npm run test`
+
+#### `npm run coverage`
+
+#### `npm run format`
+
+#### `npm run package`
+
+## Other references
+
+[Wiki](https://github.com/Cryptonomic/ConseilJS/wiki/Tutorial:-Querying-for-Tezos-alphanet-data-using-the-ConseilJS-v2-API)
+
+[Riot Dev Channel](https://matrix.to/#/!rUwpbdwWhWgKINPyOD:cryptonomic.tech?via=cryptonomic.tech&via=matrix.org&via=ostez.com)
+
+[Cryptonomic Reddit](https://www.reddit.com/r/cryptonomic)
+
+[The Cryptonomic Aperiodical](https://medium.com/the-cryptonomic-aperiodical)
+
+[@CryptonomicTech](https://twitter.com/CryptonomicTech)
diff --git a/docs/index.html b/ConseilJS-core/docs/index.html
similarity index 83%
rename from docs/index.html
rename to ConseilJS-core/docs/index.html
index 8576f1f0..3e6ee42d 100644
--- a/docs/index.html
+++ b/ConseilJS-core/docs/index.html
@@ -16,6 +16,7 @@
repo: 'https://github.com/Cryptonomic/ConseilJS'
}
-
+
+