essential-eth 0.9.2-beta.0 → 0.9.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{Keccak as t}from"sha3";import e from"big.js";import r from"isomorphic-unfetch";import{Point as n}from"@noble/secp256k1";import{Buffer as s}from"buffer";function a(){return a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a.apply(this,arguments)}function o(t){return BigInt(t).toString()}function i(t){const e=t.startsWith("-");return(t=(t=(t=t.replace("-","")).replace(/\.0*$/g,"")).replace(/^0+/,"")).includes(".")&&(t=t.replace(/0+$/,"")),t.startsWith(".")&&(t=`0${t}`),`${e?"-":""}${t}`}function c(t){if(!t.match(/e/i))return i(t);let[e,r]=t.split(/e/i);const n=Number(e)<0;e=e.replace("-",""),e=i(e);const[s,a=""]=e.split(".");if(0===Number(r))return`${n?"-":""}${i(e)}`;{e.includes(".")||(e=`${e}.`),e=e.replace(".","");const t=e.length;let o;return Number(r)<0?(s.length<Math.abs(Number(r))&&(e=e.padStart(t+Math.abs(Number(r))-s.length,"0")),o=e.split(""),s.length<Math.abs(Number(r))?o=[".",...o]:o.splice(o.length-Math.abs(Number(r)),0,".")):(a.length<Math.abs(Number(r))&&(e=e.padEnd(t+Math.abs(Number(r))-a.length,"0")),o=e.split(""),a.length>Math.abs(Number(r))&&o.splice(o.length-Math.abs(Number(r)),0,".")),`${n?"-":""}${i(o.join(""))}`}}class u extends e{constructor(t){"string"==typeof t&&t.startsWith("0x")&&(t=o(t)),super(t),this.padAndChop=(t,e,r)=>(Array(r).fill(e).join("")+t).slice(-1*r)}toHexString(){return`0x${BigInt(this.toString()).toString(16)}`}toNumber(){return Number(c(super.toString()))}toString(){return 0===this.toNumber()?"0":c(super.toString())}toTwos(t){let e;if(this.gte(0)){const r=this.toNumber().toString(2);e=this.padAndChop(r,"0",t||r.length)}else if(e=this.plus(Math.pow(2,t)).toNumber().toString(2),Number(e)<0)throw new Error("Cannot calculate twos complement");return l(Number(`0b${e}`))}}function l(t){return new u(t)}const h=(t,e)=>{if(!e.includes(typeof t))throw new Error(`${e.join(" or ")} required. Received ${typeof t}`)};function g(e){if(h(e,["string"]),!/^(0x)?[0-9a-f]{40}$/i.test(e))throw new Error(`Invalid Ethereum address "${e}"`);const r=e.toLowerCase().replace(/^0x/i,""),n=new t(256).update(r).digest("hex").replace(/^0x/i,"");let s="0x";for(let t=0;t<r.length;t++)parseInt(n[t],16)>7?s+=r[t].toUpperCase():s+=r[t];if(e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&s!==e)throw new Error(`Invalid Checksum address for "${e}"`);return s}const f="0".repeat(64),m="0".repeat(63)+"1";class p{constructor(e,r,n){var s=this;this._address=void 0,this._provider=void 0,this._address=e,this._provider=n,r.filter(t=>"function"===t.type).forEach(e=>{var r;"name"in e&&"string"==typeof e.name&&(r=async function(...r){let n=r,i={};const c=r[r.length-1];Array.isArray(c)||"object"!=typeof c||(i=c,n=r.slice(0,r.length-1));const u=function(e,r){const n=new t(256),s=`${e.name}(${e.inputs.map(t=>{return"uint[]"===(e=t.type)?"uint256[]":"int[]"===e?"int256[]":e;var e})})`,a=n.update(s).digest("hex"),o=e.inputs.length;let i=!0;if(e.inputs.find(t=>t.type.includes("["))&&(i=!1),i&&r.length!==o)throw new Error(`args inputs of "${r.length}" does not match expected length of "${e.inputs.length}"`);const c=(e.inputs||[]).reduce((t,e,n)=>{if(e.type.includes("[")){var s;const n=null==(s=/([^[]*)\[.*$/g.exec(e.type))?void 0:s[1];return r.forEach(e=>{t=t.concat([[e,n]])}),t}return t.concat([[r[n],e.type]])},[]).map(([t,e])=>{let r=t;switch(e){case"bool":return t?m:f;case"address":r=t.replace(/^0x/g,"").toLowerCase();break;default:if(e.startsWith("bytes"))return r.split("").map(t=>t.charCodeAt(0).toString(16)).join("").padEnd(64,"0");if("uint256"===e)return BigInt(t).toString(16).padStart(64,"0");if(e.startsWith("uint"))break;throw new Error(`essential-eth does not yet support "${e}" inputs. Make a PR today!"`)}return r.toString(16).padStart(64,"0")});return`0x${a.slice(0,8)}${c.join("")}`}(e,n),h="number"==typeof i.gasLimit?i.gasLimit:"number"==typeof(null==e?void 0:e.gas)?void u.split("").reduce((t,e)=>t+("0"===e?4:68),0):null,p=await async function(){return await s._provider.call(a({to:s._address.toLowerCase(),data:u},h?{gas:`0x${h.toString(16)}`}:{}),"latest")}();return function(t,e){var r;const n=t.outputs,s=e.slice(2);if(1===(null==t||null==(r=t.outputs)?void 0:r.length)&&"string"===t.outputs[0].type){const[t,e]=[s.slice(0,64),s.slice(64)],r=Number(o(`0x${t}`)),n=e.slice(0,2*r),a=Number(o(`0x${n}`));return function(t){let e="",r=0;const n=t.length;for("0x"===t.substring(0,2)&&(r=2);r<n;r+=2){const n=parseInt(t.substr(r,2),16);0!==n&&(e+=String.fromCharCode(n))}try{return decodeURIComponent(escape(e))}catch(t){return e}}(e.slice(2*r,2*r+2*a))}const a=(s.match(/.{1,64}/g)||[]).map((t,e)=>{const r=(n||[])[e].type;switch(r){case"bool":return t===m;case"address":return g(`0x${t.slice(24)}`);case"uint256":case"uint120":return l(o(`0x${t}`));case"bytes32":return`0x${t}`;case"uint8":return Number(o(`0x${t}`));default:throw new Error(`essential-eth does not yet support "${r}" outputs. Make a PR today!"`)}});return 1===a.length?a[0]:a}(e,p)},Object.defineProperty(this,e.name,{enumerable:!0,value:r,writable:!1}))})}}class d extends p{}function y(t){const e=a({},t);return Object.keys(t).forEach(r=>{if(t[r])switch(r){case"blockNumber":case"chainId":case"transactionIndex":case"type":case"v":e[r]=Number(o(t[r]));break;case"from":case"to":t[r]&&(e[r]=g(t[r]));break;case"value":case"gas":case"gasPrice":case"maxFeePerGas":case"maxPriorityFeePerGas":case"nonce":e[r]=l(o(t[r]))}}),e}function b(t,e){const r=a({},t);return Object.keys(t).forEach(n=>{switch(n){case"address":r[n]=g(t[n]);break;case"blockNumber":case"logIndex":case"transactionIndex":r[n]=Number(o(t[n]));break;case"removed":e&&delete r[n]}}),r}function v(t,e){return{jsonrpc:"2.0",id:1,method:t,params:e}}const x=new class{constructor(){this.packageVersion=void 0,this.packageVersion="0.9.2-beta.0"}throwError(t,e){const r=Object.keys(e).length;throw new Error(`${t} (${Object.entries(e).map(([t,e],n)=>`${t}=${e}${n<r-1&&", "}`)}, version=essential-eth@${this.packageVersion})`)}throwArgumentError(t,e,r){throw new Error(`${t} (argument="${e}" value=${r}, version=essential-eth@${this.packageVersion})`)}checkSafeUint53(t,e="value not safe"){"number"==typeof t&&((t<0||t>=9007199254740991)&&this.throwError(e,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}};function w(t){return!!t.toHexString}function P(t){return N(t)&&!(t.length%2)||$(t)}function E(t){return"number"==typeof t&&t==t&&t%1==0}function $(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!E(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!E(r)||r<0||r>=256)return!1}return!0}function A(t,e){if(e||(e={}),"number"==typeof t){x.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),new Uint8Array(e)}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),w(t)&&(t=t.toHexString()),N(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":x.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return new Uint8Array(n)}return $(t)?new Uint8Array(t):x.throwArgumentError("invalid arrayify value","value",t)}function k(t){const e=t.map(t=>A(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),n}function S(t){let e=A(t);if(0===e.length)return e;let r=0;for(;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e}function _(t,e){(t=A(t)).length>e&&x.throwArgumentError("value out of range","value",t);const r=new Uint8Array(e);return r.set(t,e-t.length),r}function N(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}function U(t,e){if(e||(e={}),"number"==typeof t){x.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),w(t))return t.toHexString();if(N(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":x.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if($(t)){let e="0x";for(let r=0;r<t.length;r++){const n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return x.throwArgumentError("invalid hexlify value","value",t)}function G(t){if("string"!=typeof t)t=U(t);else if(!N(t)||t.length%2)return null;return(t.length-2)/2}function F(t,e,r){return"string"!=typeof t?t=U(t):(!N(t)||t.length%2)&&x.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function C(t){let e="0x";return t.forEach(t=>{e+=U(t).substring(2)}),e}function B(t){const e=I(U(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=U(t)),N(t)||x.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}function j(t,e){for("string"!=typeof t?t=U(t):N(t)||x.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&x.throwError("value out of range",{value:t,length:e});t.length<2*e+2;)t="0x0"+t.substring(2);return t}function O(t){const r=a({},t);return Object.keys(t).forEach(n=>{switch(n){case"gas":case"gasPrice":case"nonce":case"maxFeePerGas":case"maxPriorityFeePerGas":case"value":{const s=t[n];r[n]=s instanceof u?s.toHexString():s instanceof e?`0x${BigInt(s.toString()).toString(16)}`:"number"==typeof t[n]?"0x"+t[n].toString(16):t[n].toString();break}case"data":r[n]=U(t[n])}}),r}var M={1:["eth","0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"],5:["gor","0x112234455c3a32fd11230c42e7bccd4a84e02010"],10:["oeth"],50:["xdc"],56:["bnb"],100:["gno"],137:["matic"],250:["ftm"],324:["zksync"],1101:["zkevm"],1337:["geth"],7700:["canto"],9001:["evmos"],42161:["arb1"],42220:["celo"],43114:["avax"],59140:["linea-testnet"],80001:["maticmum"],421613:["arb-goerli"],534352:["scr"],11155111:["sep"]};function R(t){return"number"==typeof t?l(t).toHexString():t}class T{constructor(t){this._rpcUrls=[],this._post=t=>function(t,e){return r(t,function(t){return{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}}(e)).then(async t=>{const e=await t.text();try{return JSON.parse(e)}catch(t){throw new Error(`Invalid JSON RPC response: "${e}"`)}}).then(t=>{if(!(null==t?void 0:t.result))throw new Error(`Invalid JSON RPC response: ${JSON.stringify(t)}`);return t.result})}(this.selectRpcUrl(),t),this._rpcUrls=t}async getNetwork(){const t=o(await this.post(v("eth_chainId",[]))),e=M[t];return{chainId:Number(t),name:e[0]||"unknown",ensAddress:e[1]||null}}async getBlockNumber(){const t=await this.post(v("eth_blockNumber",[]));return Number(o(t))}async getTransaction(t){const[e,r]=await Promise.all([this.post(v("eth_getTransactionByHash",[t])),this.getBlock("latest")]),n=y(e);return n.confirmations=r.number-n.blockNumber+1,n}async getTransactionReceipt(t){const[e,r]=await Promise.all([this.post(v("eth_getTransactionReceipt",[t])),this.getBlock("latest")]),n=function(t){const e=a({},y(t));return Object.keys(t).forEach(r=>{if(t[r])switch(r){case"status":e[r]=Number(o(t[r]));break;case"contractAddress":t[r]&&(e[r]=g(t[r]));break;case"cumulativeGasUsed":case"effectiveGasPrice":case"gasUsed":e[r]=l(o(t[r]));break;case"logs":t[r].forEach((t,n)=>{e[r][n]=b(t,!0)})}}),e.byzantium=e.blockNumber>=437e4,e}(e);return n.confirmations=r.number-n.blockNumber+1,n}async getTransactionCount(t,e="latest"){e=R(e);const r=await this.post(v("eth_getTransactionCount",[t,e]));return Number(o(r))}async getBlock(t="latest",e=!1){let r="Number";return"string"==typeof t&&66===t.length?r="Hash":t=R(t),function(t,e){const r=a({},t);return Object.keys(t).forEach(e=>{if(t[e])switch(e){case"difficulty":case"totalDifficulty":case"gasLimit":case"gasUsed":case"size":case"timestamp":case"baseFeePerGas":r[e]=l(o(t[e]));break;case"number":r[e]=Number(o(t[e]));break;case"miner":r[e]=g(t[e])}}),e&&t.transactions.forEach((t,e)=>{r.transactions[e]=y(t)}),r}(await this.post(v(`eth_getBlockBy${r}`,[t,e])),e)}async getGasPrice(){return l(o(await this.post(v("eth_gasPrice",[]))))}async getBalance(t,e="latest"){return e=R(e),l(o(await this.post(v("eth_getBalance",[t,e]))))}async getCode(t,e="latest"){return e=R(e),await this.post(v("eth_getCode",[t,e]))}async estimateGas(t){const e=O(t);return l(o(await this.post(v("eth_estimateGas",[e]))))}async getFeeData(){const[t,e]=await Promise.all([this.getBlock("latest"),this.getGasPrice()]);let r=null,n=null,s=null;return t&&t.baseFeePerGas&&(r=t.baseFeePerGas,s=l("1500000000"),n=l(t.baseFeePerGas.mul(2).add(s))),{lastBaseFeePerGas:r,maxFeePerGas:n,maxPriorityFeePerGas:s,gasPrice:e}}async getLogs(t){const e=t;return e.fromBlock&&(e.fromBlock=R(e.fromBlock)),e.toBlock&&(e.toBlock=R(e.toBlock)),(await this.post(v("eth_getLogs",[t]))).map(t=>b(t,!1))}async call(t,e="latest"){t.gasPrice&&(t.maxPriorityFeePerGas||t.maxFeePerGas)&&x.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")',{gasPrice:t.gasPrice,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),t.maxFeePerGas&&t.maxPriorityFeePerGas&&x.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"',{maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),e=R(e);const r=O(t);return await this.post(v("eth_call",[r,e]))}}class L extends T{selectRpcUrl(){return this._rpcUrls[0]}post(t){return this._post(t)}constructor(t="https://free-eth-node.com/api/eth"){super([t])}}function H(t){return new L(t)}class W extends L{constructor(t,e="mainnet"){super(`https://eth-${e}.alchemyapi.io/v2/${t}`)}}class D extends T{selectRpcUrl(){return this._rpcUrls[this.rpcUrlCounter]}constructor(t,e={}){Array.isArray(t)||x.throwError("Array required",{rpcUrls:t}),t.length<=1&&x.throwError("More than one rpcUrl is required",{rpcUrls:t}),super(t),this.rpcUrlCounter=0,this.timeoutDuration=void 0,this.post=t=>{const e=this.rpcUrlCounter,r=()=>{const n=this.selectRpcUrl();var s,a;return(s=this._post(t),a=this.timeoutDuration,new Promise((t,e)=>{const r=setTimeout(()=>e(new Error("Promise timed out")),a);s.then(e=>{clearTimeout(r),t(e)}).catch(t=>{clearTimeout(r),e(t)})})).catch(t=>{if(n===this.selectRpcUrl()&&(this.rpcUrlCounter=(this.rpcUrlCounter+1)%this._rpcUrls.length),this.rpcUrlCounter===e)throw t;return r()})};return r()},this.timeoutDuration=e.timeoutDuration||8e3}}function J(t){return t=U(t).slice(2),"0x"+n.fromPrivateKey(t).toHex()}function z(e){let r;return r="string"==typeof e?Buffer.from(e.replace(/^0x/,""),"hex"):Buffer.from(e),"0x"+new t(256).update(r).digest("hex")}function V(t){return t.startsWith("0x04")||t.startsWith("0x03")||t.startsWith("0x02")||(t=J(t)),g(F(z(F(t,1)),12))}function q(t){h(t,["string","number","object"]);const e=l(t).times("1000000000");return l(e)}function K(t){h(t,["string","number","object"]);const e=l(t).times("1000000000000000000");return l(e)}function Q(t){h(t,["string","number","object"]);const e=l(t).div("1000000000");return l(e)}function X(t){return new Uint8Array(Buffer.from(t))}function Y(t){return"string"==typeof t&&(t=X(t)),z(k([X("Ethereum Signed Message:\n"),X(String(t.length)),t]))}function Z(t){h(t,["string"]);try{return g(t),!0}catch(t){return!1}}function tt(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(P(t)){const r=A(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=U(r.slice(0,32)),e.s=U(r.slice(32,64))):65===r.length?(e.r=U(r.slice(0,32)),e.s=U(r.slice(32,64)),e.v=r[64]):x.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:x.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=U(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=_(A(e._vs),32);e._vs=U(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&x.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const s=U(r);null==e.s?e.s=s:e.s!==s&&x.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?x.throwArgumentError("signature missing v and recoveryParam","signature",t):e.recoveryParam=0===e.v||1===e.v?e.v:1-e.v%2:null==e.v?e.v=27+e.recoveryParam:e.recoveryParam!==(0===e.v||1===e.v?e.v:1-e.v%2)&&x.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&N(e.r)?e.r=j(e.r,32):x.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&N(e.s)?e.s=j(e.s,32):x.throwArgumentError("signature missing or invalid s","signature",t);const r=A(e.s);r[0]>=128&&x.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=U(r);e._vs&&(N(e._vs)||x.throwArgumentError("signature invalid _vs","signature",t),e._vs=j(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&x.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function et(t){h(t,["string","number","object"]);try{let e=t;"string"==typeof t&&"0x"===t.slice(0,2)&&(e=BigInt(t).toString());const r=l(e).div("1000000000000000000");return l(r)}catch(t){throw t}}const rt=new RegExp("^bytes([0-9]+)$"),nt=new RegExp("^(u?int)([0-9]*)$"),st=new RegExp("^(.*)\\[([0-9]*)\\]$");function at(t,e,r){switch(t){case"address":return r?_(e,32):A(e);case"string":return s.from(e);case"bytes":return A(e);case"bool":return e=e?"0x01":"0x00",r?_(e,32):A(e)}let n=t.match(nt);if(n){let s=parseInt(n[2]||"256");return(n[2]&&String(s)!==n[2]||s%8!=0||0===s||s>256)&&x.throwArgumentError("invalid number type","type",t),r&&(s=256),_(U(e=l(e).toTwos(s).toNumber()),s/8)}if(n=t.match(rt),n){const s=parseInt(n[1]);return(String(s)!==n[1]||0===s||s>32)&&x.throwArgumentError("invalid bytes type","type",t),A(e).byteLength!==s&&x.throwArgumentError(`invalid value for ${t}`,"value",e),r?A((e+f).substring(0,66)):e}if(n=t.match(st),n&&Array.isArray(e)){const r=n[1];parseInt(n[2]||String(e.length))!=e.length&&x.throwArgumentError(`invalid array length for ${t}`,"value",e);const s=[];return e.forEach(function(t){s.push(at(r,t,!0))}),k(s)}return x.throwArgumentError("invalid type","type",t)}function ot(t,e){t.length!=e.length&&x.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);const r=[];return t.forEach(function(t,n){r.push(at(t,e[n]))}),U(k(r))}function it(t,e){return z(ot(t,e))}export{W as AlchemyProvider,p as BaseContract,d as Contract,D as FallthroughProvider,L as JsonRpcProvider,u as TinyBig,A as arrayify,V as computeAddress,J as computePublicKey,k as concat,q as etherToGwei,K as etherToWei,Q as gweiToEther,Y as hashMessage,C as hexConcat,G as hexDataLength,F as hexDataSlice,I as hexStripZeros,B as hexValue,j as hexZeroPad,U as hexlify,Z as isAddress,$ as isBytes,P as isBytesLike,N as isHexString,H as jsonRpcProvider,z as keccak256,ot as pack,it as solidityKeccak256,tt as splitSignature,S as stripZeros,l as tinyBig,g as toChecksumAddress,X as toUtf8Bytes,et as weiToEther,_ as zeroPad};
1
+ import{Keccak as t}from"sha3";import e from"big.js";import r from"isomorphic-unfetch";import{Point as n}from"@noble/secp256k1";import{Buffer as s}from"buffer";function a(){return a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a.apply(this,arguments)}function o(t){return BigInt(t).toString()}function i(t){const e=t.startsWith("-");return(t=(t=(t=t.replace("-","")).replace(/\.0*$/g,"")).replace(/^0+/,"")).includes(".")&&(t=t.replace(/0+$/,"")),t.startsWith(".")&&(t=`0${t}`),`${e?"-":""}${t}`}function c(t){if(!t.match(/e/i))return i(t);let[e,r]=t.split(/e/i);const n=Number(e)<0;e=e.replace("-",""),e=i(e);const[s,a=""]=e.split(".");if(0===Number(r))return`${n?"-":""}${i(e)}`;{e.includes(".")||(e=`${e}.`),e=e.replace(".","");const t=e.length;let o;return Number(r)<0?(s.length<Math.abs(Number(r))&&(e=e.padStart(t+Math.abs(Number(r))-s.length,"0")),o=e.split(""),s.length<Math.abs(Number(r))?o=[".",...o]:o.splice(o.length-Math.abs(Number(r)),0,".")):(a.length<Math.abs(Number(r))&&(e=e.padEnd(t+Math.abs(Number(r))-a.length,"0")),o=e.split(""),a.length>Math.abs(Number(r))&&o.splice(o.length-Math.abs(Number(r)),0,".")),`${n?"-":""}${i(o.join(""))}`}}class u extends e{constructor(t){"string"==typeof t&&t.startsWith("0x")&&(t=o(t)),super(t),this.padAndChop=(t,e,r)=>(Array(r).fill(e).join("")+t).slice(-1*r)}toHexString(){return`0x${BigInt(this.toString()).toString(16)}`}toNumber(){return Number(c(super.toString()))}toString(){return 0===this.toNumber()?"0":c(super.toString())}toTwos(t){let e;if(this.gte(0)){const r=this.toNumber().toString(2);e=this.padAndChop(r,"0",t||r.length)}else if(e=this.plus(Math.pow(2,t)).toNumber().toString(2),Number(e)<0)throw new Error("Cannot calculate twos complement");return l(Number(`0b${e}`))}}function l(t){return new u(t)}const h=(t,e)=>{if(!e.includes(typeof t))throw new Error(`${e.join(" or ")} required. Received ${typeof t}`)};function g(e){if(h(e,["string"]),!/^(0x)?[0-9a-f]{40}$/i.test(e))throw new Error(`Invalid Ethereum address "${e}"`);const r=e.toLowerCase().replace(/^0x/i,""),n=new t(256).update(r).digest("hex").replace(/^0x/i,"");let s="0x";for(let t=0;t<r.length;t++)parseInt(n[t],16)>7?s+=r[t].toUpperCase():s+=r[t];if(e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&s!==e)throw new Error(`Invalid Checksum address for "${e}"`);return s}const f="0".repeat(64),m="0".repeat(63)+"1";class p{constructor(e,r,n){var s=this;this._address=void 0,this._provider=void 0,this._address=e,this._provider=n,r.filter(t=>"function"===t.type).forEach(e=>{var r;"name"in e&&"string"==typeof e.name&&(r=async function(...r){let n=r,i={};const c=r[r.length-1];Array.isArray(c)||"object"!=typeof c||(i=c,n=r.slice(0,r.length-1));const u=function(e,r){const n=new t(256),s=`${e.name}(${e.inputs.map(t=>{return"uint[]"===(e=t.type)?"uint256[]":"int[]"===e?"int256[]":e;var e})})`,a=n.update(s).digest("hex"),o=e.inputs.length;let i=!0;if(e.inputs.find(t=>t.type.includes("["))&&(i=!1),i&&r.length!==o)throw new Error(`args inputs of "${r.length}" does not match expected length of "${e.inputs.length}"`);const c=(e.inputs||[]).reduce((t,e,n)=>{if(e.type.includes("[")){var s;const n=null==(s=/([^[]*)\[.*$/g.exec(e.type))?void 0:s[1];return r.forEach(e=>{t=t.concat([[e,n]])}),t}return t.concat([[r[n],e.type]])},[]).map(([t,e])=>{let r=t;switch(e){case"bool":return t?m:f;case"address":r=t.replace(/^0x/g,"").toLowerCase();break;default:if(e.startsWith("bytes"))return r.split("").map(t=>t.charCodeAt(0).toString(16)).join("").padEnd(64,"0");if("uint256"===e)return BigInt(t).toString(16).padStart(64,"0");if(e.startsWith("uint"))break;throw new Error(`essential-eth does not yet support "${e}" inputs. Make a PR today!"`)}return r.toString(16).padStart(64,"0")});return`0x${a.slice(0,8)}${c.join("")}`}(e,n),h="number"==typeof i.gasLimit?i.gasLimit:"number"==typeof(null==e?void 0:e.gas)?void u.split("").reduce((t,e)=>t+("0"===e?4:68),0):null,p=await async function(){return await s._provider.call(a({to:s._address.toLowerCase(),data:u},h?{gas:`0x${h.toString(16)}`}:{}),"latest")}();return function(t,e){var r;const n=t.outputs,s=e.slice(2);if(1===(null==t||null==(r=t.outputs)?void 0:r.length)&&"string"===t.outputs[0].type){const[t,e]=[s.slice(0,64),s.slice(64)],r=Number(o(`0x${t}`)),n=e.slice(0,2*r),a=Number(o(`0x${n}`));return function(t){let e="",r=0;const n=t.length;for("0x"===t.substring(0,2)&&(r=2);r<n;r+=2){const n=parseInt(t.substr(r,2),16);0!==n&&(e+=String.fromCharCode(n))}try{return decodeURIComponent(escape(e))}catch(t){return e}}(e.slice(2*r,2*r+2*a))}const a=(s.match(/.{1,64}/g)||[]).map((t,e)=>{const r=(n||[])[e].type;switch(r){case"bool":return t===m;case"address":return g(`0x${t.slice(24)}`);case"uint256":case"uint120":return l(o(`0x${t}`));case"bytes32":return`0x${t}`;case"uint8":return Number(o(`0x${t}`));default:throw new Error(`essential-eth does not yet support "${r}" outputs. Make a PR today!"`)}});return 1===a.length?a[0]:a}(e,p)},Object.defineProperty(this,e.name,{enumerable:!0,value:r,writable:!1}))})}}class d extends p{}function y(t){const e=a({},t);return Object.keys(t).forEach(r=>{if(t[r])switch(r){case"blockNumber":case"chainId":case"transactionIndex":case"type":case"v":e[r]=Number(o(t[r]));break;case"from":case"to":t[r]&&(e[r]=g(t[r]));break;case"value":case"gas":case"gasPrice":case"maxFeePerGas":case"maxPriorityFeePerGas":case"nonce":e[r]=l(o(t[r]))}}),e}function b(t,e){const r=a({},t);return Object.keys(t).forEach(n=>{switch(n){case"address":r[n]=g(t[n]);break;case"blockNumber":case"logIndex":case"transactionIndex":r[n]=Number(o(t[n]));break;case"removed":e&&delete r[n]}}),r}function v(t,e){return{jsonrpc:"2.0",id:1,method:t,params:e}}const x=new class{constructor(){this.packageVersion=void 0,this.packageVersion="0.9.2-beta.1"}throwError(t,e){const r=Object.keys(e).length;throw new Error(`${t} (${Object.entries(e).map(([t,e],n)=>`${t}=${e}${n<r-1&&", "}`)}, version=essential-eth@${this.packageVersion})`)}throwArgumentError(t,e,r){throw new Error(`${t} (argument="${e}" value=${r}, version=essential-eth@${this.packageVersion})`)}checkSafeUint53(t,e="value not safe"){"number"==typeof t&&((t<0||t>=9007199254740991)&&this.throwError(e,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}};function w(t){return!!t.toHexString}function P(t){return N(t)&&!(t.length%2)||$(t)}function E(t){return"number"==typeof t&&t==t&&t%1==0}function $(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!E(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!E(r)||r<0||r>=256)return!1}return!0}function A(t,e){if(e||(e={}),"number"==typeof t){x.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),new Uint8Array(e)}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),w(t)&&(t=t.toHexString()),N(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":x.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return new Uint8Array(n)}return $(t)?new Uint8Array(t):x.throwArgumentError("invalid arrayify value","value",t)}function k(t){const e=t.map(t=>A(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),n}function S(t){let e=A(t);if(0===e.length)return e;let r=0;for(;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e}function _(t,e){(t=A(t)).length>e&&x.throwArgumentError("value out of range","value",t);const r=new Uint8Array(e);return r.set(t,e-t.length),r}function N(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}function U(t,e){if(e||(e={}),"number"==typeof t){x.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),w(t))return t.toHexString();if(N(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":x.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if($(t)){let e="0x";for(let r=0;r<t.length;r++){const n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return x.throwArgumentError("invalid hexlify value","value",t)}function G(t){if("string"!=typeof t)t=U(t);else if(!N(t)||t.length%2)return null;return(t.length-2)/2}function F(t,e,r){return"string"!=typeof t?t=U(t):(!N(t)||t.length%2)&&x.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function C(t){let e="0x";return t.forEach(t=>{e+=U(t).substring(2)}),e}function B(t){const e=I(U(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=U(t)),N(t)||x.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}function j(t,e){for("string"!=typeof t?t=U(t):N(t)||x.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&x.throwError("value out of range",{value:t,length:e});t.length<2*e+2;)t="0x0"+t.substring(2);return t}function O(t){const r=a({},t);return Object.keys(t).forEach(n=>{switch(n){case"gas":case"gasPrice":case"nonce":case"maxFeePerGas":case"maxPriorityFeePerGas":case"value":{const s=t[n];r[n]=s instanceof u?s.toHexString():s instanceof e?`0x${BigInt(s.toString()).toString(16)}`:"number"==typeof t[n]?"0x"+t[n].toString(16):t[n].toString();break}case"data":r[n]=U(t[n])}}),r}var M={1:["eth","0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"],5:["gor","0x112234455c3a32fd11230c42e7bccd4a84e02010"],10:["oeth"],50:["xdc"],56:["bnb"],100:["gno"],137:["matic"],250:["ftm"],324:["zksync"],1101:["zkevm"],1337:["geth"],7700:["canto"],9001:["evmos"],42161:["arb1"],42220:["celo"],43114:["avax"],59140:["linea-testnet"],80001:["maticmum"],421613:["arb-goerli"],534352:["scr"],11155111:["sep"]};function R(t){return"number"==typeof t?l(t).toHexString():t}class T{constructor(t){this._rpcUrls=[],this._post=t=>function(t,e){return r(t,function(t){return{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}}(e)).then(async t=>{const e=await t.text();try{return JSON.parse(e)}catch(t){throw new Error(`Invalid JSON RPC response: "${e}"`)}}).then(t=>{if(!(null==t?void 0:t.result))throw new Error(`Invalid JSON RPC response: ${JSON.stringify(t)}`);return t.result})}(this.selectRpcUrl(),t),this._rpcUrls=t}async getNetwork(){const t=o(await this.post(v("eth_chainId",[]))),e=M[t];return{chainId:Number(t),name:e[0]||"unknown",ensAddress:e[1]||null}}async getBlockNumber(){const t=await this.post(v("eth_blockNumber",[]));return Number(o(t))}async getTransaction(t){const[e,r]=await Promise.all([this.post(v("eth_getTransactionByHash",[t])),this.getBlock("latest")]),n=y(e);return n.confirmations=r.number-n.blockNumber+1,n}async getTransactionReceipt(t){const[e,r]=await Promise.all([this.post(v("eth_getTransactionReceipt",[t])),this.getBlock("latest")]),n=function(t){const e=a({},y(t));return Object.keys(t).forEach(r=>{if(t[r])switch(r){case"status":e[r]=Number(o(t[r]));break;case"contractAddress":t[r]&&(e[r]=g(t[r]));break;case"cumulativeGasUsed":case"effectiveGasPrice":case"gasUsed":e[r]=l(o(t[r]));break;case"logs":t[r].forEach((t,n)=>{e[r][n]=b(t,!0)})}}),e.byzantium=e.blockNumber>=437e4,e}(e);return n.confirmations=r.number-n.blockNumber+1,n}async getTransactionCount(t,e="latest"){e=R(e);const r=await this.post(v("eth_getTransactionCount",[t,e]));return Number(o(r))}async getBlock(t="latest",e=!1){let r="Number";return"string"==typeof t&&66===t.length?r="Hash":t=R(t),function(t,e){const r=a({},t);return Object.keys(t).forEach(e=>{if(t[e])switch(e){case"difficulty":case"totalDifficulty":case"gasLimit":case"gasUsed":case"size":case"timestamp":case"baseFeePerGas":r[e]=l(o(t[e]));break;case"number":r[e]=Number(o(t[e]));break;case"miner":r[e]=g(t[e])}}),e&&t.transactions.forEach((t,e)=>{r.transactions[e]=y(t)}),r}(await this.post(v(`eth_getBlockBy${r}`,[t,e])),e)}async getGasPrice(){return l(o(await this.post(v("eth_gasPrice",[]))))}async getBalance(t,e="latest"){return e=R(e),l(o(await this.post(v("eth_getBalance",[t,e]))))}async getCode(t,e="latest"){return e=R(e),await this.post(v("eth_getCode",[t,e]))}async estimateGas(t){const e=O(t);return l(o(await this.post(v("eth_estimateGas",[e]))))}async getFeeData(){const[t,e]=await Promise.all([this.getBlock("latest"),this.getGasPrice()]);let r=null,n=null,s=null;return t&&t.baseFeePerGas&&(r=t.baseFeePerGas,s=l("1500000000"),n=l(t.baseFeePerGas.mul(2).add(s))),{lastBaseFeePerGas:r,maxFeePerGas:n,maxPriorityFeePerGas:s,gasPrice:e}}async getLogs(t){const e=t;return e.fromBlock&&(e.fromBlock=R(e.fromBlock)),e.toBlock&&(e.toBlock=R(e.toBlock)),(await this.post(v("eth_getLogs",[t]))).map(t=>b(t,!1))}async call(t,e="latest"){t.gasPrice&&(t.maxPriorityFeePerGas||t.maxFeePerGas)&&x.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")',{gasPrice:t.gasPrice,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),t.maxFeePerGas&&t.maxPriorityFeePerGas&&x.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"',{maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),e=R(e);const r=O(t);return await this.post(v("eth_call",[r,e]))}}class L extends T{selectRpcUrl(){return this._rpcUrls[0]}post(t){return this._post(t)}constructor(t="https://free-eth-node.com/api/eth"){super([t])}}function H(t){return new L(t)}class W extends L{constructor(t,e="mainnet"){super(`https://eth-${e}.alchemyapi.io/v2/${t}`)}}class D extends T{selectRpcUrl(){return this._rpcUrls[this.rpcUrlCounter]}constructor(t,e={}){Array.isArray(t)||x.throwError("Array required",{rpcUrls:t}),t.length<=1&&x.throwError("More than one rpcUrl is required",{rpcUrls:t}),super(t),this.rpcUrlCounter=0,this.timeoutDuration=void 0,this.post=t=>{const e=this.rpcUrlCounter,r=()=>{const n=this.selectRpcUrl();var s,a;return(s=this._post(t),a=this.timeoutDuration,new Promise((t,e)=>{const r=setTimeout(()=>e(new Error("Promise timed out")),a);s.then(e=>{clearTimeout(r),t(e)}).catch(t=>{clearTimeout(r),e(t)})})).catch(t=>{if(n===this.selectRpcUrl()&&(this.rpcUrlCounter=(this.rpcUrlCounter+1)%this._rpcUrls.length),this.rpcUrlCounter===e)throw t;return r()})};return r()},this.timeoutDuration=e.timeoutDuration||8e3}}function J(t){return t=U(t).slice(2),"0x"+n.fromPrivateKey(t).toHex()}function z(e){let r;return r="string"==typeof e?Buffer.from(e.replace(/^0x/,""),"hex"):Buffer.from(e),"0x"+new t(256).update(r).digest("hex")}function V(t){return t.startsWith("0x04")||t.startsWith("0x03")||t.startsWith("0x02")||(t=J(t)),g(F(z(F(t,1)),12))}function q(t){h(t,["string","number","object"]);const e=l(t).times("1000000000");return l(e)}function K(t){h(t,["string","number","object"]);const e=l(t).times("1000000000000000000");return l(e)}function Q(t){h(t,["string","number","object"]);const e=l(t).div("1000000000");return l(e)}function X(t){return new Uint8Array(Buffer.from(t))}function Y(t){return"string"==typeof t&&(t=X(t)),z(k([X("Ethereum Signed Message:\n"),X(String(t.length)),t]))}function Z(t){h(t,["string"]);try{return g(t),!0}catch(t){return!1}}function tt(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(P(t)){const r=A(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=U(r.slice(0,32)),e.s=U(r.slice(32,64))):65===r.length?(e.r=U(r.slice(0,32)),e.s=U(r.slice(32,64)),e.v=r[64]):x.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:x.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=U(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=_(A(e._vs),32);e._vs=U(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&x.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const s=U(r);null==e.s?e.s=s:e.s!==s&&x.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?x.throwArgumentError("signature missing v and recoveryParam","signature",t):e.recoveryParam=0===e.v||1===e.v?e.v:1-e.v%2:null==e.v?e.v=27+e.recoveryParam:e.recoveryParam!==(0===e.v||1===e.v?e.v:1-e.v%2)&&x.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&N(e.r)?e.r=j(e.r,32):x.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&N(e.s)?e.s=j(e.s,32):x.throwArgumentError("signature missing or invalid s","signature",t);const r=A(e.s);r[0]>=128&&x.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=U(r);e._vs&&(N(e._vs)||x.throwArgumentError("signature invalid _vs","signature",t),e._vs=j(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&x.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function et(t){h(t,["string","number","object"]);try{let e=t;"string"==typeof t&&"0x"===t.slice(0,2)&&(e=BigInt(t).toString());const r=l(e).div("1000000000000000000");return l(r)}catch(t){throw t}}const rt=new RegExp("^bytes([0-9]+)$"),nt=new RegExp("^(u?int)([0-9]*)$"),st=new RegExp("^(.*)\\[([0-9]*)\\]$");function at(t,e,r){switch(t){case"address":return r?_(e,32):A(e);case"string":return s.from(e);case"bytes":return A(e);case"bool":return e=e?"0x01":"0x00",r?_(e,32):A(e)}let n=t.match(nt);if(n){let s=parseInt(n[2]||"256");return(n[2]&&String(s)!==n[2]||s%8!=0||0===s||s>256)&&x.throwArgumentError("invalid number type","type",t),r&&(s=256),_(U(e=l(e).toTwos(s).toNumber()),s/8)}if(n=t.match(rt),n){const s=parseInt(n[1]);return(String(s)!==n[1]||0===s||s>32)&&x.throwArgumentError("invalid bytes type","type",t),A(e).byteLength!==s&&x.throwArgumentError(`invalid value for ${t}`,"value",e),r?A((e+f).substring(0,66)):e}if(n=t.match(st),n&&Array.isArray(e)){const r=n[1];parseInt(n[2]||String(e.length))!=e.length&&x.throwArgumentError(`invalid array length for ${t}`,"value",e);const s=[];return e.forEach(function(t){s.push(at(r,t,!0))}),k(s)}return x.throwArgumentError("invalid type","type",t)}function ot(t,e){t.length!=e.length&&x.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);const r=[];return t.forEach(function(t,n){r.push(at(t,e[n]))}),U(k(r))}function it(t,e){return z(ot(t,e))}export{W as AlchemyProvider,p as BaseContract,d as Contract,D as FallthroughProvider,L as JsonRpcProvider,u as TinyBig,A as arrayify,V as computeAddress,J as computePublicKey,k as concat,q as etherToGwei,K as etherToWei,Q as gweiToEther,Y as hashMessage,C as hexConcat,G as hexDataLength,F as hexDataSlice,I as hexStripZeros,B as hexValue,j as hexZeroPad,U as hexlify,Z as isAddress,$ as isBytes,P as isBytesLike,N as isHexString,H as jsonRpcProvider,z as keccak256,ot as pack,it as solidityKeccak256,tt as splitSignature,S as stripZeros,l as tinyBig,g as toChecksumAddress,X as toUtf8Bytes,et as weiToEther,_ as zeroPad};
2
2
  //# sourceMappingURL=essential-eth.modern.mjs.map