UNPKG

@snaaps/snap

Version:

snAAps Account Abstraction snap for MetaMask

1 lines 555 kB
(()=>{var e={9752:(e,t,r)=>{"use strict";var n=r(8834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Common=void 0;const o=r(5372),i=r(7108),s=r(2699),a=r(4579),c=r(3192),u=r(4002),l=r(7623),d=r(6369),f=r(3925),h=r(649),p=r(2188),y=r(3824);class g extends s.EventEmitter{constructor(e){super(),this._eips=[],this._customChains=e.customChains??[],this._chainParams=this.setChain(e.chain),this.DEFAULT_HARDFORK=this._chainParams.defaultHardfork??h.Hardfork.Merge,this.HARDFORK_CHANGES=this.hardforks().map((e=>[e.name,p.hardforks[e.name]])),this._hardfork=this.DEFAULT_HARDFORK,void 0!==e.hardfork&&this.setHardfork(e.hardfork),e.eips&&this.setEIPs(e.eips)}static custom(e,t={}){const r=t.baseChain??"mainnet",n={...g._getChainParams(r)};if(n.name="custom-chain","string"!=typeof e)return new g({chain:{...n,...e},...t});if(e===h.CustomChain.PolygonMainnet)return g.custom({name:h.CustomChain.PolygonMainnet,chainId:137,networkId:137},t);if(e===h.CustomChain.PolygonMumbai)return g.custom({name:h.CustomChain.PolygonMumbai,chainId:80001,networkId:80001},t);if(e===h.CustomChain.ArbitrumRinkebyTestnet)return g.custom({name:h.CustomChain.ArbitrumRinkebyTestnet,chainId:421611,networkId:421611},t);if(e===h.CustomChain.ArbitrumOne)return g.custom({name:h.CustomChain.ArbitrumOne,chainId:42161,networkId:42161},t);if(e===h.CustomChain.xDaiChain)return g.custom({name:h.CustomChain.xDaiChain,chainId:100,networkId:100},t);if(e===h.CustomChain.OptimisticKovan)return g.custom({name:h.CustomChain.OptimisticKovan,chainId:69,networkId:69},{hardfork:h.Hardfork.Berlin,...t});if(e===h.CustomChain.OptimisticEthereum)return g.custom({name:h.CustomChain.OptimisticEthereum,chainId:10,networkId:10},{hardfork:h.Hardfork.Berlin,...t});throw new Error(`Custom chain ${e} not supported`)}static fromGethGenesis(e,{chain:t,eips:r,genesisHash:n,hardfork:o,mergeForkIdPostMerge:i}){const s=(0,y.parseGethGenesis)(e,t,i),a=new g({chain:s.name??"custom",customChains:[s],eips:r,hardfork:o??s.hardfork});return void 0!==n&&a.setForkHashes(n),a}static isSupportedChainId(e){const t=this._getInitializedChains();return Boolean(t.names[e.toString()])}static _getChainParams(e,t){const r=this._getInitializedChains(t);if("number"==typeof e||"bigint"==typeof e){if(e=e.toString(),r.names[e]){return r[r.names[e]]}throw new Error(`Chain with ID ${e} not supported`)}if(void 0!==r[e])return r[e];throw new Error(`Chain with name ${e} not supported`)}setChain(e){if("number"==typeof e||"bigint"==typeof e||"string"==typeof e)this._chainParams=g._getChainParams(e,this._customChains);else{if("object"!=typeof e)throw new Error("Wrong input format");{if(this._customChains.length>0)throw new Error("Chain must be a string, number, or bigint when initialized with customChains passed in");const t=["networkId","genesis","hardforks","bootstrapNodes"];for(const r of t)if(!(r in e))throw new Error(`Missing required chain parameter: ${r}`);this._chainParams=e}}for(const e of this.hardforks())if(void 0===e.block)throw new Error("Hardfork cannot have undefined block number");return this._chainParams}setHardfork(e){let t=!1;for(const r of this.HARDFORK_CHANGES)r[0]===e&&(this._hardfork!==e&&(this._hardfork=e,this.emit("hardforkChanged",e)),t=!0);if(!t)throw new Error(`Hardfork with name ${e} not supported`)}getHardforkByBlockNumber(e,t,r){e=(0,o.toType)(e,o.TypeOutput.BigInt),t=(0,o.toType)(t,o.TypeOutput.BigInt),r=(0,o.toType)(r,o.TypeOutput.Number);const n=this.hardforks().filter((e=>null!==e.block||null!==e.ttd&&void 0!==e.ttd||void 0!==e.timestamp)),i=n.findIndex((e=>null!==e.ttd&&void 0!==e.ttd));if(n.slice(i+1).findIndex((e=>null!==e.ttd&&void 0!==e.ttd))>=0)throw Error("More than one merge hardforks found with ttd specified");let s=n.findIndex((t=>null!==t.block&&t.block>e||void 0!==r&&Number(t.timestamp)>r));if(-1===s)s=n.length;else if(0===s)throw Error("Must have at least one hardfork at block 0");if(void 0===r){s-=n.slice(0,s).reverse().findIndex((e=>null!==e.block||void 0!==e.ttd))}if(s-=1,null===n[s].block&&void 0===n[s].timestamp)(null==t||BigInt(n[s].ttd)>t)&&(s-=1);else if(i>=0&&null!=t){if(s>=i&&BigInt(n[i].ttd)>t)throw Error("Maximum HF determined by total difficulty is lower than the block number HF");if(s<i&&BigInt(n[i].ttd)<=t)throw Error("HF determined by block number is lower than the minimum total difficulty HF")}const a=s;for(;s<n.length-1&&(n[s].block===n[s+1].block&&n[s].timestamp===n[s+1].timestamp);s++);if(r){if(n.slice(0,a).reduce(((e,t)=>Math.max(Number(t.timestamp??"0"),e)),0)>r)throw Error("Maximum HF determined by timestamp is lower than the block number/ttd HF");if(n.slice(s+1).reduce(((e,t)=>Math.min(Number(t.timestamp??r),e)),r)<r)throw Error("Maximum HF determined by block number/ttd is lower than timestamp HF")}return n[s].name}setHardforkByBlockNumber(e,t,r){const n=this.getHardforkByBlockNumber(e,t,r);return this.setHardfork(n),n}_getHardfork(e){const t=this.hardforks();for(const r of t)if(r.name===e)return r;return null}setEIPs(e=[]){for(const t of e){if(!(t in f.EIPs))throw new Error(`${t} not supported`);const r=this.gteHardfork(f.EIPs[t].minimumHardfork);if(!r)throw new Error(`${t} cannot be activated on hardfork ${this.hardfork()}, minimumHardfork: ${r}`);if(void 0!==f.EIPs[t].requiredEIPs)for(const r of f.EIPs[t].requiredEIPs)if(!e.includes(r)&&!this.isActivatedEIP(r))throw new Error(`${t} requires EIP ${r}, but is not included in the EIP list`)}this._eips=e}param(e,t){let r;for(const n of this._eips)if(r=this.paramByEIP(e,t,n),void 0!==r)return r;return this.paramByHardfork(e,t,this._hardfork)}paramByHardfork(e,t,r){let n=null;for(const o of this.HARDFORK_CHANGES){if("eips"in o[1]){const r=o[1].eips;for(const o of r){const r=this.paramByEIP(e,t,o);n="bigint"==typeof r?r:n}}else{if(void 0===o[1][e])throw new Error(`Topic ${e} not defined`);void 0!==o[1][e][t]&&(n=o[1][e][t].v)}if(o[0]===r)break}return BigInt(n??0)}paramByEIP(e,t,r){if(!(r in f.EIPs))throw new Error(`${r} not supported`);const n=f.EIPs[r];if(!(e in n))throw new Error(`Topic ${e} not defined`);if(void 0===n[e][t])return;const o=n[e][t].v;return BigInt(o)}paramByBlock(e,t,r,n,o){const i=this.getHardforkByBlockNumber(r,n,o);return this.paramByHardfork(e,t,i)}isActivatedEIP(e){if(this.eips().includes(e))return!0;for(const t of this.HARDFORK_CHANGES){const r=t[1];if(this.gteHardfork(r.name)&&"eips"in r&&r.eips.includes(e))return!0}return!1}hardforkIsActiveOnBlock(e,t){t=(0,o.toType)(t,o.TypeOutput.BigInt),e=e??this._hardfork;const r=this.hardforkBlock(e);return"bigint"==typeof r&&r!==BigInt(0)&&t>=r}activeOnBlock(e){return this.hardforkIsActiveOnBlock(null,e)}hardforkGteHardfork(e,t){e=e??this._hardfork;const r=this.hardforks();let n=-1,o=-1,i=0;for(const s of r)s.name===e&&(n=i),s.name===t&&(o=i),i+=1;return n>=o&&-1!==o}gteHardfork(e){return this.hardforkGteHardfork(null,e)}hardforkBlock(e){e=e??this._hardfork;const t=this._getHardfork(e)?.block;return null==t?null:BigInt(t)}hardforkTimestamp(e){e=e??this._hardfork;const t=this._getHardfork(e)?.timestamp;return null==t?null:BigInt(t)}eipBlock(e){for(const t of this.HARDFORK_CHANGES){const r=t[1];if("eips"in r&&r.eips.includes(e))return this.hardforkBlock(t[0])}return null}hardforkTTD(e){e=e??this._hardfork;const t=this._getHardfork(e)?.ttd;return null==t?null:BigInt(t)}isHardforkBlock(e,t){e=(0,o.toType)(e,o.TypeOutput.BigInt),t=t??this._hardfork;const r=this.hardforkBlock(t);return"bigint"==typeof r&&r!==BigInt(0)&&r===e}nextHardforkBlockOrTimestamp(e){e=e??this._hardfork;const t=this.hardforks();let r=t.findIndex((t=>t.name===e));if(e===h.Hardfork.Merge&&(r-=1),r<0)return null;let n=t[r].timestamp??t[r].block;n=null!=n?Number(n):null;const o=t.slice(r+1).find((e=>{let t=e.timestamp??e.block;return t=null!=t?Number(t):null,e.name!==h.Hardfork.Merge&&null!=t&&t!==n}));if(void 0===o)return null;const i=o.timestamp??o.block;return null==i?null:BigInt(i)}nextHardforkBlock(e){e=e??this._hardfork;let t=this.hardforkBlock(e);if(null===t&&e===h.Hardfork.Merge){const e=this.hardforks(),r=e.findIndex((e=>null!==e.ttd&&void 0!==e.ttd));if(r<0)throw Error("Merge hardfork should have been found");t=this.hardforkBlock(e[r-1].name)}if(null===t)return null;return this.hardforks().reduce(((e,r)=>{const n=BigInt(null===r.block||void 0!==r.ttd&&null!==r.ttd?0:r.block);return n>t&&null===e?n:e}),null)}isNextHardforkBlock(e,t){e=(0,o.toType)(e,o.TypeOutput.BigInt),t=t??this._hardfork;const r=this.nextHardforkBlock(t);return null!==r&&r===e}_calcForkHash(e,t){let r=n.alloc(0),s=0;for(const t of this.hardforks()){const{block:o,timestamp:i,name:a}=t;let c=i??o;if(c=null!==c?Number(c):null,"number"==typeof c&&0!==c&&c!==s&&a!==h.Hardfork.Merge){const e=n.from(c.toString(16).padStart(16,"0"),"hex");r=n.concat([r,e]),s=c}if(t.name===e)break}const a=n.concat([t,r]);return`0x${(0,o.intToBuffer)((0,i.buf)(a)>>>0).toString("hex")}`}forkHash(e,t){e=e??this._hardfork;const r=this._getHardfork(e);if(null===r||null===r?.block&&void 0===r?.timestamp&&void 0===r?.ttd){throw new Error("No fork hash calculation possible for future hardfork")}if(null!=r?.forkHash)return r.forkHash;if(!t)throw new Error("genesisHash required for forkHash calculation");return this._calcForkHash(e,t)}hardforkForForkHash(e){const t=this.hardforks().filter((t=>t.forkHash===e));return t.length>=1?t[t.length-1]:null}setForkHashes(e){for(const t of this.hardforks()){const r=t.timestamp??t.block;null!==t.forkHash&&void 0!==t.forkHash||null==r&&void 0===t.ttd||(t.forkHash=this.forkHash(t.name,e))}}genesis(){return this._chainParams.genesis}hardforks(){return this._chainParams.hardforks}bootstrapNodes(){return this._chainParams.bootstrapNodes}dnsNetworks(){return this._chainParams.dnsNetworks}hardfork(){return this._hardfork}chainId(){return BigInt(this._chainParams.chainId)}chainName(){return this._chainParams.name}networkId(){return BigInt(this._chainParams.networkId)}eips(){return this._eips}consensusType(){const e=this.hardfork();let t;for(const r of this.HARDFORK_CHANGES)if("consensus"in r[1]&&(t=r[1].consensus.type),r[0]===e)break;return t??this._chainParams.consensus.type}consensusAlgorithm(){const e=this.hardfork();let t;for(const r of this.HARDFORK_CHANGES)if("consensus"in r[1]&&(t=r[1].consensus.algorithm),r[0]===e)break;return t??this._chainParams.consensus.algorithm}consensusConfig(){const e=this.hardfork();let t;for(const r of this.HARDFORK_CHANGES)if("consensus"in r[1]&&(t=r[1].consensus[r[1].consensus.algorithm]),r[0]===e)break;return t??this._chainParams.consensus[this.consensusAlgorithm()]??{}}copy(){const e=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return e.removeAllListeners(),e}static _getInitializedChains(e){const t={};for(const[e,r]of Object.entries(h.Chain))t[r]=e.toLowerCase();const r={mainnet:c,ropsten:l,rinkeby:u,goerli:a,sepolia:d};if(e)for(const n of e){const{name:e}=n;t[n.chainId.toString()]=e,r[e]=n}return r.names=t,r}}t.Common=g},3925:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EIPs=void 0,t.EIPs={1153:r(9765),1559:r(9659),2315:r(609),2537:r(4335),2565:r(354),2718:r(3928),2929:r(810),2930:r(3501),3074:r(6973),3198:r(4984),3529:r(3573),3540:r(6685),3541:r(6309),3554:r(3609),3607:r(4204),3651:r(9727),3670:r(8038),3675:r(3021),3855:r(4222),3860:r(4359),4345:r(8444),4399:r(6401),4844:r(4126),4895:r(6914),5133:r(9694)}},649:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CustomChain=t.ConsensusAlgorithm=t.ConsensusType=t.Hardfork=t.Chain=void 0,function(e){e[e.Mainnet=1]="Mainnet",e[e.Ropsten=3]="Ropsten",e[e.Rinkeby=4]="Rinkeby",e[e.Goerli=5]="Goerli",e[e.Sepolia=11155111]="Sepolia"}(t.Chain||(t.Chain={})),function(e){e.Chainstart="chainstart",e.Homestead="homestead",e.Dao="dao",e.TangerineWhistle="tangerineWhistle",e.SpuriousDragon="spuriousDragon",e.Byzantium="byzantium",e.Constantinople="constantinople",e.Petersburg="petersburg",e.Istanbul="istanbul",e.MuirGlacier="muirGlacier",e.Berlin="berlin",e.London="london",e.ArrowGlacier="arrowGlacier",e.GrayGlacier="grayGlacier",e.MergeForkIdTransition="mergeForkIdTransition",e.Merge="merge",e.Shanghai="shanghai",e.ShardingForkDev="shardingFork"}(t.Hardfork||(t.Hardfork={})),function(e){e.ProofOfStake="pos",e.ProofOfWork="pow",e.ProofOfAuthority="poa"}(t.ConsensusType||(t.ConsensusType={})),function(e){e.Ethash="ethash",e.Clique="clique",e.Casper="casper"}(t.ConsensusAlgorithm||(t.ConsensusAlgorithm={})),function(e){e.PolygonMainnet="polygon-mainnet",e.PolygonMumbai="polygon-mumbai",e.ArbitrumRinkebyTestnet="arbitrum-rinkeby-testnet",e.ArbitrumOne="arbitrum-one",e.xDaiChain="x-dai-chain",e.OptimisticKovan="optimistic-kovan",e.OptimisticEthereum="optimistic-ethereum"}(t.CustomChain||(t.CustomChain={}))},2188:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hardforks=void 0,t.hardforks={chainstart:r(21),homestead:r(2001),dao:r(5774),tangerineWhistle:r(116),spuriousDragon:r(610),byzantium:r(1773),constantinople:r(9517),petersburg:r(2507),istanbul:r(3316),muirGlacier:r(8288),berlin:r(5515),london:r(6497),shanghai:r(3317),arrowGlacier:r(8874),grayGlacier:r(3292),mergeForkIdTransition:r(6552),merge:r(9024),shardingFork:r(8870)}},1664:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(9752),t),o(r(649),t),o(r(3732),t),o(r(3824),t)},3732:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3824:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseGethGenesis=void 0;const n=r(5372),o=r(649);function i(e,t=!0){const{name:r,config:i,difficulty:s,mixHash:a,gasLimit:c,coinbase:u,baseFeePerGas:l}=e;let{extraData:d,timestamp:f,nonce:h}=e;const p=Number(f),{chainId:y}=i;if(""===d&&(d="0x"),(0,n.isHexPrefixed)(f)||(f=(0,n.intToHex)(parseInt(f))),18!==h.length&&(h=function(e){return e&&"0x0"!==e?(0,n.isHexPrefixed)(e)?"0x"+(0,n.stripHexPrefix)(e).padStart(16,"0"):"0x"+e.padStart(16,"0"):"0x0000000000000000"}(h)),i.eip155Block!==i.eip158Block)throw new Error("EIP155 block number must equal EIP 158 block number since both are part of SpuriousDragon hardfork and the client only supports activating the full hardfork");const g={name:r,chainId:y,networkId:y,genesis:{timestamp:f,gasLimit:parseInt(c),difficulty:parseInt(s),nonce:h,extraData:d,mixHash:a,coinbase:u,baseFeePerGas:l},hardfork:void 0,hardforks:[],bootstrapNodes:[],consensus:void 0!==i.clique?{type:"poa",algorithm:"clique",clique:{period:i.clique.period??i.clique.blockperiodseconds,epoch:i.clique.epoch??i.clique.epochlength}}:{type:"pow",algorithm:"ethash",ethash:{}}},m={[o.Hardfork.Homestead]:{name:"homesteadBlock"},[o.Hardfork.Dao]:{name:"daoForkBlock"},[o.Hardfork.TangerineWhistle]:{name:"eip150Block"},[o.Hardfork.SpuriousDragon]:{name:"eip155Block"},[o.Hardfork.Byzantium]:{name:"byzantiumBlock"},[o.Hardfork.Constantinople]:{name:"constantinopleBlock"},[o.Hardfork.Petersburg]:{name:"petersburgBlock"},[o.Hardfork.Istanbul]:{name:"istanbulBlock"},[o.Hardfork.MuirGlacier]:{name:"muirGlacierBlock"},[o.Hardfork.Berlin]:{name:"berlinBlock"},[o.Hardfork.London]:{name:"londonBlock"},[o.Hardfork.MergeForkIdTransition]:{name:"mergeForkBlock",postMerge:t},[o.Hardfork.Shanghai]:{name:"shanghaiTime",postMerge:!0,isTimestamp:!0},[o.Hardfork.ShardingForkDev]:{name:"shardingForkTime",postMerge:!0,isTimestamp:!0}},b=Object.keys(m).reduce(((e,t)=>(e[m[t].name]=t,e)),{}),v=Object.keys(i).filter((e=>void 0!==b[e]&&void 0!==i[e]&&null!==i[e]));if(g.hardforks=v.map((e=>({name:b[e],block:!0===m[b[e]].isTimestamp||"number"!=typeof i[e]?null:i[e],timestamp:!0===m[b[e]].isTimestamp&&"number"==typeof i[e]?i[e]:void 0}))).filter((e=>null!==e.block||void 0!==e.timestamp)),g.hardforks.sort((function(e,t){return(e.block??1/0)-(t.block??1/0)})),g.hardforks.sort((function(e,t){return(e.timestamp??p)-(t.timestamp??p)})),void 0!==i.terminalTotalDifficulty){const e={name:o.Hardfork.Merge,ttd:i.terminalTotalDifficulty,block:null},t=g.hardforks.findIndex((e=>!0===m[e.name]?.postMerge));-1!==t?g.hardforks.splice(t,0,e):g.hardforks.push(e)}const w=g.hardforks.length>0?g.hardforks.slice(-1)[0]:void 0;return g.hardfork=w?.name,g.hardforks.unshift({name:o.Hardfork.Chainstart,block:0}),g}t.parseGethGenesis=function(e,t,r){try{if(["config","difficulty","gasLimit","alloc"].some((t=>!(t in e))))throw new Error("Invalid format, expected geth genesis fields missing");return void 0!==t&&(e.name=t),i(e,r)}catch(e){throw new Error(`Error parsing parameters file: ${e.message}`)}}},7256:(e,t)=>{"use strict";function r(e){if(Array.isArray(e)){const t=[];let n=0;for(let o=0;o<e.length;o++){const i=r(e[o]);t.push(i),n+=i.length}return f(i(n,192),...t)}const t=g(e);return 1===t.length&&t[0]<128?t:f(i(t.length,128),t)}function n(e,t,r){if(r>e.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function o(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return l(u(e))}function i(e,t){if(e<56)return Uint8Array.from([e+t]);const r=p(e),n=p(t+55+r.length/2);return Uint8Array.from(d(n+r))}function s(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=a(g(e));if(t)return r;if(0!==r.remainder.length)throw new Error("invalid RLP: remainder must be zero");return r.data}function a(e){let t,r,i,s,c;const u=[],l=e[0];if(l<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(l<=183){if(t=l-127,i=128===l?Uint8Array.from([]):n(e,1,t),2===t&&i[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:i,remainder:e.slice(t)}}if(l<=191){if(r=l-182,e.length-1<r)throw new Error("invalid RLP: not enough bytes for string length");if(t=o(n(e,1,r)),t<=55)throw new Error("invalid RLP: expected string length to be greater than 55");return i=n(e,r,t+r),{data:i,remainder:e.slice(t+r)}}if(l<=247){for(t=l-191,s=n(e,1,t);s.length;)c=a(s),u.push(c.data),s=c.remainder;return{data:u,remainder:e.slice(t)}}{if(r=l-246,t=o(n(e,1,r)),t<56)throw new Error("invalid RLP: encoded list too short");const i=r+t;if(i>e.length)throw new Error("invalid RLP: total length is larger than the data");for(s=n(e,r,i);s.length;)c=a(s),u.push(c.data),s=c.remainder;return{data:u,remainder:e.slice(i)}}}Object.defineProperty(t,"__esModule",{value:!0}),t.RLP=t.utils=t.decode=t.encode=void 0,t.encode=r,t.decode=s;const c=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function u(e){let t="";for(let r=0;r<e.length;r++)t+=c[e[r]];return t}function l(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw new Error("Invalid byte sequence");return t}function d(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r;t[r]=l(e.slice(n,n+2))}return t}function f(...e){if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function h(e){return(new TextEncoder).encode(e)}function p(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");const t=e.toString(16);return t.length%2?`0${t}`:t}function y(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function g(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return y(e)?d((t="string"!=typeof(r=e)?r:y(r)?r.slice(2):r).length%2?`0${t}`:t):h(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?d(p(e)):Uint8Array.from([]);if(null==e)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+typeof e)}t.utils={bytesToHex:u,concatBytes:f,hexToBytes:d,utf8ToBytes:h},t.RLP={encode:r,decode:s}},7967:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseTransaction=void 0;const n=r(1664),o=r(5372),i=r(636),s=r(8284);t.BaseTransaction=class{constructor(e,t){this.cache={hash:void 0,dataFee:void 0},this.activeCapabilities=[],this.DEFAULT_CHAIN=n.Chain.Mainnet,this.DEFAULT_HARDFORK=n.Hardfork.Merge;const{nonce:r,gasLimit:i,to:a,value:c,data:u,v:l,r:d,s:f,type:h}=e;this._type=Number((0,o.bufferToBigInt)((0,o.toBuffer)(h))),this.txOptions=t;const p=(0,o.toBuffer)(""===a?"0x":a),y=(0,o.toBuffer)(""===l?"0x":l),g=(0,o.toBuffer)(""===d?"0x":d),m=(0,o.toBuffer)(""===f?"0x":f);this.nonce=(0,o.bufferToBigInt)((0,o.toBuffer)(""===r?"0x":r)),this.gasLimit=(0,o.bufferToBigInt)((0,o.toBuffer)(""===i?"0x":i)),this.to=p.length>0?new o.Address(p):void 0,this.value=(0,o.bufferToBigInt)((0,o.toBuffer)(""===c?"0x":c)),this.data=(0,o.toBuffer)(""===u?"0x":u),this.v=y.length>0?(0,o.bufferToBigInt)(y):void 0,this.r=g.length>0?(0,o.bufferToBigInt)(g):void 0,this.s=m.length>0?(0,o.bufferToBigInt)(m):void 0,this._validateCannotExceedMaxInteger({value:this.value,r:this.r,s:this.s}),this._validateCannotExceedMaxInteger({gasLimit:this.gasLimit},64),this._validateCannotExceedMaxInteger({nonce:this.nonce},64,!0);const b=void 0===this.to||null===this.to,v=t.allowUnlimitedInitCodeSize??!1,w=t.common??this._getCommon();b&&w.isActivatedEIP(3860)&&!1===v&&(0,s.checkMaxInitCodeSize)(w,this.data.length)}get type(){return this._type}supports(e){return this.activeCapabilities.includes(e)}validate(e=!1){const t=[];return this.getBaseFee()>this.gasLimit&&t.push(`gasLimit is too low. given ${this.gasLimit}, need at least ${this.getBaseFee()}`),this.isSigned()&&!this.verifySignature()&&t.push("Invalid Signature"),e?t:0===t.length}_validateYParity(){const{v:e}=this;if(void 0!==e&&e!==BigInt(0)&&e!==BigInt(1)){const e=this._errorMsg("The y-parity of the transaction should either be 0 or 1");throw new Error(e)}}_validateHighS(){const{s:e}=this;if(this.common.gteHardfork("homestead")&&void 0!==e&&e>o.SECP256K1_ORDER_DIV_2){const e=this._errorMsg("Invalid Signature: s-values greater than secp256k1n/2 are considered invalid");throw new Error(e)}}getBaseFee(){const e=this.common.param("gasPrices","tx");let t=this.getDataFee();if(e&&(t+=e),this.common.gteHardfork("homestead")&&this.toCreationAddress()){const e=this.common.param("gasPrices","txCreation");e&&(t+=e)}return t}getDataFee(){const e=this.common.param("gasPrices","txDataZero"),t=this.common.param("gasPrices","txDataNonZero");let r=BigInt(0);for(let n=0;n<this.data.length;n++)0===this.data[n]?r+=e:r+=t;if((void 0===this.to||null===this.to)&&this.common.isActivatedEIP(3860)){const e=BigInt(Math.ceil(this.data.length/32));r+=this.common.param("gasPrices","initCodeWordCost")*e}return r}toCreationAddress(){return void 0===this.to||0===this.to.buf.length}isSigned(){const{v:e,r:t,s:r}=this;return void 0!==e&&void 0!==t&&void 0!==r}verifySignature(){try{const e=this.getSenderPublicKey();return 0!==(0,o.unpadBuffer)(e).length}catch(e){return!1}}getSenderAddress(){return new o.Address((0,o.publicToAddress)(this.getSenderPublicKey()))}sign(e){if(32!==e.length){const e=this._errorMsg("Private key must be 32 bytes in length.");throw new Error(e)}let t=!1;0===this.type&&this.common.gteHardfork("spuriousDragon")&&!this.supports(i.Capability.EIP155ReplayProtection)&&(this.activeCapabilities.push(i.Capability.EIP155ReplayProtection),t=!0);const r=this.getMessageToSign(!0),{v:n,r:s,s:a}=(0,o.ecsign)(r,e),c=this._processSignature(n,s,a);if(t){const e=this.activeCapabilities.indexOf(i.Capability.EIP155ReplayProtection);e>-1&&this.activeCapabilities.splice(e,1)}return c}_getCommon(e,t){if(void 0!==t){const r=(0,o.bufferToBigInt)((0,o.toBuffer)(t));if(e){if(e.chainId()!==r){const e=this._errorMsg("The chain ID does not match the chain ID of Common");throw new Error(e)}return e.copy()}return n.Common.isSupportedChainId(r)?new n.Common({chain:r,hardfork:this.DEFAULT_HARDFORK}):n.Common.custom({name:"custom-chain",networkId:r,chainId:r},{baseChain:this.DEFAULT_CHAIN,hardfork:this.DEFAULT_HARDFORK})}return e?.copy()??new n.Common({chain:this.DEFAULT_CHAIN,hardfork:this.DEFAULT_HARDFORK})}_validateCannotExceedMaxInteger(e,t=256,r=!1){for(const[n,i]of Object.entries(e))switch(t){case 64:if(r){if(void 0!==i&&i>=o.MAX_UINT64){const e=this._errorMsg(`${n} cannot equal or exceed MAX_UINT64 (2^64-1), given ${i}`);throw new Error(e)}}else if(void 0!==i&&i>o.MAX_UINT64){const e=this._errorMsg(`${n} cannot exceed MAX_UINT64 (2^64-1), given ${i}`);throw new Error(e)}break;case 256:if(r){if(void 0!==i&&i>=o.MAX_INTEGER){const e=this._errorMsg(`${n} cannot equal or exceed MAX_INTEGER (2^256-1), given ${i}`);throw new Error(e)}}else if(void 0!==i&&i>o.MAX_INTEGER){const e=this._errorMsg(`${n} cannot exceed MAX_INTEGER (2^256-1), given ${i}`);throw new Error(e)}break;default:{const e=this._errorMsg("unimplemented bits value");throw new Error(e)}}}static _validateNotArray(e){const t=["nonce","gasPrice","gasLimit","to","value","data","v","r","s","type","baseFee","maxFeePerGas","chainId"];for(const[r,n]of Object.entries(e))if(t.includes(r)&&Array.isArray(n))throw new Error(`${r} cannot be an array`)}_getSharedErrorPostfix(){let e="";try{e=this.isSigned()?(0,o.bufferToHex)(this.hash()):"not available (unsigned)"}catch(t){e="error"}let t="";try{t=this.isSigned().toString()}catch(t){e="error"}let r="";try{r=this.common.hardfork()}catch(e){r="error"}let n=`tx type=${this.type} hash=${e} nonce=${this.nonce} value=${this.value} `;return n+=`signed=${t} hf=${r}`,n}}},5716:(e,t,r)=>{"use strict";var n=r(8834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.FeeMarketEIP1559Transaction=void 0;const o=r(7256),i=r(5372),s=r(1115),a=r(7967),c=r(8284),u=n.from(2..toString(16).padStart(2,"0"),"hex");class l extends a.BaseTransaction{constructor(e,t={}){super({...e,type:2},t),this.DEFAULT_HARDFORK="london";const{chainId:r,accessList:n,maxFeePerGas:o,maxPriorityFeePerGas:s}=e;if(this.common=this._getCommon(t.common,r),this.chainId=this.common.chainId(),!1===this.common.isActivatedEIP(1559))throw new Error("EIP-1559 not enabled on Common");this.activeCapabilities=this.activeCapabilities.concat([1559,2718,2930]);const u=c.AccessLists.getAccessListData(n??[]);if(this.accessList=u.accessList,this.AccessListJSON=u.AccessListJSON,c.AccessLists.verifyAccessList(this.accessList),this.maxFeePerGas=(0,i.bufferToBigInt)((0,i.toBuffer)(""===o?"0x":o)),this.maxPriorityFeePerGas=(0,i.bufferToBigInt)((0,i.toBuffer)(""===s?"0x":s)),this._validateCannotExceedMaxInteger({maxFeePerGas:this.maxFeePerGas,maxPriorityFeePerGas:this.maxPriorityFeePerGas}),a.BaseTransaction._validateNotArray(e),this.gasLimit*this.maxFeePerGas>i.MAX_INTEGER){const e=this._errorMsg("gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)");throw new Error(e)}if(this.maxFeePerGas<this.maxPriorityFeePerGas){const e=this._errorMsg("maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)");throw new Error(e)}this._validateYParity(),this._validateHighS();(t?.freeze??!0)&&Object.freeze(this)}static fromTxData(e,t={}){return new l(e,t)}static fromSerializedTx(e,t={}){if(!e.slice(0,1).equals(u))throw new Error(`Invalid serialized tx input: not an EIP-1559 transaction (wrong tx type, expected: 2, received: ${e.slice(0,1).toString("hex")}`);const r=(0,i.arrToBufArr)(o.RLP.decode(e.slice(1)));if(!Array.isArray(r))throw new Error("Invalid serialized tx input: must be array");return l.fromValuesArray(r,t)}static fromValuesArray(e,t={}){if(9!==e.length&&12!==e.length)throw new Error("Invalid EIP-1559 transaction. Only expecting 9 values (for unsigned tx) or 12 values (for signed tx).");const[r,n,o,s,a,c,u,d,f,h,p,y]=e;return this._validateNotArray({chainId:r,v:h}),(0,i.validateNoLeadingZeroes)({nonce:n,maxPriorityFeePerGas:o,maxFeePerGas:s,gasLimit:a,value:u,v:h,r:p,s:y}),new l({chainId:(0,i.bufferToBigInt)(r),nonce:n,maxPriorityFeePerGas:o,maxFeePerGas:s,gasLimit:a,to:c,value:u,data:d,accessList:f??[],v:void 0!==h?(0,i.bufferToBigInt)(h):void 0,r:p,s:y},t)}getDataFee(){if(this.cache.dataFee&&this.cache.dataFee.hardfork===this.common.hardfork())return this.cache.dataFee.value;let e=super.getDataFee();return e+=BigInt(c.AccessLists.getDataFeeEIP2930(this.accessList,this.common)),Object.isFrozen(this)&&(this.cache.dataFee={value:e,hardfork:this.common.hardfork()}),e}getUpfrontCost(e=BigInt(0)){const t=this.maxPriorityFeePerGas,r=this.maxFeePerGas-e,n=(t<r?t:r)+e;return this.gasLimit*n+this.value}raw(){return[(0,i.bigIntToUnpaddedBuffer)(this.chainId),(0,i.bigIntToUnpaddedBuffer)(this.nonce),(0,i.bigIntToUnpaddedBuffer)(this.maxPriorityFeePerGas),(0,i.bigIntToUnpaddedBuffer)(this.maxFeePerGas),(0,i.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,i.bigIntToUnpaddedBuffer)(this.value),this.data,this.accessList,void 0!==this.v?(0,i.bigIntToUnpaddedBuffer)(this.v):n.from([]),void 0!==this.r?(0,i.bigIntToUnpaddedBuffer)(this.r):n.from([]),void 0!==this.s?(0,i.bigIntToUnpaddedBuffer)(this.s):n.from([])]}serialize(){const e=this.raw();return n.concat([u,n.from(o.RLP.encode((0,i.bufArrToArr)(e)))])}getMessageToSign(e=!0){const t=this.raw().slice(0,9),r=n.concat([u,n.from(o.RLP.encode((0,i.bufArrToArr)(t)))]);return e?n.from((0,s.keccak256)(r)):r}hash(){if(!this.isSigned()){const e=this._errorMsg("Cannot call hash method if transaction is not signed");throw new Error(e)}return Object.isFrozen(this)?(this.cache.hash||(this.cache.hash=n.from((0,s.keccak256)(this.serialize()))),this.cache.hash):n.from((0,s.keccak256)(this.serialize()))}getMessageToVerifySignature(){return this.getMessageToSign()}getSenderPublicKey(){if(!this.isSigned()){const e=this._errorMsg("Cannot call this method if transaction is not signed");throw new Error(e)}const e=this.getMessageToVerifySignature(),{v:t,r,s:n}=this;this._validateHighS();try{return(0,i.ecrecover)(e,t+BigInt(27),(0,i.bigIntToUnpaddedBuffer)(r),(0,i.bigIntToUnpaddedBuffer)(n))}catch(e){const t=this._errorMsg("Invalid Signature");throw new Error(t)}}_processSignature(e,t,r){const n={...this.txOptions,common:this.common};return l.fromTxData({chainId:this.chainId,nonce:this.nonce,maxPriorityFeePerGas:this.maxPriorityFeePerGas,maxFeePerGas:this.maxFeePerGas,gasLimit:this.gasLimit,to:this.to,value:this.value,data:this.data,accessList:this.accessList,v:e-BigInt(27),r:(0,i.bufferToBigInt)(t),s:(0,i.bufferToBigInt)(r)},n)}toJSON(){const e=c.AccessLists.getAccessListJSON(this.accessList);return{chainId:(0,i.bigIntToHex)(this.chainId),nonce:(0,i.bigIntToHex)(this.nonce),maxPriorityFeePerGas:(0,i.bigIntToHex)(this.maxPriorityFeePerGas),maxFeePerGas:(0,i.bigIntToHex)(this.maxFeePerGas),gasLimit:(0,i.bigIntToHex)(this.gasLimit),to:void 0!==this.to?this.to.toString():void 0,value:(0,i.bigIntToHex)(this.value),data:"0x"+this.data.toString("hex"),accessList:e,v:void 0!==this.v?(0,i.bigIntToHex)(this.v):void 0,r:void 0!==this.r?(0,i.bigIntToHex)(this.r):void 0,s:void 0!==this.s?(0,i.bigIntToHex)(this.s):void 0}}errorStr(){let e=this._getSharedErrorPostfix();return e+=` maxFeePerGas=${this.maxFeePerGas} maxPriorityFeePerGas=${this.maxPriorityFeePerGas}`,e}_errorMsg(e){return`${e} (${this.errorStr()})`}}t.FeeMarketEIP1559Transaction=l},9733:(e,t,r)=>{"use strict";var n=r(8834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.AccessListEIP2930Transaction=void 0;const o=r(7256),i=r(5372),s=r(1115),a=r(7967),c=r(8284),u=n.from(1..toString(16).padStart(2,"0"),"hex");class l extends a.BaseTransaction{constructor(e,t={}){super({...e,type:1},t),this.DEFAULT_HARDFORK="berlin";const{chainId:r,accessList:n,gasPrice:o}=e;if(this.common=this._getCommon(t.common,r),this.chainId=this.common.chainId(),!this.common.isActivatedEIP(2930))throw new Error("EIP-2930 not enabled on Common");this.activeCapabilities=this.activeCapabilities.concat([2718,2930]);const s=c.AccessLists.getAccessListData(n??[]);if(this.accessList=s.accessList,this.AccessListJSON=s.AccessListJSON,c.AccessLists.verifyAccessList(this.accessList),this.gasPrice=(0,i.bufferToBigInt)((0,i.toBuffer)(""===o?"0x":o)),this._validateCannotExceedMaxInteger({gasPrice:this.gasPrice}),a.BaseTransaction._validateNotArray(e),this.gasPrice*this.gasLimit>i.MAX_INTEGER){const e=this._errorMsg("gasLimit * gasPrice cannot exceed MAX_INTEGER");throw new Error(e)}this._validateYParity(),this._validateHighS();(t?.freeze??!0)&&Object.freeze(this)}static fromTxData(e,t={}){return new l(e,t)}static fromSerializedTx(e,t={}){if(!e.slice(0,1).equals(u))throw new Error(`Invalid serialized tx input: not an EIP-2930 transaction (wrong tx type, expected: 1, received: ${e.slice(0,1).toString("hex")}`);const r=(0,i.arrToBufArr)(o.RLP.decode(Uint8Array.from(e.slice(1))));if(!Array.isArray(r))throw new Error("Invalid serialized tx input: must be array");return l.fromValuesArray(r,t)}static fromValuesArray(e,t={}){if(8!==e.length&&11!==e.length)throw new Error("Invalid EIP-2930 transaction. Only expecting 8 values (for unsigned tx) or 11 values (for signed tx).");const[r,n,o,s,a,c,u,d,f,h,p]=e;this._validateNotArray({chainId:r,v:f}),(0,i.validateNoLeadingZeroes)({nonce:n,gasPrice:o,gasLimit:s,value:c,v:f,r:h,s:p});return new l({chainId:(0,i.bufferToBigInt)(r),nonce:n,gasPrice:o,gasLimit:s,to:a,value:c,data:u,accessList:d??[],v:void 0!==f?(0,i.bufferToBigInt)(f):void 0,r:h,s:p},t)}getDataFee(){if(this.cache.dataFee&&this.cache.dataFee.hardfork===this.common.hardfork())return this.cache.dataFee.value;let e=super.getDataFee();return e+=BigInt(c.AccessLists.getDataFeeEIP2930(this.accessList,this.common)),Object.isFrozen(this)&&(this.cache.dataFee={value:e,hardfork:this.common.hardfork()}),e}getUpfrontCost(){return this.gasLimit*this.gasPrice+this.value}raw(){return[(0,i.bigIntToUnpaddedBuffer)(this.chainId),(0,i.bigIntToUnpaddedBuffer)(this.nonce),(0,i.bigIntToUnpaddedBuffer)(this.gasPrice),(0,i.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,i.bigIntToUnpaddedBuffer)(this.value),this.data,this.accessList,void 0!==this.v?(0,i.bigIntToUnpaddedBuffer)(this.v):n.from([]),void 0!==this.r?(0,i.bigIntToUnpaddedBuffer)(this.r):n.from([]),void 0!==this.s?(0,i.bigIntToUnpaddedBuffer)(this.s):n.from([])]}serialize(){const e=this.raw();return n.concat([u,n.from(o.RLP.encode((0,i.bufArrToArr)(e)))])}getMessageToSign(e=!0){const t=this.raw().slice(0,8),r=n.concat([u,n.from(o.RLP.encode((0,i.bufArrToArr)(t)))]);return e?n.from((0,s.keccak256)(r)):r}hash(){if(!this.isSigned()){const e=this._errorMsg("Cannot call hash method if transaction is not signed");throw new Error(e)}return Object.isFrozen(this)?(this.cache.hash||(this.cache.hash=n.from((0,s.keccak256)(this.serialize()))),this.cache.hash):n.from((0,s.keccak256)(this.serialize()))}getMessageToVerifySignature(){return this.getMessageToSign()}getSenderPublicKey(){if(!this.isSigned()){const e=this._errorMsg("Cannot call this method if transaction is not signed");throw new Error(e)}const e=this.getMessageToVerifySignature(),{v:t,r,s:n}=this;this._validateHighS();try{return(0,i.ecrecover)(e,t+BigInt(27),(0,i.bigIntToUnpaddedBuffer)(r),(0,i.bigIntToUnpaddedBuffer)(n))}catch(e){const t=this._errorMsg("Invalid Signature");throw new Error(t)}}_processSignature(e,t,r){const n={...this.txOptions,common:this.common};return l.fromTxData({chainId:this.chainId,nonce:this.nonce,gasPrice:this.gasPrice,gasLimit:this.gasLimit,to:this.to,value:this.value,data:this.data,accessList:this.accessList,v:e-BigInt(27),r:(0,i.bufferToBigInt)(t),s:(0,i.bufferToBigInt)(r)},n)}toJSON(){const e=c.AccessLists.getAccessListJSON(this.accessList);return{chainId:(0,i.bigIntToHex)(this.chainId),nonce:(0,i.bigIntToHex)(this.nonce),gasPrice:(0,i.bigIntToHex)(this.gasPrice),gasLimit:(0,i.bigIntToHex)(this.gasLimit),to:void 0!==this.to?this.to.toString():void 0,value:(0,i.bigIntToHex)(this.value),data:"0x"+this.data.toString("hex"),accessList:e,v:void 0!==this.v?(0,i.bigIntToHex)(this.v):void 0,r:void 0!==this.r?(0,i.bigIntToHex)(this.r):void 0,s:void 0!==this.s?(0,i.bigIntToHex)(this.s):void 0}}errorStr(){let e=this._getSharedErrorPostfix();return e+=` gasPrice=${this.gasPrice} accessListCount=${this.accessList?.length??0}`,e}_errorMsg(e){return`${e} (${this.errorStr()})`}}t.AccessListEIP2930Transaction=l},3217:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeTxParams=void 0;const n=r(5372);t.normalizeTxParams=e=>{const t=Object.assign({},e);return t.gasLimit=(0,n.toType)(t.gasLimit??t.gas,n.TypeOutput.BigInt),t.data=void 0===t.data?t.input:t.data,t.gasPrice=void 0!==t.gasPrice?BigInt(t.gasPrice):void 0,t.value=void 0!==t.value?BigInt(t.value):void 0,t.to=null!==t.to&&void 0!==t.to?(0,n.setLengthLeft)((0,n.toBuffer)(t.to),20):null,t.v="0x0"===t.v?"0x":t.v,t.r="0x0"===t.r?"0x":t.r,t.s="0x0"===t.s?"0x":t.s,"0x"!==t.v&&(t.v=(0,n.toType)(t.v,n.TypeOutput.BigInt)),t}},4670:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.TransactionFactory=t.Transaction=t.AccessListEIP2930Transaction=t.FeeMarketEIP1559Transaction=void 0;var i=r(5716);Object.defineProperty(t,"FeeMarketEIP1559Transaction",{enumerable:!0,get:function(){return i.FeeMarketEIP1559Transaction}});var s=r(9733);Object.defineProperty(t,"AccessListEIP2930Transaction",{enumerable:!0,get:function(){return s.AccessListEIP2930Transaction}});var a=r(1247);Object.defineProperty(t,"Transaction",{enumerable:!0,get:function(){return a.Transaction}});var c=r(921);Object.defineProperty(t,"TransactionFactory",{enumerable:!0,get:function(){return c.TransactionFactory}}),o(r(636),t)},1247:(e,t,r)=>{"use strict";var n=r(8834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Transaction=void 0;const o=r(7256),i=r(5372),s=r(1115),a=r(7967),c=r(636);function u(e,t){const r=Number(e),n=2*Number(t);return r===n+35||r===n+36}class l extends a.BaseTransaction{constructor(e,t={}){if(super({...e,type:0},t),this.common=this._validateTxV(this.v,t.common),this.gasPrice=(0,i.bufferToBigInt)((0,i.toBuffer)(""===e.gasPrice?"0x":e.gasPrice)),this.gasPrice*this.gasLimit>i.MAX_INTEGER){const e=this._errorMsg("gas limit * gasPrice cannot exceed MAX_INTEGER (2^256-1)");throw new Error(e)}this._validateCannotExceedMaxInteger({gasPrice:this.gasPrice}),a.BaseTransaction._validateNotArray(e),this.common.gteHardfork("spuriousDragon")&&(this.isSigned()?u(this.v,this.common.chainId())&&this.activeCapabilities.push(c.Capability.EIP155ReplayProtection):this.activeCapabilities.push(c.Capability.EIP155ReplayProtection));(t?.freeze??!0)&&Object.freeze(this)}static fromTxData(e,t={}){return new l(e,t)}static fromSerializedTx(e,t={}){const r=(0,i.arrToBufArr)(o.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(r))throw new Error("Invalid serialized tx input. Must be array");return this.fromValuesArray(r,t)}static fromValuesArray(e,t={}){if(6!==e.length&&9!==e.length)throw new Error("Invalid transaction. Only expecting 6 values (for unsigned tx) or 9 values (for signed tx).");const[r,n,o,s,a,c,u,d,f]=e;return(0,i.validateNoLeadingZeroes)({nonce:r,gasPrice:n,gasLimit:o,value:a,v:u,r:d,s:f}),new l({nonce:r,gasPrice:n,gasLimit:o,to:s,value:a,data:c,v:u,r:d,s:f},t)}raw(){return[(0,i.bigIntToUnpaddedBuffer)(this.nonce),(0,i.bigIntToUnpaddedBuffer)(this.gasPrice),(0,i.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,i.bigIntToUnpaddedBuffer)(this.value),this.data,void 0!==this.v?(0,i.bigIntToUnpaddedBuffer)(this.v):n.from([]),void 0!==this.r?(0,i.bigIntToUnpaddedBuffer)(this.r):n.from([]),void 0!==this.s?(0,i.bigIntToUnpaddedBuffer)(this.s):n.from([])]}serialize(){return n.from(o.RLP.encode((0,i.bufArrToArr)(this.raw())))}_getMessageToSign(){const e=[(0,i.bigIntToUnpaddedBuffer)(this.nonce),(0,i.bigIntToUnpaddedBuffer)(this.gasPrice),(0,i.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,i.bigIntToUnpaddedBuffer)(this.value),this.data];return this.supports(c.Capability.EIP155ReplayProtection)&&(e.push((0,i.bigIntToUnpaddedBuffer)(this.common.chainId())),e.push((0,i.unpadBuffer)((0,i.toBuffer)(0))),e.push((0,i.unpadBuffer)((0,i.toBuffer)(0)))),e}getMessageToSign(e=!0){const t=this._getMessageToSign();return e?n.from((0,s.keccak256)(o.RLP.encode((0,i.bufArrToArr)(t)))):t}getDataFee(){return this.cache.dataFee&&this.cache.dataFee.hardfork===this.common.hardfork()?this.cache.dataFee.value:(Object.isFrozen(this)&&(this.cache.dataFee={value:super.getDataFee(),hardfork:this.common.hardfork()}),super.getDataFee())}getUpfrontCost(){return this.gasLimit*this.gasPrice+this.value}hash(){if(!this.isSigned()){const e=this._errorMsg("Cannot call hash method if transaction is not signed");throw new Error(e)}return Object.isFrozen(this)?(this.cache.hash||(this.cache.hash=n.from((0,s.keccak256)(o.RLP.encode((0,i.bufArrToArr)(this.raw()))))),this.cache.hash):n.from((0,s.keccak256)(o.RLP.encode((0,i.bufArrToArr)(this.raw()))))}getMessageToVerifySignature(){if(!this.isSigned()){const e=this._errorMsg("This transaction is not signed");throw new Error(e)}const e=this._getMessageToSign();return n.from((0,s.keccak256)(o.RLP.encode((0,i.bufArrToArr)(e))))}getSenderPublicKey(){const e=this.getMessageToVerifySignature(),{v:t,r,s:n}=this;this._validateHighS();try{return(0,i.ecrecover)(e,t,(0,i.bigIntToUnpaddedBuffer)(r),(0,i.bigIntToUnpaddedBuffer)(n),this.supports(c.Capability.EIP155ReplayProtection)?this.common.chainId():void 0)}catch(e){const t=this._errorMsg("Invalid Signature");throw new Error(t)}}_processSignature(e,t,r){this.supports(c.Capability.EIP155ReplayProtection)&&(e+=this.common.chainId()*BigInt(2)+BigInt(8));const n={...this.txOptions,common:this.common};return l.fromTxData({nonce:this.nonce,gasPrice:this.gasPrice,gasLimit:this.gasLimit,to:this.to,value:this.value,data:this.data,v:e,r:(0,i.bufferToBigInt)(t),s:(0,i.bufferToBigInt)(r)},n)}toJSON(){return{nonce:(0,i.bigIntToHex)(this.nonce),gasPrice:(0,i.bigIntToHex)(this.gasPrice),gasLimit:(0,i.bigIntToHex)(this.gasLimit),to:void 0!==this.to?this.to.toString():void 0,value:(0,i.bigIntToHex)(this.value),data:"0x"+this.data.toString("hex"),v:void 0!==this.v?(0,i.bigIntToHex)(this.v):void 0,r:void 0!==this.r?(0,i.bigIntToHex)(this.r):void 0,s:void 0!==this.s?(0,i.bigIntToHex)(this.s):void 0}}_validateTxV(e,t){let r;const n=void 0!==e?Number(e):void 0;if(void 0!==n&&n<37&&27!==n&&28!==n)throw new Error(`Legacy txs need either v = 27/28 or v >= 37 (EIP-155 replay protection), got v = ${n}`);if(void 0!==n&&0!==n&&(!t||t.gteHardfork("spuriousDragon"))&&27!==n&&28!==n)if(t){if(!u(BigInt(n),t.chainId()))throw new Error(`Incompatible EIP155-based V ${n} and chain id ${t.chainId()}. See the Common parameter of the Transaction constructor to set the chain id.`)}else{let e;e=(n-35)%2==0?35:36,r=BigInt(n-e)/BigInt(2)}return this._getCommon(t,r)}errorStr(){let e=this._getSharedErrorPostfix();return e+=` gasPrice=${this.gasPrice}`,e}_errorMsg(e){return`${e} (${this.errorStr()})`}}t.Transaction=l},921:(e,t,r)=>{"use strict";var n=r(8834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.TransactionFactory=void 0;const o=r(5372),i=r(5716),s=r(9733),a=r(3217),c=r(1247);class u{constructor(){}static fromTxData(e,t={}){if("type"in e&&void 0!==e.type){const r=Number((0,o.bufferToBigInt)((0,o.toBuffer)(e.type)));if(0===r)return c.Transaction.fromTxData(e,t);if(1===r)return s.AccessListEIP2930Transaction.fromTxData(e,t);if(2===r)return i.FeeMarketEIP1559Transaction.fromTxData(e,t);throw new Error(`Tx instantiation with type ${r} not supported`)}return c.Transaction.fromTxData(e,t)}static fromSerializedData(e,t={}){if(!(e[0]<=127))return c.Transaction.fromSerializedTx(e,t);switch(e[0]){case 1:return s.AccessListEIP2930Transaction.fromSerializedTx(e,t);case 2:return i.FeeMarketEIP1559Transaction.fromSerializedTx(e,t);default:throw new Error(`TypedTransaction with ID ${e[0]} unknown`)}}static fromBlockBodyData(e,t={}){if(n.isBuffer(e))return this.fromSerializedData(e,t);if(Array.isArray(e))return c.Transaction.fromValuesArray(e,t);throw new Error("Cannot decode transaction: unknown type input")}static async fromEthersProvider(e,t,r){const n=(0,o.getProvider)(e),i=await(0,o.fetchFromProvider)(n,{method:"eth_getTransactionByHash",params:[t]});if(null===i)throw new Error("No data returned from provider");return u.fromRPCTx(i,r)}static async fromRPCTx(e,t={}){return u.fromTxData((0,a.normalizeTxParams)(e),t)}}t.TransactionFactory=u},636:(e,t)=>{"use strict";function r(e){if(0===e.length)return!0;const t=e[0];return!!Array.isArray(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isAccessList=t.isAccessListBuffer=t.Capability=void 0,function(e){e[e.EIP155ReplayProtection=155]="EIP155ReplayProtection",e[e.EIP1559FeeMarket=1559]="EIP1559FeeMarket",e[e.EIP2718TypedTransaction=2718]="EIP2718TypedTransaction",e[e.EIP2930AccessLists=2930]="EIP2930AccessLists"}(t.Capability||(t.Capability={})),t.isAccessListBuffer=r,t.isAccessList=function(e){return!r(e)}},8284:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AccessLists=t.checkMaxInitCodeSize=void 0;const n=r(5372),o=r(636);t.checkMaxInitCodeSize=function(e,t){const r=e.param("vm","maxInitCodeSize");if(r&&BigInt(t)>r)throw new Error(`the initcode size of this transaction is too large: it is ${t} while the max is ${e.param("vm","maxInitCodeSize")}`)};t.AccessLists=class{static getAccessListData(e){let t,r;if((0,o.isAccessList)(e)){t=e;const o=[];for(let t=0;t<e.length;t++){const r=e[t],i=(0,n.toBuffer)(r.address),s=[];for(let e=0;e<r.storageKeys.length;e++)s.push((0,n.toBuffer)(r.storageKeys[e]));o.push([i,s])}r=o}else{r=e??[];const o=[];for(let e=0;e<r.length;e++){const t=r[e],i=(0,n.bufferToHex)(t[0]),s=[];for(let e=0;e<t[1].length;e++)s.push((0,n.bufferToHex)(t[1][e]));const a={address:i,storageKeys:s};o.push(a)}t=o}return{AccessListJSON:t,accessList:r}}static verifyAccessList(e){for(let t=0;t<e.length;t++){const r=e[t],n=r[0],o=r[1];if(void 0!==r[2])throw new Error("Access list item cannot have 3 elements. It can only have an address, and an array of storage slots.");if(20!==n.length)throw new Error("Invalid EIP-2930 transaction: address length should be 20 bytes");for(let e=0;e<o.length;e++)if(32!==o[e].length)throw new Error("Invalid EIP-2930 transaction: storage slot length should be 32 bytes")}}static getAccessListJSON(e){const t=[];for(let r=0;r<e.length;r++){const o=e[r],i={address:"0x"+(0,n.setLengthLeft)(o[0],20).toString("hex"),storageKeys:[]},s=o[1];for(let e=0;e<s.length;e++){const t=s[e];i.storageKeys.push("0x"+(0,n.setLengthLeft)(t,32).toString("hex"))}t.push(i)}return t}static getDataFeeEIP2930(e,t){const r=t.param("gasPrices","accessListStorageKeyCost"),n=t.param("gasPrices","accessListAddressCost");let o=0;for(let t=0;t<e.length;t++){o+=e[t][1].length}return e.length*Number(n)+o*Number(r)}}},4706:(e,t,r)=>{"use strict";var n=r(8834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.accountBodyToRLP=t.accountBodyToSlim=t.accountBodyFromSlim=t.isZeroAddress=t.zeroAddress=t.importPublic=t.privateToAddress=t.privateToPublic=t.publicToAddress=t.pubToAddress=t.isValidPublic=t.isValidPrivate=t.generateAddress2=t.generateAddress=t.isValidChecksumAddress=t.toChecksumAddress=t.isValidAddress=t.Account=void 0;const o=r(7256),i=r(1115),s=r(101),a=r(144),c=r(4916),u=r(8127),l=r(8707),d=r(4243),f=BigInt(0);class h{constructor(e=f,t=f,r=u.KECCAK256_RLP,n=u.KECCAK256_NULL){this.nonce=e,this.balance=t,this.storageRoot=r,this.codeHash=n,this._validate()}static fromAccountData(e){const{nonce:t,balance:r,storageRoot:n,codeHash:o}=e;return new h(void 0!==t?(0,c.bufferToBigInt)((0,c.toBuffer)(t)):void 0,void 0!==r?(0,c.bufferToBigInt)((0,c.toBuffer)(r)):void 0,void 0!==n?(0,c.toBuffer)(n):void 0,void 0!==o?(0,c.toBuffer)(o):void 0)}static fromRlpSerializedAccount(e){const t=(0,c.arrToBufArr)(o.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(t))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(t)}static fromValuesArray(e){const[t,r,n,o]=e;return new h((0,c.bufferToBigInt)(t),(0,c.bufferToBigInt)(r),n,o)}_validate(){if(this.nonce<f)throw new Error("nonce must be greater than zero");if(this.balance<f)throw new Error("balance must be greater than zero");if(32!==this.storageRoot.length)throw new Error("storageRoot must have a length of 32");if(32!==this.codeHash.length)throw new Error("codeHash must have a length of 32")}raw(){return[(0,c.bigIntToUnpaddedBuffer)(this.nonce),(0,c.bigIntToUnpaddedBuffer)(this.balance),this.storageRoot,this.codeHash]}serialize(){return n.from(o.RLP.encode((0,c.bufArrToArr)(this.raw())))}isContract(){return!this.codeHash.equals(u.KECCAK256_NULL)}isEmpty(){return this.balance===f&&this.nonce===f&&this.codeHash.equals(u.KECCAK256_NULL)}}t.Account=h;t.isValidAddress=function(e){try{(0,l.assertIsString)(e)}catch(e){return!1}return/^0x[0-9a-fA-F]{40}$/.test(e)};t.toChecksumAddress=function(e,t){(0,l.assertIsHexString)(e);const r=(0,d.stripHexPrefix)(e).toLowerCase();let o="";if(void 0!==t){o=(0,c.bufferToBigInt)((0,c.toBuffer)(t)).toString()+"0x"}const s=n.from(o+r,"utf8"),u=(0,a.bytesToHex)((0,i.keccak256)(s));let f="0x";for(let e=0;e<r.length;e++)parseInt(u[e],16)>=8?f+=r[e].toUpperCase():f+=r[e];return f};t.isValidChecksumAddress=function(e,r){return(0,t.isValidAddress)(e)&&(0,t.toChecksumAddress)(e,r)===e};t.generateAddress=function(e,t){return(0,l.assertIsBuffer)(e),(0,l.assertIsBuffer)(t),(0,c.bufferToBigInt)(t)===