UNPKG

sevm

Version:

A Symbolic Ethereum Virtual Machine (EVM) bytecode decompiler & analyzer library & CLI

1 lines 77.5 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("sevm",[],t):"object"==typeof exports?exports.sevm=t():e.sevm=t()}(self,(()=>{return e={788:(e,t,s)=>{const a=s(326);a.Contract.prototype.patch=async function(e={}){const t=Object.keys,s=e=>"0x"+e,a=[...t(this.functions),...t(this.reverts)].map(s).join(","),n=t(this.events).map(s).join(",");if(!e.function||!e.event){const t=`https://api.openchain.xyz/signature-database/v1/lookup?function=${a}&event=${n}`,s=await fetch(t);if(!s.ok)throw new Error(`Failed to fetch signatures from api.openchain.xyz, url: ${t}`);const{result:r}=await s.json(),o=e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t?.map((({name:e})=>e))??[]])));e.function=o(r.function),e.event=o(r.event)}for(let[t,s]of Object.entries(this.functions))t="0x"+t,t in e.function&&(s.label=e.function[t][0]);for(let[t,s]of Object.entries(this.events))t="0x"+t,t in e.event&&(s.sig=e.event[t][0]);for(let[t,s]of Object.entries(this.reverts))t="0x"+t,t in e.function&&(s.sig=e.function[t][0]);return this},e.exports=a},90:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hexlify=t.arrayify=void 0,t.arrayify=function(e){if(e instanceof Uint8Array)return e;if("string"!=typeof e)return new Uint8Array(e);if(e.length%2!=0)throw new Error(`Unable to decode, input should have even length, but got length '${e.length}'`);const t="0x"===e.slice(0,2).toLowerCase()?2:0,s=new Uint8Array((e.length-t)/2);for(let a=t,n=0;a<e.length;a+=2,n++){const t=e.slice(a,a+2),r=Number("0x"+t);if(!(r>=0))throw new Error(`Unable to decode, invalid hex byte '${t}' found at position '${a+1}'`);s[n]=r}return s},t.hexlify=function(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}},69:function(e,t){"use strict";var s,a=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},n=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};function r(e){return l.includes(e)}function o(e){switch(e){case"uint":return"uint256";case"int":return"int256";case"fixed":return"fixed128x18";case"ufixed":return"ufixed128x18";default:return e}}Object.defineProperty(t,"__esModule",{value:!0}),t.fnsig=t.sighash=t.parseSig=t.isElemType=void 0,t.isElemType=r;const i=[...Array(32).keys()].map((e=>8*(e+1))),c=[...Array(32).keys()].map((e=>e+1)),l=["address","address payable","bool","uint",...i.map((e=>`uint${e}`)),"int",...i.map((e=>`int${e}`)),"bytes",...c.map((e=>`bytes${e}`)),"string","function"];class d{constructor(e){this.input=e,this.ID_REGEX=/^\w+\b/,this.position=0}next(){for(;" "===this.input[this.position];)this.position++;const e=this.position,t=this.input.slice(e).match(this.ID_REGEX);if(t)return this.position+=t[0].length,[e,r(t[0])?"TYPE":Number.isNaN(Number(t[0]))?"ID":"LIT",t[0]];switch(this.input[e]){case"(":case")":case",":case"[":case"]":return this.position++,[e,"OP",this.input[e]]}return[e,null,null]}*[Symbol.iterator](){for(let[e,t,s]=this.next();null!==s;[e,t,s]=this.next())yield[e+1,t,s]}}class u{constructor(e){this.sig=e,s.set(this,[]),a(this,s,[...new d(e)],"f")}peek(){if(0===n(this,s,"f").length)throw new Error("peek: reached end of input");return n(this,s,"f")[0]}next(){if(0===n(this,s,"f").length)throw new Error("next: reached end of input");return n(this,s,"f").shift()}consume(e){const[,,t]=this.next();if(t!==e)throw new Error(`Expected '${e}' but got '${t}'`)}}function f(e){if(void 0!==e.arrayType){const t=null===e.arrayLength?"":e.arrayLength;return`${f(e.arrayType)}[${t}]`}return"tuple"===e.type?`(${e.components.map(f).join(",")})`:e.type}s=new WeakMap,t.parseSig=function(e){const t=new u(e);let[s,a,n]=t.next();if("function"===n&&([s,a,n]=t.next()),"ID"!==a)throw new Error(`Expected function name, found '${n}':${s}`);const i=[];t.consume("(");let[,,c]=t.peek();for(;")"!==c;)i.push(l()),[,,c]=t.peek(),","===c&&t.consume(",");return t.consume(")"),{name:n,inputs:i};function l(){const e=d(),[,s,a]=t.peek();return"ID"!==s?{...e}:(t.consume(a),{...e,name:a})}function d(){const s=function(){let[s,,a]=t.peek();if("("===a){const e=[];let s;for(t.consume("("),[,,a]=t.peek();")"!==a;)s=d(),e.push(s),[,,a]=t.peek(),","===a&&t.consume(",");return t.consume(")"),{type:"tuple",components:e}}if(r(a))return t.next(),{type:o(a)};throw new Error(`Invalid elementary type found: \`${a}\` at position ${s} in \`${e}\``)}(),a=[];let[,,n]=t.peek();for(;"["===n;){t.consume("[");const[,e,s]=t.peek();"LIT"===e?(t.consume(s),t.consume("]"),a.push(Number(s))):(a.push(null),t.consume("]")),[,,n]=t.peek()}return a.reduce(((e,t,n)=>({type:`${s.type}${a.slice(0,n+1).map((e=>`[${null===e?"":e}]`)).join("")}`,arrayType:e,arrayLength:t})),s)}},t.sighash=function(e){return`${e.name}(${e.inputs.map(f).join(",")})`},t.fnsig=function(e){return`${e.name}(${e.inputs.map(((e,t)=>`${f(e)} ${e.name??"_arg"+t}`)).join(", ")})`}},773:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Sar=t.Shr=t.Shl=t.Byte=t.Not=t.Xor=t.Or=t.And=t.IsZero=t.Eq=t.Gt=t.Lt=t.Exp=t.Mod=t.Div=t.Sub=t.Mul=t.Add=void 0;const a=s(224);class n extends a.Tag{constructor(e,t){super(Math.max(e.depth,t.depth)+1,e.count+t.count+1),this.left=e,this.right=t}}const r=e=>(e%a.MOD_256+a.MOD_256)%a.MOD_256;function o(e){try{return e()}catch{return null}}class i extends n{constructor(){super(...arguments),this.tag="Add"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(r(e.val+t.val)):e.isZero()?t:t.isZero()?e:new i(e,t)}}t.Add=i;class c extends n{constructor(){super(...arguments),this.tag="Mul"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(r(e.val*t.val)):e.isZero()||t.isZero()?new a.Val(0n):new c(e,t)}}t.Mul=c;class l extends n{constructor(){super(...arguments),this.tag="Sub"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(r(e.val-t.val)):t.isZero()?e:new l(e,t)}}t.Sub=l;class d extends n{constructor(){super(...arguments),this.tag="Div"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?0n===t.val?new d(e,t):new a.Val(e.val/t.val):t.isVal()&&1n===t.val?e:new d(e,t)}}t.Div=d;class u extends n{constructor(){super(...arguments),this.tag="Mod"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()&&0n!==t.val?new a.Val(e.val%t.val):new u(e,t)}}t.Mod=u;class f extends n{constructor(){super(...arguments),this.tag="Exp"}eval(){const e=this.left.eval(),t=this.right.eval();if(e.isVal()&&t.isVal()&&t.val>=0){const s=o((()=>e.val**t.val));if(null!==s)return new a.Val(r(s))}return new f(e,t)}}t.Exp=f;class h extends a.Tag{constructor(e,t,s=!1){super(Math.max(e.depth,t.depth)+1,e.count+t.count+1),this.left=e,this.right=t,this.equal=s}}class p extends a.Tag{constructor(e){super(e.depth+1,e.count+1),this.value=e}}class v extends a.Tag{constructor(e,t){super(Math.max(e.depth,t.depth)+1,e.count+t.count+1),this.value=e,this.shift=t}}class b extends h{constructor(){super(...arguments),this.tag="Lt"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(e.val<t.val?1n:0n):new b(e,t)}}t.Lt=b;class g extends h{constructor(){super(...arguments),this.tag="Gt"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(e.val>t.val?1n:0n):new g(e,t)}}t.Gt=g;class m extends n{constructor(){super(...arguments),this.tag="Eq"}eval(){return new m(this.left.eval(),this.right.eval())}}t.Eq=m;class w extends a.Tag{constructor(e){super(e.depth+1,e.count+1),this.value=e,this.tag="IsZero"}eval(){const e=this.value.eval();return e.isVal()?0n===e.val?new a.Val(1n):new a.Val(0n):"Lt"===e.tag?new g(e.left,e.right,!e.equal):"Gt"===e.tag?new b(e.left,e.right,!e.equal):"IsZero"===e.tag?e.value:new w(e)}}t.IsZero=w;class y extends n{constructor(){super(...arguments),this.tag="And"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(e.val&t.val):e.isVal()&&/^[f]+$/.test(e.val.toString(16))?t:t.isVal()&&/^[f]+$/.test(t.val.toString(16))?e:e.isVal()&&"And"===t.tag&&t.left.isVal()&&e.val===t.left.val?t.right:new y(e,t)}}t.And=y;class $ extends n{constructor(){super(...arguments),this.tag="Or"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(e.val|t.val):new $(e,t)}}t.Or=$;class S extends n{constructor(){super(...arguments),this.tag="Xor"}eval(){const e=this.left.eval(),t=this.right.eval();return e.isVal()&&t.isVal()?new a.Val(e.val^t.val):new S(e,t)}}t.Xor=S;class _ extends p{constructor(){super(...arguments),this.tag="Not"}eval(){const e=this.value.eval();return e.isVal()?new a.Val(r(~e.val)):new _(e)}}t.Not=_;class x extends a.Tag{constructor(e,t){super(Math.max(e.depth,t.depth)+1,e.count+t.count+1),this.pos=e,this.data=t,this.tag="Byte"}eval(){const e=this.pos.eval(),t=this.data.eval();return t.isVal()&&e.isVal()?new a.Val(t.val>>e.val&1n):new x(e,t)}}t.Byte=x;class E extends v{constructor(){super(...arguments),this.tag="Shl"}eval(){const e=this.value.eval(),t=this.shift.eval();if(e.isVal()&&t.isVal()){const s=o((()=>e.val<<t.val));if(null!==s)return new a.Val(r(s))}return new E(e,t)}}t.Shl=E;class k extends v{constructor(){super(...arguments),this.tag="Shr"}eval(){const e=this.value.eval(),t=this.shift.eval();return e.isVal()&&t.isVal()?new a.Val(e.val>>t.val):new k(e,t)}}t.Shr=k;class V extends v{constructor(){super(...arguments),this.tag="Sar"}eval(){const e=this.value.eval(),t=this.shift.eval();return e.isVal()&&t.isVal()?new a.Val(e.val>>t.val):new V(e,t)}}t.Sar=V},865:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SigCase=t.Sig=t.JumpDest=t.Jumpi=t.Jump=t.Branch=void 0;const a=s(224);class n{constructor(e,t){this.pc=e,this.state=t}static make(e,t){return new n(e,t.clone())}}t.Branch=n,t.Jump=class{constructor(e,t,s){this.offset=e,this.destBranch=t,this.pushStateId=s,this.name="Jump"}eval(){return this}next(){return[this.destBranch]}};class r{constructor(e,t,s,a,n){this.cond=e,this.offset=t,this.fallBranch=s,this.destBranch=a,this.pushStateId=n,this.name="Jumpi",this.evalCond=e.eval()}eval(){return new r(this.cond.eval(),this.offset,this.fallBranch,this.destBranch,this.pushStateId)}next(){return this.evalCond.isVal()?0n===this.evalCond.val?[this.fallBranch]:[this.destBranch]:[this.destBranch,this.fallBranch]}}t.Jumpi=r,t.JumpDest=class{constructor(e){this.fallBranch=e,this.name="JumpDest"}eval(){return this}next(){return[this.fallBranch]}};class o extends a.Tag{constructor(e,t=!0){super(0,1),this.selector=e,this.positive=t,this.tag="Sig"}eval(){return this}}t.Sig=o,t.SigCase=class{constructor(e,t,s){this.condition=e,this.offset=t,this.fallBranch=s,this.name="SigCase"}eval(){return this}next(){return[this.fallBranch]}}},224:function(e,t,s){"use strict";var a,n=this&&this.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,n)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),r=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||n(t,e,s)},o=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},i=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s};Object.defineProperty(t,"__esModule",{value:!0}),t.mem=t.inline0=t.reduce=t.Locali=t.Local=t.Val=t.MOD_256=t.Tag=t.Require=t.CallSite=t.If=t.Throw=t.evalE=t.isInst=t.isExpr=void 0,t.isExpr=e=>null!==e&&"object"==typeof e&&"tag"in e,t.isInst=e=>null!==e&&"object"==typeof e&&"name"in e,t.evalE=e=>e.eval(),t.Throw=class{constructor(e,t){this.reason=e,this.opcode=t,this.name="Throw"}eval(){return this}};class c{constructor(e,t,s){this.condition=e,this.trueBlock=t,this.falseBlock=s,this.name="If"}eval(){return new c(this.condition.eval(),this.trueBlock?f(this.trueBlock):void 0,this.falseBlock?f(this.falseBlock):void 0)}}t.If=c,t.CallSite=class{constructor(e){this.selector=e,this.name="CallSite"}eval(){return this}};class l{constructor(e,t,s){this.condition=e,this.selector=t,this.args=s,this.name="Require"}eval(){return new l(this.condition.eval(),this.selector,this.args.map(t.evalE))}}t.Require=l;class d{constructor(e,t){this.depth=e,this.count=t}isVal(){return"Val"===this.tag}isZero(){return this.isVal()&&0n===this.val}isJumpDest(){return this.isVal()&&null!==this.jumpDest}children(){return Object.values(this).filter((e=>e instanceof d))}unwrap(){return this}}t.Tag=d,t.MOD_256=1n<<0x100n;class u extends d{constructor(e,s){if(e<0||e>=t.MOD_256)throw new Error(`Val is a not a valid unsigned 256-word: ${e}`);super(0,1),this.val=e,this.pushStateId=s,this.tag="Val",this.jumpDest=null}eval(){return new u(this.val)}}function f(e){return e?.flatMap((e=>["Local","MStore"].includes(e.name)?[]:e.eval()))}t.Val=u,t.Local=class extends d{constructor(e,t){super(t.depth+1,t.count+1),this.index=e,this.value=t,this.tag="Local",this.nrefs=0,a.set(this,void 0)}eval(){return void 0===o(this,a,"f")&&i(this,a,this.value.eval(),"f"),o(this,a,"f")}unwrap(){return this.value}},a=new WeakMap,t.Locali=class{constructor(e){this.local=e,this.name="Local"}eval(){return this}},t.reduce=f,t.inline0=function(e){const t=new WeakSet,s=[];for(const n of e.reverse()){if("MStore"===n.name)a(n.location),a(n.data);else if("Local"===n.name&&t.has(n.local))continue;s.unshift(n)}return s;function a(e){t.add(e),e.children().forEach(a)}},t.mem=function(e){const t=[];for(const a of e.reverse())"MStore"===a.name&&(s(a.location),s(a.data)),t.unshift(a);return t;function s(e){"Local"===e.tag&&e.nrefs--,e.children().forEach(s)}},r(s(773),t),r(s(865),t),r(s(418),t),r(s(8),t),r(s(872),t),r(s(939),t),r(s(350),t)},418:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0;const a=s(224);class n{constructor(e,t,s,a,n){this.event=e,this.offset=t,this.size=s,this.topics=a,this.args=n,this.name="Log"}get eventName(){if(void 0!==this.event&&void 0!==this.event.sig)return this.event.sig.split("(")[0]}eval(){return new n(this.event,this.offset.eval(),this.size.eval(),this.topics.map(a.evalE),this.args?.map(a.evalE))}}t.Log=n},8:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MStore=t.MLoad=void 0;const a=s(224);class n extends a.Tag{constructor(e,t){super(Math.max(e.depth,t?.depth??0)+1,e.count+(t?.count??0)+1),this.location=e,this.value=t,this.tag="MLoad"}eval(){return this.value?this.value.eval():new n(this.location.eval())}}t.MLoad=n;class r{constructor(e,t){this.location=e,this.data=t,this.name="MStore"}eval(){return new r(this.location.eval(),this.data.eval())}}t.MStore=r},872:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CallDataLoad=t.CallValue=t.DataCopy=t.Fn=t.FNS=t.Props=t.Prop=void 0;const a=s(224);class n extends a.Tag{constructor(e,t){super(0,1),this.symbol=e,this.type=t,this.tag="Prop"}eval(){return this}}t.Prop=n;const r=e=>[e[0],new n(e[0],e[1])],o=(e,t)=>e.map((([e,s])=>[`${t}.${e}`,s]));t.Props=Object.assign(Object.fromEntries([["address(this)","address"],["codesize()","uint"],["returndatasize()","uint"],["address(this).balance","uint"],["gasleft()","uint"]].map(r)),Object.fromEntries(o([["basefee","uint"],["coinbase","address payable"],["timestamp","uint"],["number","uint"],["difficulty","uint"],["gaslimit","uint"],["chainid","uint"],["prevrandao","uint"]],"block").map(r)),Object.fromEntries(o([["sender","address"],["data.length","uint"]],"msg").map(r)),Object.fromEntries(o([["origin","address"],["gasprice","uint"]],"tx").map(r))),t.FNS={BALANCE:[e=>`${e}.balance`,"uint256",49],EXTCODESIZE:[e=>`address(${e}).code.length`,"uint256",59],EXTCODEHASH:[e=>`keccak256(address(${e}).code)`,"bytes32",63],BLOCKHASH:[e=>`blockhash(${e})`,"bytes32",64]};class i extends a.Tag{constructor(e,s){super(s.depth+1,s.count+1),this.mnemonic=e,this.value=s,this.tag="Fn",this.type=t.FNS[e][1]}eval(){return new i(this.mnemonic,this.value.eval())}}t.Fn=i;class c extends a.Tag{constructor(e,t,s,a,n){super(Math.max(t.depth,s.depth,a?.depth??0)+1,t.count+s.count+(a?.count??0)+1),this.kind=e,this.offset=t,this.size=s,this.address=a,this.bytecode=n,this.tag="DataCopy"}eval(){return this}}t.DataCopy=c;class l extends a.Tag{constructor(){super(0,1),this.tag="CallValue"}eval(){return this}}t.CallValue=l;class d extends a.Tag{constructor(e){super(e.depth+1,e.count+1),this.location=e,this.tag="CallDataLoad"}eval(){return new d(this.location.eval())}}t.CallDataLoad=d},939:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SLoad=t.MappingLoad=t.SStore=t.MappingStore=t.Variable=void 0;const a=s(224);t.Variable=class{constructor(e,t,s){this.label=e,this.types=t,this.index=s}};class n{constructor(e,t,s,a,n,r){this.slot=e,this.mappings=t,this.location=s,this.items=a,this.data=n,this.structlocation=r,this.name="MappingStore";const o=s;o in t||(t[o]={name:void 0,structs:[],keys:[],values:[]}),t[o].keys.push(a),void 0===r&&t[o].values.push(n)}eval(){return new n(this.slot,this.mappings,this.location,this.items,this.data.eval(),this.structlocation)}}t.MappingStore=n;class r{constructor(e,t,s){this.slot=e,this.data=t,this.variable=s,this.name="SStore"}eval(){const e=this.data.eval();if(void 0!==this.variable){const t=this.variable.types.indexOf(this.data);if(-1===t)throw new Error("error in eval sstore");this.variable.types[t]=e}return new r(this.slot.eval(),e,this.variable)}}t.SStore=r;class o extends a.Tag{constructor(e,t,s,a,n){super(Math.max(e.depth,...a.map((e=>e.depth)))+1,e.count+a.reduce(((e,t)=>e+t.count),0)+1),this.slot=e,this.mappings=t,this.location=s,this.items=a,this.structlocation=n,this.tag="MappingLoad",s in t||(t[s]={name:void 0,structs:[],keys:[],values:[]}),t[s].keys.push(a)}eval(){return this}}t.MappingLoad=o;class i extends a.Tag{constructor(e,t){super(e.depth+1,e.count+1),this.slot=e,this.variable=t,this.tag="SLoad"}eval(){return new i(this.slot.eval(),this.variable)}}t.SLoad=i},350:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDestruct=t.Invalid=t.Revert=t.Return=t.Stop=t.DelegateCall=t.StaticCall=t.Create2=t.CallCode=t.ReturnData=t.Call=t.Create=t.Sha3=void 0;const a=s(224);function n(...e){return[Math.max(...e.map((e=>e.depth)))+1,(e?.reduce(((e,t)=>e+t.count),0)??0)+1]}class r extends a.Tag{constructor(e,t,s){super(...n(e,t,...s??[])),this.offset=e,this.size=t,this.args=s,this.tag="Sha3"}eval(){return new r(this.offset.eval(),this.size.eval(),this.args?.map(a.evalE))}children(){return[...super.children(),...this.args??[]]}}t.Sha3=r;class o extends a.Tag{constructor(e,t,s,a=null){super(...n(e,t,s)),this.value=e,this.offset=t,this.size=s,this.bytecode=a,this.tag="Create",this.type="address"}eval(){return new o(this.value.eval(),this.offset.eval(),this.size.eval(),this.bytecode)}}t.Create=o;class i extends a.Tag{constructor(e,t,s,a,r,o,i){super(...n(e,t,s,a,r,o,i)),this.gas=e,this.address=t,this.value=s,this.argsStart=a,this.argsLen=r,this.retStart=o,this.retLen=i,this.tag="Call",this.throwOnFail=!1}eval(){return this}}t.Call=i;class c extends a.Tag{constructor(e,t){super(...n(e,t)),this.retOffset=e,this.retSize=t,this.tag="ReturnData",this.type="bytes",this.wrapped=!1}eval(){return this}}t.ReturnData=c;class l extends a.Tag{constructor(e,t,s,a,r,o,i){super(...n(e,t,s,a,r,o,i)),this.gas=e,this.address=t,this.value=s,this.memoryStart=a,this.memoryLength=r,this.outputStart=o,this.outputLength=i,this.tag="CallCode"}eval(){return this}}t.CallCode=l;class d extends a.Tag{constructor(e,t,s){super(...n(e,t,s)),this.offset=e,this.size=t,this.value=s,this.tag="Create2"}eval(){return this}}t.Create2=d;class u extends a.Tag{constructor(e,t,s,a,r,o){super(...n(e,t,s,a,r,o)),this.gas=e,this.address=t,this.memoryStart=s,this.memoryLength=a,this.outputStart=r,this.outputLength=o,this.tag="StaticCall"}eval(){return this}}t.StaticCall=u;class f extends a.Tag{constructor(e,t,s,a,r,o){super(...n(e,t,s,a,r,o)),this.gas=e,this.address=t,this.memoryStart=s,this.memoryLength=a,this.outputStart=r,this.outputLength=o,this.tag="DelegateCall"}eval(){return this}}t.DelegateCall=f,t.Stop=class{constructor(){this.name="Stop"}eval(){return this}};class h{constructor(e,t,s){this.offset=e,this.size=t,this.args=s,this.name="Return"}eval(){return new h(this.offset.eval(),this.size.eval(),this.args?.map(a.evalE))}}t.Return=h;class p{constructor(e,t,s,a,n){this.offset=e,this.size=t,this.selector=s,this.sig=a,this.args=n,this.name="Revert"}eval(){return new p(this.offset.eval(),this.size.eval(),this.selector,this.sig,this.args?.map(a.evalE))}static isRequireOrAssert(e){return void 0===e||e===p.ERROR||e===p.PANIC}isRequireOrAssert(){return p.isRequireOrAssert(this.selector)}}t.Revert=p,p.ERROR="08c379a0",p.PANIC="4e487b71",t.Invalid=class{constructor(e){this.opcode=e,this.name="Invalid"}eval(){return this}},t.SelfDestruct=class{constructor(e){this.address=e,this.name="SelfDestruct"}eval(){return this}}},755:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={ERC1155:{selectors:["00fdd58e","4e1273f4","e985e9c5","2eb2c2d6","f242432a","a22cb465","01ffc9a7"],topics:["17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31","4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb","c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62","6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b"],functions:{"00fdd58e":"function balanceOf(address _owner, uint256 _id) view returns (uint256)","4e1273f4":"function balanceOfBatch(address[] _owners, uint256[] _ids) view returns (uint256[])",e985e9c5:"function isApprovedForAll(address _owner, address _operator) view returns (bool)","2eb2c2d6":"function safeBatchTransferFrom(address _from, address _to, uint256[] _ids, uint256[] _values, bytes _data)",f242432a:"function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes _data)",a22cb465:"function setApprovalForAll(address _operator, bool _approved)","01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)"},events:{"17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31":"event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)","4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb":"event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values)",c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62:"event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value)","6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b":"event URI(string _value, uint256 indexed _id)"}},ERC1155MetadataURI:{selectors:["00fdd58e","4e1273f4","e985e9c5","2eb2c2d6","f242432a","a22cb465","01ffc9a7","0e89341c"],topics:["17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31","4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb","c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62","6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b"],functions:{"00fdd58e":"function balanceOf(address _owner, uint256 _id) view returns (uint256)","4e1273f4":"function balanceOfBatch(address[] _owners, uint256[] _ids) view returns (uint256[])",e985e9c5:"function isApprovedForAll(address _owner, address _operator) view returns (bool)","2eb2c2d6":"function safeBatchTransferFrom(address _from, address _to, uint256[] _ids, uint256[] _values, bytes _data)",f242432a:"function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes _data)",a22cb465:"function setApprovalForAll(address _operator, bool _approved)","01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)","0e89341c":"function uri(uint256 _id) view returns (string)"},events:{"17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31":"event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)","4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb":"event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values)",c3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62:"event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value)","6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b":"event URI(string _value, uint256 indexed _id)"}},ERC165:{selectors:["01ffc9a7"],topics:[],functions:{"01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)"},events:{}},ERC173:{selectors:["8da5cb5b","01ffc9a7","f2fde38b"],topics:["8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0"],functions:{"8da5cb5b":"function owner() view returns (address)","01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)",f2fde38b:"function transferOwnership(address _newOwner)"},events:{"8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0":"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)"}},ERC20:{selectors:["dd62ed3e","095ea7b3","70a08231","18160ddd","a9059cbb","23b872dd"],topics:["8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],functions:{dd62ed3e:"function allowance(address _owner, address _spender) view returns (uint256 remaining)","095ea7b3":"function approve(address _spender, uint256 _value) returns (bool success)","70a08231":"function balanceOf(address _owner) view returns (uint256 balance)","18160ddd":"function totalSupply() view returns (uint256)",a9059cbb:"function transfer(address _to, uint256 _value) returns (bool success)","23b872dd":"function transferFrom(address _from, address _to, uint256 _value) returns (bool success)"},events:{"8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925":"event Approval(address indexed _owner, address indexed _spender, uint256 _value)",ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef:"event Transfer(address indexed _from, address indexed _to, uint256 _value)"}},ERC20Metadata:{selectors:["dd62ed3e","095ea7b3","70a08231","313ce567","06fdde03","95d89b41","18160ddd","a9059cbb","23b872dd"],topics:["8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],functions:{dd62ed3e:"function allowance(address _owner, address _spender) view returns (uint256 remaining)","095ea7b3":"function approve(address _spender, uint256 _value) returns (bool success)","70a08231":"function balanceOf(address _owner) view returns (uint256 balance)","313ce567":"function decimals() view returns (uint8)","06fdde03":"function name() view returns (string)","95d89b41":"function symbol() view returns (string)","18160ddd":"function totalSupply() view returns (uint256)",a9059cbb:"function transfer(address _to, uint256 _value) returns (bool success)","23b872dd":"function transferFrom(address _from, address _to, uint256 _value) returns (bool success)"},events:{"8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925":"event Approval(address indexed _owner, address indexed _spender, uint256 _value)",ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef:"event Transfer(address indexed _from, address indexed _to, uint256 _value)"}},ERC721:{selectors:["095ea7b3","70a08231","081812fc","e985e9c5","6352211e","42842e0e","b88d4fde","a22cb465","01ffc9a7","23b872dd"],topics:["8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31","ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],functions:{"095ea7b3":"function approve(address _approved, uint256 _tokenId) payable","70a08231":"function balanceOf(address _owner) view returns (uint256)","081812fc":"function getApproved(uint256 _tokenId) view returns (address)",e985e9c5:"function isApprovedForAll(address _owner, address _operator) view returns (bool)","6352211e":"function ownerOf(uint256 _tokenId) view returns (address)","42842e0e":"function safeTransferFrom(address _from, address _to, uint256 _tokenId) payable",b88d4fde:"function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) payable",a22cb465:"function setApprovalForAll(address _operator, bool _approved)","01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)","23b872dd":"function transferFrom(address _from, address _to, uint256 _tokenId) payable"},events:{"8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925":"event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)","17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31":"event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)",ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef:"event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)"}},ERC721Enumerable:{selectors:["095ea7b3","70a08231","081812fc","e985e9c5","6352211e","42842e0e","b88d4fde","a22cb465","01ffc9a7","4f6ccce7","2f745c59","18160ddd","23b872dd"],topics:["8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31","ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],functions:{"095ea7b3":"function approve(address _approved, uint256 _tokenId) payable","70a08231":"function balanceOf(address _owner) view returns (uint256)","081812fc":"function getApproved(uint256 _tokenId) view returns (address)",e985e9c5:"function isApprovedForAll(address _owner, address _operator) view returns (bool)","6352211e":"function ownerOf(uint256 _tokenId) view returns (address)","42842e0e":"function safeTransferFrom(address _from, address _to, uint256 _tokenId) payable",b88d4fde:"function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) payable",a22cb465:"function setApprovalForAll(address _operator, bool _approved)","01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)","4f6ccce7":"function tokenByIndex(uint256 _index) view returns (uint256)","2f745c59":"function tokenOfOwnerByIndex(address _owner, uint256 _index) view returns (uint256)","18160ddd":"function totalSupply() view returns (uint256)","23b872dd":"function transferFrom(address _from, address _to, uint256 _tokenId) payable"},events:{"8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925":"event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)","17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31":"event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)",ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef:"event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)"}},ERC721Metadata:{selectors:["095ea7b3","70a08231","081812fc","e985e9c5","06fdde03","6352211e","42842e0e","b88d4fde","a22cb465","01ffc9a7","95d89b41","c87b56dd","23b872dd"],topics:["8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31","ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],functions:{"095ea7b3":"function approve(address _approved, uint256 _tokenId) payable","70a08231":"function balanceOf(address _owner) view returns (uint256)","081812fc":"function getApproved(uint256 _tokenId) view returns (address)",e985e9c5:"function isApprovedForAll(address _owner, address _operator) view returns (bool)","06fdde03":"function name() view returns (string)","6352211e":"function ownerOf(uint256 _tokenId) view returns (address)","42842e0e":"function safeTransferFrom(address _from, address _to, uint256 _tokenId) payable",b88d4fde:"function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) payable",a22cb465:"function setApprovalForAll(address _operator, bool _approved)","01ffc9a7":"function supportsInterface(bytes4 interfaceID) view returns (bool)","95d89b41":"function symbol() view returns (string)",c87b56dd:"function tokenURI(uint256 _tokenId) view returns (string)","23b872dd":"function transferFrom(address _from, address _to, uint256 _tokenId) payable"},events:{"8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925":"event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)","17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31":"event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)",ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef:"event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)"}}}},42:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EVM=void 0;const a=s(90),n=s(224),r=s(360),o=s(554);class i{constructor(e,t){this.step=t,this.blocks=new Map,this.errors=[],this._ids={_count:0,push(e){void 0===e.id&&(e.id=this._count++)}},this.bytecode=(0,a.arrayify)(e)}static new(e){return new i(e,new o.Shanghai)}chunks(){let e=0;const t=[],s=[...this.blocks.keys()];s.sort(((e,t)=>e-t));for(const a of s){const s=this.blocks.get(a);e!==a&&t.push({pcbegin:e,pcend:a,content:this.bytecode.subarray(e,a)}),e=s.pcend;const n=s.opcodes.map((({opcode:e})=>e));t.push({pcbegin:a,pcend:s.pcend,content:n,states:s.states})}return e!==this.bytecode.length&&t.push({pcbegin:e,pcend:this.bytecode.length,content:this.bytecode.subarray(e)}),t}start(){const e=new r.State;this.run(0,e);for(const[,e]of this.step.functionBranches)this.run(e.pc,e.state);return e}run(e,t){const s=[new n.Branch(e,t)];for(;s.length>0;){const e=s.shift(),t=this.blocks.get(e.pc);if(void 0!==t&&t.states.length>10)continue;this.exec(e.pc,e.state);const a=e.state.last;for(const e of a.next?a.next():[])s.unshift(e)}}exec(e,t){if(this._ids.push(t),t.halted)throw new Error(`State at ${e} must be non-halted to be \`exec\``);const s=[];let a;for(a of this.step.decode(this.bytecode,e)){const[,e,i]=this.step[a.opcode],c={opcode:a};s.push(c);try{t.halted||(this.step[i](t,a,this),c.stack=t.stack.clone())}catch(e){if(!(e instanceof r.ExecError))throw e;const s=new n.Throw(e.message,a);t.halt(s),this.errors.push({err:s,state:t})}if(!e&&this.bytecode[a.nextpc]===o.JUMPDEST){const e=n.Branch.make(a.nextpc,t);t.halted||t.halt(new n.JumpDest(e));break}if(e){if(!t.halted)throw Error("asfdasdf 12123");break}}if(void 0===a)throw new Error(`Executing block at ${e} cannot be empty`);if(!t.halted){const s=new n.Throw(`State must be halted after executing block at ${e}..${a.pc}`,a);t.halt(s),this.errors.push({err:s,state:t})}const i=this.blocks.get(e);void 0===i?this.blocks.set(e,{pcend:a.nextpc,opcodes:s,states:[t]}):i.states.push(t)}opcodes(){if(0===this.blocks.size)throw new Error("`blocks` is empty, call `start`, `run` or `exec` first");return[...this.blocks.values()].flatMap((e=>e.opcodes.map((e=>e.opcode))))}gc(e){const t=this.blocks.get(e.pc);if(void 0!==t)for(const s of t.states)if(c(e.state,s))return s}}function c({stack:e},{stack:t}){const s=(e,t)=>!(e.isVal()&&e.pushStateId&&t.isVal()&&t.pushStateId&&e.val!==t.val);if(e.values.length!==t.values.length)return!1;for(let a=0;a<e.values.length;a++)if(!s(e.values[a],t.values[a]))return!1;return!0}t.EVM=i},326:function(e,t,s){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,n)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),n=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||a(t,e,s)},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.reduce0=t.build=t.PublicFunction=t.isRevertBlock=t.Contract=t.ERCIds=void 0;const o=s(224),i=s(773),c=s(939),l=s(90),d=r(s(755)),u=s(42),f=s(452),h=s(360),p=s(554);t.ERCIds=Object.keys(d.default);class v{constructor(e,t=new p.Shanghai,s=new h.State){this.events={},this.variables=new Map,this.mappings={},this.functionBranches=new Map,this.reverts={},this.functions={},this.bytecode=(0,l.arrayify)(e);const a=new u.EVM(this.bytecode,t);a.run(0,s),this.main=m(s),this.payable=!w(this.main,!0);for(const[e,t]of a.step.functionBranches)a.run(t.pc,t.state),this.functions[e]=new g(this,m(t.state),e);this.events=a.step.events,this.variables=a.step.variables,this.mappings=a.step.mappings,this.functionBranches=a.step.functionBranches,this.reverts=a.step.reverts,this.metadata=(0,f.splitMetadataHash)(this.bytecode).metadata,this.errors=a.errors,this.blocks=a.blocks,this.chunks=()=>a.chunks(),this.opcodes=()=>a.opcodes()}reduce(){const e=Object.create(v.prototype),t=Object.assign(e,this);t.main=(0,o.reduce)(this.main),t.payable=!w(t.main),t.functions={};for(const[e,s]of Object.entries(this.functions)){const a=new g(t,(0,o.reduce)(s.stmts),e,s.payable);a.label=s.label,t.functions[e]=a}return t}getFunctions(){return Object.values(this.functions).flatMap((e=>void 0===e.label?[]:[e.label]))}getEvents(){return Object.values(this.events).flatMap((e=>void 0===e.sig?[]:[e.sig]))}isERC(e,t=!0){return d.default[e].selectors.every((e=>this.functionBranches.has(e)))&&(!t||d.default[e].topics.every((e=>e in this.events)))}}function b(e){return e.length>=1&&e.slice(0,-1).every((e=>"Local"===e.name||"MStore"===e.name))&&"Revert"===e.at(-1).name&&e.at(-1).isRequireOrAssert()}t.Contract=v,t.isRevertBlock=b;class g{constructor(e,t,s,a){this.contract=e,this.stmts=t,this.selector=s,this._label=void 0,this.returns=[],this.visibility="public",void 0===a?w(this.stmts)?this.payable=!1:e.payable?this.payable=!0:this.payable=!1:this.payable=a,this.constant=1===this.stmts.length&&"Return"===this.stmts[0].name;const n=[];g.findReturns(t,n),n.length>0&&n.every((e=>e.length===n[0].length&&e.map((e=>e.type)).join("")===n[0].map((e=>e.type)).join("")))?n[0].forEach((e=>{e.isVal()?this.returns.push("uint256"):e.type?this.returns.push(e.type):this.returns.push("unknown")})):n.length>0&&this.returns.push("<unknown>")}get label(){return this._label}set label(e){if(this._label=e,void 0!==e){const t=e.split("(")[0];if(this.isGetter()){const e=this.stmts.at(-1).args[0].slot.val,s=this.contract.variables.get(e);void 0!==s?s.label=t:this.contract.variables.set(e,new c.Variable(t,[],this.contract.variables.size+1))}if(this.isMappingGetter()){const e=this.stmts.at(-1).args[0].location;this.contract.mappings[e].name=t}const s=e.replace(t,"").slice(1,-1).split(",");(s.length>1||1===s.length&&""!==s[0])&&this.stmts.forEach((e=>g.patchCallDataLoad(e,s)))}}isGetter(){const e=this.stmts.at(-1);return this.stmts.length>=1&&this.stmts.slice(0,-1).every((e=>"Local"===e.name||"MStore"===e.name||"Require"===e.name))&&"Return"===e.name&&void 0!==e.args&&1===e.args.length&&"SLoad"===e.args[0].tag&&e.args[0].slot.isVal()}isMappingGetter(){const e=this.stmts.find((e=>"Local"!==e.name&&"MStore"!==e.name&&"Require"!==e.name));return void 0!==e&&this.stmts.at(-1)===e&&"Return"===e.name&&void 0!==e.args&&e.args.every((e=>"MappingLoad"===e.tag))}static findReturns(e,t){for(const s of e)"Return"===s.name&&s.args&&s.args.length>0?t.push(s.args):"If"===s.name&&[s.trueBlock,s.falseBlock].forEach((e=>{void 0!==e&&g.findReturns(e,t)}))}static patchCallDataLoad(e,t,s=new Set){if(null!==e&&!s.has(e)){s.add(e);for(const a in e)if("mappings"!==a&&Object.prototype.hasOwnProperty.call(e,a)){const n=e[a];if(n&&"CallDataLoad"===n.tag&&n.location.isVal()){const e=Number((n.location.val-4n)/32n);n.type=t[e]}"object"!=typeof n||n instanceof c.Variable||n instanceof o.Throw||g.patchCallDataLoad(n,t,s)}}}}function m(e){const t=new WeakSet,s=function e(s){if(t.has(s))return[];t.add(s);const a=s.last;if(void 0===a)return[];for(let e=0;e<s.stmts.length;e++);switch(a.name){case"Jumpi":{if(a.evalCond.isVal())return 0n===a.evalCond.val?[...s.stmts.slice(0,-1),...e(a.fallBranch.state)]:[...s.stmts.slice(0,-1),...e(a.destBranch.state)];const t=e(a.destBranch.state),n=e(a.fallBranch.state);return[...s.stmts.slice(0,-1),...b(n)?[new o.Require(a.cond,n.at(-1).selector,n.at(-1).args??[]),...t]:[new o.If(new i.IsZero(a.cond),n),...t]]}case"SigCase":{const t=e(a.fallBranch.state);return[...s.stmts.slice(0,-1),new o.If(a.condition,[new o.CallSite(a.condition.selector)],t)]}case"Jump":return[...s.stmts.slice(0,-1),...e(a.destBranch.state)];case"JumpDest":return[...s.stmts.slice(0,-1),...e(a.fallBranch.state)];default:return s.stmts}}(e);return s}function w(e,t=!1){const s=(e=t&&e[0]instanceof o.MStore?e.slice(1):e).find((e=>"Local"!==e.name));return s instanceof o.Require&&(e=>"IsZero"===e.condition.tag&&"CallValue"===e.condition.value.tag)(s.eval())}t.PublicFunction=g,t.build=m,t.reduce0=function(e){const t=[];for(const s of e)("Local"!==s.name||s.local.nrefs>0)&&t.push(s);return t},n(s(69),t),n(s(42),t),n(s(452),t),n(s(989),t),n(s(360),t),n(s(554),t),n(s(693),t)},452:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitMetadataHash=t.Metadata=void 0;const a=s(90);class n{constructor(){this.protocol="",this.hash="",this.solc=""}get url(){return`${this.protocol}://${this.hash}`}get minor(){const e=/^0\.(\d+)\./.exec(this.solc)?.[1];return e?parseInt(e):void 0}}t.Metadata=n,t.splitMetadataHash=function(e){const t=(0,a.arrayify)(e);if(t.length<=2)return{bytecode:t,metadata:void 0};const s=(t.at(-2)<<8)+t.at(-1),r=new Uint8Array(t.subarray(t.length-2-s,t.length-2));if(r.length!==s)return{bytecode:t,metadata:void 0};let o;try{o=function(e){const t=Math.pow(2,-24),s=Math.pow(2,32),a=new DataView(e);let n=0;function r(e,t){return n+=t,e}function o(t){return r(new Uint8Array(e,n,t),t)}const i=()=>r(a.getUint8(n),1),c=()=>r(a.getUint16(n),2),l=()=>r(a.getUint32(n),4);function d(){return 255===a.getUint8(n)&&(n+=1,!0)}function u(e){if(e<24)return e;if(24===e)return i();if(25===e)return c();if(26===e)return l();if(27===e)return l()*s+l();if(31===e)return-1;throw"Invalid length encoding"}function f(e){const t=i();if(255===t)return-1;const s=u(31&t);if(s<0||t>>5!==e)throw"Invalid indefinite length element";return s}function h(e,t){for(let s=0;s<t;++s){let s=i();128&s&&(s<224?(s=(31&s)<<6|63&i(),t-=1):s<240?(s=(15&s)<<12|(63&i())<<6|63&i(),t-=2):(s=(15&s)<<18|(63&i())<<12|(63&i())<<6|63&i(),t-=3)),s<65536?e.push(s):(s-=65536,e.push(55296|s>>10),e.push(56320|1023&s))}}const p=function e(){const s=i(),l=s>>5,p=31&s;let v,b;if(7===l)switch(p){case 25:return function(){const e=new ArrayBuffer(4),s=new DataView(e),a=c(),n=32768&a;let r=31744&a;const o=1023&a;if(31744===r)r=261120;else if(0!==r)r+=114688;else if(0!==o)return o*t;return s.setUint32(0,n<<16|r<<13|o<<13),s.getFloat32(0)}();case 26:return r(a.getFloat32(n),4);case 27:return r(a.getFloat64(n),8)}if(b=u(p),b<0&&(l<2||6<l))throw"Invalid length";switch(l){case 0:return b;case 1:return-1-b;case 2:if(b<0){const e=[];let t=0;for(;(b=f(l))>=0;)t+=b,e.push(o(b));const s=new Uint8Array(t);let a=0;for(v=0;v<e.length;++v)s.set(e[v],a),a+=e[v].length;return s}return o(b);case 3:const t=[];if(b<0)for(;(b=f(l))>=0;)h(t,b);else h(t,b);return String.fromCharCode.apply(null,t);case 4:let s;if(b<0)for(s=[];!d();)s.push(e());else for(s=new Array(b),v=0;v<b;++v)s[v]=e();return s;case 5:const a={};for(v=0;v<b||b<0&&!d();++v)a[e()]=e();return a;case 6:return e();case 7:switch(b){case 20:return!1;case 21:return!0;case 22:return null;default:return}default:throw new Error("Unrecognized major type")}}();if(n!==e.byteLength)throw"Remaining bytes";return p}(r.buffer)}catch{return{bytecode:t,metadata:void 0}}if(null===o||"object"!=typeof o)return{bytecode:t,metadata:void 0};const i=new n;return"ipfs"in o&&o.ipfs instanceof Uint8Array?(i.protocol="ipfs",i.hash=function(e){const t="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",s=Array(256).fill(-1);for(let e=0;e<t.length;++e)s[t.charCodeAt(e)]=e;const a=[];for(const n of e){let e=n;for(let n=0;n<a.length;++n){const r=(s[a[n]]<<8)+e;a[n]=t.charCodeAt(r%58),e=r/58|0}for(;e;)a.push(t.charCodeAt(e%58)),e=e/58|0}for(const t of e){if(t)break;a.push("1".charCodeAt(0))}return a.reverse(),String.fromCharCode(...a)}(o.ipfs),delete o.ipfs):"bzzr0"in o&&o.bzzr0 instanceof Uint8Array?(i.protocol="bzzr0",i.hash=(0,a.hexlify)(o.bzzr0),delete o.bzzr0):"bzzr1"in o&&o.bzzr1 instanceof Uint8Array&&(i.protocol="bzzr1",i.hash=(0,a.hexlify)(o.bzzr1),delete o.bzzr1),"solc"in o&&o.solc instanceof Uint8Array&&(i.solc=o.solc.join("."),delete o.solc),{bytecode:t.subarray(0,t.length-2-s),metadata:Object.assign(i,o)}}},989:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.solMappings=t.solStructs=t.solVars=t.solEvents=t.solStmts=t.sol=void 0;const a=s(326),n=s(69),r=s(224),o=s(872);function i(e,...t){const s=[e[0]];return t.forEach(((t,a)=>{const n=(0,r.isExpr)(t)?u(t):(0,r.isInst)(t)?v(t):`${t}`;s.push(n,e[a+1])})),s.join("")}t.sol=i;const c={Add:["+",11],Mul:["*",12],Sub:["-",11],Div:["/",12],Mod:["%",12],Exp:["**",14],Lt:["<",9],Gt:[">",9],Eq:["==",8],And:["&",4],Or:["|",3],Xor:["^",6],Not:["not",14],Byte:["byte",10],Shl:["<<",10],Shr:[">>>",10],Sar:[">>",10]},l=e=>{const t=e.tag;return t in c?c[t][1]:16};function d(e,t){return l(e)<l(t)?i`(${e})`:i`${e}`}function u(e){switch(e.tag){case"Val":return`${e.isJumpDest()?"[J]":""}0x${e.val.toString(16)}`;case"Local":return e.nrefs>0?`local${e.index}`:e.count>=1e3?`/*expression too big to decompile: ${e.count} AST nodes*/local${e.index}`:i`${e.value}`;case"Add":case"Mul":case"Sub":case"Div":case"Mod":case"Exp":case"Eq":case"And":case"Or":case"Xor":return`${d(e.left,e)} ${c[e.tag][0]} ${d(e.right,e)}`;case"Lt":case"Gt":return`${d(e.left,e)} ${c[e.tag][0]}${e.equal?"=":""} ${d(e.right,e)}`;case"IsZero":return"Eq"===e.value.tag?d(e.value.left,e)+" != "+d(e.value.right,e):d(e.value,e)+" == 0";case"Not":return`~${d(e.value,e)}`;case"Byte":return`(${d(e.data,e)} >> ${d(e.pos,e)}) & 1`;case"Shl":case"Shr":case"Sar":return`${d(e.value,e)} ${c[e.tag][0]} ${d(e.shift,e)}`;case"Sig":return`msg.sig == ${e.selector}`;case"CallValue":return"msg.value";case"CallDataLoad":{const t=e.location;return t.isVal()&&0n===t.val?"msg.data":t.isVal()&&(t.val-4n)%32n===0n?"_arg"+(t.val-4n)/32n:i`msg.data[${t}]`}case"Prop":return e.symbol;case"Fn":return o.FNS[e.mnemonic][0](u(e.value));case"DataCopy":switch(e.kind){case"calldatacopy":return i`msg.data[${e.offset}:(${e.offset}+${e.size})]`;case"codecopy":return i`this.code[${e.offset}:(${e.offset}+${e.size})]`;case"extcodecopy":return i`address(${e.address}).code[${e.offset}:(${e.offset}+${e.size})]`;case"returndatacopy":return i`output[${e.offset}:(${e.offset}+${e.size})]`}case"MLoad":return i`memory[${e.location}]`;case"Sha3":return void 0===e.args?i`keccak256(memory[${e.offset}:(${e.offset}+${e.size})])`:`keccak256(${e.args.map(u).join(", ")})`;case"Create":return i`new Contract(memory[${e.offset}..${e.offset}+${e.size}]).value(${e.value}).address`;case"Call":return e.argsLen.isZero()&&e.retLen.isZero()?"Mul"===e.gas.tag&&e.gas.left.isZero()&&e.gas.right.isVal()&&2300n===e.gas.right.val?e.throwOnFail?i`address(${e.address}).transfer(${e.value})`:i`address(${e.address}).send(${e.value})`:i`address(${e.address}).call.gas(${e.gas}).value(${e.value})`:i`call(${e.gas},${e.address},${e.value},${e.argsStart},${e.argsLen},${e.retStart},${e.retLen})`;case"ReturnData":return i`output:ReturnData:${e.retOffset}:${e.retSize}`;case"CallCode":return i`callcode(${e.gas},${e.address},${e.value},${e.memoryStart},${e.memoryLength},${e.outputStart},${e.outputLength})`;case"Create2":return i`new Contract(memory[${e.offset}:(${e.offset}+${e.size})]).value(${e.value}).address`;case"StaticCall":return i`staticcall(${e.gas},${e.address},${e.memoryStart},${e.memoryLength},${e.outputStart},${e.outputLength})`;case"DelegateCall":return i`delegatecall(${e.gas},${e.address},${e.memoryStart},${e.memoryLength},${e.outputStart},${e.outputLength})`;case"SLoad":if(void 0!==e.variable){return e.variable.label||`var_${e.variable.index}`}return i`storage[${e.slot}]`;case"MappingLoad":{let t=`mapping${e.location+1}`;const s=e.mappings[e.location].name;return e.location in e.mappings&&s&&(t=s),e.structlocation?t+e.items.map((e=>i`[${e}]`)).join("")+"["+e.structlocation.toString()+"]":t+e.items.map((e=>"["+u(e)+"]")).join("")}}}function f(e){return 3===e?.length&&e.every((e=>e.isVal()))}function h(e){let t="";for(let s=0;s<e.length&&"00"!==e.slice(s,s+2);s+=2)t+=String.fromCharCode(parseInt(e.substring(s,s+2),16));return