essential-eth 0.5.9 → 0.5.10
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.
- package/{lib/esm → dist}/classes/Contract.d.ts +11 -11
- package/dist/classes/test/Contract/crv-abi.d.ts +2 -0
- package/dist/classes/test/Contract/ens-abi.d.ts +2 -0
- package/dist/classes/test/Contract/fei-abi.d.ts +2 -0
- package/dist/classes/test/Contract/foo-abi.d.ts +2 -0
- package/dist/classes/test/Contract/uniswap-abi.d.ts +2 -0
- package/dist/classes/utils/clean-block.d.ts +3 -0
- package/{lib/esm → dist}/classes/utils/clean-log.d.ts +2 -2
- package/{lib/esm → dist}/classes/utils/clean-transaction-receipt.d.ts +2 -2
- package/{lib/esm → dist}/classes/utils/clean-transaction.d.ts +2 -2
- package/{lib/esm → dist}/classes/utils/encode-decode-transaction.d.ts +4 -4
- package/{lib/esm → dist}/classes/utils/fetchers.d.ts +9 -9
- package/{lib/esm → dist}/classes/utils/hex-to-decimal.d.ts +1 -1
- package/{lib/esm → dist}/classes/utils/prepare-transaction.d.ts +2 -2
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/{lib/esm → dist}/index.d.ts +25 -25
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +2 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.modern.mjs +2 -0
- package/dist/index.modern.mjs.map +1 -0
- package/dist/index.module.js +2 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/{lib/esm → dist}/logger/logger.d.ts +11 -11
- package/dist/logger/package-version.d.ts +1 -0
- package/{lib/esm → dist}/providers/BaseProvider.d.ts +24 -24
- package/{lib/esm → dist}/providers/FallthroughProvider.d.ts +11 -11
- package/{lib/esm → dist}/providers/JsonRpcProvider.d.ts +7 -7
- package/{lib/cjs → dist}/providers/test/rpc-urls.d.ts +11 -11
- package/{lib/cjs → dist}/providers/utils/chains-info.d.ts +467 -423
- package/{lib/esm → dist}/shared/tiny-big/helpers.d.ts +1 -1
- package/{lib/esm → dist}/shared/tiny-big/tiny-big.d.ts +10 -10
- package/{lib/cjs → dist}/shared/validate-type.d.ts +3 -3
- package/{lib/cjs → dist}/types/Block.types.d.ts +40 -41
- package/{lib/cjs → dist}/types/Contract.types.d.ts +24 -24
- package/{lib/esm → dist}/types/Filter.types.d.ts +12 -12
- package/{lib/esm → dist}/types/Network.types.d.ts +5 -5
- package/{lib/esm → dist}/types/Transaction.types.d.ts +113 -113
- package/{lib/esm → dist}/utils/bytes.d.ts +40 -40
- package/{lib/esm → dist}/utils/compute-address.d.ts +1 -1
- package/{lib/esm → dist}/utils/compute-public-key.d.ts +2 -2
- package/{lib/esm → dist}/utils/ether-to-gwei.d.ts +3 -3
- package/dist/utils/ether-to-wei.d.ts +3 -0
- package/dist/utils/gwei-to-ether.d.ts +3 -0
- package/{lib/esm → dist}/utils/hash-message.d.ts +2 -2
- package/{lib/esm → dist}/utils/is-address.d.ts +1 -1
- package/{lib/esm → dist}/utils/keccak256.d.ts +2 -2
- package/{lib/esm → dist}/utils/solidity-keccak256.d.ts +2 -2
- package/{lib/esm → dist}/utils/split-signature.d.ts +2 -2
- package/{lib/esm → dist}/utils/to-checksum-address.d.ts +1 -1
- package/{lib/esm → dist}/utils/to-utf8-bytes.d.ts +1 -1
- package/dist/utils/wei-to-ether.d.ts +3 -0
- package/package.json +42 -19
- package/lib/cjs/classes/Contract.d.ts +0 -78
- package/lib/cjs/classes/Contract.js +0 -140
- package/lib/cjs/classes/test/Contract/crv-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/crv-abi.js +0 -488
- package/lib/cjs/classes/test/Contract/ens-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/ens-abi.js +0 -453
- package/lib/cjs/classes/test/Contract/fei-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/fei-abi.js +0 -526
- package/lib/cjs/classes/test/Contract/foo-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/foo-abi.js +0 -42
- package/lib/cjs/classes/test/Contract/uniswap-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/uniswap-abi.js +0 -121
- package/lib/cjs/classes/utils/clean-block.d.ts +0 -121
- package/lib/cjs/classes/utils/clean-block.js +0 -160
- package/lib/cjs/classes/utils/clean-log.d.ts +0 -9
- package/lib/cjs/classes/utils/clean-log.js +0 -37
- package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +0 -14
- package/lib/cjs/classes/utils/clean-transaction-receipt.js +0 -50
- package/lib/cjs/classes/utils/clean-transaction.d.ts +0 -14
- package/lib/cjs/classes/utils/clean-transaction.js +0 -51
- package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +0 -16
- package/lib/cjs/classes/utils/encode-decode-transaction.js +0 -137
- package/lib/cjs/classes/utils/fetchers.d.ts +0 -39
- package/lib/cjs/classes/utils/fetchers.js +0 -81
- package/lib/cjs/classes/utils/hex-to-decimal.d.ts +0 -18
- package/lib/cjs/classes/utils/hex-to-decimal.js +0 -24
- package/lib/cjs/classes/utils/prepare-transaction.d.ts +0 -6
- package/lib/cjs/classes/utils/prepare-transaction.js +0 -45
- package/lib/cjs/index.d.ts +0 -25
- package/lib/cjs/index.js +0 -54
- package/lib/cjs/logger/logger.d.ts +0 -11
- package/lib/cjs/logger/logger.js +0 -36
- package/lib/cjs/logger/package-version.d.ts +0 -1
- package/lib/cjs/logger/package-version.js +0 -5
- package/lib/cjs/providers/BaseProvider.d.ts +0 -353
- package/lib/cjs/providers/BaseProvider.js +0 -512
- package/lib/cjs/providers/FallthroughProvider.d.ts +0 -24
- package/lib/cjs/providers/FallthroughProvider.js +0 -65
- package/lib/cjs/providers/JsonRpcProvider.d.ts +0 -33
- package/lib/cjs/providers/JsonRpcProvider.js +0 -46
- package/lib/cjs/providers/test/rpc-urls.js +0 -14
- package/lib/cjs/providers/utils/chains-info.js +0 -1270
- package/lib/cjs/shared/tiny-big/helpers.d.ts +0 -17
- package/lib/cjs/shared/tiny-big/helpers.js +0 -97
- package/lib/cjs/shared/tiny-big/tiny-big.d.ts +0 -58
- package/lib/cjs/shared/tiny-big/tiny-big.js +0 -101
- package/lib/cjs/shared/validate-type.js +0 -9
- package/lib/cjs/types/Block.types.js +0 -2
- package/lib/cjs/types/Contract.types.js +0 -2
- package/lib/cjs/types/Filter.types.d.ts +0 -16
- package/lib/cjs/types/Filter.types.js +0 -2
- package/lib/cjs/types/Network.types.d.ts +0 -8
- package/lib/cjs/types/Network.types.js +0 -2
- package/lib/cjs/types/Transaction.types.d.ts +0 -123
- package/lib/cjs/types/Transaction.types.js +0 -2
- package/lib/cjs/utils/bytes.d.ts +0 -289
- package/lib/cjs/utils/bytes.js +0 -711
- package/lib/cjs/utils/compute-address.d.ts +0 -17
- package/lib/cjs/utils/compute-address.js +0 -33
- package/lib/cjs/utils/compute-public-key.d.ts +0 -18
- package/lib/cjs/utils/compute-public-key.js +0 -26
- package/lib/cjs/utils/ether-to-gwei.d.ts +0 -27
- package/lib/cjs/utils/ether-to-gwei.js +0 -35
- package/lib/cjs/utils/ether-to-wei.d.ts +0 -27
- package/lib/cjs/utils/ether-to-wei.js +0 -35
- package/lib/cjs/utils/gwei-to-ether.d.ts +0 -27
- package/lib/cjs/utils/gwei-to-ether.js +0 -35
- package/lib/cjs/utils/hash-message.d.ts +0 -14
- package/lib/cjs/utils/hash-message.js +0 -28
- package/lib/cjs/utils/is-address.d.ts +0 -24
- package/lib/cjs/utils/is-address.js +0 -39
- package/lib/cjs/utils/keccak256.d.ts +0 -16
- package/lib/cjs/utils/keccak256.js +0 -31
- package/lib/cjs/utils/solidity-keccak256.d.ts +0 -39
- package/lib/cjs/utils/solidity-keccak256.js +0 -138
- package/lib/cjs/utils/split-signature.d.ts +0 -24
- package/lib/cjs/utils/split-signature.js +0 -163
- package/lib/cjs/utils/to-checksum-address.d.ts +0 -17
- package/lib/cjs/utils/to-checksum-address.js +0 -46
- package/lib/cjs/utils/to-utf8-bytes.d.ts +0 -15
- package/lib/cjs/utils/to-utf8-bytes.js +0 -21
- package/lib/cjs/utils/wei-to-ether.d.ts +0 -27
- package/lib/cjs/utils/wei-to-ether.js +0 -45
- package/lib/esm/classes/Contract.js +0 -65
- package/lib/esm/classes/test/Contract/crv-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/crv-abi.js +0 -470
- package/lib/esm/classes/test/Contract/ens-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/ens-abi.js +0 -435
- package/lib/esm/classes/test/Contract/fei-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/fei-abi.js +0 -521
- package/lib/esm/classes/test/Contract/foo-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/foo-abi.js +0 -33
- package/lib/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/uniswap-abi.js +0 -116
- package/lib/esm/classes/utils/clean-block.d.ts +0 -3
- package/lib/esm/classes/utils/clean-block.js +0 -35
- package/lib/esm/classes/utils/clean-log.js +0 -26
- package/lib/esm/classes/utils/clean-transaction-receipt.js +0 -34
- package/lib/esm/classes/utils/clean-transaction.js +0 -33
- package/lib/esm/classes/utils/encode-decode-transaction.js +0 -98
- package/lib/esm/classes/utils/fetchers.js +0 -43
- package/lib/esm/classes/utils/hex-to-decimal.js +0 -3
- package/lib/esm/classes/utils/prepare-transaction.js +0 -34
- package/lib/esm/index.js +0 -20
- package/lib/esm/logger/logger.js +0 -33
- package/lib/esm/logger/package-version.d.ts +0 -1
- package/lib/esm/logger/package-version.js +0 -1
- package/lib/esm/providers/BaseProvider.js +0 -157
- package/lib/esm/providers/FallthroughProvider.js +0 -41
- package/lib/esm/providers/JsonRpcProvider.js +0 -15
- package/lib/esm/providers/test/rpc-urls.d.ts +0 -11
- package/lib/esm/providers/test/rpc-urls.js +0 -11
- package/lib/esm/providers/utils/chains-info.d.ts +0 -423
- package/lib/esm/providers/utils/chains-info.js +0 -1266
- package/lib/esm/shared/tiny-big/helpers.js +0 -58
- package/lib/esm/shared/tiny-big/tiny-big.js +0 -45
- package/lib/esm/shared/validate-type.d.ts +0 -3
- package/lib/esm/shared/validate-type.js +0 -5
- package/lib/esm/types/Block.types.d.ts +0 -40
- package/lib/esm/types/Block.types.js +0 -1
- package/lib/esm/types/Contract.types.d.ts +0 -24
- package/lib/esm/types/Contract.types.js +0 -1
- package/lib/esm/types/Filter.types.js +0 -1
- package/lib/esm/types/Network.types.js +0 -1
- package/lib/esm/types/Transaction.types.js +0 -1
- package/lib/esm/utils/bytes.js +0 -245
- package/lib/esm/utils/compute-address.js +0 -11
- package/lib/esm/utils/compute-public-key.js +0 -6
- package/lib/esm/utils/ether-to-gwei.js +0 -7
- package/lib/esm/utils/ether-to-wei.d.ts +0 -3
- package/lib/esm/utils/ether-to-wei.js +0 -7
- package/lib/esm/utils/gwei-to-ether.d.ts +0 -3
- package/lib/esm/utils/gwei-to-ether.js +0 -7
- package/lib/esm/utils/hash-message.js +0 -12
- package/lib/esm/utils/is-address.js +0 -12
- package/lib/esm/utils/keccak256.js +0 -13
- package/lib/esm/utils/solidity-keccak256.js +0 -85
- package/lib/esm/utils/split-signature.js +0 -126
- package/lib/esm/utils/to-checksum-address.js +0 -25
- package/lib/esm/utils/to-utf8-bytes.js +0 -3
- package/lib/esm/utils/wei-to-ether.d.ts +0 -3
- package/lib/esm/utils/wei-to-ether.js +0 -16
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Keccak as t}from"sha3";import e from"isomorphic-unfetch";import r from"big.js";import{Point as n}from"@noble/secp256k1";function o(){return o=Object.assign?Object.assign.bind():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},o.apply(this,arguments)}function i(t){return BigInt(t).toString()}const s="0".repeat(64),a="0".repeat(63)+"1";function u(t,r){return e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).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})}function c(t,e){return{jsonrpc:"2.0",id:1,method:t,params:e}}class f{constructor(e,r,n){var f=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,h={};const l=r[r.length-1];Array.isArray(l)||"object"!=typeof l||(h=l,n=r.slice(0,r.length-1));const p=function(e,r){const n=new t(256),o=`${e.name}(${e.inputs.map(t=>{return"uint[]"===(e=t.type)?"uint256[]":"int[]"===e?"int256[]":e;var e})})`,i=n.update(o).digest("hex"),u=e.inputs.length;let c=!0;if(e.inputs.find(t=>t.type.includes("["))&&(c=!1),c&&r.length!==u)throw new Error(`args inputs of "${r.length}" does not match expected length of "${e.inputs.length}"`);const f=(e.inputs||[]).reduce((t,e,n)=>{if(e.type.includes("[")){var o;const n=null==(o=/([^[]*)\[.*$/g.exec(e.type))?void 0:o[1];return r.forEach(e=>{t=t.concat([[e,n]])}),t}return t.concat([[r[n],e.type]])},[]),h=f.map(([t,e])=>{let r=t;switch(e){case"bool":return t?a:s;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${i.slice(0,8)}${h.join("")}`}(e,n),g="number"==typeof h.gasLimit?h.gasLimit:"number"==typeof(null==e?void 0:e.gas)?void p.split("").reduce((t,e)=>t+("0"===e?4:68),0):null,y=await async function(){return await u(f._provider.selectRpcUrl(),c("eth_call",[o({to:f._address.toLowerCase(),data:p},g?{gas:`0x${g.toString(16)}`}:{}),"latest"]))}();return function(t,e){const r=t.outputs,n=(e.slice(2).match(/.{1,64}/g)||[]).map((t,e)=>{const n=(r||[])[e].type;switch(n){case"bool":return t===a;case"address":return w(`0x${t.slice(24)}`);case"uint256":return m(i(`0x${t}`));case"bytes32":return`0x${t}`;case"uint8":return Number(i(`0x${t}`));default:throw new Error(`essential-eth does not yet support "${n}" outputs. Make a PR today!"`)}});return 1===n.length?n[0]:n}(e,y)},Object.defineProperty(this,e.name,{enumerable:!0,value:r,writable:!1}))})}}class h extends f{}const l=new class{constructor(){this.packageVersion=void 0,this.packageVersion="0.5.10"}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 p(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 g(t){if(!t.match(/e/i))return p(t);let[e,r]=t.split(/e/i);const n=Number(e)<0;e=e.replace("-",""),e=p(e);const[o,i=""]=e.split(".");if(0===Number(r))return`${n?"-":""}${p(e)}`;{e.includes(".")||(e=`${e}.`),e=e.replace(".","");const t=e.length;let s;return Number(r)<0?(o.length<Math.abs(Number(r))&&(e=e.padStart(t+Math.abs(Number(r))-o.length,"0")),s=e.split(""),o.length<Math.abs(Number(r))?s=[".",...s]:s.splice(s.length-Math.abs(Number(r)),0,".")):(i.length<Math.abs(Number(r))&&(e=e.padEnd(t+Math.abs(Number(r))-i.length,"0")),s=e.split(""),i.length>Math.abs(Number(r))&&s.splice(s.length-Math.abs(Number(r)),0,".")),`${n?"-":""}${p(s.join(""))}`}}class y extends r{constructor(t){"string"==typeof t&&t.startsWith("0x")&&(t=i(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(g(super.toString()))}toString(){return 0===this.toNumber()?"0":g(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 m(Number(`0b${e}`))}}function m(t){return new y(t)}function d(t){const e=o({},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(i(t[r]));break;case"from":case"to":t[r]&&(e[r]=w(t[r]));break;case"value":case"gas":case"gasPrice":case"maxFeePerGas":case"maxPriorityFeePerGas":case"nonce":e[r]=m(i(t[r]))}}),e}const b=(t,e)=>{if(!e.includes(typeof t))throw new Error(`${e.join(" or ")} required. Received ${typeof t}`)};function w(e){if(b(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 o="0x";for(let t=0;t<r.length;t++)parseInt(n[t],16)>7?o+=r[t].toUpperCase():o+=r[t];if(e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&o!==e)throw new Error(`Invalid Checksum address for "${e}"`);return o}function v(t,e){const r=o({},t);return Object.keys(t).forEach(n=>{switch(n){case"address":r[n]=w(t[n]);break;case"blockNumber":case"logIndex":case"transactionIndex":r[n]=Number(i(t[n]));break;case"removed":e&&delete r[n]}}),r}function E(t){return!!t.toHexString}function x(t){return S(t)&&!(t.length%2)||A(t)}function B(t){return"number"==typeof t&&t==t&&t%1==0}function A(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!B(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!B(r)||r<0||r>=256)return!1}return!0}function k(t,e){if(e||(e={}),"number"==typeof t){l.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),E(t)&&(t=t.toHexString()),S(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":l.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 A(t)?new Uint8Array(t):l.throwArgumentError("invalid arrayify value","value",t)}function I(t){const e=t.map(t=>k(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 U(t){let e=k(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 P(t,e){(t=k(t)).length>e&&l.throwArgumentError("value out of range","value",t);const r=new Uint8Array(e);return r.set(t,e-t.length),r}function S(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}function T(t,e){if(e||(e={}),"number"==typeof t){l.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),E(t))return t.toHexString();if(S(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":l.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(A(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 l.throwArgumentError("invalid hexlify value","value",t)}function _(t){if("string"!=typeof t)t=T(t);else if(!S(t)||t.length%2)return null;return(t.length-2)/2}function C(t,e,r){return"string"!=typeof t?t=T(t):(!S(t)||t.length%2)&&l.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function $(t){let e="0x";return t.forEach(t=>{e+=T(t).substring(2)}),e}function O(t){const e=R(T(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function R(t){"string"!=typeof t&&(t=T(t)),S(t)||l.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 N(t,e){for("string"!=typeof t?t=T(t):S(t)||l.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&l.throwError("value out of range",{value:t,length:e});t.length<2*e+2;)t="0x0"+t.substring(2);return t}function L(t){const e=o({},t);return Object.keys(t).forEach(n=>{switch(n){case"gas":case"gasPrice":case"nonce":case"maxFeePerGas":case"maxPriorityFeePerGas":case"value":{const o=t[n];e[n]=o instanceof y?o.toHexString():o instanceof r?`0x${BigInt(o.toString()).toString(16)}`:"number"==typeof t[n]?"0x"+t[n].toString(16):t[n].toString();break}case"data":e[n]=T(t[n])}}),e}var M={1:["eth","0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"],2:["exp"],3:["rop","0x112234455c3a32fd11230c42e7bccd4a84e02010"],4:["rin","0xe7410170f87102df0055eb195163a03b7f2bff4a"],5:["gor","0x112234455c3a32fd11230c42e7bccd4a84e02010"],6:["kot"],7:["tch"],8:["ubq"],9:["tubq"],10:["oeth"],11:["meta"],12:["kal"],13:["dstg"],14:["flr"],15:["diode"],16:["cflr"],17:["tfi"],18:["TST"],19:["sgb"],20:["elaeth"],21:["elaetht"],22:["eladid"],23:["eladidt"],24:["dthmainnet"],25:["cro"],26:["L1test"],27:["shib"],28:["Boba Rinkeby"],29:["L1"],30:["rsk"],31:["trsk"],32:["GooDT"],33:["GooD"],34:["dth"],35:["tbwg"],36:["dx"],38:["val"],40:["Telos EVM"],41:["Telos EVM Testnet"],42:["kov"],43:["pangolin"],44:["crab"],45:["pangoro"],46:["darwinia"],50:["xdc"],51:["TXDC"],52:["cet"],53:["tcet"],54:["OP"],55:["ZYX"],56:["bnb"],57:["sys"],58:["Ontology Mainnet"],59:["EOS Mainnet"],60:["go"],61:["etc"],62:["tetc"],63:["metc"],64:["ellaism"],65:["tokt"],66:["okt"],67:["dbm"],68:["SO1"],69:["okov"],70:["hsc"],71:["cfxtest"],72:["dxc"],74:["idchain"],76:["mix"],77:["spoa"],78:["primuschain"],79:["zenith"],80:["GeneChain"],81:["VIL"],82:["Meter"],83:["MeterTest"],85:["gttest"],86:["gt"],87:["nnw"],88:["tomo"],89:["tomot"],90:["gar-s0"],91:["gar-s1"],92:["gar-s2"],93:["gar-s3"],95:["Kylin Testnet"],96:["nsc"],97:["bnbt"],99:["poa"],100:["gno"],101:["eti"],102:["tw3g"],104:["tklc"],105:["dw3g"],106:["vlx"],107:["ntn"],108:["TT"],110:["xpr"],111:["ETL"],122:["fuse"],123:["spark"],124:["dwu"],125:["oychain testnet"],126:["oychain mainnet"],127:["feth"],128:["heco"],137:["MATIC"],141:["OPtest"],142:["dax"],162:["tpht"],163:["pht"],168:["aioz"],170:["hoosmartchain"],172:["resil"],180:["ame"],186:["Seele"],188:["BMC"],189:["BMCT"],193:["cem"],199:["BTT"],200:["aox"],211:["EDI"],218:["SO1-old"],222:["ASK"],225:["LA"],226:["TLA"],246:["ewt"],250:["ftm"],256:["hecot"],258:["setm"],262:["SUR"],269:["hpb"],280:["zksync-goerli"],288:["Boba"],300:["ogc"],321:["kcs"],322:["kcst"],333:["w3q"],335:["DFKTEST"],336:["sdn"],338:["tcro"],361:["theta-mainnet"],363:["theta-sapphire"],364:["theta-amber"],365:["theta-testnet"],369:["pls"],385:["lisinski"],416:["SX"],420:["ogor"],499:["rupx"],512:["aac"],513:["aact"],520:["xt"],530:["f(x)Core"],534:["CNDL"],555:["CLASS"],558:["tao"],588:["metis-stardust"],592:["astr"],595:["maca"],596:["tkar"],597:["taca"],600:["mesh-chain-testnet"],647:["SX-Testnet"],666:["pixie-chain-testnet"],686:["kar"],700:["SNS"],707:["bcs"],708:["tbcs"],721:["tfeth"],776:["opc"],777:["cth"],787:["aca"],788:["taero"],803:["haic"],808:["PFTEST"],820:["clo"],821:["tclo"],880:["ambros"],888:["wan"],900:["gar-test-s0"],901:["gar-test-s1"],902:["gar-test-s2"],903:["gar-test-s3"],909:["PF"],940:["tpls"],941:["t2bpls"],942:["t3pls"],977:["yeti"],980:["top_evm"],989:["top"],998:["ln"],999:["twan"],1e3:["gton"],1001:["Baobab"],1007:["tnew"],1008:["eun"],1010:["EVC"],1012:["new"],1022:["sku"],1023:["tclv"],1024:["clv"],1028:["tbtt"],1030:["cfx"],1088:["metis-andromeda"],1139:["MATH"],1140:["tMATH"],1197:["iora"],1201:["avis"],1202:["wtt"],1213:["popcat"],1214:["enter"],1246:["om"],1280:["HO"],1284:["mbeam"],1285:["mriver"],1286:["mrock-old"],1287:["mbase"],1288:["mrock"],1297:["Bobabase"],1319:["aitd"],1320:["aitdtestnet"],1337:["cennz-old"],1506:["Sherpax"],1507:["Sherpax Testnet"],1618:["cate"],1620:["ath"],1657:["bta"],1688:["LUDAN"],1818:["cube"],1819:["cubet"],1856:["tsf"],1898:["boya"],1984:["euntest"],1987:["egem"],2001:["milkAda"],2008:["cloudwalk_testnet"],2009:["cloudwalk_mainnet"],2020:["420"],2021:["edg"],2022:["edgt"],2023:["taycan-testnet"],2025:["rpg"],2100:["eco"],2101:["esp"],2152:["fra"],2153:["findora-testnet"],2213:["evanesco"],2221:["tkava"],2222:["kava"],2223:["VChain"],2559:["ktoc"],2569:["tpc"],2612:["EZChain"],2613:["Fuji-EZChain"],3e3:["cennz-r"],3001:["cennz-n"],3331:["zcrbeach"],3333:["w3q-t"],3334:["w3q-g"],3400:["prb"],3500:["prbtestnet"],3501:["jfin"],3690:["btx"],3737:["csb"],3966:["dyno"],3967:["tdyno"],3999:["ycc"],4002:["tftm"],4051:["Bobaopera Testnet"],4102:["aioz-testnet"],4181:["PHI"],4689:["iotex-mainnet"],4690:["iotex-testnet"],4918:["txvm"],4919:["xvm"],5177:["tlc"],5197:["es"],5315:["UZMI"],5551:["Nahmii"],5553:["Nahmii testnet"],5700:["tsys"],5777:["dgcc"],5851:["Ontology Testnet"],5869:["rbd"],6626:["pixie-chain"],6969:["tombchain"],7027:["ELLA"],7341:["shyft"],7777:["Rise of the Warbots Testnet"],7878:["tscas"],8e3:["teleport"],8001:["teleport-testnet"],8029:["mdgl"],8080:["GeneChainAdn"],8217:["Cypress"],8285:["Kortho"],8723:["olo"],8724:["tolo"],8888:["ambrostestnet"],8898:["mmt"],8995:["berg"],9e3:["evmos-testnet"],9001:["evmos"],9012:["brb"],9100:["GENEC"],9527:["trpg"],9999:["myn"],1e4:["smartbch"],10001:["smartbchtest"],10101:["GEN"],10823:["CCP"],10946:["quadrans"],10947:["quadranstestnet"],11111:["WAGMI"],11437:["shyftt"],12051:["tZERO"],12052:["ZERO"],13381:["Phoenix"],16e3:["mtt"],16001:["mtttest"],16888:["tivar"],19845:["btcix"],21337:["cennz-a"],21816:["omc"],22023:["SFL"],24484:["web"],24734:["mintme"],26863:["OAC"],30067:["Piece"],31102:["esn"],31337:["got"],32520:["Brise"],32659:["fsn"],35441:["q"],35443:["q-testnet"],39797:["nrg"],42069:["PC"],42161:["arb1"],42170:["arb-nova"],42220:["CELO"],42261:["emerald"],42262:["oasis"],43110:["avaeth"],43113:["Fuji"],43114:["avax"],44787:["ALFA"],45e3:["Autobahn Network"],47805:["REI"],49797:["tnrg"],50021:["tgton"],53935:["DFK"],55555:["reichain"],55556:["trei"],6e4:["TKM-test0"],60001:["TKM-test1"],60002:["TKM-test2"],60103:["TKM-test103"],62320:["BKLV"],62621:["mtv"],63e3:["ecs"],63001:["ecs-testnet"],69420:["cndr"],7e4:["TKM0"],70001:["TKM1"],70002:["TKM2"],70103:["TKM103"],71393:["ckb"],71401:["gw-testnet-v1"],71402:["gw-mainnet-v1"],73799:["vt"],73927:["mvm"],75e3:["resin"],78110:["firenze"],80001:["maticmum"],88888:["ivar"],99998:["usctest"],99999:["usc"],1e5:["qkc-r"],100001:["qkc-s0"],100002:["qkc-s1"],100003:["qkc-s2"],100004:["qkc-s3"],100005:["qkc-s4"],100006:["qkc-s5"],100007:["qkc-s6"],100008:["qkc-s7"],103090:["CRFI"],108801:["bro"],11e4:["qkc-d-r"],110001:["qkc-d-s0"],110002:["qkc-d-s1"],110003:["qkc-d-s2"],110004:["qkc-d-s3"],110005:["qkc-d-s4"],110006:["qkc-d-s5"],110007:["qkc-d-s6"],110008:["qkc-d-s7"],131419:["ETND"],200101:["milkTAda"],200625:["aka"],201018:["alaya"],201030:["alayadev"],210425:["platon"],234666:["hym"],246529:["ats"],246785:["atstau"],281121:["SoChain"],333888:["sparta"],333999:["olympus"],421611:["arb-rinkeby"],421613:["arb-goerli"],432201:["Dexalot"],444900:["wlkt"],474142:["oc"],512512:["cmp"],666666:["vpioneer"],846e3:["bloqs4good"],888888:["vision"],955305:["elv"],1313114:["etho"],1313500:["xero"],1337702:["kintsugi"],1337802:["kiln"],2203181:["platondev"],2206132:["platondev2"],7762959:["music"],11155111:["sep"],13371337:["tpep"],18289463:["ilt"],20180430:["spectrum"],20181205:["qki"],28945486:["auxi"],35855456:["JOYS"],61717561:["aqua"],99415706:["TOYS"],192837465:["GTH"],245022926:["neonevm-devnet"],245022934:["neonevm-mainnet"],245022940:["neonevm-testnet"],311752642:["oneledger"],356256156:["tGTH"],486217935:["dGTH"],1122334455:["ipos"],1313161554:["aurora"],1313161555:["aurora-testnet"],1313161556:["aurora-betanet"],16666e5:["hmy-s0"],1666600001:["hmy-s1"],1666600002:["hmy-s2"],1666600003:["hmy-s3"],16667e5:["hmy-b-s0"],1666700001:["hmy-b-s1"],1666700002:["hmy-b-s2"],1666700003:["hmy-b-s3"],2021121117:["hop"],3125659152:["pirl"],4216137055:["frankenstein"],11297108099:["tpalm"],11297108109:["palm"],197710212030:["ntt"],197710212031:["ntt-haradev"],6022140761023:["mole"],868455272153094:["gw-testnet-v1-deprecated"]};function F(t){return"number"==typeof t?m(t).toHexString():t}class j{constructor(t){this._rpcUrls=[],this._post=t=>u(this.selectRpcUrl(),t),this._rpcUrls=t}async getNetwork(){const t=i(await this.post(c("eth_chainId",[]))),e=M[t];return{chainId:Number(t),name:e[0]||"unknown",ensAddress:e[1]||null}}async getBlockNumber(){const t=await this.post(c("eth_blockNumber",[]));return Number(i(t))}async getTransaction(t){const[e,r]=await Promise.all([this.post(c("eth_getTransactionByHash",[t])),this.getBlock("latest")]),n=d(e);return n.confirmations=r.number-n.blockNumber+1,n}async getTransactionReceipt(t){const[e,r]=await Promise.all([this.post(c("eth_getTransactionReceipt",[t])),this.getBlock("latest")]),n=function(t){const e=o({},d(t));return Object.keys(t).forEach(r=>{if(t[r])switch(r){case"status":e[r]=Number(i(t[r]));break;case"contractAddress":t[r]&&(e[r]=w(t[r]));break;case"cumulativeGasUsed":case"effectiveGasPrice":case"gasUsed":e[r]=m(i(t[r]));break;case"logs":t[r].forEach((t,n)=>{e[r][n]=v(t,!0)})}}),e.byzantium=e.blockNumber>=437e4,e}(e);return n.confirmations=r.number-n.blockNumber+1,n}async getTransactionCount(t,e="latest"){e=F(e);const r=await this.post(c("eth_getTransactionCount",[t,e]));return Number(i(r))}async getBlock(t="latest",e=!1){let r="Number";return"string"==typeof t&&66===t.length?r="Hash":t=F(t),function(t,e){const r=o({},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]=m(i(t[e]));break;case"number":r[e]=Number(i(t[e]));break;case"miner":r[e]=w(t[e])}}),e&&t.transactions.forEach((t,e)=>{r.transactions[e]=d(t)}),r}(await this.post(c(`eth_getBlockBy${r}`,[t,e])),e)}async getGasPrice(){return m(i(await this.post(c("eth_gasPrice",[]))))}async getBalance(t,e="latest"){return e=F(e),m(i(await this.post(c("eth_getBalance",[t,e]))))}async getCode(t,e="latest"){return e=F(e),await this.post(c("eth_getCode",[t,e]))}async estimateGas(t){const e=L(t);return m(i(await this.post(c("eth_estimateGas",[e]))))}async getLogs(t){const e=t;return e.fromBlock&&(e.fromBlock=F(e.fromBlock)),e.toBlock&&(e.toBlock=F(e.toBlock)),(await this.post(c("eth_getLogs",[t]))).map(t=>v(t,!1))}async call(t,e="latest"){t.gasPrice&&(t.maxPriorityFeePerGas||t.maxFeePerGas)&&l.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")',{gasPrice:t.gasPrice,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),t.maxFeePerGas&&t.maxPriorityFeePerGas&&l.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"',{maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),e=F(e);const r=L(t);return await this.post(c("eth_call",[r,e]))}}class G extends j{selectRpcUrl(){return this._rpcUrls[this.rpcUrlCounter]}constructor(t,e={}){Array.isArray(t)||l.throwError("Array required",{rpcUrls:t}),t.length<=1&&l.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 o,i;return(o=this._post(t),i=this.timeoutDuration,Promise.race([o,new Promise((t,e)=>setTimeout(()=>e("Promise timed out"),i))])).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}}class q extends j{selectRpcUrl(){return this._rpcUrls[0]}post(t){return this._post(t)}constructor(t="https://free-eth-node.com/api/eth"){super([t])}}function D(t){return new q(t)}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 H(t){return t.startsWith("0x04")||t.startsWith("0x03")||t.startsWith("0x02")||(t=K(t)),w(C(z(C(t,1)),12))}function K(t){return t=T(t).slice(2),"0x"+n.fromPrivateKey(t).toHex()}function V(t){b(t,["string","number","object"]);const e=m(t).times("1000000000");return m(e)}function W(t){b(t,["string","number","object"]);const e=m(t).times("1000000000000000000");return m(e)}function Y(t){b(t,["string","number","object"]);const e=m(t).div("1000000000");return m(e)}function J(t){return"string"==typeof t&&(t=Q(t)),z(I([Q("Ethereum Signed Message:\n"),Q(String(t.length)),t]))}function Z(t){b(t,["string"]);try{return w(t),!0}catch(t){return!1}}function X(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(x(t)){const r=k(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=T(r.slice(0,32)),e.s=T(r.slice(32,64))):65===r.length?(e.r=T(r.slice(0,32)),e.s=T(r.slice(32,64)),e.v=r[64]):l.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:l.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=T(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=P(k(e._vs),32);e._vs=T(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&l.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const o=T(r);null==e.s?e.s=o:e.s!==o&&l.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?l.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)&&l.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&S(e.r)?e.r=N(e.r,32):l.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&S(e.s)?e.s=N(e.s,32):l.throwArgumentError("signature missing or invalid s","signature",t);const r=k(e.s);r[0]>=128&&l.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=T(r);e._vs&&(S(e._vs)||l.throwArgumentError("signature invalid _vs","signature",t),e._vs=N(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&l.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function Q(t){return new Uint8Array(Buffer.from(t))}function tt(t){b(t,["string","number","object"]);try{let e=t;"string"==typeof t&&"0x"===t.slice(0,2)&&(e=BigInt(t).toString());const r=m(e).div("1000000000000000000");return m(r)}catch(t){throw t}}for(var et=[],rt=[],nt="undefined"!=typeof Uint8Array?Uint8Array:Array,ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",it=0,st=ot.length;it<st;++it)et[it]=ot[it],rt[ot.charCodeAt(it)]=it;function at(t,e,r){for(var n,o=[],i=e;i<r;i+=3)o.push(et[(n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]))>>18&63]+et[n>>12&63]+et[n>>6&63]+et[63&n]);return o.join("")}rt["-".charCodeAt(0)]=62,rt["_".charCodeAt(0)]=63;var ut,ct,ft=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,f=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+h],h+=l,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,n),i-=c}return(p?-1:1)*s*Math.pow(2,i-n)},ht=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,h=f>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,g=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=g,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[r+p]=255&s,p+=g,s/=256,c-=8);t[r+p-g]|=128*y},lt=(ut=function(t,e){const r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;const n=2147483647;function o(t){if(t>n)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|l(t,e);let n=o(r);const s=n.write(t,e);return s!==r&&(n=n.slice(0,s)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(K(t,ArrayBuffer)||t&&K(t.buffer,ArrayBuffer))return f(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return f(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return i.from(n,e,r);const s=function(t){if(i.isBuffer(t)){const e=0|h(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?o(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return a(t),o(t<0?0:0|h(t))}function c(t){const e=t.length<0?0:0|h(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function f(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,i.prototype),n}function h(t){if(t>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|t}function l(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||K(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(o)return n?-1:D(t).length;e=(""+e).toLowerCase(),o=!0}}function p(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return B(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,o){let i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let n=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===u)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){let r=!0;for(let n=0;n<u;n++)if(c(t,i+n)!==c(e,n)){r=!1;break}if(r)return i}return-1}function d(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let s;for(n>i/2&&(n=i/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(V(n))return s;t[r+s]=n}return s}function b(t,e,r,n){return H(D(e,t.length-r),t,r,n)}function w(t,e,r,n){return H(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function v(t,e,r,n){return H(z(e),t,r,n)}function E(t,e,r,n){return H(function(t,e){let r,n,o;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return function(t){for(var e,r=t.length,n=r%3,o=[],i=16383,s=0,a=r-n;s<a;s+=i)o.push(at(t,s,s+i>a?a:s+i));return 1===n?o.push(et[(e=t[r-1])>>2]+et[e<<4&63]+"=="):2===n&&o.push(et[(e=(t[r-2]<<8)+t[r-1])>>10]+et[e>>4&63]+et[e<<2&63]+"="),o.join("")}(0===e&&r===t.length?t:t.slice(e,r))}function B(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],a=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}e.kMaxLength=n,(i.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,r){return s(t,e,r)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},i.allocUnsafe=function(t){return u(t)},i.allocUnsafeSlow=function(t){return u(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(K(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),K(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=i.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if(K(e,Uint8Array))o+e.length>n.length?(i.isBuffer(e)||(e=i.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!i.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},i.byteLength=l,i.prototype._isBuffer=!0,i.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},i.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},i.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},i.prototype.toLocaleString=i.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?B(this,0,t):p.apply(this,arguments)},i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},r&&(i.prototype[r]=i.prototype.inspect),i.prototype.compare=function(t,e,r,n,o){if(K(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const u=Math.min(s,a),c=this.slice(n,o),f=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==f[t]){s=c[t],a=f[t];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},i.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},i.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},i.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return d(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return w(this,t,e,r);case"base64":return v(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function I(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function U(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=W[t[n]];return o}function P(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function S(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,s){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function _(t,e,r,n,o){F(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function C(t,e,r,n,o){F(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function $(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(t,e,r,n,o){return e=+e,r>>>=0,o||$(t,0,r,4),ht(t,e,r,n,23,4),r+4}function R(t,e,r,n,o){return e=+e,r>>>=0,o||$(t,0,r,8),ht(t,e,r,n,52,8),r+8}i.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,i.prototype),n},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readBigUInt64LE=Y(function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))}),i.prototype.readBigUInt64BE=Y(function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)}),i.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readBigInt64LE=Y(function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];return void 0!==e&&void 0!==r||G(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),i.prototype.readBigInt64BE=Y(function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),i.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),ft(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),ft(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),ft(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),ft(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeBigUInt64LE=Y(function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=Y(function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=0,i=1,s=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);T(this,t,e,r,n-1,-n)}let o=r-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeBigInt64LE=Y(function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=Y(function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return R(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return R(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const s=i.isBuffer(t)?t:i.from(t,n),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};const N={};function L(t,e,r){N[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function M(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new N.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){j(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,o,i)}function j(t,e){if("number"!=typeof t)throw new N.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw j(t,r),new N.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new N.ERR_BUFFER_OUT_OF_BOUNDS;throw new N.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}L("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),L("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),L("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=M(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=M(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);const q=/[^+/0-9A-Za-z-_]/g;function D(t,e){let r;e=e||Infinity;const n=t.length;let o=null;const i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function z(t){return function(t){var e,r,n=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}(t),o=n[0],i=n[1],s=new nt(function(t,e,r){return 3*(e+r)/4-r}(0,o,i)),a=0,u=i>0?o-4:o;for(r=0;r<u;r+=4)e=rt[t.charCodeAt(r)]<<18|rt[t.charCodeAt(r+1)]<<12|rt[t.charCodeAt(r+2)]<<6|rt[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=rt[t.charCodeAt(r)]<<2|rt[t.charCodeAt(r+1)]>>4,s[a++]=255&e),1===i&&(e=rt[t.charCodeAt(r)]<<10|rt[t.charCodeAt(r+1)]<<4|rt[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const W=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Y(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}},ut(ct={exports:{}},ct.exports),ct.exports);const pt=new RegExp("^bytes([0-9]+)$"),gt=new RegExp("^(u?int)([0-9]*)$"),yt=new RegExp("^(.*)\\[([0-9]*)\\]$");function mt(t,e,r){switch(t){case"address":return r?P(e,32):k(e);case"string":return lt.Buffer.from(e);case"bytes":return k(e);case"bool":return e=e?"0x01":"0x00",r?P(e,32):k(e)}let n=t.match(gt);if(n){let o=parseInt(n[2]||"256");return(n[2]&&String(o)!==n[2]||o%8!=0||0===o||o>256)&&l.throwArgumentError("invalid number type","type",t),r&&(o=256),P(T(e=m(e).toTwos(o).toNumber()),o/8)}if(n=t.match(pt),n){const o=parseInt(n[1]);return(String(o)!==n[1]||0===o||o>32)&&l.throwArgumentError("invalid bytes type","type",t),k(e).byteLength!==o&&l.throwArgumentError(`invalid value for ${t}`,"value",e),r?k((e+s).substring(0,66)):e}if(n=t.match(yt),n&&Array.isArray(e)){const r=n[1];parseInt(n[2]||String(e.length))!=e.length&&l.throwArgumentError(`invalid array length for ${t}`,"value",e);const o=[];return e.forEach(function(t){o.push(mt(r,t,!0))}),I(o)}return l.throwArgumentError("invalid type","type",t)}function dt(t,e){t.length!=e.length&&l.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);const r=[];return t.forEach(function(t,n){r.push(mt(t,e[n]))}),T(I(r))}function bt(t,e){return z(dt(t,e))}export{f as BaseContract,h as Contract,G as FallthroughProvider,q as JsonRpcProvider,y as TinyBig,k as arrayify,H as computeAddress,K as computePublicKey,I as concat,V as etherToGwei,W as etherToWei,Y as gweiToEther,J as hashMessage,$ as hexConcat,_ as hexDataLength,C as hexDataSlice,R as hexStripZeros,O as hexValue,N as hexZeroPad,T as hexlify,Z as isAddress,A as isBytes,x as isBytesLike,S as isHexString,D as jsonRpcProvider,z as keccak256,dt as pack,bt as solidityKeccak256,X as splitSignature,U as stripZeros,m as tinyBig,w as toChecksumAddress,Q as toUtf8Bytes,tt as weiToEther,P as zeroPad};
|
|
2
|
+
//# sourceMappingURL=index.modern.js.map
|