UNPKG

sevm

Version:

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

1 lines 61.7 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("sevm",[],e):"object"==typeof exports?exports.sevm=e():t.sevm=e()}(self,(()=>{return t={788:(t,e,s)=>{const a=s(326),n=t=>t[0].name;a.Contract.prototype.patch=async function(){const t=`https://api.openchain.xyz/signature-database/v1/lookup?function=${Object.keys(this.functions).map((t=>"0x"+t)).join(",")}&event=${Object.keys(this.events).map((t=>"0x"+t)).join(",")}`,e=await fetch(t);if(!e.ok)throw new Error(`error fetching signatures, url: ${t}`);const{result:s}=await e.json();for(let[t,e]of Object.entries(this.functions))t="0x"+t,t in s.function&&(e.label=n(s.function[t]));for(let[t,e]of Object.entries(this.events))t="0x"+t,t in s.event&&(e.sig=n(s.event[t]));return this},t.exports=a},90:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hexlify=e.arrayify=void 0,e.arrayify=function(t){if(t instanceof Uint8Array)return t;if("string"!=typeof t)return new Uint8Array(t);if(t.length%2!=0)throw new Error(`Unable to decode, input should have even length, but got length '${t.length}'`);const e="0x"===t.slice(0,2).toLowerCase()?2:0,s=new Uint8Array((t.length-e)/2);for(let a=e,n=0;a<t.length;a+=2,n++){const e=t.slice(a,a+2),r=parseInt(e,16);if(!(r>=0))throw new Error(`Unable to decode, invalid hex byte '${e}' found at position '${a+1}'`);s[n]=r}return s},e.hexlify=function(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}},773:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sig=e.Sar=e.Shr=e.Shl=e.Byte=e.Not=e.Xor=e.Or=e.And=e.IsZero=e.Eq=e.Gt=e.Lt=e.Exp=e.Mod=e.Div=e.Sub=e.Mul=e.Add=void 0;const a=s(224);class n extends a.Tag{constructor(t,e){super(),this.left=t,this.right=e}}class r extends n{constructor(){super(...arguments),this.tag="Add"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val+e.val):t.isZero()?e:e.isZero()?t:new r(t,e)}}e.Add=r;class o extends n{constructor(){super(...arguments),this.tag="Mul"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val*e.val):t.isZero()||e.isZero()?new a.Val(0n):new o(t,e)}}e.Mul=o;class i extends n{constructor(){super(...arguments),this.tag="Sub"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val-e.val):e.isZero()?t:new i(t,e)}}e.Sub=i;class c extends n{constructor(){super(...arguments),this.tag="Div"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?0n===e.val?new c(t,e):new a.Val(t.val/e.val):e.isVal()&&1n===e.val?t:new c(t,e)}}e.Div=c;class l extends n{constructor(){super(...arguments),this.tag="Mod"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()&&0n!==e.val?new a.Val(t.val%e.val):new l(t,e)}}e.Mod=l;class u extends n{constructor(){super(...arguments),this.tag="Exp"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()&&e.val>=0?new a.Val(t.val**e.val):new u(t,e)}}e.Exp=u;class h extends a.Tag{constructor(t,e,s=!1){super(),this.left=t,this.right=e,this.equal=s}}class d extends a.Tag{constructor(t){super(),this.value=t}}class p extends a.Tag{constructor(t,e){super(),this.value=t,this.shift=e}}class f extends h{constructor(){super(...arguments),this.tag="Lt"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val<e.val?1n:0n):new f(t,e)}}e.Lt=f;class v extends h{constructor(){super(...arguments),this.tag="Gt"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val>e.val?1n:0n):new v(t,e)}}e.Gt=v;class g extends n{constructor(){super(...arguments),this.tag="Eq"}eval(){return new g(this.left.eval(),this.right.eval())}}e.Eq=g;class m extends a.Tag{constructor(t){super(),this.value=t,this.tag="IsZero"}eval(){const t=this.value.eval();return t.isVal()?0n===t.val?new a.Val(1n):new a.Val(0n):"Lt"===t.tag?new v(t.left,t.right,!t.equal):"Gt"===t.tag?new f(t.left,t.right,!t.equal):"IsZero"===t.tag?t.value:new m(t)}}e.IsZero=m;class b extends n{constructor(){super(...arguments),this.tag="And"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val&e.val):t.isVal()&&/^[f]+$/.test(t.val.toString(16))?e:e.isVal()&&/^[f]+$/.test(e.val.toString(16))?t:t.isVal()&&"And"===e.tag&&e.left.isVal()&&t.val===e.left.val?e.right:new b(t,e)}}e.And=b;class w extends n{constructor(){super(...arguments),this.tag="Or"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val|e.val):new w(t,e)}}e.Or=w;class y extends n{constructor(){super(...arguments),this.tag="Xor"}eval(){const t=this.left.eval(),e=this.right.eval();return t.isVal()&&e.isVal()?new a.Val(t.val^e.val):new y(t,e)}}e.Xor=y;const $=1n<<0x100n;class S extends d{constructor(){super(...arguments),this.tag="Not"}eval(){const t=this.value.eval();return t.isVal()?new a.Val((~t.val%$+$)%$):new S(t)}}e.Not=S;class E extends a.Tag{constructor(t,e){super(),this.pos=t,this.data=e,this.tag="Byte"}eval(){const t=this.pos.eval(),e=this.data.eval();return e.isVal()&&t.isVal()?new a.Val(e.val>>t.val&1n):new E(t,e)}}e.Byte=E;class V extends p{constructor(){super(...arguments),this.tag="Shl"}eval(){const t=this.value.eval(),e=this.shift.eval();return t.isVal()&&e.isVal()?new a.Val(t.val<<e.val):new V(t,e)}}e.Shl=V;class k extends p{constructor(){super(...arguments),this.tag="Shr"}eval(){const t=this.value.eval(),e=this.shift.eval();return t.isVal()&&e.isVal()?new a.Val(t.val>>e.val):new k(t,e)}}e.Shr=k;class x extends p{constructor(){super(...arguments),this.tag="Sar"}eval(){const t=this.value.eval(),e=this.shift.eval();return t.isVal()&&e.isVal()?new a.Val(t.val>>e.val):new x(t,e)}}e.Sar=x;class C extends a.Tag{constructor(t){super(),this.selector=t,this.tag="Sig"}eval(){return this}}e.Sig=C},865:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SigCase=e.JumpDest=e.Jumpi=e.Jump=e.Branch=void 0;class s{constructor(t,e){this.pc=t,this.state=e}static make(t,e){return new s(t,e.clone())}}e.Branch=s,e.Jump=class{constructor(t,e){this.offset=t,this.destBranch=e,this.name="Jump"}eval(){return this}next(){return[this.destBranch]}};class a{constructor(t,e,s,a){this.cond=t,this.offset=e,this.fallBranch=s,this.destBranch=a,this.name="Jumpi",this.evalCond=t.eval()}eval(){return new a(this.cond.eval(),this.offset,this.fallBranch,this.destBranch)}next(){return this.evalCond.isVal()?0n===this.evalCond.val?[this.fallBranch]:[this.destBranch]:[this.destBranch,this.fallBranch]}}e.Jumpi=a,e.JumpDest=class{constructor(t){this.fallBranch=t,this.name="JumpDest"}eval(){return this}next(){return[this.fallBranch]}},e.SigCase=class{constructor(t,e,s){this.condition=t,this.offset=e,this.fallBranch=s,this.name="SigCase"}eval(){return this}next(){return[this.fallBranch]}}},224:function(t,e,s){"use strict";var a=this&&this.__createBinding||(Object.create?function(t,e,s,a){void 0===a&&(a=s);var n=Object.getOwnPropertyDescriptor(e,s);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,a,n)}:function(t,e,s,a){void 0===a&&(a=s),t[a]=e[s]}),n=this&&this.__exportStar||function(t,e){for(var s in t)"default"===s||Object.prototype.hasOwnProperty.call(e,s)||a(e,t,s)};Object.defineProperty(e,"__esModule",{value:!0}),e.mem=e.inline0=e.reduce=e.Locali=e.Local=e.Val=e.Tag=e.Require=e.CallSite=e.If=e.Throw=e.evalE=e.isInst=e.isExpr=void 0,e.isExpr=t=>null!==t&&"object"==typeof t&&"tag"in t,e.isInst=t=>null!==t&&"object"==typeof t&&"name"in t,e.evalE=t=>t.eval(),e.Throw=class{constructor(t,e,s){this.reason=t,this.opcode=e,this.state=s,this.name="Throw"}eval(){return this}};class r{constructor(t,e,s){this.condition=t,this.trueBlock=e,this.falseBlock=s,this.name="If"}eval(){return new r(this.condition.eval(),this.trueBlock?l(this.trueBlock):void 0,this.falseBlock?l(this.falseBlock):void 0)}}e.If=r,e.CallSite=class{constructor(t){this.selector=t,this.name="CallSite"}eval(){return this}};class o{constructor(t,e){this.condition=t,this.args=e,this.name="Require"}eval(){return new o(this.condition.eval(),this.args.map(e.evalE))}}e.Require=o;class i{isVal(){return"Val"===this.tag}isZero(){return this.isVal()&&0n===this.val}isJumpDest(){return this.isVal()&&null!==this.jumpDest}is(t){return(this instanceof c?this.value:this)instanceof t}children(){return Object.values(this).filter((t=>t instanceof i))}}e.Tag=i,e.Val=class extends i{constructor(t,e=!1){super(),this.val=t,this.isPush=e,this.tag="Val",this.jumpDest=null}eval(){return this}};class c extends i{constructor(t,e){super(),this.index=t,this.value=e,this.tag="Local",this.nrefs=0}eval(){return this.value.eval()}}function l(t){return t?.flatMap((t=>["Local","MStore"].includes(t.name)?[]:t.eval()))}e.Local=c,e.Locali=class{constructor(t){this.local=t,this.name="Local"}eval(){return this}},e.reduce=l,e.inline0=function(t){const e=new WeakSet,s=[];for(const n of t.reverse()){if("MStore"===n.name)a(n.location),a(n.data);else if("Local"===n.name&&e.has(n.local))continue;s.unshift(n)}return s;function a(t){e.add(t),t.children().forEach(a)}},e.mem=function(t){const e=[];for(const a of t.reverse())"MStore"===a.name&&(s(a.location),s(a.data)),e.unshift(a);return e;function s(t){"Local"===t.tag&&t.nrefs--,t.children().forEach(s)}},n(s(773),e),n(s(865),e),n(s(418),e),n(s(8),e),n(s(872),e),n(s(939),e),n(s(350),e)},418:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Log=void 0;const a=s(224);class n{constructor(t,e,s,a,n){this.event=t,this.offset=e,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))}}e.Log=n},8:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MStore=e.MLoad=void 0;const a=s(224);class n extends a.Tag{constructor(t,e){super(),this.location=t,this.value=e,this.tag="MLoad"}eval(){return this.value?this.value.eval():new n(this.location.eval())}}e.MLoad=n;class r{constructor(t,e){this.location=t,this.data=e,this.name="MStore"}eval(){return new r(this.location.eval(),this.data.eval())}}e.MStore=r},872:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CallDataLoad=e.CallValue=e.DataCopy=e.Fn=e.FNS=e.Props=e.Prop=void 0;const a=s(224);class n extends a.Tag{constructor(t,e){super(),this.symbol=t,this.type=e,this.tag="Prop"}eval(){return this}}e.Prop=n;const r=t=>[t[0],new n(t[0],t[1])],o=(t,e)=>t.map((([t,s])=>[`${e}.${t}`,s]));e.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))),e.FNS={BALANCE:[t=>`${t}.balance`,"uint256",49],EXTCODESIZE:[t=>`address(${t}).code.length`,"uint256",59],EXTCODEHASH:[t=>`keccak256(address(${t}).code)`,"bytes32",63],BLOCKHASH:[t=>`blockhash(${t})`,"bytes32",64]};class i extends a.Tag{constructor(t,s){super(),this.mnemonic=t,this.value=s,this.tag="Fn",this.type=e.FNS[t][1]}eval(){return new i(this.mnemonic,this.value.eval())}}e.Fn=i;class c extends a.Tag{constructor(t,e,s,a,n){super(),this.kind=t,this.offset=e,this.size=s,this.address=a,this.bytecode=n,this.tag="DataCopy"}eval(){return this}}e.DataCopy=c;class l extends a.Tag{constructor(){super(...arguments),this.tag="CallValue"}eval(){return this}}e.CallValue=l;class u extends a.Tag{constructor(t){super(),this.location=t,this.tag="CallDataLoad"}eval(){return new u(this.location.eval())}}e.CallDataLoad=u},939:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SLoad=e.MappingLoad=e.SStore=e.MappingStore=e.Variable=void 0;const a=s(224);e.Variable=class{constructor(t,e,s){this.label=t,this.types=e,this.index=s}};class n{constructor(t,e,s,a,n,r){this.slot=t,this.mappings=e,this.location=s,this.items=a,this.data=n,this.structlocation=r,this.name="MappingStore";const o=s;o in e||(e[o]={name:void 0,structs:[],keys:[],values:[]}),e[o].keys.push(a),void 0===r&&e[o].values.push(n)}eval(){return new n(this.slot,this.mappings,this.location,this.items,this.data.eval(),this.structlocation)}}e.MappingStore=n;class r{constructor(t,e,s){this.slot=t,this.data=e,this.variable=s,this.name="SStore"}eval(){const t=this.data.eval();if(void 0!==this.variable){const e=this.variable.types.indexOf(this.data);if(-1===e)throw new Error("error in eval sstore");this.variable.types[e]=t}return new r(this.slot.eval(),t,this.variable)}}e.SStore=r;class o extends a.Tag{constructor(t,e,s,a,n){super(),this.slot=t,this.mappings=e,this.location=s,this.items=a,this.structlocation=n,this.tag="MappingLoad",s in e||(e[s]={name:void 0,structs:[],keys:[],values:[]}),e[s].keys.push(a)}eval(){return this}}e.MappingLoad=o;class i extends a.Tag{constructor(t,e){super(),this.slot=t,this.variable=e,this.tag="SLoad"}eval(){return new i(this.slot.eval(),this.variable)}}e.SLoad=i},350:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SelfDestruct=e.Invalid=e.Revert=e.Return=e.Stop=e.DelegateCall=e.StaticCall=e.Create2=e.CallCode=e.ReturnData=e.Call=e.Create=e.Sha3=void 0;const a=s(224);class n extends a.Tag{constructor(t,e,s){super(),this.offset=t,this.size=e,this.args=s,this.tag="Sha3"}eval(){return new n(this.offset,this.size,this.args?.map(a.evalE))}children(){return[...super.children(),...this.args??[]]}}e.Sha3=n;class r extends a.Tag{constructor(t,e,s,a=null){super(),this.value=t,this.offset=e,this.size=s,this.bytecode=a,this.tag="Create",this.type="address"}eval(){return new r(this.value.eval(),this.offset.eval(),this.size.eval(),this.bytecode)}}e.Create=r;class o extends a.Tag{constructor(t,e,s,a,n,r,o){super(),this.gas=t,this.address=e,this.value=s,this.argsStart=a,this.argsLen=n,this.retStart=r,this.retLen=o,this.tag="Call",this.throwOnFail=!1}eval(){return this}}e.Call=o;class i extends a.Tag{constructor(t,e){super(),this.retOffset=t,this.retSize=e,this.tag="ReturnData",this.type="bytes",this.wrapped=!1}eval(){return this}}e.ReturnData=i;class c extends a.Tag{constructor(t,e,s,a,n,r,o){super(),this.gas=t,this.address=e,this.value=s,this.memoryStart=a,this.memoryLength=n,this.outputStart=r,this.outputLength=o,this.tag="CallCode"}eval(){return this}}e.CallCode=c;class l extends a.Tag{constructor(t,e,s){super(),this.offset=t,this.size=e,this.value=s,this.tag="Create2"}eval(){return this}}e.Create2=l;class u extends a.Tag{constructor(t,e,s,a,n,r){super(),this.gas=t,this.address=e,this.memoryStart=s,this.memoryLength=a,this.outputStart=n,this.outputLength=r,this.tag="StaticCall"}eval(){return this}}e.StaticCall=u;class h extends a.Tag{constructor(t,e,s,a,n,r){super(),this.gas=t,this.address=e,this.memoryStart=s,this.memoryLength=a,this.outputStart=n,this.outputLength=r,this.tag="DelegateCall"}eval(){return this}}e.DelegateCall=h,e.Stop=class{constructor(){this.name="Stop"}eval(){return this}};class d{constructor(t,e,s){this.offset=t,this.size=e,this.args=s,this.name="Return"}eval(){return new d(this.offset.eval(),this.size.eval(),this.args?.map(a.evalE))}}e.Return=d;class p{constructor(t,e,s){this.offset=t,this.size=e,this.args=s,this.name="Revert"}eval(){return new p(this.offset.eval(),this.size.eval(),this.args?.map(a.evalE))}}e.Revert=p,e.Invalid=class{constructor(t){this.opcode=t,this.name="Invalid"}eval(){return this}},e.SelfDestruct=class{constructor(t){this.address=t,this.name="SelfDestruct"}eval(){return this}}},755:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={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)"}}}},42:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.EVM=void 0;const a=s(90),n=s(224),r=s(360),o=s(554);class i{constructor(t,e){this.step=e,this.blocks=new Map,this.errors=[],this.bytecode=(0,a.arrayify)(t)}static new(t){return new i(t,new o.Shanghai)}chunks(){let t=0;const e=[],s=[...this.blocks.keys()];s.sort(((t,e)=>t-e));for(const a of s){const s=this.blocks.get(a);t!==a&&e.push({pcbegin:t,pcend:a,content:this.bytecode.subarray(t,a)}),t=s.pcend;const n=s.opcodes.map((({opcode:t})=>t));e.push({pcbegin:a,pcend:s.pcend,content:n,states:s.states})}return t!==this.bytecode.length&&e.push({pcbegin:t,pcend:this.bytecode.length,content:this.bytecode.subarray(t)}),e}start(){const t=new r.State;this.run(0,t);for(const[,t]of this.step.functionBranches)this.run(t.pc,t.state);return t}run(t,e){const s=[new n.Branch(t,e)];for(;s.length>0;){const t=s.shift(),e=this.blocks.get(t.pc);if(void 0!==e&&e.states.length>10)continue;this.exec(t.pc,t.state);const a=t.state.last;for(const t of a.next?a.next():[])s.unshift(t)}}exec(t,e){if(e.halted)throw new Error(`State at ${t} must be non-halted to be \`exec\``);const s=[];let a;for(a of this.step.decode(this.bytecode,t)){const[,t,i]=this.step[a.opcode],c={opcode:a};s.push(c);try{e.halted||(this.step[i](e,a,this.bytecode),c.stack=e.stack.clone())}catch(t){if(!(t instanceof r.ExecError))throw t;const s=new n.Throw(t.message,a,e);e.halt(s),this.errors.push(s)}if(!t&&this.bytecode[a.nextpc]===o.JUMPDEST){const t=n.Branch.make(a.nextpc,e);e.halt(new n.JumpDest(t));break}if(t){if(!e.halted)throw Error("asfdasdf 12123");break}}if(void 0===a)throw new Error(`Executing block at ${t} cannot be empty`);if(!e.halted)throw new Error(`State must be halted after executing block at ${t}..${a.pc}`);const i=this.blocks.get(t);void 0===i?this.blocks.set(t,{pcend:a.nextpc,opcodes:s,states:[e]}):i.states.push(e)}opcodes(){if(0===this.blocks.size)throw new Error("`blocks` is empty, call `start`, `run` or `exec` first");return[...this.blocks.values()].flatMap((t=>t.opcodes.map((t=>t.opcode))))}gc(t){const e=this.blocks.get(t.pc);if(void 0!==e)for(const s of e.states)if(c(t.state,s))return s}}function c({stack:t},{stack:e}){const s=(t,e)=>!(t.isVal()&&t.isPush&&e.isVal()&&e.isPush&&t.val!==e.val);if(t.values.length!==e.values.length)return!1;for(let a=0;a<t.values.length;a++)if(!s(t.values[a],e.values[a]))return!1;return!0}e.EVM=i},326:function(t,e,s){"use strict";var a=this&&this.__createBinding||(Object.create?function(t,e,s,a){void 0===a&&(a=s);var n=Object.getOwnPropertyDescriptor(e,s);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,a,n)}:function(t,e,s,a){void 0===a&&(a=s),t[a]=e[s]}),n=this&&this.__exportStar||function(t,e){for(var s in t)"default"===s||Object.prototype.hasOwnProperty.call(e,s)||a(e,t,s)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.reduce0=e.build=e.PublicFunction=e.isRevertBlock=e.Contract=e.ERCIds=void 0;const o=s(224),i=s(773),c=s(939),l=s(90),u=r(s(755)),h=s(42),d=s(452),p=s(360),f=s(554);e.ERCIds=Object.keys(u.default);class v{constructor(t,e={}){this.events={},this.variables=new Map,this.mappings={},this.functionBranches=new Map,this.functions={},this.bytecode=(0,l.arrayify)(t);const s=new h.EVM(this.bytecode,new f.Shanghai),a=new p.State;s.run(0,a),this.main=b(a),this.payable=!w(this.main,!0);for(const[t,e]of s.step.functionBranches)s.run(e.pc,e.state),this.functions[t]=new m(this,b(e.state),t);this.events=s.step.events,this.variables=s.step.variables,this.mappings=s.step.mappings,this.functionBranches=s.step.functionBranches,this.metadata=(0,d.splitMetadataHash)(this.bytecode).metadata,this.errors=s.errors,this.blocks=s.blocks,this.chunks=()=>s.chunks(),this.opcodes=()=>s.opcodes()}reduce(){const t=Object.create(v.prototype),e=Object.assign(t,this);e.main=(0,o.reduce)(this.main),e.payable=!w(e.main),e.functions={};for(const[t,s]of Object.entries(this.functions))e.functions[t]=new m(e,(0,o.reduce)(s.stmts),t,s.payable);return e}getFunctions(){return Object.values(this.functions).flatMap((t=>void 0===t.label?[]:[t.label]))}getEvents(){return Object.values(this.events).flatMap((t=>void 0===t.sig?[]:[t.sig]))}isERC(t,e=!0){return u.default[t].selectors.every((t=>this.functionBranches.has(t)))&&(!e||u.default[t].topics.every((t=>t in this.events)))}}function g(t){return t.length>=1&&t.slice(0,-1).every((t=>"Local"===t.name||"MStore"===t.name))&&"Revert"===t.at(-1).name}e.Contract=v,e.isRevertBlock=g;class m{constructor(t,e,s,a){this.contract=t,this.stmts=e,this.selector=s,this._label=void 0,this.returns=[],this.visibility="public",void 0===a?w(this.stmts)?this.payable=!1:t.payable?this.payable=!0:this.payable=!1:this.payable=a,this.constant=1===this.stmts.length&&"Return"===this.stmts[0].name;const n=[];m.findReturns(e,n),n.length>0&&n.every((t=>t.length===n[0].length&&t.map((t=>t.type)).join("")===n[0].map((t=>t.type)).join("")))?n[0].forEach((t=>{t.isVal()?this.returns.push("uint256"):t.type?this.returns.push(t.type):this.returns.push("unknown")})):n.length>0&&this.returns.push("<unknown>")}get label(){return this._label}set label(t){if(this._label=t,void 0!==t){const e=t.split("(")[0];if(this.isGetter()){const t=this.stmts.at(-1).args[0].slot.val,s=this.contract.variables.get(t);void 0!==s?s.label=e:this.contract.variables.set(t,new c.Variable(e,[],this.contract.variables.size+1))}if(this.isMappingGetter()){const t=this.stmts.at(-1).args[0].location;this.contract.mappings[t].name=e}const s=t.replace(e,"").slice(1,-1).split(",");(s.length>1||1===s.length&&""!==s[0])&&this.stmts.forEach((t=>m.patchCallDataLoad(t,s)))}}isGetter(){const t=this.stmts.at(-1);return this.stmts.length>=1&&this.stmts.slice(0,-1).every((t=>"Local"===t.name||"MStore"===t.name||"Require"===t.name))&&"Return"===t.name&&void 0!==t.args&&1===t.args.length&&"SLoad"===t.args[0].tag&&t.args[0].slot.isVal()}isMappingGetter(){const t=this.stmts.find((t=>"Local"!==t.name&&"MStore"!==t.name&&"Require"!==t.name));return void 0!==t&&this.stmts.at(-1)===t&&"Return"===t.name&&void 0!==t.args&&t.args.every((t=>"MappingLoad"===t.tag))}static findReturns(t,e){for(const s of t)"Return"===s.name&&s.args&&s.args.length>0?e.push(s.args):"If"===s.name&&[s.trueBlock,s.falseBlock].forEach((t=>{void 0!==t&&m.findReturns(t,e)}))}static patchCallDataLoad(t,e){for(const s in t)if("mappings"!==s&&Object.prototype.hasOwnProperty.call(t,s)){const a=t[s];if(a&&"CallDataLoad"===a.tag&&a.location.isVal()){const t=Number((a.location.val-4n)/32n);a.type=e[t]}"object"!=typeof a||a instanceof c.Variable||a instanceof o.Throw||m.patchCallDataLoad(a,e)}}}function b(t){const e=new WeakSet,s=function t(s){if(e.has(s))return[];e.add(s);const a=s.last;if(void 0===a)return[];for(let t=0;t<s.stmts.length;t++);switch(a.name){case"Jumpi":{if(a.evalCond.isVal())return 0n===a.evalCond.val?[...s.stmts.slice(0,-1),...t(a.fallBranch.state)]:[...s.stmts.slice(0,-1),...t(a.destBranch.state)];const e=t(a.destBranch.state),n=t(a.fallBranch.state);return[...s.stmts.slice(0,-1),...g(n)?[new o.Require(a.cond,n.at(-1).args??[]),...e]:[new o.If(new i.Not(a.cond),n),...e]]}case"SigCase":{const e=t(a.fallBranch.state);return[...s.stmts.slice(0,-1),new o.If(a.condition,[new o.CallSite(a.condition.selector)],e)]}case"Jump":return[...s.stmts.slice(0,-1),...t(a.destBranch.state)];case"JumpDest":return[...s.stmts.slice(0,-1),...t(a.fallBranch.state)];default:return s.stmts}}(t);return s}function w(t,e=!1){const s=(t=e&&t[0]instanceof o.MStore?t.slice(1):t).find((t=>"Local"!==t.name));return s instanceof o.Require&&(t=>"IsZero"===t.condition.tag&&"CallValue"===t.condition.value.tag)(s.eval())}e.PublicFunction=m,e.build=b,e.reduce0=function(t){const e=[];for(const s of t)("Local"!==s.name||s.local.nrefs>0)&&e.push(s);return e},n(s(42),e),n(s(452),e),n(s(989),e),n(s(360),e),n(s(554),e),n(s(697),e),n(s(693),e)},452:function(t,e,s){"use strict";var a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.splitMetadataHash=e.Metadata=void 0;const n=a(s(964)),r=s(90);class o{constructor(){this.protocol="",this.hash="",this.solc=""}get url(){return`${this.protocol}://${this.hash}`}get minor(){const t=/^0\.(\d+)\./.exec(this.solc)?.[1];return t?parseInt(t):void 0}}e.Metadata=o,e.splitMetadataHash=function(t){const e=(0,r.arrayify)(t);if(t.length<=2)return{bytecode:e,metadata:void 0};const s=(e.at(-2)<<8)+e.at(-1),a=new Uint8Array(e.subarray(e.length-2-s,e.length-2));if(a.length!==s)return{bytecode:e,metadata:void 0};try{const t=n.default.decode(a.buffer),i=new o;return"ipfs"in t&&t.ipfs instanceof Uint8Array?(i.protocol="ipfs",i.hash=function(t){const e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",s=Array(256).fill(-1);for(let t=0;t<e.length;++t)s[e.charCodeAt(t)]=t;const a=[];for(const n of t){let t=n;for(let n=0;n<a.length;++n){const r=(s[a[n]]<<8)+t;a[n]=e.charCodeAt(r%58),t=r/58|0}for(;t;)a.push(e.charCodeAt(t%58)),t=t/58|0}for(const e of t){if(e)break;a.push("1".charCodeAt(0))}return a.reverse(),String.fromCharCode(...a)}(t.ipfs),delete t.ipfs):"bzzr0"in t&&t.bzzr0 instanceof Uint8Array?(i.protocol="bzzr0",i.hash=(0,r.hexlify)(t.bzzr0),delete t.bzzr0):"bzzr1"in t&&t.bzzr1 instanceof Uint8Array&&(i.protocol="bzzr1",i.hash=(0,r.hexlify)(t.bzzr1),delete t.bzzr1),"solc"in t&&t.solc instanceof Uint8Array&&(i.solc=t.solc.join("."),delete t.solc),{bytecode:e.subarray(0,e.length-2-s),metadata:Object.assign(i,t)}}catch{return{bytecode:e,metadata:void 0}}}},989:(t,e,s)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.solMappings=e.solStructs=e.solVars=e.solEvents=e.solStmts=e.sol=void 0;const a=s(872),n=s(224),r=s(326);function o(t,...e){const s=[t[0]];return e.forEach(((e,a)=>{const r=(0,n.isExpr)(e)?u(e):(0,n.isInst)(e)?h(e):`${e}`;s.push(r,t[a+1])})),s.join("")}e.sol=o;const i={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]},c=t=>{const e=t.tag;return e in i?i[e][1]:16};function l(t,e){return c(t)<c(e)?o`(${t})`:o`${t}`}function u(t){switch(t.tag){case"Val":return`${t.isJumpDest()?"[J]":""}0x${t.val.toString(16)}`;case"Local":return t.nrefs>0?`local${t.index}`:o`${t.value}`;case"Add":case"Mul":case"Sub":case"Div":case"Mod":case"Exp":case"Eq":case"And":case"Or":case"Xor":return`${l(t.left,t)} ${i[t.tag][0]} ${l(t.right,t)}`;case"Lt":case"Gt":return`${l(t.left,t)} ${i[t.tag][0]}${t.equal?"=":""} ${l(t.right,t)}`;case"IsZero":return"Eq"===t.value.tag?l(t.value.left,t)+" != "+l(t.value.right,t):l(t.value,t)+" == 0";case"Not":return`~${l(t.value,t)}`;case"Byte":return`(${l(t.data,t)} >> ${l(t.pos,t)}) & 1`;case"Shl":case"Shr":case"Sar":return`${l(t.value,t)} ${i[t.tag][0]} ${l(t.shift,t)}`;case"Sig":return`msg.sig == ${t.selector}`;case"CallValue":return"msg.value";case"CallDataLoad":{const e=t.location;return e.isVal()&&0n===e.val?"msg.data":e.isVal()&&(e.val-4n)%32n===0n?"_arg"+(e.val-4n)/32n:o`msg.data[${e}]`}case"Prop":return t.symbol;case"Fn":return a.FNS[t.mnemonic][0](u(t.value));case"DataCopy":switch(t.kind){case"calldatacopy":return o`msg.data[${t.offset}:(${t.offset}+${t.size})]`;case"codecopy":return o`this.code[${t.offset}:(${t.offset}+${t.size})]`;case"extcodecopy":return o`address(${t.address}).code[${t.offset}:(${t.offset}+${t.size})]`;case"returndatacopy":return o`output[${t.offset}:(${t.offset}+${t.size})]`}case"MLoad":return o`memory[${t.location}]`;case"Sha3":return void 0===t.args?o`keccak256(memory[${t.offset}:(${t.offset}+${t.size})])`:`keccak256(${t.args.map(u).join(", ")})`;case"Create":return o`new Contract(memory[${t.offset}..${t.offset}+${t.size}]).value(${t.value}).address`;case"Call":return t.argsLen.isZero()&&t.retLen.isZero()?"Mul"===t.gas.tag&&t.gas.left.isZero()&&t.gas.right.isVal()&&2300n===t.gas.right.val?t.throwOnFail?o`address(${t.address}).transfer(${t.value})`:o`address(${t.address}).send(${t.value})`:o`address(${t.address}).call.gas(${t.gas}).value(${t.value})`:o`call(${t.gas},${t.address},${t.value},${t.argsStart},${t.argsLen},${t.retStart},${t.retLen})`;case"ReturnData":return o`output:ReturnData:${t.retOffset}:${t.retSize}`;case"CallCode":return o`callcode(${t.gas},${t.address},${t.value},${t.memoryStart},${t.memoryLength},${t.outputStart},${t.outputLength})`;case"Create2":return o`new Contract(memory[${t.offset}:(${t.offset}+${t.size})]).value(${t.value}).address`;case"StaticCall":return o`staticcall(${t.gas},${t.address},${t.memoryStart},${t.memoryLength},${t.outputStart},${t.outputLength})`;case"DelegateCall":return o`delegatecall(${t.gas},${t.address},${t.memoryStart},${t.memoryLength},${t.outputStart},${t.outputLength})`;case"SLoad":if(void 0!==t.variable){return t.variable.label||`var_${t.variable.index}`}return o`storage[${t.slot}]`;case"MappingLoad":{let e=`mapping${t.location+1}`;const s=t.mappings[t.location].name;return t.location in t.mappings&&s&&(e=s),t.structlocation?e+t.items.map((t=>o`[${t}]`)).join("")+"["+t.structlocation.toString()+"]":e+t.items.map((t=>"["+u(t)+"]")).join("")}}}function h(t){switch(t.name){case"If":return o`(${t.condition})`;case"CallSite":return o`$${t.selector}();`;case"Require":return`require(${[t.condition,...t.args].map(u).join(", ")});`;default:return function(t){switch(t.name){case"Local":return o`${t.local.value.type} local${t.local.index} = ${t.local.value}; // #refs ${t.local.nrefs}`;case"MStore":return o`memory[${t.location}] = ${t.data};`;case"Stop":return"return;";case"Return":return void 0===t.args?o`return memory[${t.offset}:(${t.offset}+${t.size})];`:0===t.args.length?"return;":3===(e=t.args).length&&e.every((t=>t.isVal()))&&32n===t.args[0].val?`return '${function(t){let e="";for(let s=0;s<t.length&&"00"!==t.slice(s,s+2);s+=2)e+=String.fromCharCode(parseInt(t.substring(s,s+2),16));return e}(t.args[2].val.toString(16))}';`:1===t.args.length?o`return ${t.args[0]};`:`return (${t.args.map(u).join(", ")});`;case"Revert":return void 0===t.args?o`revert(memory[${t.offset}:(${t.offset}+${t.size})]);`:`revert(${t.args.map(u).join(", ")});`;case"SelfDestruct":return o`selfdestruct(${t.address});`;case"Invalid":return`revert('Invalid instruction (0x${t.opcode.toString(16)})');`;case"Log":return t.eventName?`emit ${t.eventName}(${[...t.topics.slice(1),...t.args??[]].map(u).join(", ")});`:"log("+(void 0===t.args?[...t.topics,o`memory[${t.offset}:${t.size} ]`].join(", ")+"ii":[...t.topics,...t.args].map(u).join(", "))+");";case"Jump":return o`goto :${t.offset} branch:${t.destBranch.pc}`;case"Jumpi":return o`when ${t.cond} goto ${t.destBranch.pc} or fall ${t.fallBranch.pc}`;case"JumpDest":return`fall: ${t.fallBranch.pc}:`;case"SigCase":return o`case when ${t.condition} goto ${t.offset} or fall ${t.fallBranch.pc}`;case"SStore":{const e=t.slot.eval(),s=t=>"SLoad"===t.tag&&u(t.slot.eval())===u(e);let a=o`storage[${e}]`;e.isVal()&&void 0!==t.variable&&(a=t.variable.label||`var_${t.variable.index}`);const n=t.data.eval();return"Add"===n.tag&&s(n.left)?o`${a} += ${n.right};`:"Add"===n.tag&&s(n.right)?o`${a} += ${n.left};`:"Sub"===n.tag&&s(n.left)?o`${a} -= ${n.right};`:o`${a} = ${t.data};`}case"MappingStore":{let e=`mapping${t.location+1}`;return t.location in t.mappings&&t.mappings[t.location].name&&(e=t.mappings[t.location].name),"Add"===t.data.tag&&"MappingLoad"===t.data.right.tag&&t.data.right.location===t.location?e+t.items.map((t=>"["+u(t)+"]")).join("")+" += "+u(t.data.left)+";":"Add"===t.data.tag&&"MappingLoad"===t.data.left.tag&&t.data.left.location===t.location?e+t.items.map((t=>o`[${t}]`)).join("")+" += "+u(t.data.right)+";":"Sub"===t.data.tag&&"MappingLoad"===t.data.left.tag&&t.data.left.location===t.location?e+t.items.map((t=>o`[${t}]`)).join("")+" -= "+u(t.data.right)+";":e+t.items.map((t=>o`[${t}]`)).join("")+" = "+u(t.data)+";"}case"Throw":return`throw('${t.reason}');`}var e}(t)}}function d(t,e=0){let s="";for(const a of t)if(a instanceof n.If){const t=h(a);s+=" ".repeat(e)+"if "+t+" {\n",s+=d(a.trueBlock,e+4),a.falseBlock&&(s+=" ".repeat(e)+"} else {\n",s+=d(a.falseBlock,e+4)),s+=" ".repeat(e)+"}\n"}else{if("Local"===a.name&&a.local.nrefs<=0)continue;if("MStore"===a.name)continue;s+=" ".repeat(e)+h(a)+"\n"}return s}function p(t,e=0){let s="";for(const[a,n]of Object.entries(t)){if(s+=" ".repeat(e)+"event ",void 0===n.sig)s+=a;else{const t=n.sig.split("(")[0],e=n.sig.replace(t,"").substring(1).slice(0,-1);e?(s+=t+"(",s+=e.split(",").map(((t,e)=>e<n.indexedCount?`${t} indexed _arg${e}`:`${t} _arg${e}`)).join(", "),s+=")"):s+=n.sig}s+=";\n"}return s}function f(t){let e="";return[...t.entries()].forEach((([t,s],a)=>{const n=s.types.map((t=>t.isVal()?"uint256":t.type??"")).filter((t=>""!==t.trim()));0===n.length&&n.push("unknown");const r=s.label?` public ${s.label}`:` var${a+1}__${s.index}`;e+=` ${[...new Set(n)].join("|")+r}; // Slot #${t}\n`})),e}function v(t){let e="";return Object.keys(t).filter((e=>t[e].structs.length>0)).forEach((s=>{const a=t[s];e+=`struct ${a.name}Struct {\n`,a.structs.forEach((t=>{e+=` ${t.toString()};\n`})),e+="}\n\n"})),e}function g(t){let e="";return Object.keys(t).forEach(((a,n)=>{const r=t[a],o=r.name?`public ${r.name}`:`mapping${n+1}`;e+=` ${s(r)} ${o};\n`})),e;function s(t){const e=[],a=[];let n=!1;return t.keys.filter((t=>t.length>0)).forEach((r=>{const o=r[0];r.length>0&&o.type&&!e.includes(o.type)&&e.push(o.type),r.length>1&&!n?(n=!0,a.push(s({name:t.name,structs:t.structs,keys:t.keys.map((t=>t.slice(1))),values:t.values}))):1!==r.length||n||t.values.forEach((t=>{t.type&&!a.includes(t.type)&&a.push(t.type)}))})),0===e.length&&e.push("unknown"),t.structs.length>0&&0===a.length?a.push(`${t.name}Struct`):0===a.length&&a.push("unknown"),"mapping ("+e.join("|")+" => "+a.join("|")+")"}}function m(t,e=" "){let s="";if(s+=e+"function ",void 0!==t.label){const e=t.label,a=e.split("(")[0],n=e.replace(a,"").substring(1).slice(0,-1);n?(s+=a+"(",s+=n.split(",").map(((t,e)=>`${t} _arg${e}`)).join(", "),s+=")"):s+=e}else s+=t.selector+"()";return s+=" "+t.visibility,t.constant&&(s+=" view"),t.payable&&(s+=" payable"),t.returns.length>0&&(s+=` returns (${t.returns.join(", ")})`),s+=" {\n",s+=d(t.stmts,8),s+=e+"}\n\n",s}e.solStmts=d,e.solEvents=p,e.solVars=f,e.solStructs=v,e.solMappings=g,r.Contract.prototype.solidify=function(t={}){const{license:e="UNLICENSED",pragma:s=!0,contractName:a="Contract"}=t;let n="";e&&(n+=`// SPDX-License-Identifier: ${e}\n`),s&&this.metadata&&(n+=`// Metadata ${this.metadata.url}\n`,n+=`pragma solidity ${this.metadata.solc};\n`,n+="\n"),n+=`contract ${a} {\n\n`;const r=t=>""===t?"":t+"\n";n+=r(p(this.events,4)),n+=v(this.mappings),n+=r(g(this.mappings)),n+=r(f(this.variables));const o=this.metadata?.minor>=6?"fallback":"function";n+=" ".repeat(4)+`${o}() external payable {\n`,n+=d(this.main,8),n+=" ".repeat(4)+"}\n\n";for(const[,t]of Object.entries(this.functions))n+=m(t);return n+="}\n",n}},360:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ExecError=e.State=e.Stack=void 0;class s{constructor(){this.values=[]}get top(){return this.values[0]}push(t){if(this.values.length>=1024)throw new n("Stack too deep");this.values.unshift(t)}pop(){if(0===this.values.length)throw new n("POP with empty stack");return this.values.shift()}swap(t){if(t<1||t>16)throw new n("Unsupported position for swap operation");if(!(t in this.values))throw new n("Position not found for swap operation,");const e=this.values[0],s=this.values[t];this.values[0]=s,this.values[t]=e}clone(){const t=new s;return t.values.push(...this.values),t}}e.Stack=s;class a{constructor(t=new s,e={},a=0){this.stack=t,this.memory=e,this.nlocals=a,this._halted=!1,this.stmts=[]}get halted(){return this._halted}get last(){return this.stmts.at(-1)}halt(t){if(this._halted)throw new n("State already halted");this.stmts.push(t),this._halted=!0}clone(){return new a(this.stack.clone(),{...this.memory},this.nlocals)}}e.State=a;class n extends Error{}e.ExecError=n},554:function(t,e,s){"use strict";var a=this&&this.__createBinding||(Object.create?function(t,e,s,a){void 0===a&&(a=s);var n=Object.getOwnPropertyDescriptor(e,s);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,a,n)}:function(t,e,s,a){void 0===a&&(a=s),t[a]=e[s]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)"default"!==s&&Object.prototype.hasOwnProperty.call(t,s)&&a(e,t,s);return n(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.Shanghai=e.Paris=e.London=e.JUMPDEST=e.Undef=e.Members=e.Opcode=void 0;const o=s(90),i=s(360),c=r(s(224)),l=s(224),u=s(773),h=s(865),d=s(872),p=s(350);class f{constructor(t,e,s,a=null){this.pc=t,this.opcode=e,this.mnemonic=s,this.data=a}get nextpc(){return this.pc+(this.data?.length??0)+1}hexData(){return null===this.data?void 0:(0,o.hexlify)(this.data)}format(t=!0){const e=this.data?` 0x${this.hexData()}`+(t?` (${parseInt(this.hexData(),16)})`:""):"";return`${this.mnemonic}(0x${this.opcode.toString(16)})@${this.pc}${e}`}}e.Opcode=f;class v{constructor(){this.events={},this.variables=new Map,this.mappings={},this.functionBranches=new Map}}e.Members=v;class g extends v{constructor(){super(),this.UNDEF=(t,e)=>t.halt(new c.Invalid(e.opcode)),Object.assign(this,Object.fromEntries([...Array(256).keys()].map((t=>[t,[0,!0,"UNDEF"]]))))}haltingSteps(){return[...Array(256).keys()].map((t=>this[t])).filter((([,t,e])=>t&&"UNDEF"!==e)).map((([,,t])=>t))}opcodes(){return Object.fromEntries([...Array(256).keys()].map((t=>[this[t][2],t])).filter((([t])=>"UNDEF"!==t)))}*decode(t,e=0){const s=(0,o.arrayify)(t);for(let t=e;t<s.length;t++){const e=s[t],[a,,n]=this[e];yield new f(t,e,n,0===a?null:function(){const r=s.subarray(t+1,t+a+1);if(r.length!==a){const s=new f(t,e,n,r).format(!1);throw new Error(`Trying to get \`${a}\` bytes but got only \`${r.length}\` while decoding \`${s}\` before reaching the end of bytecode`)}return t+=a,r}())}}}e.Undef=g;const m={ADDMOD:[8,({stack:t})=>{const e=t.pop(),s=t.pop(),a=t.pop();t.push(e.isVal()&&s.isVal()&&a.isVal()?new l.Val((e.val+s.val)%a.val):e.isVal()&&s.isVal()?new c.Mod(new l.Val(e.val+s.val),a):new c.Mod(new c.Add(e,s),a))}],MULMOD:[9,({stack:t})=>{const e=t.pop(),s=t.pop(),a=t.pop();t.push(e.isVal()&&s.isVal()&&a.isVal()?new l.Val(e.val*s.val%a.val):e.isVal()&&s.isVal()?new c.Mod(new l.Val(e.val*s.val),a):new c.Mod(new c.Mul(e,s),a))}],SIGNEXTEND:[11,({stack:t})=>{const e=t.pop(),s=t.pop();t.push(e.isVal()&&s.isVal()?new l.Val(s.val<<32n-e.val>>32n-e.val):e.isVal()?new u.Sar(new u.Shl(s,new l.Val(32n-e.val)),new l.Val(32n-e.val)):new u.Sar(new u.Shl(s,new c.Sub(new l.Val(32n),e)),new c.Sub(new l.Val(32n),e)))}],EQ:[20,({stack:t})=>{const e=(t,e)=>{if(t=t.eval(),e=e.eval(),t.isVal()&&"Div"===e.tag&&e.right.isVal()){const s=t.val*e.right.val;if(e=e.left,s%(1n<<0xe0n)===0n&&"CallDataLoad"===e.tag&&e.location.isZero())return new c.Sig(s.toString(16).substring(0,8-(64-s.toString(16).length)).padStart(8,"0"))}},s=t.pop(),a=t.pop();t.push(s.isVal()&&a.isVal()?s.val===a.val?new l.Val(1n):new l.Val(0n):e(s,a)??e(a,s)??new c.Eq(s,a))}],ISZERO:[21,({stack:t})=>{const e=t.pop();t.push(new c.IsZero(e))}],NOT:[25,({stack:t})=>{const e=t.pop();t.push(new c.Not(e))}],BYTE:[26,({stack:t})=>{const e=t.pop(),s=t.pop();t.push(new c.Byte(e,s))}]},b=t=>({stack:e})=>e.push(c.Props[t]),w={COINBASE:[65,b("block.coinbase")],TIMESTAMP:[66,b("block.timestamp")],NUMBER:[67,b("block.number")],DIFFICULTY:[68,b("block.difficulty")],GASLIMIT:[69,b("block.gaslimit")],CALLER:[51,b("msg.sender")],CALLDATASIZE:[54,b("msg.data.length")],ORIGIN:[50,b("tx.origin")],GASPRICE:[58,b("tx.gasprice")],ADDRESS:[48,b("address(this)")],CODESIZE:[56,b("codesize()")],RETURNDATASIZE:[61,b("returndatasize()")],GAS:[90,b("gasleft()")],CALLVALUE:[52,({stack:t})=>t.push(new c.CallValue)],CALLDATALOAD:[53,({stack:t})=>t.push(new c.CallDataLoad(t.pop()))]},y=t=>function({stack:e,memory:s},a){const n=e.pop(),r=e.pop(),o=e.pop();n.isVal()&&(s[Number(n.val)]=new c.DataCopy(t,r,o,a))},$={CALLDATACOPY:[55,t=>y("calldatacopy")(t)],CODECOPY:[57,function({stack:t,memory:e},s,a){const n=t.pop().eval(),r=t.pop(),o=t.pop();if(!n.isVal()||n.val>=32768)throw new i.ExecError("Memory destination for CODECOPY is not reducible to Val");e[Number(n.val)]=new c.DataCopy("codecopy",r,o,void 0,((t,e)=>{if(t.isVal()&&e.isVal())return a.subarray(Number(t.val),Number(t.val+e.val))})(r.eval(),o.eval()))}],EXTCODECOPY:[60,t=>{const e=t.stack.pop();y("extcodecopy")(t,e)}],RETURNDATACOPY:[62,t=>y("returndatacopy")(t)]};function S({stack:t,memory:e},s){const a=t.pop(),n=t.pop();return new s(a,n,function(t,a){if(t.isVal()&&a.isVal()&&a.val<=32768){const s=[];for(let n=Number(t.val);n<Number(t.val+a.val);n+=32)s.push(n in e?e[n].eval():new c.MLoad(new l.Val(BigInt(n))));return s}if(a.isVal()&&a.val>32768)throw new Error(`memargs size ${s.name} ${a.val}`)}(a.eval(),n.eval()))}const E=(t,e,s)=>{let a;return t.isVal()&&(a=s.variables.get(t.val),void 0===a?(a=new l.Variable(null,e,s.variables.size+1),s.variables.set(t.val,a)):a.types.push(...e)),a},V={SLOAD:[84,function({stack:t}){const e=t.pop();let s,a;const n=t=>([s,a]=k(t),void 0!==s&&a.length>0);"Sha3"===e.tag&&n(e)?t.push(new l.MappingLoad(e,this.mappings,s,a)):"Add"===e.tag&&"Sha3"===e.left.tag&&e.right.isVal()&&n(e.left)?t.push(new l.MappingLoad(e,this.mappings,s,a,e.right.val)):"Add"===e.tag&&e.left.isVal()&&"Sha3"===e.right.tag&&n(e.right)?t.push(new l.MappingLoad(e,this.mappings,s,a,e.left.val)):t.push(new c.SLoad(e,E(e.eval(),[],this)))}],SSTORE:[85,function({stack:t,stmts:e}){const s=t.pop(),a=t.pop();let n,r;"Local"===s.tag&&s.nrefs--;const o=t=>([n,r]=k(t),void 0!==n&&r.length>0);"Sha3"===s.tag&&o(s)?e.push(new l.MappingStore(s,this.mappings,n,r,a)):"Add"===s.tag&&"Sha3"===s.left.tag&&s.right.isVal()&&o(s.left)?e.push(new l.MappingStore(s,this.mappings,n,r,a,s.right.val)):"Add"===s.tag&&s.left.isVal()&&"Sha3"===s.right.tag&&o(s.right)?e.push(new l.MappingStore(s,this.mappings,n,r,a,s.left.val)):e.push(new c.SStore(s,a,E(s.eval(),[a],this)))}]};function k(t){const e=[t],s=[];let a;for(;e.length>0;){const t=e.shift();for(const n of t.args??[])"Sha3"===n.tag&&n.args?e.unshift(n):void 0===a&&"Val"===n.tag?a=Number(n.val):s.unshift(n)}return[a,s]}function x(t,s,a){const n=t.eval();if(!n.isVal())throw new i.ExecError(`${s.format()} offset should be numeric but found '${t.tag}'`);const r=Number(n.val);if(a[r]===e.JUMPDEST)return t instanceof l.Val||"Local"===t.tag?n.jumpDest=r:t.jumpDest=r,r;throw new i.ExecError(`${s.format()} destination should be JUMPDEST@${r} but ${void 0===a[r]?`'${r}' is out-of-bounds`:`found '0x${a[r].toString(16)}'`}`)}e.JUMPDEST=91;const C=Object.fromEntries,L={POP:[80,({stack:t})=>t.pop()],...C([...Array(32).keys()].map((t=>[`PUSH${t+1}`,[{opcode:96+t,size:t+1},({stack:t},e)=>t.push(new l.Val(BigInt("0x"+e.hexData()),!0))]]))),...C([...Array(16).keys()].map((t=>[`DUP${t+1}`,[128+t,e=>{if(t>=e.stack.values.length)throw new i.ExecError("Invalid duplication operation, position was not found");const s=e.stack.values[t];if("Local"!==s.tag){const a=new l.Local(e.nlocals++,s);e.stack.values[t]=a,e.stmts.push(new l.Locali(a))}else s.nrefs++;e.stack.push(e.stack.values[t])}]]))),...C([...Array(16).keys()].map((t=>[`SWAP${t+1}`,[144+t,({stack:e})=>e.swap(t+1)]]))),...C([["ADD",1,c.Add],["MUL",2,c.Mul],["SUB",3,c.Sub],["DIV",4,c.Div],["SDIV",5,c.Div],["MOD",6,c.Mod],["SMOD",7,c.Mod],["EXP",10,c.Exp],["LT",16,c.Lt],["GT",17,c.Gt],["SLT",18,c.Lt],["SGT",19,c.Gt],["AND",22,c.And],["OR",23,c.Or],["XOR",24,c.Xor]].map((([t,e,s])=>[t,[e,({stack:t})=>{const e=t.pop(),a=t.pop();t.push(new s(e,a))}]]))),...m,...w,PC:[88,({stack:t},e)=>t.push(new l.Val(BigInt(e.pc)))],...C(Object.entries(d.FNS).map((([t,[,,e]])=>[t,[e,({stack:e})=>e.push(new d.Fn(t,e.pop()))]]))),...$,MLOAD:[81,({stack:t,memory:e})=>{const s=t.pop();t.push(new c.MLoad(s,(t=>t.isVal()&&Number(t.val)in e?e[Number(t.val)]:void 0)(s.eval())))}],...C([["MSTORE",82],["MSTORE8",83]].map((([t,e])=>[t,[e,({stack:t,memory:e,stmts:s})=>{let a=t.pop();const n=t.pop();"Local"===a.tag&&a.nrefs--,"Local"===n.tag&&n.nrefs--,s.push(new c.MStore(a,n)),a=a.eval(),a.isVal()&&(e[Number(a.val)]=n)}]]))),MSIZE:[89,({stack:t})=>t.push(new d.Prop("msize()","uint"))],SHA3:[32,t=>t.stack.push(S(t,p.Sha3))],STOP:[{opcode:0,halts:!0},t=>t.halt(new c.Stop)],CREATE:[240,function({stack:t,memory:e}){const s=t.pop(),a=t.pop(),n=t.pop();t.push(new c.Create(s,a,n,((t,s)=>{if(t.isVal()&&s.isVal()&&Number(t.val)in e){const a=e[Number(t.val)];if("DataCopy"===a.tag&&void 0!==a.bytecode&&a.bytecode.length===Number(s.val))return a.bytecode}return null})(a.eval(),n.eval())))}],CALL:[241,function({stack:t,memory:e}){const s=t.pop(),a=t.pop(),n=t.pop(),r=t.pop(),o=t.pop(),i=t.pop(),l=t.pop();t.push(new c.Call(s,a,n,r,o,i,l)),i.isVal()&&(e[Number(i.val)]=new c.ReturnData(i,l))}],CALLCODE:[242,function({stack:t}){const e=t.pop(),s=t.pop(),a=t.pop(),n=t.pop(),r=t