@biuauth/wallet-connect-v2-adapter
Version:
wallet connect v2 adapter for web3auth
2 lines • 962 kB
JavaScript
/*! For license information please see walletConnectV2Adapter.umd.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WalletConnectV2Adapter=t():e.WalletConnectV2Adapter=t()}(self,(()=>(()=>{var e={5945:(e,t,r)=>{"use strict";var n=r(5291).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Common=void 0;const i=r(1741),o=r(6233),s=r(7531),a=r(7847),c=r(4870),u=r(8638),l=r(7776),h=r(5850),f=r(2601),d=r(5924),p=r(3237),g=r(5434);class y extends s.EventEmitter{constructor(e){super(),this._eips=[],this._customChains=e.customChains??[],this._chainParams=this.setChain(e.chain),this.DEFAULT_HARDFORK=this._chainParams.defaultHardfork??d.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={...y._getChainParams(r)};if(n.name="custom-chain","string"!=typeof e)return new y({chain:{...n,...e},...t});if(e===d.CustomChain.PolygonMainnet)return y.custom({name:d.CustomChain.PolygonMainnet,chainId:137,networkId:137},t);if(e===d.CustomChain.PolygonMumbai)return y.custom({name:d.CustomChain.PolygonMumbai,chainId:80001,networkId:80001},t);if(e===d.CustomChain.ArbitrumRinkebyTestnet)return y.custom({name:d.CustomChain.ArbitrumRinkebyTestnet,chainId:421611,networkId:421611},t);if(e===d.CustomChain.ArbitrumOne)return y.custom({name:d.CustomChain.ArbitrumOne,chainId:42161,networkId:42161},t);if(e===d.CustomChain.xDaiChain)return y.custom({name:d.CustomChain.xDaiChain,chainId:100,networkId:100},t);if(e===d.CustomChain.OptimisticKovan)return y.custom({name:d.CustomChain.OptimisticKovan,chainId:69,networkId:69},{hardfork:d.Hardfork.Berlin,...t});if(e===d.CustomChain.OptimisticEthereum)return y.custom({name:d.CustomChain.OptimisticEthereum,chainId:10,networkId:10},{hardfork:d.Hardfork.Berlin,...t});throw new Error(`Custom chain ${e} not supported`)}static fromGethGenesis(e,{chain:t,eips:r,genesisHash:n,hardfork:i,mergeForkIdPostMerge:o}){const s=(0,g.parseGethGenesis)(e,t,o),a=new y({chain:s.name??"custom",customChains:[s],eips:r,hardfork:i??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=y._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,i.toType)(e,i.TypeOutput.BigInt),t=(0,i.toType)(t,i.TypeOutput.BigInt),r=(0,i.toType)(r,i.TypeOutput.Number);const n=this.hardforks().filter((e=>null!==e.block||null!==e.ttd&&void 0!==e.ttd||void 0!==e.timestamp)),o=n.findIndex((e=>null!==e.ttd&&void 0!==e.ttd));if(n.slice(o+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))),s-=1,null===n[s].block&&void 0===n[s].timestamp)(null==t||BigInt(n[s].ttd)>t)&&(s-=1);else if(o>=0&&null!=t){if(s>=o&&BigInt(n[o].ttd)>t)throw Error("Maximum HF determined by total difficulty is lower than the block number HF");if(s<o&&BigInt(n[o].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 i of this.HARDFORK_CHANGES){if("eips"in i[1]){const r=i[1].eips;for(const i of r){const r=this.paramByEIP(e,t,i);n="bigint"==typeof r?r:n}}else{if(void 0===i[1][e])throw new Error(`Topic ${e} not defined`);void 0!==i[1][e][t]&&(n=i[1][e][t].v)}if(i[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 i=n[e][t].v;return BigInt(i)}paramByBlock(e,t,r,n,i){const o=this.getHardforkByBlockNumber(r,n,i);return this.paramByHardfork(e,t,o)}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,i.toType)(t,i.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,i=-1,o=0;for(const s of r)s.name===e&&(n=o),s.name===t&&(i=o),o+=1;return n>=i&&-1!==i}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,i.toType)(e,i.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===d.Hardfork.Merge&&(r-=1),r<0)return null;let n=t[r].timestamp??t[r].block;n=null!=n?Number(n):null;const i=t.slice(r+1).find((e=>{let t=e.timestamp??e.block;return t=null!=t?Number(t):null,e.name!==d.Hardfork.Merge&&null!=t&&t!==n}));if(void 0===i)return null;const o=i.timestamp??i.block;return null==o?null:BigInt(o)}nextHardforkBlock(e){e=e??this._hardfork;let t=this.hardforkBlock(e);if(null===t&&e===d.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)}return null===t?null: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,i.toType)(e,i.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:i,timestamp:o,name:a}=t;let c=o??i;if(c=null!==c?Number(c):null,"number"==typeof c&&0!==c&&c!==s&&a!==d.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,i.intToBuffer)((0,o.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(d.Chain))t[r]=e.toLowerCase();const r={mainnet:c,ropsten:l,rinkeby:u,goerli:a,sepolia:h};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=y},2601:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EIPs=void 0,t.EIPs={1153:r(2799),1559:r(488),2315:r(7666),2537:r(9856),2565:r(9070),2718:r(3918),2929:r(6404),2930:r(7677),3074:r(5403),3198:r(9909),3529:r(9227),3540:r(722),3541:r(9582),3554:r(7081),3607:r(1318),3651:r(3787),3670:r(828),3675:r(4118),3855:r(9978),3860:r(3322),4345:r(2162),4399:r(4032),4844:r(7306),4895:r(5735),5133:r(1833)}},5924:(e,t)=>{"use strict";var r,n,i,o,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CustomChain=t.ConsensusAlgorithm=t.ConsensusType=t.Hardfork=t.Chain=void 0,(s=t.Chain||(t.Chain={}))[s.Mainnet=1]="Mainnet",s[s.Ropsten=3]="Ropsten",s[s.Rinkeby=4]="Rinkeby",s[s.Goerli=5]="Goerli",s[s.Sepolia=11155111]="Sepolia",(o=t.Hardfork||(t.Hardfork={})).Chainstart="chainstart",o.Homestead="homestead",o.Dao="dao",o.TangerineWhistle="tangerineWhistle",o.SpuriousDragon="spuriousDragon",o.Byzantium="byzantium",o.Constantinople="constantinople",o.Petersburg="petersburg",o.Istanbul="istanbul",o.MuirGlacier="muirGlacier",o.Berlin="berlin",o.London="london",o.ArrowGlacier="arrowGlacier",o.GrayGlacier="grayGlacier",o.MergeForkIdTransition="mergeForkIdTransition",o.Merge="merge",o.Shanghai="shanghai",o.ShardingForkDev="shardingFork",(i=t.ConsensusType||(t.ConsensusType={})).ProofOfStake="pos",i.ProofOfWork="pow",i.ProofOfAuthority="poa",(n=t.ConsensusAlgorithm||(t.ConsensusAlgorithm={})).Ethash="ethash",n.Clique="clique",n.Casper="casper",(r=t.CustomChain||(t.CustomChain={})).PolygonMainnet="polygon-mainnet",r.PolygonMumbai="polygon-mumbai",r.ArbitrumRinkebyTestnet="arbitrum-rinkeby-testnet",r.ArbitrumOne="arbitrum-one",r.xDaiChain="x-dai-chain",r.OptimisticKovan="optimistic-kovan",r.OptimisticEthereum="optimistic-ethereum"},3237:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hardforks=void 0,t.hardforks={chainstart:r(6838),homestead:r(4638),dao:r(4341),tangerineWhistle:r(8092),spuriousDragon:r(4033),byzantium:r(8),constantinople:r(3065),petersburg:r(5786),istanbul:r(2779),muirGlacier:r(3822),berlin:r(3416),london:r(8966),shanghai:r(8077),arrowGlacier:r(7257),grayGlacier:r(7812),mergeForkIdTransition:r(857),merge:r(3977),shardingFork:r(4276)}},7226:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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}),i(r(5945),t),i(r(5924),t),i(r(624),t),i(r(5434),t)},624:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5434:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseGethGenesis=void 0;const n=r(1741),i=r(5924);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),function(e,t=!0){const{name:r,config:o,difficulty:s,mixHash:a,gasLimit:c,coinbase:u,baseFeePerGas:l}=e;let{extraData:h,timestamp:f,nonce:d}=e;const p=Number(f),{chainId:g}=o;if(""===h&&(h="0x"),(0,n.isHexPrefixed)(f)||(f=(0,n.intToHex)(parseInt(f))),18!==d.length&&(d=function(e){return e&&"0x0"!==e?(0,n.isHexPrefixed)(e)?"0x"+(0,n.stripHexPrefix)(e).padStart(16,"0"):"0x"+e.padStart(16,"0"):"0x0000000000000000"}(d)),o.eip155Block!==o.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 y={name:r,chainId:g,networkId:g,genesis:{timestamp:f,gasLimit:parseInt(c),difficulty:parseInt(s),nonce:d,extraData:h,mixHash:a,coinbase:u,baseFeePerGas:l},hardfork:void 0,hardforks:[],bootstrapNodes:[],consensus:void 0!==o.clique?{type:"poa",algorithm:"clique",clique:{period:o.clique.period??o.clique.blockperiodseconds,epoch:o.clique.epoch??o.clique.epochlength}}:{type:"pow",algorithm:"ethash",ethash:{}}},m={[i.Hardfork.Homestead]:{name:"homesteadBlock"},[i.Hardfork.Dao]:{name:"daoForkBlock"},[i.Hardfork.TangerineWhistle]:{name:"eip150Block"},[i.Hardfork.SpuriousDragon]:{name:"eip155Block"},[i.Hardfork.Byzantium]:{name:"byzantiumBlock"},[i.Hardfork.Constantinople]:{name:"constantinopleBlock"},[i.Hardfork.Petersburg]:{name:"petersburgBlock"},[i.Hardfork.Istanbul]:{name:"istanbulBlock"},[i.Hardfork.MuirGlacier]:{name:"muirGlacierBlock"},[i.Hardfork.Berlin]:{name:"berlinBlock"},[i.Hardfork.London]:{name:"londonBlock"},[i.Hardfork.MergeForkIdTransition]:{name:"mergeForkBlock",postMerge:t},[i.Hardfork.Shanghai]:{name:"shanghaiTime",postMerge:!0,isTimestamp:!0},[i.Hardfork.ShardingForkDev]:{name:"shardingForkTime",postMerge:!0,isTimestamp:!0}},b=Object.keys(m).reduce(((e,t)=>(e[m[t].name]=t,e)),{}),v=Object.keys(o).filter((e=>void 0!==b[e]&&void 0!==o[e]&&null!==o[e]));if(y.hardforks=v.map((e=>({name:b[e],block:!0===m[b[e]].isTimestamp||"number"!=typeof o[e]?null:o[e],timestamp:!0===m[b[e]].isTimestamp&&"number"==typeof o[e]?o[e]:void 0}))).filter((e=>null!==e.block||void 0!==e.timestamp)),y.hardforks.sort((function(e,t){return(e.block??1/0)-(t.block??1/0)})),y.hardforks.sort((function(e,t){return(e.timestamp??p)-(t.timestamp??p)})),void 0!==o.terminalTotalDifficulty){const e={name:i.Hardfork.Merge,ttd:o.terminalTotalDifficulty,block:null},t=y.hardforks.findIndex((e=>!0===m[e.name]?.postMerge));-1!==t?y.hardforks.splice(t,0,e):y.hardforks.push(e)}const w=y.hardforks.length>0?y.hardforks.slice(-1)[0]:void 0;return y.hardfork=w?.name,y.hardforks.unshift({name:i.Hardfork.Chainstart,block:0}),y}(e,r)}catch(e){throw new Error(`Error parsing parameters file: ${e.message}`)}}},9966:(e,t)=>{"use strict";function r(e){if(Array.isArray(e)){const t=[];let n=0;for(let i=0;i<e.length;i++){const o=r(e[i]);t.push(o),n+=o.length}return f(o(n,192),...t)}const t=y(e);return 1===t.length&&t[0]<128?t:f(o(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 i(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return l(u(e))}function o(e,t){if(e<56)return Uint8Array.from([e+t]);const r=p(e),n=p(t+55+r.length/2);return Uint8Array.from(h(n+r))}function s(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=a(y(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,o,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,o=128===l?Uint8Array.from([]):n(e,1,t),2===t&&o[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:o,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=i(n(e,1,r)),t<=55)throw new Error("invalid RLP: expected string length to be greater than 55");return o=n(e,r,t+r),{data:o,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=i(n(e,1,r)),t<56)throw new Error("invalid RLP: encoded list too short");const o=r+t;if(o>e.length)throw new Error("invalid RLP: total length is larger than the data");for(s=n(e,r,o);s.length;)c=a(s),u.push(c.data),s=c.remainder;return{data:u,remainder:e.slice(o)}}}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 h(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 i=e[t];r.set(i,n),n+=i.length}return r}function d(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 g(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function y(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return g(e)?h((t="string"!=typeof(r=e)?r:g(r)?r.slice(2):r).length%2?`0${t}`:t):d(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?h(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:h,utf8ToBytes:d},t.RLP={encode:r,decode:s}},8381:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseTransaction=void 0;const n=r(7226),i=r(1741),o=r(9413),s=r(5417);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:o,to:a,value:c,data:u,v:l,r:h,s:f,type:d}=e;this._type=Number((0,i.bufferToBigInt)((0,i.toBuffer)(d))),this.txOptions=t;const p=(0,i.toBuffer)(""===a?"0x":a),g=(0,i.toBuffer)(""===l?"0x":l),y=(0,i.toBuffer)(""===h?"0x":h),m=(0,i.toBuffer)(""===f?"0x":f);this.nonce=(0,i.bufferToBigInt)((0,i.toBuffer)(""===r?"0x":r)),this.gasLimit=(0,i.bufferToBigInt)((0,i.toBuffer)(""===o?"0x":o)),this.to=p.length>0?new i.Address(p):void 0,this.value=(0,i.bufferToBigInt)((0,i.toBuffer)(""===c?"0x":c)),this.data=(0,i.toBuffer)(""===u?"0x":u),this.v=g.length>0?(0,i.bufferToBigInt)(g):void 0,this.r=y.length>0?(0,i.bufferToBigInt)(y):void 0,this.s=m.length>0?(0,i.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>i.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,i.unpadBuffer)(e).length}catch(e){return!1}}getSenderAddress(){return new i.Address((0,i.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(o.Capability.EIP155ReplayProtection)&&(this.activeCapabilities.push(o.Capability.EIP155ReplayProtection),t=!0);const r=this.getMessageToSign(!0),{v:n,r:s,s:a}=(0,i.ecsign)(r,e),c=this._processSignature(n,s,a);if(t){const e=this.activeCapabilities.indexOf(o.Capability.EIP155ReplayProtection);e>-1&&this.activeCapabilities.splice(e,1)}return c}_getCommon(e,t){if(void 0!==t){const r=(0,i.bufferToBigInt)((0,i.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,o]of Object.entries(e))switch(t){case 64:if(r){if(void 0!==o&&o>=i.MAX_UINT64){const e=this._errorMsg(`${n} cannot equal or exceed MAX_UINT64 (2^64-1), given ${o}`);throw new Error(e)}}else if(void 0!==o&&o>i.MAX_UINT64){const e=this._errorMsg(`${n} cannot exceed MAX_UINT64 (2^64-1), given ${o}`);throw new Error(e)}break;case 256:if(r){if(void 0!==o&&o>=i.MAX_INTEGER){const e=this._errorMsg(`${n} cannot equal or exceed MAX_INTEGER (2^256-1), given ${o}`);throw new Error(e)}}else if(void 0!==o&&o>i.MAX_INTEGER){const e=this._errorMsg(`${n} cannot exceed MAX_INTEGER (2^256-1), given ${o}`);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,i.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}}},6456:(e,t,r)=>{"use strict";var n=r(5291).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.FeeMarketEIP1559Transaction=void 0;const i=r(9966),o=r(1741),s=r(7864),a=r(8381),c=r(5417),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:i,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,o.bufferToBigInt)((0,o.toBuffer)(""===i?"0x":i)),this.maxPriorityFeePerGas=(0,o.bufferToBigInt)((0,o.toBuffer)(""===s?"0x":s)),this._validateCannotExceedMaxInteger({maxFeePerGas:this.maxFeePerGas,maxPriorityFeePerGas:this.maxPriorityFeePerGas}),a.BaseTransaction._validateNotArray(e),this.gasLimit*this.maxFeePerGas>o.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??1)&&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,o.arrToBufArr)(i.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,i,s,a,c,u,h,f,d,p,g]=e;return this._validateNotArray({chainId:r,v:d}),(0,o.validateNoLeadingZeroes)({nonce:n,maxPriorityFeePerGas:i,maxFeePerGas:s,gasLimit:a,value:u,v:d,r:p,s:g}),new l({chainId:(0,o.bufferToBigInt)(r),nonce:n,maxPriorityFeePerGas:i,maxFeePerGas:s,gasLimit:a,to:c,value:u,data:h,accessList:f??[],v:void 0!==d?(0,o.bufferToBigInt)(d):void 0,r:p,s:g},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,o.bigIntToUnpaddedBuffer)(this.chainId),(0,o.bigIntToUnpaddedBuffer)(this.nonce),(0,o.bigIntToUnpaddedBuffer)(this.maxPriorityFeePerGas),(0,o.bigIntToUnpaddedBuffer)(this.maxFeePerGas),(0,o.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,o.bigIntToUnpaddedBuffer)(this.value),this.data,this.accessList,void 0!==this.v?(0,o.bigIntToUnpaddedBuffer)(this.v):n.from([]),void 0!==this.r?(0,o.bigIntToUnpaddedBuffer)(this.r):n.from([]),void 0!==this.s?(0,o.bigIntToUnpaddedBuffer)(this.s):n.from([])]}serialize(){const e=this.raw();return n.concat([u,n.from(i.RLP.encode((0,o.bufArrToArr)(e)))])}getMessageToSign(e=!0){const t=this.raw().slice(0,9),r=n.concat([u,n.from(i.RLP.encode((0,o.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,o.ecrecover)(e,t+BigInt(27),(0,o.bigIntToUnpaddedBuffer)(r),(0,o.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,o.bufferToBigInt)(t),s:(0,o.bufferToBigInt)(r)},n)}toJSON(){const e=c.AccessLists.getAccessListJSON(this.accessList);return{chainId:(0,o.bigIntToHex)(this.chainId),nonce:(0,o.bigIntToHex)(this.nonce),maxPriorityFeePerGas:(0,o.bigIntToHex)(this.maxPriorityFeePerGas),maxFeePerGas:(0,o.bigIntToHex)(this.maxFeePerGas),gasLimit:(0,o.bigIntToHex)(this.gasLimit),to:void 0!==this.to?this.to.toString():void 0,value:(0,o.bigIntToHex)(this.value),data:"0x"+this.data.toString("hex"),accessList:e,v:void 0!==this.v?(0,o.bigIntToHex)(this.v):void 0,r:void 0!==this.r?(0,o.bigIntToHex)(this.r):void 0,s:void 0!==this.s?(0,o.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},1742:(e,t,r)=>{"use strict";var n=r(5291).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.AccessListEIP2930Transaction=void 0;const i=r(9966),o=r(1741),s=r(7864),a=r(8381),c=r(5417),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:i}=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,o.bufferToBigInt)((0,o.toBuffer)(""===i?"0x":i)),this._validateCannotExceedMaxInteger({gasPrice:this.gasPrice}),a.BaseTransaction._validateNotArray(e),this.gasPrice*this.gasLimit>o.MAX_INTEGER){const e=this._errorMsg("gasLimit * gasPrice cannot exceed MAX_INTEGER");throw new Error(e)}this._validateYParity(),this._validateHighS(),(t?.freeze??1)&&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,o.arrToBufArr)(i.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,i,s,a,c,u,h,f,d,p]=e;return this._validateNotArray({chainId:r,v:f}),(0,o.validateNoLeadingZeroes)({nonce:n,gasPrice:i,gasLimit:s,value:c,v:f,r:d,s:p}),new l({chainId:(0,o.bufferToBigInt)(r),nonce:n,gasPrice:i,gasLimit:s,to:a,value:c,data:u,accessList:h??[],v:void 0!==f?(0,o.bufferToBigInt)(f):void 0,r:d,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,o.bigIntToUnpaddedBuffer)(this.chainId),(0,o.bigIntToUnpaddedBuffer)(this.nonce),(0,o.bigIntToUnpaddedBuffer)(this.gasPrice),(0,o.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,o.bigIntToUnpaddedBuffer)(this.value),this.data,this.accessList,void 0!==this.v?(0,o.bigIntToUnpaddedBuffer)(this.v):n.from([]),void 0!==this.r?(0,o.bigIntToUnpaddedBuffer)(this.r):n.from([]),void 0!==this.s?(0,o.bigIntToUnpaddedBuffer)(this.s):n.from([])]}serialize(){const e=this.raw();return n.concat([u,n.from(i.RLP.encode((0,o.bufArrToArr)(e)))])}getMessageToSign(e=!0){const t=this.raw().slice(0,8),r=n.concat([u,n.from(i.RLP.encode((0,o.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,o.ecrecover)(e,t+BigInt(27),(0,o.bigIntToUnpaddedBuffer)(r),(0,o.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,o.bufferToBigInt)(t),s:(0,o.bufferToBigInt)(r)},n)}toJSON(){const e=c.AccessLists.getAccessListJSON(this.accessList);return{chainId:(0,o.bigIntToHex)(this.chainId),nonce:(0,o.bigIntToHex)(this.nonce),gasPrice:(0,o.bigIntToHex)(this.gasPrice),gasLimit:(0,o.bigIntToHex)(this.gasLimit),to:void 0!==this.to?this.to.toString():void 0,value:(0,o.bigIntToHex)(this.value),data:"0x"+this.data.toString("hex"),accessList:e,v:void 0!==this.v?(0,o.bigIntToHex)(this.v):void 0,r:void 0!==this.r?(0,o.bigIntToHex)(this.r):void 0,s:void 0!==this.s?(0,o.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},3732:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeTxParams=void 0;const n=r(1741);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}},2857:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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 o=r(6456);Object.defineProperty(t,"FeeMarketEIP1559Transaction",{enumerable:!0,get:function(){return o.FeeMarketEIP1559Transaction}});var s=r(1742);Object.defineProperty(t,"AccessListEIP2930Transaction",{enumerable:!0,get:function(){return s.AccessListEIP2930Transaction}});var a=r(7789);Object.defineProperty(t,"Transaction",{enumerable:!0,get:function(){return a.Transaction}});var c=r(6910);Object.defineProperty(t,"TransactionFactory",{enumerable:!0,get:function(){return c.TransactionFactory}}),i(r(9413),t)},7789:(e,t,r)=>{"use strict";var n=r(5291).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Transaction=void 0;const i=r(9966),o=r(1741),s=r(7864),a=r(8381),c=r(9413);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,o.bufferToBigInt)((0,o.toBuffer)(""===e.gasPrice?"0x":e.gasPrice)),this.gasPrice*this.gasLimit>o.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??1)&&Object.freeze(this)}static fromTxData(e,t={}){return new l(e,t)}static fromSerializedTx(e,t={}){const r=(0,o.arrToBufArr)(i.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,i,s,a,c,u,h,f]=e;return(0,o.validateNoLeadingZeroes)({nonce:r,gasPrice:n,gasLimit:i,value:a,v:u,r:h,s:f}),new l({nonce:r,gasPrice:n,gasLimit:i,to:s,value:a,data:c,v:u,r:h,s:f},t)}raw(){return[(0,o.bigIntToUnpaddedBuffer)(this.nonce),(0,o.bigIntToUnpaddedBuffer)(this.gasPrice),(0,o.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,o.bigIntToUnpaddedBuffer)(this.value),this.data,void 0!==this.v?(0,o.bigIntToUnpaddedBuffer)(this.v):n.from([]),void 0!==this.r?(0,o.bigIntToUnpaddedBuffer)(this.r):n.from([]),void 0!==this.s?(0,o.bigIntToUnpaddedBuffer)(this.s):n.from([])]}serialize(){return n.from(i.RLP.encode((0,o.bufArrToArr)(this.raw())))}_getMessageToSign(){const e=[(0,o.bigIntToUnpaddedBuffer)(this.nonce),(0,o.bigIntToUnpaddedBuffer)(this.gasPrice),(0,o.bigIntToUnpaddedBuffer)(this.gasLimit),void 0!==this.to?this.to.buf:n.from([]),(0,o.bigIntToUnpaddedBuffer)(this.value),this.data];return this.supports(c.Capability.EIP155ReplayProtection)&&(e.push((0,o.bigIntToUnpaddedBuffer)(this.common.chainId())),e.push((0,o.unpadBuffer)((0,o.toBuffer)(0))),e.push((0,o.unpadBuffer)((0,o.toBuffer)(0)))),e}getMessageToSign(e=!0){const t=this._getMessageToSign();return e?n.from((0,s.keccak256)(i.RLP.encode((0,o.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)(i.RLP.encode((0,o.bufArrToArr)(this.raw()))))),this.cache.hash):n.from((0,s.keccak256)(i.RLP.encode((0,o.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)(i.RLP.encode((0,o.bufArrToArr)(e))))}getSenderPublicKey(){const e=this.getMessageToVerifySignature(),{v:t,r,s:n}=this;this._validateHighS();try{return(0,o.ecrecover)(e,t,(0,o.bigIntToUnpaddedBuffer)(r),(0,o.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,o.bufferToBigInt)(t),s:(0,o.bufferToBigInt)(r)},n)}toJSON(){return{nonce:(0,o.bigIntToHex)(this.nonce),gasPrice:(0,o.bigIntToHex)(this.gasPrice),gasLimit:(0,o.bigIntToHex)(this.gasLimit),to:void 0!==this.to?this.to.toString():void 0,value:(0,o.bigIntToHex)(this.value),data:"0x"+this.data.toString("hex"),v:void 0!==this.v?(0,o.bigIntToHex)(this.v):void 0,r:void 0!==this.r?(0,o.bigIntToHex)(this.r):void 0,s:void 0!==this.s?(0,o.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},6910:(e,t,r)=>{"use strict";var n=r(5291).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.TransactionFactory=void 0;const i=r(1741),o=r(6456),s=r(1742),a=r(3732),c=r(7789);class u{constructor(){}static fromTxData(e,t={}){if("type"in e&&void 0!==e.type){const r=Number((0,i.bufferToBigInt)((0,i.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 o.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 o.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,i.getProvider)(e),o=await(0,i.fetchFromProvider)(n,{method:"eth_getTransactionByHash",params:[t]});if(null===o)throw new Error("No data returned from provider");return u.fromRPCTx(o,r)}static async fromRPCTx(e,t={}){return u.fromTxData((0,a.normalizeTxParams)(e),t)}}t.TransactionFactory=u},9413:(e,t)=>{"use strict";function r(e){if(0===e.length)return!0;const t=e[0];return!!Array.isArray(t)}var n;Object.defineProperty(t,"__esModule",{value:!0}),t.isAccessList=t.isAccessListBuffer=t.Capability=void 0,(n=t.Capability||(t.Capability={}))[n.EIP155ReplayProtection=155]="EIP155ReplayProtection",n[n.EIP1559FeeMarket=1559]="EIP1559FeeMarket",n[n.EIP2718TypedTransaction=2718]="EIP2718TypedTransaction",n[n.EIP2930AccessLists=2930]="EIP2930AccessLists",t.isAccessListBuffer=r,t.isAccessList=function(e){return!r(e)}},5417:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AccessLists=t.checkMaxInitCodeSize=void 0;const n=r(1741),i=r(9413);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,i.isAccessList)(e)){t=e;const i=[];for(let t=0;t<e.length;t++){const r=e[t],o=(0,n.toBuffer)(r.address),s=[];for(let e=0;e<r.storageKeys.length;e++)s.push((0,n.toBuffer)(r.storageKeys[e]));i.push([o,s])}r=i}else{r=e??[];const i=[];for(let e=0;e<r.length;e++){const t=r[e],o=(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:o,storageKeys:s};i.push(a)}t=i}return{AccessListJSON:t,accessList:r}}static verifyAccessList(e){for(let t=0;t<e.length;t++){const r=e[t],n=r[0],i=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<i.length;e++)if(32!==i[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 i=e[r],o={address:"0x"+(0,n.setLengthLeft)(i[0],20).toString("hex"),storageKeys:[]},s=i[1];for(let e=0;e<s.length;e++){const t=s[e];o.storageKeys.push("0x"+(0,n.setLengthLeft)(t,32).toString("hex"))}t.push(o)}return t}static getDataFeeEIP2930(e,t){const r=t.param("gasPrices","accessListStorageKeyCost"),n=t.param("gasPrices","accessListAddressCost");let i=0;for(let t=0;t<e.length;t++)i+=e[t][1].length;return e.length*Number(n)+i*Number(r)}}},2961:(e,t,r)=>{"use strict";var n=r(5291).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 i=r(9966),o=r(7864),s=r(3293),a=r(6626),c=r(1267),u=r(137),l=r(1830),h=r(8653),f=BigInt(0);class d{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:i}=e;return new d(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!==i?(0,c.toBuffer)(i):void 0)}static fromRlpSerializedAccount(e){const t=(0,c.arrToBufArr)(i.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,i]=e;return new d((0,c.bufferToBigInt)(t),(0,c.bufferToBigInt)(r),n,i)}_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(i.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)}}function p(e){const[t,r,n,i]=e;return[t,r,0===(0,c.arrToBufArr)(n).length?u.KECCAK256_RLP:n,0===(0,c.arrToBufArr)(i).length?u.KECCAK256_NULL:i]}t.Account=d,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,h.stripHexPrefix)(e).toLowerCase();let i="";void 0!==t&&(i=(0,c.bufferToBigInt)((0,c.toBuffer)(