essential-eth 0.5.11-next.0 → 0.5.11-next.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.
- package/dist/index.js +1903 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +1864 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logger/package-version.d.ts +1 -1
- package/package.json +2 -6
- package/dist/index.modern.mjs +0 -2
- package/dist/index.modern.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,1904 @@
|
|
|
1
|
-
var t=require("sha3"),e=require("isomorphic-unfetch"),r=require("big.js"),n=require("@noble/secp256k1");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=/*#__PURE__*/o(e),s=/*#__PURE__*/o(r);function a(){return a=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},a.apply(this,arguments)}function u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,f(t,e)}function f(t,e){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},f(t,e)}function c(t){return BigInt(t).toString()}var h="0".repeat(64),l="0".repeat(63)+"1";function p(e,r){var n=new t.Keccak(256),o=e.name+"("+e.inputs.map(function(t){return"uint[]"===(e=t.type)?"uint256[]":"int[]"===e?"int256[]":e;var e})+")",i=n.update(o).digest("hex"),s=e.inputs.length,a=!0;if(e.inputs.find(function(t){return t.type.includes("[")})&&(a=!1),a&&r.length!==s)throw new Error('args inputs of "'+r.length+'" does not match expected length of "'+e.inputs.length+'"');var u=(e.inputs||[]).reduce(function(t,e,n){if(e.type.includes("[")){var o,i=null==(o=/([^[]*)\[.*$/g.exec(e.type))?void 0:o[1];return r.forEach(function(e){t=t.concat([[e,i]])}),t}return t.concat([[r[n],e.type]])},[]),f=u.map(function(t){var e=t[0],r=t[1],n=e;switch(r){case"bool":return e?l:h;case"address":n=e.replace(/^0x/g,"").toLowerCase();break;default:if(r.startsWith("bytes"))return n.split("").map(function(t){return t.charCodeAt(0).toString(16)}).join("").padEnd(64,"0");if("uint256"===r)return BigInt(e).toString(16).padStart(64,"0");if(r.startsWith("uint"))break;throw new Error('essential-eth does not yet support "'+r+'" inputs. Make a PR today!"')}return n.toString(16).padStart(64,"0")});return"0x"+i.slice(0,8)+f.join("")}function g(t,e){var r=t.outputs,n=(e.slice(2).match(/.{1,64}/g)||[]).map(function(t,e){var n=(r||[])[e].type;switch(n){case"bool":return t===l;case"address":return I("0x"+t.slice(24));case"uint256":return A(c("0x"+t));case"bytes32":return"0x"+t;case"uint8":return Number(c("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}function y(t,e){return i.default(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(function(t){try{return Promise.resolve(t.text()).then(function(t){try{return JSON.parse(t)}catch(e){throw new Error('Invalid JSON RPC response: "'+t+'"')}})}catch(t){return Promise.reject(t)}}).then(function(t){if(!(null==t?void 0:t.result))throw new Error("Invalid JSON RPC response: "+JSON.stringify(t));return t.result})}function m(t,e){return{jsonrpc:"2.0",id:1,method:t,params:e}}function d(t){t.split("").reduce(function(t,e){return t+("0"===e?4:68)},0)}var v=function(t,e,r){var n=this,o=this;this._address=void 0,this._provider=void 0,this._address=t,this._provider=r,e.filter(function(t){return"function"===t.type}).forEach(function(t){var e;"name"in t&&"string"==typeof t.name&&(e=function(){try{var e=arguments,r=[].slice.call(e),n=r,i={},s=r[r.length-1];Array.isArray(s)||"object"!=typeof s||(i=s,n=r.slice(0,r.length-1));var u=p(t,n),f="number"==typeof i.gasLimit?i.gasLimit:"number"==typeof(null==t?void 0:t.gas)?d(u):null,c=function(){try{return Promise.resolve(y(o._provider.selectRpcUrl(),m("eth_call",[a({to:o._address.toLowerCase(),data:u},f?{gas:"0x"+f.toString(16)}:{}),"latest"])))}catch(t){return Promise.reject(t)}};return Promise.resolve(c()).then(function(e){return g(t,e)})}catch(t){return Promise.reject(t)}},Object.defineProperty(n,t.name,{enumerable:!0,value:e,writable:!1}))})},b=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e}(v),w=new(/*#__PURE__*/function(){function t(){this.packageVersion=void 0,this.packageVersion="0.5.11-next.0"}var e=t.prototype;return e.throwError=function(t,e){var r=Object.keys(e).length;throw new Error(t+" ("+Object.entries(e).map(function(t,e){return t[0]+"="+t[1]+(e<r-1&&", ")})+", version=essential-eth@"+this.packageVersion+")")},e.throwArgumentError=function(t,e,r){throw new Error(t+' (argument="'+e+'" value='+r+", version=essential-eth@"+this.packageVersion+")")},e.checkSafeUint53=function(t,e){void 0===e&&(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}))},t}());function x(t){var 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 E(t){if(!t.match(/e/i))return x(t);var e=t.split(/e/i),r=e[0],n=e[1],o=Number(r)<0,i=(r=x(r=r.replace("-",""))).split("."),s=i[0],a=i[1],u=void 0===a?"":a;if(0===Number(n))return(o?"-":"")+x(r);r.includes(".")||(r+=".");var f,c=(r=r.replace(".","")).length;return Number(n)<0?(s.length<Math.abs(Number(n))&&(r=r.padStart(c+Math.abs(Number(n))-s.length,"0")),f=r.split(""),s.length<Math.abs(Number(n))?f=["."].concat(f):f.splice(f.length-Math.abs(Number(n)),0,".")):(u.length<Math.abs(Number(n))&&(r=r.padEnd(c+Math.abs(Number(n))-u.length,"0")),f=r.split(""),u.length>Math.abs(Number(n))&&f.splice(f.length-Math.abs(Number(n)),0,".")),(o?"-":"")+x(f.join(""))}var B=/*#__PURE__*/function(t){function e(e){var r;return"string"==typeof e&&e.startsWith("0x")&&(e=c(e)),(r=t.call(this,e)||this).padAndChop=function(t,e,r){return(Array(r).fill(e).join("")+t).slice(-1*r)},r}u(e,t);var r=e.prototype;return r.toHexString=function(){return"0x"+BigInt(this.toString()).toString(16)},r.toNumber=function(){return Number(E(t.prototype.toString.call(this)))},r.toString=function(){return 0===this.toNumber()?"0":E(t.prototype.toString.call(this))},r.toTwos=function(t){var e;if(this.gte(0)){var 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 A(Number("0b"+e))},e}(s.default);function A(t){return new B(t)}function P(t){var e=a({},t);return Object.keys(t).forEach(function(r){if(t[r])switch(r){case"blockNumber":case"chainId":case"transactionIndex":case"type":case"v":e[r]=Number(c(t[r]));break;case"from":case"to":t[r]&&(e[r]=I(t[r]));break;case"value":case"gas":case"gasPrice":case"maxFeePerGas":case"maxPriorityFeePerGas":case"nonce":e[r]=A(c(t[r]))}}),e}var k=function(t,e){if(!e.includes(typeof t))throw new Error(e.join(" or ")+" required. Received "+typeof t)};function I(e){if(k(e,["string"]),!/^(0x)?[0-9a-f]{40}$/i.test(e))throw new Error('Invalid Ethereum address "'+e+'"');for(var r=e.toLowerCase().replace(/^0x/i,""),n=new t.Keccak(256).update(r).digest("hex").replace(/^0x/i,""),o="0x",i=0;i<r.length;i++)parseInt(n[i],16)>7?o+=r[i].toUpperCase():o+=r[i];if(e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&o!==e)throw new Error('Invalid Checksum address for "'+e+'"');return o}function U(t,e){var r=a({},t);return Object.keys(t).forEach(function(n){switch(n){case"address":r[n]=I(t[n]);break;case"blockNumber":case"logIndex":case"transactionIndex":r[n]=Number(c(t[n]));break;case"removed":e&&delete r[n]}}),r}function S(t){return!!t.toHexString}function T(t){return L(t)&&!(t.length%2)||C(t)}function _(t){return"number"==typeof t&&t==t&&t%1==0}function C(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!_(t.length)||t.length<0)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(!_(r)||r<0||r>=256)return!1}return!0}function O(t,e){if(e||(e={}),"number"==typeof t){w.checkSafeUint53(t,"invalid arrayify value");for(var r=[];t;)r.unshift(255&t),t=parseInt(String(t/256));return 0===r.length&&r.push(0),new Uint8Array(r)}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),S(t)&&(t=t.toHexString()),L(t)){var n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":w.throwArgumentError("hex data is odd-length","value",t));for(var o=[],i=0;i<n.length;i+=2)o.push(parseInt(n.substring(i,i+2),16));return new Uint8Array(o)}return C(t)?new Uint8Array(t):w.throwArgumentError("invalid arrayify value","value",t)}function R(t){var e=t.map(function(t){return O(t)}),r=e.reduce(function(t,e){return t+e.length},0),n=new Uint8Array(r);return e.reduce(function(t,e){return n.set(e,t),t+e.length},0),n}function N(t,e){(t=O(t)).length>e&&w.throwArgumentError("value out of range","value",t);var r=new Uint8Array(e);return r.set(t,e-t.length),r}function L(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}function M(t,e){if(e||(e={}),"number"==typeof t){w.checkSafeUint53(t,"invalid hexlify value");for(var r="";t;)r="0123456789abcdef"[15&t]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"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),S(t))return t.toHexString();if(L(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":w.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(C(t)){for(var n="0x",o=0;o<t.length;o++){var i=t[o];n+="0123456789abcdef"[(240&i)>>4]+"0123456789abcdef"[15&i]}return n}return w.throwArgumentError("invalid hexlify value","value",t)}function j(t,e,r){return"string"!=typeof t?t=M(t):(!L(t)||t.length%2)&&w.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function F(t){"string"!=typeof t&&(t=M(t)),L(t)||w.throwArgumentError("invalid hex string","value",t),t=t.substring(2);for(var e=0;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}function G(t,e){for("string"!=typeof t?t=M(t):L(t)||w.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&w.throwError("value out of range",{value:t,length:e});t.length<2*e+2;)t="0x0"+t.substring(2);return t}function q(t){var e=a({},t);return Object.keys(t).forEach(function(r){switch(r){case"gas":case"gasPrice":case"nonce":case"maxFeePerGas":case"maxPriorityFeePerGas":case"value":var n=t[r];e[r]=n instanceof B?n.toHexString():n instanceof s.default?"0x"+BigInt(n.toString()).toString(16):"number"==typeof t[r]?"0x"+t[r].toString(16):t[r].toString();break;case"data":e[r]=M(t[r])}}),e}var $={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 D(t){return"number"==typeof t?A(t).toHexString():t}var z=/*#__PURE__*/function(){function t(t){var e=this;this._rpcUrls=[],this._post=function(t){return y(e.selectRpcUrl(),t)},this._rpcUrls=t}var e=t.prototype;return e.getNetwork=function(){try{return Promise.resolve(this.post(m("eth_chainId",[]))).then(function(t){var e=c(t),r=$[e];return{chainId:Number(e),name:r[0]||"unknown",ensAddress:r[1]||null}})}catch(t){return Promise.reject(t)}},e.getBlockNumber=function(){try{return Promise.resolve(this.post(m("eth_blockNumber",[]))).then(function(t){return Number(c(t))})}catch(t){return Promise.reject(t)}},e.getTransaction=function(t){try{return Promise.resolve(Promise.all([this.post(m("eth_getTransactionByHash",[t])),this.getBlock("latest")])).then(function(t){var e=t[1],r=P(t[0]);return r.confirmations=e.number-r.blockNumber+1,r})}catch(t){return Promise.reject(t)}},e.getTransactionReceipt=function(t){try{return Promise.resolve(Promise.all([this.post(m("eth_getTransactionReceipt",[t])),this.getBlock("latest")])).then(function(t){var e=t[1],r=function(t){var e=a({},P(t));return Object.keys(t).forEach(function(r){if(t[r])switch(r){case"status":e[r]=Number(c(t[r]));break;case"contractAddress":t[r]&&(e[r]=I(t[r]));break;case"cumulativeGasUsed":case"effectiveGasPrice":case"gasUsed":e[r]=A(c(t[r]));break;case"logs":t[r].forEach(function(t,n){e[r][n]=U(t,!0)})}}),e.byzantium=e.blockNumber>=437e4,e}(t[0]);return r.confirmations=e.number-r.blockNumber+1,r})}catch(t){return Promise.reject(t)}},e.getTransactionCount=function(t,e){void 0===e&&(e="latest");try{return e=D(e),Promise.resolve(this.post(m("eth_getTransactionCount",[t,e]))).then(function(t){return Number(c(t))})}catch(t){return Promise.reject(t)}},e.getBlock=function(t,e){void 0===t&&(t="latest"),void 0===e&&(e=!1);try{var r="Number";return"string"==typeof t&&66===t.length?r="Hash":t=D(t),Promise.resolve(this.post(m("eth_getBlockBy"+r,[t,e]))).then(function(t){return function(t,e){var r=a({},t);return Object.keys(t).forEach(function(e){if(t[e])switch(e){case"difficulty":case"totalDifficulty":case"gasLimit":case"gasUsed":case"size":case"timestamp":case"baseFeePerGas":r[e]=A(c(t[e]));break;case"number":r[e]=Number(c(t[e]));break;case"miner":r[e]=I(t[e])}}),e&&t.transactions.forEach(function(t,e){r.transactions[e]=P(t)}),r}(t,e)})}catch(t){return Promise.reject(t)}},e.getGasPrice=function(){try{return Promise.resolve(this.post(m("eth_gasPrice",[]))).then(function(t){return A(c(t))})}catch(t){return Promise.reject(t)}},e.getBalance=function(t,e){void 0===e&&(e="latest");try{return e=D(e),Promise.resolve(this.post(m("eth_getBalance",[t,e]))).then(function(t){return A(c(t))})}catch(t){return Promise.reject(t)}},e.getCode=function(t,e){void 0===e&&(e="latest");try{return e=D(e),Promise.resolve(this.post(m("eth_getCode",[t,e])))}catch(t){return Promise.reject(t)}},e.estimateGas=function(t){try{var e=q(t);return Promise.resolve(this.post(m("eth_estimateGas",[e]))).then(function(t){return A(c(t))})}catch(t){return Promise.reject(t)}},e.getLogs=function(t){try{var e=t;return e.fromBlock&&(e.fromBlock=D(e.fromBlock)),e.toBlock&&(e.toBlock=D(e.toBlock)),Promise.resolve(this.post(m("eth_getLogs",[t]))).then(function(t){return t.map(function(t){return U(t,!1)})})}catch(t){return Promise.reject(t)}},e.call=function(t,e){void 0===e&&(e="latest");try{t.gasPrice&&(t.maxPriorityFeePerGas||t.maxFeePerGas)&&w.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")',{gasPrice:t.gasPrice,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),t.maxFeePerGas&&t.maxPriorityFeePerGas&&w.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"',{maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas}),e=D(e);var r=q(t);return Promise.resolve(this.post(m("eth_call",[r,e])))}catch(t){return Promise.reject(t)}},t}(),K=/*#__PURE__*/function(t){function e(e,r){var n;return void 0===r&&(r={}),Array.isArray(e)||w.throwError("Array required",{rpcUrls:e}),e.length<=1&&w.throwError("More than one rpcUrl is required",{rpcUrls:e}),(n=t.call(this,e)||this).rpcUrlCounter=0,n.timeoutDuration=void 0,n.post=function(t){var e=n.rpcUrlCounter;return function r(){var o,i,s=n.selectRpcUrl();return(o=n._post(t),i=n.timeoutDuration,Promise.race([o,new Promise(function(t,e){return setTimeout(function(){return e("Promise timed out")},i)})])).catch(function(t){if(s===n.selectRpcUrl()&&(n.rpcUrlCounter=(n.rpcUrlCounter+1)%n._rpcUrls.length),n.rpcUrlCounter===e)throw t;return r()})}()},n.timeoutDuration=r.timeoutDuration||8e3,n}return u(e,t),e.prototype.selectRpcUrl=function(){return this._rpcUrls[this.rpcUrlCounter]},e}(z),H=/*#__PURE__*/function(t){u(r,t);var e=r.prototype;function r(e){return void 0===e&&(e="https://free-eth-node.com/api/eth"),t.call(this,[e])||this}return e.selectRpcUrl=function(){return this._rpcUrls[0]},e.post=function(t){return this._post(t)},r}(z);function V(e){var r;return r="string"==typeof e?Buffer.from(e.replace(/^0x/,""),"hex"):Buffer.from(e),"0x"+new t.Keccak(256).update(r).digest("hex")}function W(t){return t=M(t).slice(2),"0x"+n.Point.fromPrivateKey(t).toHex()}function Z(t){return new Uint8Array(Buffer.from(t))}for(var Y=[],J=[],X="undefined"!=typeof Uint8Array?Uint8Array:Array,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tt=0,et=Q.length;tt<et;++tt)Y[tt]=Q[tt],J[Q.charCodeAt(tt)]=tt;function rt(t,e,r){for(var n,o=[],i=e;i<r;i+=3)o.push(Y[(n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]))>>18&63]+Y[n>>12&63]+Y[n>>6&63]+Y[63&n]);return o.join("")}J["-".charCodeAt(0)]=62,J["_".charCodeAt(0)]=63;var nt,ot,it=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,f=u>>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=a;c>0;i=256*i+t[e+h],h+=l,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=l,c-=8);if(0===i)i=1-f;else{if(i===u)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},st=function(t,e,r,n,o,i){var s,a,u,f=8*i-o-1,c=(1<<f)-1,h=c>>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=c):(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>=c?(a=0,s=c):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,f+=o;f>0;t[r+p]=255&s,p+=g,s/=256,f-=8);t[r+p-g]|=128*y},at=(nt=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(H(t,Uint8Array)){const e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return f(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(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return c(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return c(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):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(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 f(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 c(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)||H(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 I(this,e,r);case"utf8":case"utf-8":return B(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(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 f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let n=-1;for(i=r;i<a;i++)if(f(t,i)===f(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(f(t,i+n)!==f(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 v(t,e,r,n){return K(D(e,t.length-r),t,r,n)}function b(t,e,r,n){return K(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 w(t,e,r,n){return K(z(e),t,r,n)}function x(t,e,r,n){return K(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 E(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(rt(t,s,s+i>a?a:s+i));return 1===n?o.push(Y[(e=t[r-1])>>2]+Y[e<<4&63]+"=="):2===n&&o.push(Y[(e=(t[r-2]<<8)+t[r-1])>>10]+Y[e>>4&63]+Y[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(H(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),H(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(H(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(H(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),f=this.slice(n,o),c=t.slice(e,r);for(let t=0;t<u;++t)if(f[t]!==c[t]){s=f[t],a=c[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 v(this,t,e,r);case"ascii":case"latin1":case"binary":return b(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(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 P(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 k(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 I(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 U(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 O(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 R(t,e,r,n,o){return e=+e,r>>>=0,o||O(t,0,r,4),st(t,e,r,n,23,4),r+4}function N(t,e,r,n,o){return e=+e,r>>>=0,o||O(t,0,r,8),st(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=Z(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(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=Z(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(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=Z(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];return void 0!==e&&void 0!==r||q(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=Z(function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(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),it(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),it(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),it(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),it(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=Z(function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=Z(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=Z(function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=Z(function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return N(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 L={};function M(t,e,r){L[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 j(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 L.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||q(e,t.length-(r+1))}(n,o,i)}function G(t,e){if("number"!=typeof t)throw new L.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new L.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),M("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=j(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=j(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);const $=/[^+/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 X(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=J[t.charCodeAt(r)]<<18|J[t.charCodeAt(r+1)]<<12|J[t.charCodeAt(r+2)]<<6|J[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=J[t.charCodeAt(r)]<<2|J[t.charCodeAt(r+1)]>>4,s[a++]=255&e),1===i&&(e=J[t.charCodeAt(r)]<<10|J[t.charCodeAt(r+1)]<<4|J[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($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(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 H(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 Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},nt(ot={exports:{}},ot.exports),ot.exports),ut=new RegExp("^bytes([0-9]+)$"),ft=new RegExp("^(u?int)([0-9]*)$"),ct=new RegExp("^(.*)\\[([0-9]*)\\]$");function ht(t,e,r){switch(t){case"address":return r?N(e,32):O(e);case"string":return at.Buffer.from(e);case"bytes":return O(e);case"bool":return e=e?"0x01":"0x00",r?N(e,32):O(e)}var n=t.match(ft);if(n){var o=parseInt(n[2]||"256");return(n[2]&&String(o)!==n[2]||o%8!=0||0===o||o>256)&&w.throwArgumentError("invalid number type","type",t),r&&(o=256),N(M(e=A(e).toTwos(o).toNumber()),o/8)}if(n=t.match(ut)){var i=parseInt(n[1]);return(String(i)!==n[1]||0===i||i>32)&&w.throwArgumentError("invalid bytes type","type",t),O(e).byteLength!==i&&w.throwArgumentError("invalid value for "+t,"value",e),r?O((e+h).substring(0,66)):e}if((n=t.match(ct))&&Array.isArray(e)){var s=n[1];parseInt(n[2]||String(e.length))!=e.length&&w.throwArgumentError("invalid array length for "+t,"value",e);var a=[];return e.forEach(function(t){a.push(ht(s,t,!0))}),R(a)}return w.throwArgumentError("invalid type","type",t)}function lt(t,e){t.length!=e.length&&w.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);var r=[];return t.forEach(function(t,n){r.push(ht(t,e[n]))}),M(R(r))}exports.BaseContract=v,exports.Contract=b,exports.FallthroughProvider=K,exports.JsonRpcProvider=H,exports.TinyBig=B,exports.arrayify=O,exports.computeAddress=function(t){return t.startsWith("0x04")||t.startsWith("0x03")||t.startsWith("0x02")||(t=W(t)),I(j(V(j(t,1)),12))},exports.computePublicKey=W,exports.concat=R,exports.etherToGwei=function(t){k(t,["string","number","object"]);var e=A(t).times("1000000000");return A(e)},exports.etherToWei=function(t){k(t,["string","number","object"]);var e=A(t).times("1000000000000000000");return A(e)},exports.gweiToEther=function(t){k(t,["string","number","object"]);var e=A(t).div("1000000000");return A(e)},exports.hashMessage=function(t){return"string"==typeof t&&(t=Z(t)),V(R([Z("Ethereum Signed Message:\n"),Z(String(t.length)),t]))},exports.hexConcat=function(t){var e="0x";return t.forEach(function(t){e+=M(t).substring(2)}),e},exports.hexDataLength=function(t){if("string"!=typeof t)t=M(t);else if(!L(t)||t.length%2)return null;return(t.length-2)/2},exports.hexDataSlice=j,exports.hexStripZeros=F,exports.hexValue=function(t){var e=F(M(t,{hexPad:"left"}));return"0x"===e?"0x0":e},exports.hexZeroPad=G,exports.hexlify=M,exports.isAddress=function(t){k(t,["string"]);try{return I(t),!0}catch(t){return!1}},exports.isBytes=C,exports.isBytesLike=T,exports.isHexString=L,exports.jsonRpcProvider=function(t){return new H(t)},exports.keccak256=V,exports.pack=lt,exports.solidityKeccak256=function(t,e){return V(lt(t,e))},exports.splitSignature=function(t){var e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(T(t)){var r=O(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=M(r.slice(0,32)),e.s=M(r.slice(32,64))):65===r.length?(e.r=M(r.slice(0,32)),e.s=M(r.slice(32,64)),e.v=r[64]):w.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:w.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=M(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){var n=N(O(e._vs),32);e._vs=M(n);var o=n[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=o:e.recoveryParam!==o&&w.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;var i=M(n);null==e.s?e.s=i:e.s!==i&&w.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?w.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)&&w.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&L(e.r)?e.r=G(e.r,32):w.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&L(e.s)?e.s=G(e.s,32):w.throwArgumentError("signature missing or invalid s","signature",t);var s=O(e.s);s[0]>=128&&w.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(s[0]|=128);var a=M(s);e._vs&&(L(e._vs)||w.throwArgumentError("signature invalid _vs","signature",t),e._vs=G(e._vs,32)),null==e._vs?e._vs=a:e._vs!==a&&w.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e},exports.stripZeros=function(t){var e=O(t);if(0===e.length)return e;for(var r=0;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e},exports.tinyBig=A,exports.toChecksumAddress=I,exports.toUtf8Bytes=Z,exports.weiToEther=function(t){k(t,["string","number","object"]);try{var e=t;"string"==typeof t&&"0x"===t.slice(0,2)&&(e=BigInt(t).toString());var r=A(e).div("1000000000000000000");return A(r)}catch(t){throw t}},exports.zeroPad=N;
|
|
1
|
+
var sha3 = require('sha3');
|
|
2
|
+
var unfetch = require('isomorphic-unfetch');
|
|
3
|
+
var Big = require('big.js');
|
|
4
|
+
var secp256k1 = require('@noble/secp256k1');
|
|
5
|
+
var buffer = require('buffer');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var unfetch__default = /*#__PURE__*/_interopDefaultLegacy(unfetch);
|
|
10
|
+
var Big__default = /*#__PURE__*/_interopDefaultLegacy(Big);
|
|
11
|
+
|
|
12
|
+
function _extends() {
|
|
13
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
14
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
+
var source = arguments[i];
|
|
16
|
+
|
|
17
|
+
for (var key in source) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
19
|
+
target[key] = source[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
return _extends.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function hexToDecimal(hex) {
|
|
30
|
+
return BigInt(hex).toString();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const hexFalse = '0'.repeat(64);
|
|
34
|
+
const hexTrue = '0'.repeat(63) + '1';
|
|
35
|
+
|
|
36
|
+
function expandType(type) {
|
|
37
|
+
if (type === 'uint[]') {
|
|
38
|
+
return 'uint256[]';
|
|
39
|
+
} else if (type === 'int[]') {
|
|
40
|
+
return 'int256[]';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return type;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function encodeData(jsonABIArgument, args) {
|
|
47
|
+
const hash = new sha3.Keccak(256);
|
|
48
|
+
const functionString = `${jsonABIArgument.name}(${jsonABIArgument.inputs.map(input => expandType(input.type))})`;
|
|
49
|
+
const functionHash = hash.update(functionString).digest('hex');
|
|
50
|
+
const jsonABIInputsLength = jsonABIArgument.inputs.length;
|
|
51
|
+
let shouldValidateInputLength = true;
|
|
52
|
+
|
|
53
|
+
if (jsonABIArgument.inputs.find(input => input.type.includes('['))) {
|
|
54
|
+
shouldValidateInputLength = false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (shouldValidateInputLength && args.length !== jsonABIInputsLength) {
|
|
58
|
+
throw new Error(`args inputs of "${args.length}" does not match expected length of "${jsonABIArgument.inputs.length}"`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const argsWithTypes = (jsonABIArgument.inputs || []).reduce((acc, input, i) => {
|
|
62
|
+
if (input.type.includes('[')) {
|
|
63
|
+
var _exec;
|
|
64
|
+
|
|
65
|
+
const basicType = (_exec = /([^[]*)\[.*$/g.exec(input.type)) == null ? void 0 : _exec[1];
|
|
66
|
+
args.forEach(arg => {
|
|
67
|
+
acc = acc.concat([[arg, basicType]]);
|
|
68
|
+
});
|
|
69
|
+
return acc;
|
|
70
|
+
} else {
|
|
71
|
+
return acc.concat([[args[i], input.type]]);
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
const encodedArgs = argsWithTypes.map(([arg, inputType]) => {
|
|
75
|
+
let rawArg = arg;
|
|
76
|
+
|
|
77
|
+
switch (inputType) {
|
|
78
|
+
case 'bool':
|
|
79
|
+
return arg ? hexTrue : hexFalse;
|
|
80
|
+
|
|
81
|
+
case 'address':
|
|
82
|
+
rawArg = arg.replace(/^0x/g, '').toLowerCase();
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
default:
|
|
86
|
+
if (inputType.startsWith('bytes')) {
|
|
87
|
+
const argEncoded = rawArg.split('').map(character => character.charCodeAt(0).toString(16)).join('');
|
|
88
|
+
const paddedEncodedArg = argEncoded.padEnd(64, '0');
|
|
89
|
+
return paddedEncodedArg;
|
|
90
|
+
} else if (inputType === 'uint256') {
|
|
91
|
+
const argEncoded = BigInt(arg).toString(16);
|
|
92
|
+
const paddedEncodedArg = argEncoded.padStart(64, '0');
|
|
93
|
+
return paddedEncodedArg;
|
|
94
|
+
} else if (inputType.startsWith('uint')) {
|
|
95
|
+
break;
|
|
96
|
+
} else {
|
|
97
|
+
throw new Error(`essential-eth does not yet support "${inputType}" inputs. Make a PR today!"`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const argEncoded = rawArg.toString(16);
|
|
103
|
+
const paddedEncodedArg = argEncoded.padStart(64, '0');
|
|
104
|
+
return paddedEncodedArg;
|
|
105
|
+
});
|
|
106
|
+
const functionEncoded = functionHash.slice(0, 8);
|
|
107
|
+
const data = `0x${functionEncoded}${encodedArgs.join('')}`;
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
function decodeRPCResponse(jsonABIArgument, nodeResponse) {
|
|
111
|
+
const rawOutputs = jsonABIArgument.outputs;
|
|
112
|
+
const encodedOutputs = nodeResponse.slice(2).match(/.{1,64}/g);
|
|
113
|
+
const outputs = (encodedOutputs || []).map((output, i) => {
|
|
114
|
+
const outputType = (rawOutputs || [])[i].type;
|
|
115
|
+
|
|
116
|
+
switch (outputType) {
|
|
117
|
+
case 'bool':
|
|
118
|
+
return output === hexTrue;
|
|
119
|
+
|
|
120
|
+
case 'address':
|
|
121
|
+
return toChecksumAddress(`0x${output.slice(24)}`);
|
|
122
|
+
|
|
123
|
+
case 'uint256':
|
|
124
|
+
return tinyBig(hexToDecimal(`0x${output}`));
|
|
125
|
+
|
|
126
|
+
case 'bytes32':
|
|
127
|
+
return `0x${output}`;
|
|
128
|
+
|
|
129
|
+
case 'uint8':
|
|
130
|
+
return Number(hexToDecimal(`0x${output}`));
|
|
131
|
+
|
|
132
|
+
default:
|
|
133
|
+
throw new Error(`essential-eth does not yet support "${outputType}" outputs. Make a PR today!"`);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return outputs.length === 1 ? outputs[0] : outputs;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function post(url, body) {
|
|
140
|
+
return unfetch__default["default"](url, {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: {
|
|
143
|
+
'Content-Type': 'application/json'
|
|
144
|
+
},
|
|
145
|
+
body: JSON.stringify(body)
|
|
146
|
+
}).then(async r => {
|
|
147
|
+
const t = await r.text();
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
return JSON.parse(t);
|
|
151
|
+
} catch (_unused) {
|
|
152
|
+
throw new Error(`Invalid JSON RPC response: "${t}"`);
|
|
153
|
+
}
|
|
154
|
+
}).then(response => {
|
|
155
|
+
const result = response == null ? void 0 : response.result;
|
|
156
|
+
|
|
157
|
+
if (!result) {
|
|
158
|
+
throw new Error(`Invalid JSON RPC response: ${JSON.stringify(response)}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return response.result;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function buildRPCPostBody(method, params) {
|
|
165
|
+
return {
|
|
166
|
+
jsonrpc: '2.0',
|
|
167
|
+
id: 1,
|
|
168
|
+
method,
|
|
169
|
+
params
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function estimateGas(txnData) {
|
|
174
|
+
txnData.split('').reduce((previousValue, currentValue) => {
|
|
175
|
+
const characterCost = currentValue === '0' ? 4 : 68;
|
|
176
|
+
return previousValue + characterCost;
|
|
177
|
+
}, 0);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
class BaseContract {
|
|
181
|
+
constructor(addressOrName, contractInterface, signerOrProvider) {
|
|
182
|
+
this._address = void 0;
|
|
183
|
+
this._provider = void 0;
|
|
184
|
+
this._address = addressOrName;
|
|
185
|
+
this._provider = signerOrProvider;
|
|
186
|
+
contractInterface.filter(jsonABIArgument => jsonABIArgument.type === 'function').forEach(jsonABIArgument => {
|
|
187
|
+
if ('name' in jsonABIArgument && typeof jsonABIArgument.name === 'string') {
|
|
188
|
+
defineReadOnly(this, jsonABIArgument.name, async (..._args) => {
|
|
189
|
+
let functionArguments = _args;
|
|
190
|
+
let options = {};
|
|
191
|
+
const lastArg = _args[_args.length - 1];
|
|
192
|
+
|
|
193
|
+
if (!Array.isArray(lastArg) && typeof lastArg === 'object') {
|
|
194
|
+
options = lastArg;
|
|
195
|
+
functionArguments = _args.slice(0, _args.length - 1);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const data = encodeData(jsonABIArgument, functionArguments);
|
|
199
|
+
const decimalGas = typeof options.gasLimit === 'number' ? options.gasLimit : typeof (jsonABIArgument == null ? void 0 : jsonABIArgument.gas) === 'number' ? estimateGas(data) : null;
|
|
200
|
+
|
|
201
|
+
const req = async () => {
|
|
202
|
+
return await post(this._provider.selectRpcUrl(), buildRPCPostBody('eth_call', [_extends({
|
|
203
|
+
to: this._address.toLowerCase(),
|
|
204
|
+
data
|
|
205
|
+
}, decimalGas ? {
|
|
206
|
+
gas: `0x${decimalGas.toString(16)}`
|
|
207
|
+
} : {}), 'latest']));
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const nodeResponse = await req();
|
|
211
|
+
return decodeRPCResponse(jsonABIArgument, nodeResponse);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
function defineReadOnly(object, name, value) {
|
|
219
|
+
Object.defineProperty(object, name, {
|
|
220
|
+
enumerable: true,
|
|
221
|
+
value: value,
|
|
222
|
+
writable: false
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
class Contract extends BaseContract {}
|
|
226
|
+
|
|
227
|
+
const version = '0.5.11-next.1';
|
|
228
|
+
|
|
229
|
+
class Logger {
|
|
230
|
+
constructor() {
|
|
231
|
+
this.packageVersion = void 0;
|
|
232
|
+
this.packageVersion = version;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
throwError(message, args) {
|
|
236
|
+
const argsLength = Object.keys(args).length;
|
|
237
|
+
throw new Error(`${message} (${Object.entries(args).map(([key, value], index) => `${key}=${value}${index < argsLength - 1 && ', '}`)}, version=essential-eth@${this.packageVersion})`);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
throwArgumentError(message, arg, value) {
|
|
241
|
+
throw new Error(`${message} (argument="${arg}" value=${value}, version=essential-eth@${this.packageVersion})`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
checkSafeUint53(value, message = 'value not safe') {
|
|
245
|
+
if (typeof value !== 'number') {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (value < 0 || value >= 0x1fffffffffffff) {
|
|
250
|
+
this.throwError(message, {
|
|
251
|
+
operation: 'checkSafeInteger',
|
|
252
|
+
fault: 'out-of-safe-range',
|
|
253
|
+
value: value
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (value % 1) {
|
|
258
|
+
this.throwError(message, {
|
|
259
|
+
operation: 'checkSafeInteger',
|
|
260
|
+
fault: 'non-integer',
|
|
261
|
+
value: value
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const logger = new Logger();
|
|
269
|
+
|
|
270
|
+
function stripTrailingZeroes(numberString) {
|
|
271
|
+
const isNegative = numberString.startsWith('-');
|
|
272
|
+
numberString = numberString.replace('-', '');
|
|
273
|
+
numberString = numberString.replace(/\.0*$/g, '');
|
|
274
|
+
numberString = numberString.replace(/^0+/, '');
|
|
275
|
+
|
|
276
|
+
if (numberString.includes('.')) {
|
|
277
|
+
numberString = numberString.replace(/0+$/, '');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (numberString.startsWith('.')) {
|
|
281
|
+
numberString = `0${numberString}`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return `${isNegative ? '-' : ''}${numberString}`;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function scientificStrToDecimalStr(scientificString) {
|
|
288
|
+
if (!scientificString.match(/e/i)) {
|
|
289
|
+
return stripTrailingZeroes(scientificString);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
let [base, power] = scientificString.split(/e/i);
|
|
293
|
+
const isNegative = Number(base) < 0;
|
|
294
|
+
base = base.replace('-', '');
|
|
295
|
+
base = stripTrailingZeroes(base);
|
|
296
|
+
const [wholeNumber, fraction = ''] = base.split('.');
|
|
297
|
+
|
|
298
|
+
if (Number(power) === 0) {
|
|
299
|
+
return `${isNegative ? '-' : ''}${stripTrailingZeroes(base)}`;
|
|
300
|
+
} else {
|
|
301
|
+
const includesDecimal = base.includes('.');
|
|
302
|
+
|
|
303
|
+
if (!includesDecimal) {
|
|
304
|
+
base = `${base}.`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
base = base.replace('.', '');
|
|
308
|
+
const baseLength = base.length;
|
|
309
|
+
let splitPaddedNumber;
|
|
310
|
+
|
|
311
|
+
if (Number(power) < 0) {
|
|
312
|
+
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
313
|
+
base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, '0');
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
splitPaddedNumber = base.split('');
|
|
317
|
+
|
|
318
|
+
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
319
|
+
splitPaddedNumber = ['.', ...splitPaddedNumber];
|
|
320
|
+
} else {
|
|
321
|
+
splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
if (fraction.length < Math.abs(Number(power))) {
|
|
325
|
+
base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, '0');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
splitPaddedNumber = base.split('');
|
|
329
|
+
|
|
330
|
+
if (fraction.length > Math.abs(Number(power))) {
|
|
331
|
+
splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const toReturn = stripTrailingZeroes(splitPaddedNumber.join(''));
|
|
336
|
+
return `${isNegative ? '-' : ''}${toReturn}`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
class TinyBig extends Big__default["default"] {
|
|
341
|
+
constructor(value) {
|
|
342
|
+
if (typeof value === 'string' && value.startsWith('0x')) {
|
|
343
|
+
value = hexToDecimal(value);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
super(value);
|
|
347
|
+
|
|
348
|
+
this.padAndChop = (str, padChar, length) => {
|
|
349
|
+
return (Array(length).fill(padChar).join('') + str).slice(length * -1);
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
toHexString() {
|
|
354
|
+
return `0x${BigInt(this.toString()).toString(16)}`;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
toNumber() {
|
|
358
|
+
return Number(scientificStrToDecimalStr(super.toString()));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
toString() {
|
|
362
|
+
if (this.toNumber() === 0) {
|
|
363
|
+
return '0';
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return scientificStrToDecimalStr(super.toString());
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
toTwos(bitCount) {
|
|
370
|
+
let binaryStr;
|
|
371
|
+
|
|
372
|
+
if (this.gte(0)) {
|
|
373
|
+
const twosComp = this.toNumber().toString(2);
|
|
374
|
+
binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
|
|
375
|
+
} else {
|
|
376
|
+
binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
|
|
377
|
+
|
|
378
|
+
if (Number(binaryStr) < 0) {
|
|
379
|
+
throw new Error('Cannot calculate twos complement');
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const binary = `0b${binaryStr}`;
|
|
384
|
+
const decimal = Number(binary);
|
|
385
|
+
return tinyBig(decimal);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
}
|
|
389
|
+
function tinyBig(value) {
|
|
390
|
+
return new TinyBig(value);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function cleanTransaction(transaction) {
|
|
394
|
+
const cleanedTransaction = _extends({}, transaction);
|
|
395
|
+
|
|
396
|
+
Object.keys(transaction).forEach(key => {
|
|
397
|
+
if (!transaction[key]) return;
|
|
398
|
+
|
|
399
|
+
switch (key) {
|
|
400
|
+
case 'blockNumber':
|
|
401
|
+
case 'chainId':
|
|
402
|
+
case 'transactionIndex':
|
|
403
|
+
case 'type':
|
|
404
|
+
case 'v':
|
|
405
|
+
cleanedTransaction[key] = Number(hexToDecimal(transaction[key]));
|
|
406
|
+
break;
|
|
407
|
+
|
|
408
|
+
case 'from':
|
|
409
|
+
case 'to':
|
|
410
|
+
if (transaction[key]) {
|
|
411
|
+
cleanedTransaction[key] = toChecksumAddress(transaction[key]);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
break;
|
|
415
|
+
|
|
416
|
+
case 'value':
|
|
417
|
+
case 'gas':
|
|
418
|
+
case 'gasPrice':
|
|
419
|
+
case 'maxFeePerGas':
|
|
420
|
+
case 'maxPriorityFeePerGas':
|
|
421
|
+
case 'nonce':
|
|
422
|
+
cleanedTransaction[key] = tinyBig(hexToDecimal(transaction[key]));
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
return cleanedTransaction;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function cleanBlock(block, returnTransactionObjects) {
|
|
430
|
+
const cleanedBlock = _extends({}, block);
|
|
431
|
+
|
|
432
|
+
Object.keys(block).forEach(key => {
|
|
433
|
+
if (!block[key]) return;
|
|
434
|
+
|
|
435
|
+
switch (key) {
|
|
436
|
+
case 'difficulty':
|
|
437
|
+
case 'totalDifficulty':
|
|
438
|
+
case 'gasLimit':
|
|
439
|
+
case 'gasUsed':
|
|
440
|
+
case 'size':
|
|
441
|
+
case 'timestamp':
|
|
442
|
+
case 'baseFeePerGas':
|
|
443
|
+
cleanedBlock[key] = tinyBig(hexToDecimal(block[key]));
|
|
444
|
+
break;
|
|
445
|
+
|
|
446
|
+
case 'number':
|
|
447
|
+
cleanedBlock[key] = Number(hexToDecimal(block[key]));
|
|
448
|
+
break;
|
|
449
|
+
|
|
450
|
+
case 'miner':
|
|
451
|
+
cleanedBlock[key] = toChecksumAddress(block[key]);
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
if (returnTransactionObjects) {
|
|
457
|
+
const txns = block.transactions;
|
|
458
|
+
txns.forEach((transaction, index) => {
|
|
459
|
+
cleanedBlock.transactions[index] = cleanTransaction(transaction);
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return cleanedBlock;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const validateType = (value, allowedTypes) => {
|
|
467
|
+
if (!allowedTypes.includes(typeof value)) {
|
|
468
|
+
throw new Error(`${allowedTypes.join(' or ')} required. Received ${typeof value}`);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
function toChecksumAddress(address) {
|
|
473
|
+
validateType(address, ['string']);
|
|
474
|
+
|
|
475
|
+
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
|
|
476
|
+
throw new Error(`Invalid Ethereum address "${address}"`);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const _address = address.toLowerCase().replace(/^0x/i, '');
|
|
480
|
+
|
|
481
|
+
const keccak = new sha3.Keccak(256);
|
|
482
|
+
const addressHash = keccak.update(_address).digest('hex').replace(/^0x/i, '');
|
|
483
|
+
let checksumAddress = '0x';
|
|
484
|
+
|
|
485
|
+
for (let i = 0; i < _address.length; i++) {
|
|
486
|
+
if (parseInt(addressHash[i], 16) > 7) {
|
|
487
|
+
checksumAddress += _address[i].toUpperCase();
|
|
488
|
+
} else {
|
|
489
|
+
checksumAddress += _address[i];
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && checksumAddress !== address) {
|
|
494
|
+
throw new Error(`Invalid Checksum address for "${address}"`);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return checksumAddress;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function cleanLog(log, receiptLog) {
|
|
501
|
+
const cleanedLog = _extends({}, log);
|
|
502
|
+
|
|
503
|
+
Object.keys(log).forEach(key => {
|
|
504
|
+
switch (key) {
|
|
505
|
+
case 'address':
|
|
506
|
+
cleanedLog[key] = toChecksumAddress(log[key]);
|
|
507
|
+
break;
|
|
508
|
+
|
|
509
|
+
case 'blockNumber':
|
|
510
|
+
case 'logIndex':
|
|
511
|
+
case 'transactionIndex':
|
|
512
|
+
cleanedLog[key] = Number(hexToDecimal(log[key]));
|
|
513
|
+
break;
|
|
514
|
+
|
|
515
|
+
case 'removed':
|
|
516
|
+
if (receiptLog) {
|
|
517
|
+
delete cleanedLog[key];
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
return cleanedLog;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function cleanTransactionReceipt(transactionReceipt) {
|
|
527
|
+
const cleanedTransaction = cleanTransaction(transactionReceipt);
|
|
528
|
+
|
|
529
|
+
const cleanedTransactionReceipt = _extends({}, cleanedTransaction);
|
|
530
|
+
|
|
531
|
+
Object.keys(transactionReceipt).forEach(key => {
|
|
532
|
+
if (!transactionReceipt[key]) return;
|
|
533
|
+
|
|
534
|
+
switch (key) {
|
|
535
|
+
case 'status':
|
|
536
|
+
cleanedTransactionReceipt[key] = Number(hexToDecimal(transactionReceipt[key]));
|
|
537
|
+
break;
|
|
538
|
+
|
|
539
|
+
case 'contractAddress':
|
|
540
|
+
if (transactionReceipt[key]) {
|
|
541
|
+
cleanedTransactionReceipt[key] = toChecksumAddress(transactionReceipt[key]);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
break;
|
|
545
|
+
|
|
546
|
+
case 'cumulativeGasUsed':
|
|
547
|
+
case 'effectiveGasPrice':
|
|
548
|
+
case 'gasUsed':
|
|
549
|
+
cleanedTransactionReceipt[key] = tinyBig(hexToDecimal(transactionReceipt[key]));
|
|
550
|
+
break;
|
|
551
|
+
|
|
552
|
+
case 'logs':
|
|
553
|
+
transactionReceipt[key].forEach((log, index) => {
|
|
554
|
+
cleanedTransactionReceipt[key][index] = cleanLog(log, true);
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
cleanedTransactionReceipt.byzantium = cleanedTransactionReceipt.blockNumber >= 4370000;
|
|
559
|
+
return cleanedTransactionReceipt;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function isHexable(value) {
|
|
563
|
+
return !!value.toHexString;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function isBytesLike(value) {
|
|
567
|
+
return isHexString(value) && !(value.length % 2) || isBytes(value);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function isInteger(value) {
|
|
571
|
+
return typeof value === 'number' && value == value && value % 1 === 0;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function isBytes(value) {
|
|
575
|
+
if (value == null) {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (value.constructor === Uint8Array) {
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (typeof value === 'string') {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (!isInteger(value.length) || value.length < 0) {
|
|
588
|
+
return false;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
for (let i = 0; i < value.length; i++) {
|
|
592
|
+
const v = value[i];
|
|
593
|
+
|
|
594
|
+
if (!isInteger(v) || v < 0 || v >= 256) {
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
function arrayify(value, options) {
|
|
602
|
+
if (!options) {
|
|
603
|
+
options = {};
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (typeof value === 'number') {
|
|
607
|
+
logger.checkSafeUint53(value, 'invalid arrayify value');
|
|
608
|
+
const result = [];
|
|
609
|
+
|
|
610
|
+
while (value) {
|
|
611
|
+
result.unshift(value & 0xff);
|
|
612
|
+
value = parseInt(String(value / 256));
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (result.length === 0) {
|
|
616
|
+
result.push(0);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return new Uint8Array(result);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (options.allowMissingPrefix && typeof value === 'string' && value.substring(0, 2) !== '0x') {
|
|
623
|
+
value = '0x' + value;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (isHexable(value)) {
|
|
627
|
+
value = value.toHexString();
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
if (isHexString(value)) {
|
|
631
|
+
let hex = value.substring(2);
|
|
632
|
+
|
|
633
|
+
if (hex.length % 2) {
|
|
634
|
+
if (options.hexPad === 'left') {
|
|
635
|
+
hex = '0' + hex;
|
|
636
|
+
} else if (options.hexPad === 'right') {
|
|
637
|
+
hex += '0';
|
|
638
|
+
} else {
|
|
639
|
+
logger.throwArgumentError('hex data is odd-length', 'value', value);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const result = [];
|
|
644
|
+
|
|
645
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
646
|
+
result.push(parseInt(hex.substring(i, i + 2), 16));
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return new Uint8Array(result);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (isBytes(value)) {
|
|
653
|
+
return new Uint8Array(value);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return logger.throwArgumentError('invalid arrayify value', 'value', value);
|
|
657
|
+
}
|
|
658
|
+
function concat(arrayOfBytesLike) {
|
|
659
|
+
const objects = arrayOfBytesLike.map(item => arrayify(item));
|
|
660
|
+
const length = objects.reduce((accum, item) => accum + item.length, 0);
|
|
661
|
+
const result = new Uint8Array(length);
|
|
662
|
+
objects.reduce((offset, object) => {
|
|
663
|
+
result.set(object, offset);
|
|
664
|
+
return offset + object.length;
|
|
665
|
+
}, 0);
|
|
666
|
+
return result;
|
|
667
|
+
}
|
|
668
|
+
function stripZeros(value) {
|
|
669
|
+
let result = arrayify(value);
|
|
670
|
+
|
|
671
|
+
if (result.length === 0) {
|
|
672
|
+
return result;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
let start = 0;
|
|
676
|
+
|
|
677
|
+
while (start < result.length && result[start] === 0) {
|
|
678
|
+
start++;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (start) {
|
|
682
|
+
result = result.slice(start);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return result;
|
|
686
|
+
}
|
|
687
|
+
function zeroPad(value, length) {
|
|
688
|
+
value = arrayify(value);
|
|
689
|
+
|
|
690
|
+
if (value.length > length) {
|
|
691
|
+
logger.throwArgumentError('value out of range', 'value', value);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const result = new Uint8Array(length);
|
|
695
|
+
result.set(value, length - value.length);
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
function isHexString(value, length) {
|
|
699
|
+
if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (length && value.length !== 2 + 2 * length) {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
const HexCharacters = '0123456789abcdef';
|
|
710
|
+
function hexlify(value, options) {
|
|
711
|
+
if (!options) {
|
|
712
|
+
options = {};
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if (typeof value === 'number') {
|
|
716
|
+
logger.checkSafeUint53(value, 'invalid hexlify value');
|
|
717
|
+
let hex = '';
|
|
718
|
+
|
|
719
|
+
while (value) {
|
|
720
|
+
hex = HexCharacters[value & 0xf] + hex;
|
|
721
|
+
value = Math.floor(value / 16);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (hex.length) {
|
|
725
|
+
if (hex.length % 2) {
|
|
726
|
+
hex = '0' + hex;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
return '0x' + hex;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return '0x00';
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (typeof value === 'bigint') {
|
|
736
|
+
value = value.toString(16);
|
|
737
|
+
|
|
738
|
+
if (value.length % 2) {
|
|
739
|
+
return '0x0' + value;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return '0x' + value;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (options.allowMissingPrefix && typeof value === 'string' && value.substring(0, 2) !== '0x') {
|
|
746
|
+
value = '0x' + value;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
if (isHexable(value)) {
|
|
750
|
+
return value.toHexString();
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (isHexString(value)) {
|
|
754
|
+
if (value.length % 2) {
|
|
755
|
+
if (options.hexPad === 'left') {
|
|
756
|
+
value = '0x0' + value.substring(2);
|
|
757
|
+
} else if (options.hexPad === 'right') {
|
|
758
|
+
value += '0';
|
|
759
|
+
} else {
|
|
760
|
+
logger.throwArgumentError('hex data is odd-length', 'value', value);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
return value.toLowerCase();
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
if (isBytes(value)) {
|
|
768
|
+
let result = '0x';
|
|
769
|
+
|
|
770
|
+
for (let i = 0; i < value.length; i++) {
|
|
771
|
+
const v = value[i];
|
|
772
|
+
result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
return result;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
return logger.throwArgumentError('invalid hexlify value', 'value', value);
|
|
779
|
+
}
|
|
780
|
+
function hexDataLength(data) {
|
|
781
|
+
if (typeof data !== 'string') {
|
|
782
|
+
data = hexlify(data);
|
|
783
|
+
} else if (!isHexString(data) || data.length % 2) {
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
return (data.length - 2) / 2;
|
|
788
|
+
}
|
|
789
|
+
function hexDataSlice(data, offset, endOffset) {
|
|
790
|
+
if (typeof data !== 'string') {
|
|
791
|
+
data = hexlify(data);
|
|
792
|
+
} else if (!isHexString(data) || data.length % 2) {
|
|
793
|
+
logger.throwArgumentError('invalid hexData', 'value', data);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
offset = 2 + 2 * offset;
|
|
797
|
+
|
|
798
|
+
if (endOffset != null) {
|
|
799
|
+
return '0x' + data.substring(offset, 2 + 2 * endOffset);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return '0x' + data.substring(offset);
|
|
803
|
+
}
|
|
804
|
+
function hexConcat(items) {
|
|
805
|
+
let result = '0x';
|
|
806
|
+
items.forEach(item => {
|
|
807
|
+
result += hexlify(item).substring(2);
|
|
808
|
+
});
|
|
809
|
+
return result;
|
|
810
|
+
}
|
|
811
|
+
function hexValue(value) {
|
|
812
|
+
const trimmed = hexStripZeros(hexlify(value, {
|
|
813
|
+
hexPad: 'left'
|
|
814
|
+
}));
|
|
815
|
+
|
|
816
|
+
if (trimmed === '0x') {
|
|
817
|
+
return '0x0';
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
return trimmed;
|
|
821
|
+
}
|
|
822
|
+
function hexStripZeros(value) {
|
|
823
|
+
if (typeof value !== 'string') {
|
|
824
|
+
value = hexlify(value);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
if (!isHexString(value)) {
|
|
828
|
+
logger.throwArgumentError('invalid hex string', 'value', value);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
value = value.substring(2);
|
|
832
|
+
let offset = 0;
|
|
833
|
+
|
|
834
|
+
while (offset < value.length && value[offset] === '0') {
|
|
835
|
+
offset++;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
return '0x' + value.substring(offset);
|
|
839
|
+
}
|
|
840
|
+
function hexZeroPad(value, length) {
|
|
841
|
+
if (typeof value !== 'string') {
|
|
842
|
+
value = hexlify(value);
|
|
843
|
+
} else if (!isHexString(value)) {
|
|
844
|
+
logger.throwArgumentError('invalid hex string', 'value', value);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
if (value.length > 2 * length + 2) {
|
|
848
|
+
logger.throwError('value out of range', {
|
|
849
|
+
value,
|
|
850
|
+
length
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
while (value.length < 2 * length + 2) {
|
|
855
|
+
value = '0x0' + value.substring(2);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return value;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function prepareTransaction(transaction) {
|
|
862
|
+
const preparedTransaction = _extends({}, transaction);
|
|
863
|
+
|
|
864
|
+
Object.keys(transaction).forEach(key => {
|
|
865
|
+
switch (key) {
|
|
866
|
+
case 'gas':
|
|
867
|
+
case 'gasPrice':
|
|
868
|
+
case 'nonce':
|
|
869
|
+
case 'maxFeePerGas':
|
|
870
|
+
case 'maxPriorityFeePerGas':
|
|
871
|
+
case 'value':
|
|
872
|
+
{
|
|
873
|
+
const value = transaction[key];
|
|
874
|
+
|
|
875
|
+
if (value instanceof TinyBig) {
|
|
876
|
+
preparedTransaction[key] = value.toHexString();
|
|
877
|
+
} else if (value instanceof Big__default["default"]) {
|
|
878
|
+
preparedTransaction[key] = `0x${BigInt(value.toString()).toString(16)}`;
|
|
879
|
+
} else if (typeof transaction[key] === 'number') preparedTransaction[key] = '0x' + transaction[key].toString(16);else preparedTransaction[key] = transaction[key].toString();
|
|
880
|
+
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
case 'data':
|
|
885
|
+
preparedTransaction[key] = hexlify(transaction[key]);
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
return preparedTransaction;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
var chainsInfo = {
|
|
893
|
+
"1": ["eth", "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"],
|
|
894
|
+
"2": ["exp"],
|
|
895
|
+
"3": ["rop", "0x112234455c3a32fd11230c42e7bccd4a84e02010"],
|
|
896
|
+
"4": ["rin", "0xe7410170f87102df0055eb195163a03b7f2bff4a"],
|
|
897
|
+
"5": ["gor", "0x112234455c3a32fd11230c42e7bccd4a84e02010"],
|
|
898
|
+
"6": ["kot"],
|
|
899
|
+
"7": ["tch"],
|
|
900
|
+
"8": ["ubq"],
|
|
901
|
+
"9": ["tubq"],
|
|
902
|
+
"10": ["oeth"],
|
|
903
|
+
"11": ["meta"],
|
|
904
|
+
"12": ["kal"],
|
|
905
|
+
"13": ["dstg"],
|
|
906
|
+
"14": ["flr"],
|
|
907
|
+
"15": ["diode"],
|
|
908
|
+
"16": ["cflr"],
|
|
909
|
+
"17": ["tfi"],
|
|
910
|
+
"18": ["TST"],
|
|
911
|
+
"19": ["sgb"],
|
|
912
|
+
"20": ["elaeth"],
|
|
913
|
+
"21": ["elaetht"],
|
|
914
|
+
"22": ["eladid"],
|
|
915
|
+
"23": ["eladidt"],
|
|
916
|
+
"24": ["dthmainnet"],
|
|
917
|
+
"25": ["cro"],
|
|
918
|
+
"26": ["L1test"],
|
|
919
|
+
"27": ["shib"],
|
|
920
|
+
"28": ["Boba Rinkeby"],
|
|
921
|
+
"29": ["L1"],
|
|
922
|
+
"30": ["rsk"],
|
|
923
|
+
"31": ["trsk"],
|
|
924
|
+
"32": ["GooDT"],
|
|
925
|
+
"33": ["GooD"],
|
|
926
|
+
"34": ["dth"],
|
|
927
|
+
"35": ["tbwg"],
|
|
928
|
+
"36": ["dx"],
|
|
929
|
+
"38": ["val"],
|
|
930
|
+
"40": ["Telos EVM"],
|
|
931
|
+
"41": ["Telos EVM Testnet"],
|
|
932
|
+
"42": ["kov"],
|
|
933
|
+
"43": ["pangolin"],
|
|
934
|
+
"44": ["crab"],
|
|
935
|
+
"45": ["pangoro"],
|
|
936
|
+
"46": ["darwinia"],
|
|
937
|
+
"50": ["xdc"],
|
|
938
|
+
"51": ["TXDC"],
|
|
939
|
+
"52": ["cet"],
|
|
940
|
+
"53": ["tcet"],
|
|
941
|
+
"54": ["OP"],
|
|
942
|
+
"55": ["ZYX"],
|
|
943
|
+
"56": ["bnb"],
|
|
944
|
+
"57": ["sys"],
|
|
945
|
+
"58": ["Ontology Mainnet"],
|
|
946
|
+
"59": ["EOS Mainnet"],
|
|
947
|
+
"60": ["go"],
|
|
948
|
+
"61": ["etc"],
|
|
949
|
+
"62": ["tetc"],
|
|
950
|
+
"63": ["metc"],
|
|
951
|
+
"64": ["ellaism"],
|
|
952
|
+
"65": ["tokt"],
|
|
953
|
+
"66": ["okt"],
|
|
954
|
+
"67": ["dbm"],
|
|
955
|
+
"68": ["SO1"],
|
|
956
|
+
"69": ["okov"],
|
|
957
|
+
"70": ["hsc"],
|
|
958
|
+
"71": ["cfxtest"],
|
|
959
|
+
"72": ["dxc"],
|
|
960
|
+
"74": ["idchain"],
|
|
961
|
+
"76": ["mix"],
|
|
962
|
+
"77": ["spoa"],
|
|
963
|
+
"78": ["primuschain"],
|
|
964
|
+
"79": ["zenith"],
|
|
965
|
+
"80": ["GeneChain"],
|
|
966
|
+
"81": ["VIL"],
|
|
967
|
+
"82": ["Meter"],
|
|
968
|
+
"83": ["MeterTest"],
|
|
969
|
+
"85": ["gttest"],
|
|
970
|
+
"86": ["gt"],
|
|
971
|
+
"87": ["nnw"],
|
|
972
|
+
"88": ["tomo"],
|
|
973
|
+
"89": ["tomot"],
|
|
974
|
+
"90": ["gar-s0"],
|
|
975
|
+
"91": ["gar-s1"],
|
|
976
|
+
"92": ["gar-s2"],
|
|
977
|
+
"93": ["gar-s3"],
|
|
978
|
+
"95": ["Kylin Testnet"],
|
|
979
|
+
"96": ["nsc"],
|
|
980
|
+
"97": ["bnbt"],
|
|
981
|
+
"99": ["poa"],
|
|
982
|
+
"100": ["gno"],
|
|
983
|
+
"101": ["eti"],
|
|
984
|
+
"102": ["tw3g"],
|
|
985
|
+
"104": ["tklc"],
|
|
986
|
+
"105": ["dw3g"],
|
|
987
|
+
"106": ["vlx"],
|
|
988
|
+
"107": ["ntn"],
|
|
989
|
+
"108": ["TT"],
|
|
990
|
+
"110": ["xpr"],
|
|
991
|
+
"111": ["ETL"],
|
|
992
|
+
"122": ["fuse"],
|
|
993
|
+
"123": ["spark"],
|
|
994
|
+
"124": ["dwu"],
|
|
995
|
+
"125": ["oychain testnet"],
|
|
996
|
+
"126": ["oychain mainnet"],
|
|
997
|
+
"127": ["feth"],
|
|
998
|
+
"128": ["heco"],
|
|
999
|
+
"137": ["MATIC"],
|
|
1000
|
+
"141": ["OPtest"],
|
|
1001
|
+
"142": ["dax"],
|
|
1002
|
+
"162": ["tpht"],
|
|
1003
|
+
"163": ["pht"],
|
|
1004
|
+
"168": ["aioz"],
|
|
1005
|
+
"170": ["hoosmartchain"],
|
|
1006
|
+
"172": ["resil"],
|
|
1007
|
+
"180": ["ame"],
|
|
1008
|
+
"186": ["Seele"],
|
|
1009
|
+
"188": ["BMC"],
|
|
1010
|
+
"189": ["BMCT"],
|
|
1011
|
+
"193": ["cem"],
|
|
1012
|
+
"199": ["BTT"],
|
|
1013
|
+
"200": ["aox"],
|
|
1014
|
+
"211": ["EDI"],
|
|
1015
|
+
"218": ["SO1-old"],
|
|
1016
|
+
"222": ["ASK"],
|
|
1017
|
+
"225": ["LA"],
|
|
1018
|
+
"226": ["TLA"],
|
|
1019
|
+
"246": ["ewt"],
|
|
1020
|
+
"250": ["ftm"],
|
|
1021
|
+
"256": ["hecot"],
|
|
1022
|
+
"258": ["setm"],
|
|
1023
|
+
"262": ["SUR"],
|
|
1024
|
+
"269": ["hpb"],
|
|
1025
|
+
"280": ["zksync-goerli"],
|
|
1026
|
+
"288": ["Boba"],
|
|
1027
|
+
"300": ["ogc"],
|
|
1028
|
+
"321": ["kcs"],
|
|
1029
|
+
"322": ["kcst"],
|
|
1030
|
+
"333": ["w3q"],
|
|
1031
|
+
"335": ["DFKTEST"],
|
|
1032
|
+
"336": ["sdn"],
|
|
1033
|
+
"338": ["tcro"],
|
|
1034
|
+
"361": ["theta-mainnet"],
|
|
1035
|
+
"363": ["theta-sapphire"],
|
|
1036
|
+
"364": ["theta-amber"],
|
|
1037
|
+
"365": ["theta-testnet"],
|
|
1038
|
+
"369": ["pls"],
|
|
1039
|
+
"385": ["lisinski"],
|
|
1040
|
+
"416": ["SX"],
|
|
1041
|
+
"420": ["ogor"],
|
|
1042
|
+
"499": ["rupx"],
|
|
1043
|
+
"512": ["aac"],
|
|
1044
|
+
"513": ["aact"],
|
|
1045
|
+
"520": ["xt"],
|
|
1046
|
+
"530": ["f(x)Core"],
|
|
1047
|
+
"534": ["CNDL"],
|
|
1048
|
+
"555": ["CLASS"],
|
|
1049
|
+
"558": ["tao"],
|
|
1050
|
+
"588": ["metis-stardust"],
|
|
1051
|
+
"592": ["astr"],
|
|
1052
|
+
"595": ["maca"],
|
|
1053
|
+
"596": ["tkar"],
|
|
1054
|
+
"597": ["taca"],
|
|
1055
|
+
"600": ["mesh-chain-testnet"],
|
|
1056
|
+
"647": ["SX-Testnet"],
|
|
1057
|
+
"666": ["pixie-chain-testnet"],
|
|
1058
|
+
"686": ["kar"],
|
|
1059
|
+
"700": ["SNS"],
|
|
1060
|
+
"707": ["bcs"],
|
|
1061
|
+
"708": ["tbcs"],
|
|
1062
|
+
"721": ["tfeth"],
|
|
1063
|
+
"776": ["opc"],
|
|
1064
|
+
"777": ["cth"],
|
|
1065
|
+
"787": ["aca"],
|
|
1066
|
+
"788": ["taero"],
|
|
1067
|
+
"803": ["haic"],
|
|
1068
|
+
"808": ["PFTEST"],
|
|
1069
|
+
"820": ["clo"],
|
|
1070
|
+
"821": ["tclo"],
|
|
1071
|
+
"880": ["ambros"],
|
|
1072
|
+
"888": ["wan"],
|
|
1073
|
+
"900": ["gar-test-s0"],
|
|
1074
|
+
"901": ["gar-test-s1"],
|
|
1075
|
+
"902": ["gar-test-s2"],
|
|
1076
|
+
"903": ["gar-test-s3"],
|
|
1077
|
+
"909": ["PF"],
|
|
1078
|
+
"940": ["tpls"],
|
|
1079
|
+
"941": ["t2bpls"],
|
|
1080
|
+
"942": ["t3pls"],
|
|
1081
|
+
"977": ["yeti"],
|
|
1082
|
+
"980": ["top_evm"],
|
|
1083
|
+
"989": ["top"],
|
|
1084
|
+
"998": ["ln"],
|
|
1085
|
+
"999": ["twan"],
|
|
1086
|
+
"1000": ["gton"],
|
|
1087
|
+
"1001": ["Baobab"],
|
|
1088
|
+
"1007": ["tnew"],
|
|
1089
|
+
"1008": ["eun"],
|
|
1090
|
+
"1010": ["EVC"],
|
|
1091
|
+
"1012": ["new"],
|
|
1092
|
+
"1022": ["sku"],
|
|
1093
|
+
"1023": ["tclv"],
|
|
1094
|
+
"1024": ["clv"],
|
|
1095
|
+
"1028": ["tbtt"],
|
|
1096
|
+
"1030": ["cfx"],
|
|
1097
|
+
"1088": ["metis-andromeda"],
|
|
1098
|
+
"1139": ["MATH"],
|
|
1099
|
+
"1140": ["tMATH"],
|
|
1100
|
+
"1197": ["iora"],
|
|
1101
|
+
"1201": ["avis"],
|
|
1102
|
+
"1202": ["wtt"],
|
|
1103
|
+
"1213": ["popcat"],
|
|
1104
|
+
"1214": ["enter"],
|
|
1105
|
+
"1246": ["om"],
|
|
1106
|
+
"1280": ["HO"],
|
|
1107
|
+
"1284": ["mbeam"],
|
|
1108
|
+
"1285": ["mriver"],
|
|
1109
|
+
"1286": ["mrock-old"],
|
|
1110
|
+
"1287": ["mbase"],
|
|
1111
|
+
"1288": ["mrock"],
|
|
1112
|
+
"1297": ["Bobabase"],
|
|
1113
|
+
"1319": ["aitd"],
|
|
1114
|
+
"1320": ["aitdtestnet"],
|
|
1115
|
+
"1337": ["cennz-old"],
|
|
1116
|
+
"1506": ["Sherpax"],
|
|
1117
|
+
"1507": ["Sherpax Testnet"],
|
|
1118
|
+
"1618": ["cate"],
|
|
1119
|
+
"1620": ["ath"],
|
|
1120
|
+
"1657": ["bta"],
|
|
1121
|
+
"1688": ["LUDAN"],
|
|
1122
|
+
"1818": ["cube"],
|
|
1123
|
+
"1819": ["cubet"],
|
|
1124
|
+
"1856": ["tsf"],
|
|
1125
|
+
"1898": ["boya"],
|
|
1126
|
+
"1984": ["euntest"],
|
|
1127
|
+
"1987": ["egem"],
|
|
1128
|
+
"2001": ["milkAda"],
|
|
1129
|
+
"2008": ["cloudwalk_testnet"],
|
|
1130
|
+
"2009": ["cloudwalk_mainnet"],
|
|
1131
|
+
"2020": ["420"],
|
|
1132
|
+
"2021": ["edg"],
|
|
1133
|
+
"2022": ["edgt"],
|
|
1134
|
+
"2023": ["taycan-testnet"],
|
|
1135
|
+
"2025": ["rpg"],
|
|
1136
|
+
"2100": ["eco"],
|
|
1137
|
+
"2101": ["esp"],
|
|
1138
|
+
"2152": ["fra"],
|
|
1139
|
+
"2153": ["findora-testnet"],
|
|
1140
|
+
"2213": ["evanesco"],
|
|
1141
|
+
"2221": ["tkava"],
|
|
1142
|
+
"2222": ["kava"],
|
|
1143
|
+
"2223": ["VChain"],
|
|
1144
|
+
"2559": ["ktoc"],
|
|
1145
|
+
"2569": ["tpc"],
|
|
1146
|
+
"2612": ["EZChain"],
|
|
1147
|
+
"2613": ["Fuji-EZChain"],
|
|
1148
|
+
"3000": ["cennz-r"],
|
|
1149
|
+
"3001": ["cennz-n"],
|
|
1150
|
+
"3331": ["zcrbeach"],
|
|
1151
|
+
"3333": ["w3q-t"],
|
|
1152
|
+
"3334": ["w3q-g"],
|
|
1153
|
+
"3400": ["prb"],
|
|
1154
|
+
"3500": ["prbtestnet"],
|
|
1155
|
+
"3501": ["jfin"],
|
|
1156
|
+
"3690": ["btx"],
|
|
1157
|
+
"3737": ["csb"],
|
|
1158
|
+
"3966": ["dyno"],
|
|
1159
|
+
"3967": ["tdyno"],
|
|
1160
|
+
"3999": ["ycc"],
|
|
1161
|
+
"4002": ["tftm"],
|
|
1162
|
+
"4051": ["Bobaopera Testnet"],
|
|
1163
|
+
"4102": ["aioz-testnet"],
|
|
1164
|
+
"4181": ["PHI"],
|
|
1165
|
+
"4689": ["iotex-mainnet"],
|
|
1166
|
+
"4690": ["iotex-testnet"],
|
|
1167
|
+
"4918": ["txvm"],
|
|
1168
|
+
"4919": ["xvm"],
|
|
1169
|
+
"5177": ["tlc"],
|
|
1170
|
+
"5197": ["es"],
|
|
1171
|
+
"5315": ["UZMI"],
|
|
1172
|
+
"5551": ["Nahmii"],
|
|
1173
|
+
"5553": ["Nahmii testnet"],
|
|
1174
|
+
"5700": ["tsys"],
|
|
1175
|
+
"5777": ["dgcc"],
|
|
1176
|
+
"5851": ["Ontology Testnet"],
|
|
1177
|
+
"5869": ["rbd"],
|
|
1178
|
+
"6626": ["pixie-chain"],
|
|
1179
|
+
"6969": ["tombchain"],
|
|
1180
|
+
"7027": ["ELLA"],
|
|
1181
|
+
"7341": ["shyft"],
|
|
1182
|
+
"7777": ["Rise of the Warbots Testnet"],
|
|
1183
|
+
"7878": ["tscas"],
|
|
1184
|
+
"8000": ["teleport"],
|
|
1185
|
+
"8001": ["teleport-testnet"],
|
|
1186
|
+
"8029": ["mdgl"],
|
|
1187
|
+
"8080": ["GeneChainAdn"],
|
|
1188
|
+
"8217": ["Cypress"],
|
|
1189
|
+
"8285": ["Kortho"],
|
|
1190
|
+
"8723": ["olo"],
|
|
1191
|
+
"8724": ["tolo"],
|
|
1192
|
+
"8888": ["ambrostestnet"],
|
|
1193
|
+
"8898": ["mmt"],
|
|
1194
|
+
"8995": ["berg"],
|
|
1195
|
+
"9000": ["evmos-testnet"],
|
|
1196
|
+
"9001": ["evmos"],
|
|
1197
|
+
"9012": ["brb"],
|
|
1198
|
+
"9100": ["GENEC"],
|
|
1199
|
+
"9527": ["trpg"],
|
|
1200
|
+
"9999": ["myn"],
|
|
1201
|
+
"10000": ["smartbch"],
|
|
1202
|
+
"10001": ["smartbchtest"],
|
|
1203
|
+
"10101": ["GEN"],
|
|
1204
|
+
"10823": ["CCP"],
|
|
1205
|
+
"10946": ["quadrans"],
|
|
1206
|
+
"10947": ["quadranstestnet"],
|
|
1207
|
+
"11111": ["WAGMI"],
|
|
1208
|
+
"11437": ["shyftt"],
|
|
1209
|
+
"12051": ["tZERO"],
|
|
1210
|
+
"12052": ["ZERO"],
|
|
1211
|
+
"13381": ["Phoenix"],
|
|
1212
|
+
"16000": ["mtt"],
|
|
1213
|
+
"16001": ["mtttest"],
|
|
1214
|
+
"16888": ["tivar"],
|
|
1215
|
+
"19845": ["btcix"],
|
|
1216
|
+
"21337": ["cennz-a"],
|
|
1217
|
+
"21816": ["omc"],
|
|
1218
|
+
"22023": ["SFL"],
|
|
1219
|
+
"24484": ["web"],
|
|
1220
|
+
"24734": ["mintme"],
|
|
1221
|
+
"26863": ["OAC"],
|
|
1222
|
+
"30067": ["Piece"],
|
|
1223
|
+
"31102": ["esn"],
|
|
1224
|
+
"31337": ["got"],
|
|
1225
|
+
"32520": ["Brise"],
|
|
1226
|
+
"32659": ["fsn"],
|
|
1227
|
+
"35441": ["q"],
|
|
1228
|
+
"35443": ["q-testnet"],
|
|
1229
|
+
"39797": ["nrg"],
|
|
1230
|
+
"42069": ["PC"],
|
|
1231
|
+
"42161": ["arb1"],
|
|
1232
|
+
"42170": ["arb-nova"],
|
|
1233
|
+
"42220": ["CELO"],
|
|
1234
|
+
"42261": ["emerald"],
|
|
1235
|
+
"42262": ["oasis"],
|
|
1236
|
+
"43110": ["avaeth"],
|
|
1237
|
+
"43113": ["Fuji"],
|
|
1238
|
+
"43114": ["avax"],
|
|
1239
|
+
"44787": ["ALFA"],
|
|
1240
|
+
"45000": ["Autobahn Network"],
|
|
1241
|
+
"47805": ["REI"],
|
|
1242
|
+
"49797": ["tnrg"],
|
|
1243
|
+
"50021": ["tgton"],
|
|
1244
|
+
"53935": ["DFK"],
|
|
1245
|
+
"55555": ["reichain"],
|
|
1246
|
+
"55556": ["trei"],
|
|
1247
|
+
"60000": ["TKM-test0"],
|
|
1248
|
+
"60001": ["TKM-test1"],
|
|
1249
|
+
"60002": ["TKM-test2"],
|
|
1250
|
+
"60103": ["TKM-test103"],
|
|
1251
|
+
"62320": ["BKLV"],
|
|
1252
|
+
"62621": ["mtv"],
|
|
1253
|
+
"63000": ["ecs"],
|
|
1254
|
+
"63001": ["ecs-testnet"],
|
|
1255
|
+
"69420": ["cndr"],
|
|
1256
|
+
"70000": ["TKM0"],
|
|
1257
|
+
"70001": ["TKM1"],
|
|
1258
|
+
"70002": ["TKM2"],
|
|
1259
|
+
"70103": ["TKM103"],
|
|
1260
|
+
"71393": ["ckb"],
|
|
1261
|
+
"71401": ["gw-testnet-v1"],
|
|
1262
|
+
"71402": ["gw-mainnet-v1"],
|
|
1263
|
+
"73799": ["vt"],
|
|
1264
|
+
"73927": ["mvm"],
|
|
1265
|
+
"75000": ["resin"],
|
|
1266
|
+
"78110": ["firenze"],
|
|
1267
|
+
"80001": ["maticmum"],
|
|
1268
|
+
"88888": ["ivar"],
|
|
1269
|
+
"99998": ["usctest"],
|
|
1270
|
+
"99999": ["usc"],
|
|
1271
|
+
"100000": ["qkc-r"],
|
|
1272
|
+
"100001": ["qkc-s0"],
|
|
1273
|
+
"100002": ["qkc-s1"],
|
|
1274
|
+
"100003": ["qkc-s2"],
|
|
1275
|
+
"100004": ["qkc-s3"],
|
|
1276
|
+
"100005": ["qkc-s4"],
|
|
1277
|
+
"100006": ["qkc-s5"],
|
|
1278
|
+
"100007": ["qkc-s6"],
|
|
1279
|
+
"100008": ["qkc-s7"],
|
|
1280
|
+
"103090": ["CRFI"],
|
|
1281
|
+
"108801": ["bro"],
|
|
1282
|
+
"110000": ["qkc-d-r"],
|
|
1283
|
+
"110001": ["qkc-d-s0"],
|
|
1284
|
+
"110002": ["qkc-d-s1"],
|
|
1285
|
+
"110003": ["qkc-d-s2"],
|
|
1286
|
+
"110004": ["qkc-d-s3"],
|
|
1287
|
+
"110005": ["qkc-d-s4"],
|
|
1288
|
+
"110006": ["qkc-d-s5"],
|
|
1289
|
+
"110007": ["qkc-d-s6"],
|
|
1290
|
+
"110008": ["qkc-d-s7"],
|
|
1291
|
+
"131419": ["ETND"],
|
|
1292
|
+
"200101": ["milkTAda"],
|
|
1293
|
+
"200625": ["aka"],
|
|
1294
|
+
"201018": ["alaya"],
|
|
1295
|
+
"201030": ["alayadev"],
|
|
1296
|
+
"210425": ["platon"],
|
|
1297
|
+
"234666": ["hym"],
|
|
1298
|
+
"246529": ["ats"],
|
|
1299
|
+
"246785": ["atstau"],
|
|
1300
|
+
"281121": ["SoChain"],
|
|
1301
|
+
"333888": ["sparta"],
|
|
1302
|
+
"333999": ["olympus"],
|
|
1303
|
+
"421611": ["arb-rinkeby"],
|
|
1304
|
+
"421613": ["arb-goerli"],
|
|
1305
|
+
"432201": ["Dexalot"],
|
|
1306
|
+
"444900": ["wlkt"],
|
|
1307
|
+
"474142": ["oc"],
|
|
1308
|
+
"512512": ["cmp"],
|
|
1309
|
+
"666666": ["vpioneer"],
|
|
1310
|
+
"846000": ["bloqs4good"],
|
|
1311
|
+
"888888": ["vision"],
|
|
1312
|
+
"955305": ["elv"],
|
|
1313
|
+
"1313114": ["etho"],
|
|
1314
|
+
"1313500": ["xero"],
|
|
1315
|
+
"1337702": ["kintsugi"],
|
|
1316
|
+
"1337802": ["kiln"],
|
|
1317
|
+
"2203181": ["platondev"],
|
|
1318
|
+
"2206132": ["platondev2"],
|
|
1319
|
+
"7762959": ["music"],
|
|
1320
|
+
"11155111": ["sep"],
|
|
1321
|
+
"13371337": ["tpep"],
|
|
1322
|
+
"18289463": ["ilt"],
|
|
1323
|
+
"20180430": ["spectrum"],
|
|
1324
|
+
"20181205": ["qki"],
|
|
1325
|
+
"28945486": ["auxi"],
|
|
1326
|
+
"35855456": ["JOYS"],
|
|
1327
|
+
"61717561": ["aqua"],
|
|
1328
|
+
"99415706": ["TOYS"],
|
|
1329
|
+
"192837465": ["GTH"],
|
|
1330
|
+
"245022926": ["neonevm-devnet"],
|
|
1331
|
+
"245022934": ["neonevm-mainnet"],
|
|
1332
|
+
"245022940": ["neonevm-testnet"],
|
|
1333
|
+
"311752642": ["oneledger"],
|
|
1334
|
+
"356256156": ["tGTH"],
|
|
1335
|
+
"486217935": ["dGTH"],
|
|
1336
|
+
"1122334455": ["ipos"],
|
|
1337
|
+
"1313161554": ["aurora"],
|
|
1338
|
+
"1313161555": ["aurora-testnet"],
|
|
1339
|
+
"1313161556": ["aurora-betanet"],
|
|
1340
|
+
"1666600000": ["hmy-s0"],
|
|
1341
|
+
"1666600001": ["hmy-s1"],
|
|
1342
|
+
"1666600002": ["hmy-s2"],
|
|
1343
|
+
"1666600003": ["hmy-s3"],
|
|
1344
|
+
"1666700000": ["hmy-b-s0"],
|
|
1345
|
+
"1666700001": ["hmy-b-s1"],
|
|
1346
|
+
"1666700002": ["hmy-b-s2"],
|
|
1347
|
+
"1666700003": ["hmy-b-s3"],
|
|
1348
|
+
"2021121117": ["hop"],
|
|
1349
|
+
"3125659152": ["pirl"],
|
|
1350
|
+
"4216137055": ["frankenstein"],
|
|
1351
|
+
"11297108099": ["tpalm"],
|
|
1352
|
+
"11297108109": ["palm"],
|
|
1353
|
+
"197710212030": ["ntt"],
|
|
1354
|
+
"197710212031": ["ntt-haradev"],
|
|
1355
|
+
"6022140761023": ["mole"],
|
|
1356
|
+
"868455272153094": ["gw-testnet-v1-deprecated"]
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
function prepBlockTag(blockTag) {
|
|
1360
|
+
return typeof blockTag === 'number' ? tinyBig(blockTag).toHexString() : blockTag;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
class BaseProvider {
|
|
1364
|
+
constructor(rpcUrls) {
|
|
1365
|
+
this._rpcUrls = [];
|
|
1366
|
+
|
|
1367
|
+
this._post = body => post(this.selectRpcUrl(), body);
|
|
1368
|
+
|
|
1369
|
+
this._rpcUrls = rpcUrls;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
async getNetwork() {
|
|
1373
|
+
const hexChainId = await this.post(buildRPCPostBody('eth_chainId', []));
|
|
1374
|
+
const chainId = hexToDecimal(hexChainId);
|
|
1375
|
+
const info = chainsInfo[chainId];
|
|
1376
|
+
return {
|
|
1377
|
+
chainId: Number(chainId),
|
|
1378
|
+
name: info[0] || 'unknown',
|
|
1379
|
+
ensAddress: info[1] || null
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
async getBlockNumber() {
|
|
1384
|
+
const currentBlockNumber = await this.post(buildRPCPostBody('eth_blockNumber', []));
|
|
1385
|
+
return Number(hexToDecimal(currentBlockNumber));
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
async getTransaction(transactionHash) {
|
|
1389
|
+
const [rpcTransaction, blockNumber] = await Promise.all([this.post(buildRPCPostBody('eth_getTransactionByHash', [transactionHash])), this.getBlock('latest')]);
|
|
1390
|
+
const cleanedTransaction = cleanTransaction(rpcTransaction);
|
|
1391
|
+
cleanedTransaction.confirmations = blockNumber.number - cleanedTransaction.blockNumber + 1;
|
|
1392
|
+
return cleanedTransaction;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
async getTransactionReceipt(transactionHash) {
|
|
1396
|
+
const [rpcTransaction, blockNumber] = await Promise.all([this.post(buildRPCPostBody('eth_getTransactionReceipt', [transactionHash])), this.getBlock('latest')]);
|
|
1397
|
+
const cleanedTransactionReceipt = cleanTransactionReceipt(rpcTransaction);
|
|
1398
|
+
cleanedTransactionReceipt.confirmations = blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
|
|
1399
|
+
return cleanedTransactionReceipt;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
async getTransactionCount(address, blockTag = 'latest') {
|
|
1403
|
+
blockTag = prepBlockTag(blockTag);
|
|
1404
|
+
const transactionCount = await this.post(buildRPCPostBody('eth_getTransactionCount', [address, blockTag]));
|
|
1405
|
+
return Number(hexToDecimal(transactionCount));
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
async getBlock(timeFrame = 'latest', returnTransactionObjects = false) {
|
|
1409
|
+
let type = 'Number';
|
|
1410
|
+
|
|
1411
|
+
if (typeof timeFrame === 'string' && timeFrame.length === 66) {
|
|
1412
|
+
type = 'Hash';
|
|
1413
|
+
} else {
|
|
1414
|
+
timeFrame = prepBlockTag(timeFrame);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
const rpcBlock = await this.post(buildRPCPostBody(`eth_getBlockBy${type}`, [timeFrame, returnTransactionObjects]));
|
|
1418
|
+
return cleanBlock(rpcBlock, returnTransactionObjects);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
async getGasPrice() {
|
|
1422
|
+
const hexGasPrice = await this.post(buildRPCPostBody('eth_gasPrice', []));
|
|
1423
|
+
return tinyBig(hexToDecimal(hexGasPrice));
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
async getBalance(address, blockTag = 'latest') {
|
|
1427
|
+
blockTag = prepBlockTag(blockTag);
|
|
1428
|
+
const hexBalance = await this.post(buildRPCPostBody('eth_getBalance', [address, blockTag]));
|
|
1429
|
+
return tinyBig(hexToDecimal(hexBalance));
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
async getCode(address, blockTag = 'latest') {
|
|
1433
|
+
blockTag = prepBlockTag(blockTag);
|
|
1434
|
+
const contractCode = await this.post(buildRPCPostBody('eth_getCode', [address, blockTag]));
|
|
1435
|
+
return contractCode;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
async estimateGas(transaction) {
|
|
1439
|
+
const rpcTransaction = prepareTransaction(transaction);
|
|
1440
|
+
const gasUsed = await this.post(buildRPCPostBody('eth_estimateGas', [rpcTransaction]));
|
|
1441
|
+
return tinyBig(hexToDecimal(gasUsed));
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
async getLogs(filter) {
|
|
1445
|
+
const filterByRange = filter;
|
|
1446
|
+
if (filterByRange.fromBlock) filterByRange.fromBlock = prepBlockTag(filterByRange.fromBlock);
|
|
1447
|
+
if (filterByRange.toBlock) filterByRange.toBlock = prepBlockTag(filterByRange.toBlock);
|
|
1448
|
+
const rpcLogs = await this.post(buildRPCPostBody('eth_getLogs', [filter]));
|
|
1449
|
+
const logs = rpcLogs.map(log => cleanLog(log, false));
|
|
1450
|
+
return logs;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
async call(transaction, blockTag = 'latest') {
|
|
1454
|
+
if (transaction.gasPrice && (transaction.maxPriorityFeePerGas || transaction.maxFeePerGas)) {
|
|
1455
|
+
logger.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")', {
|
|
1456
|
+
gasPrice: transaction.gasPrice,
|
|
1457
|
+
maxFeePerGas: transaction.maxFeePerGas,
|
|
1458
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
if (transaction.maxFeePerGas && transaction.maxPriorityFeePerGas) {
|
|
1463
|
+
logger.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"', {
|
|
1464
|
+
maxFeePerGas: transaction.maxFeePerGas,
|
|
1465
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
blockTag = prepBlockTag(blockTag);
|
|
1470
|
+
const rpcTransaction = prepareTransaction(transaction);
|
|
1471
|
+
const transactionRes = await this.post(buildRPCPostBody('eth_call', [rpcTransaction, blockTag]));
|
|
1472
|
+
return transactionRes;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
const promiseTimeout = (prom, time) => Promise.race([prom, new Promise((_r, reject) => setTimeout(() => reject('Promise timed out'), time))]);
|
|
1478
|
+
|
|
1479
|
+
const DEFAULT_TIMEOUT_DURATION = 8000;
|
|
1480
|
+
class FallthroughProvider extends BaseProvider {
|
|
1481
|
+
selectRpcUrl() {
|
|
1482
|
+
return this._rpcUrls[this.rpcUrlCounter];
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
constructor(rpcUrls, options = {}) {
|
|
1486
|
+
if (!Array.isArray(rpcUrls)) {
|
|
1487
|
+
logger.throwError('Array required', {
|
|
1488
|
+
rpcUrls
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
if (rpcUrls.length <= 1) {
|
|
1493
|
+
logger.throwError('More than one rpcUrl is required', {
|
|
1494
|
+
rpcUrls
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
super(rpcUrls);
|
|
1499
|
+
this.rpcUrlCounter = 0;
|
|
1500
|
+
this.timeoutDuration = void 0;
|
|
1501
|
+
|
|
1502
|
+
this.post = body => {
|
|
1503
|
+
const genesisCount = this.rpcUrlCounter;
|
|
1504
|
+
|
|
1505
|
+
const recursivePostRetry = () => {
|
|
1506
|
+
const genesisRpcUrl = this.selectRpcUrl();
|
|
1507
|
+
const res = promiseTimeout(this._post(body), this.timeoutDuration).catch(e => {
|
|
1508
|
+
if (genesisRpcUrl === this.selectRpcUrl()) {
|
|
1509
|
+
this.rpcUrlCounter = (this.rpcUrlCounter + 1) % this._rpcUrls.length;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
if (this.rpcUrlCounter === genesisCount) {
|
|
1513
|
+
throw e;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
return recursivePostRetry();
|
|
1517
|
+
});
|
|
1518
|
+
return res;
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
return recursivePostRetry();
|
|
1522
|
+
};
|
|
1523
|
+
|
|
1524
|
+
this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
class JsonRpcProvider extends BaseProvider {
|
|
1530
|
+
selectRpcUrl() {
|
|
1531
|
+
return this._rpcUrls[0];
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
post(body) {
|
|
1535
|
+
return this._post(body);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
constructor(rpcUrl = 'https://free-eth-node.com/api/eth') {
|
|
1539
|
+
super([rpcUrl]);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
}
|
|
1543
|
+
function jsonRpcProvider(rpcUrl) {
|
|
1544
|
+
return new JsonRpcProvider(rpcUrl);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
function keccak256(data) {
|
|
1548
|
+
let bufferableData;
|
|
1549
|
+
|
|
1550
|
+
if (typeof data === 'string') {
|
|
1551
|
+
bufferableData = Buffer.from(data.replace(/^0x/, ''), 'hex');
|
|
1552
|
+
} else {
|
|
1553
|
+
bufferableData = Buffer.from(data);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
const keccak = new sha3.Keccak(256);
|
|
1557
|
+
const addressHash = '0x' + keccak.update(bufferableData).digest('hex');
|
|
1558
|
+
return addressHash;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
function computeAddress(key) {
|
|
1562
|
+
if (!key.startsWith('0x04') && !key.startsWith('0x03') && !key.startsWith('0x02')) {
|
|
1563
|
+
key = computePublicKey(key);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
return toChecksumAddress(hexDataSlice(keccak256(hexDataSlice(key, 1)), 12));
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
function computePublicKey(privKey) {
|
|
1570
|
+
privKey = hexlify(privKey).slice(2);
|
|
1571
|
+
return '0x' + secp256k1.Point.fromPrivateKey(privKey).toHex();
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function etherToGwei(etherQuantity) {
|
|
1575
|
+
validateType(etherQuantity, ['string', 'number', 'object']);
|
|
1576
|
+
const result = tinyBig(etherQuantity).times('1000000000');
|
|
1577
|
+
return tinyBig(result);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
function etherToWei(etherQuantity) {
|
|
1581
|
+
validateType(etherQuantity, ['string', 'number', 'object']);
|
|
1582
|
+
const result = tinyBig(etherQuantity).times('1000000000000000000');
|
|
1583
|
+
return tinyBig(result);
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
function gweiToEther(gweiQuantity) {
|
|
1587
|
+
validateType(gweiQuantity, ['string', 'number', 'object']);
|
|
1588
|
+
const result = tinyBig(gweiQuantity).div('1000000000');
|
|
1589
|
+
return tinyBig(result);
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
const messagePrefix = '\x19Ethereum Signed Message:\n';
|
|
1593
|
+
function hashMessage(message) {
|
|
1594
|
+
if (typeof message === 'string') {
|
|
1595
|
+
message = toUtf8Bytes(message);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
return keccak256(concat([toUtf8Bytes(messagePrefix), toUtf8Bytes(String(message.length)), message]));
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
function isAddress(address) {
|
|
1602
|
+
validateType(address, ['string']);
|
|
1603
|
+
|
|
1604
|
+
try {
|
|
1605
|
+
toChecksumAddress(address);
|
|
1606
|
+
return true;
|
|
1607
|
+
} catch (error) {
|
|
1608
|
+
return false;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
function splitSignature(signature) {
|
|
1613
|
+
const result = {
|
|
1614
|
+
r: '0x',
|
|
1615
|
+
s: '0x',
|
|
1616
|
+
_vs: '0x',
|
|
1617
|
+
recoveryParam: 0,
|
|
1618
|
+
v: 0,
|
|
1619
|
+
yParityAndS: '0x',
|
|
1620
|
+
compact: '0x'
|
|
1621
|
+
};
|
|
1622
|
+
|
|
1623
|
+
if (isBytesLike(signature)) {
|
|
1624
|
+
const bytes = arrayify(signature);
|
|
1625
|
+
|
|
1626
|
+
if (bytes.length === 64) {
|
|
1627
|
+
result.v = 27 + (bytes[32] >> 7);
|
|
1628
|
+
bytes[32] &= 0x7f;
|
|
1629
|
+
result.r = hexlify(bytes.slice(0, 32));
|
|
1630
|
+
result.s = hexlify(bytes.slice(32, 64));
|
|
1631
|
+
} else if (bytes.length === 65) {
|
|
1632
|
+
result.r = hexlify(bytes.slice(0, 32));
|
|
1633
|
+
result.s = hexlify(bytes.slice(32, 64));
|
|
1634
|
+
result.v = bytes[64];
|
|
1635
|
+
} else {
|
|
1636
|
+
logger.throwArgumentError('invalid signature string', 'signature', signature);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
if (result.v < 27) {
|
|
1640
|
+
if (result.v === 0 || result.v === 1) {
|
|
1641
|
+
result.v += 27;
|
|
1642
|
+
} else {
|
|
1643
|
+
logger.throwArgumentError('signature invalid v byte', 'signature', signature);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
result.recoveryParam = 1 - result.v % 2;
|
|
1648
|
+
|
|
1649
|
+
if (result.recoveryParam) {
|
|
1650
|
+
bytes[32] |= 0x80;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
result._vs = hexlify(bytes.slice(32, 64));
|
|
1654
|
+
} else {
|
|
1655
|
+
result.r = signature.r;
|
|
1656
|
+
result.s = signature.s;
|
|
1657
|
+
result.v = signature.v;
|
|
1658
|
+
result.recoveryParam = signature.recoveryParam;
|
|
1659
|
+
result._vs = signature._vs;
|
|
1660
|
+
|
|
1661
|
+
if (result._vs != null) {
|
|
1662
|
+
const vs_1 = zeroPad(arrayify(result._vs), 32);
|
|
1663
|
+
result._vs = hexlify(vs_1);
|
|
1664
|
+
const recoveryParam = vs_1[0] >= 128 ? 1 : 0;
|
|
1665
|
+
|
|
1666
|
+
if (result.recoveryParam == null) {
|
|
1667
|
+
result.recoveryParam = recoveryParam;
|
|
1668
|
+
} else if (result.recoveryParam !== recoveryParam) {
|
|
1669
|
+
logger.throwArgumentError('signature recoveryParam mismatch _vs', 'signature', signature);
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
vs_1[0] &= 0x7f;
|
|
1673
|
+
const s = hexlify(vs_1);
|
|
1674
|
+
|
|
1675
|
+
if (result.s == null) {
|
|
1676
|
+
result.s = s;
|
|
1677
|
+
} else if (result.s !== s) {
|
|
1678
|
+
logger.throwArgumentError('signature v mismatch _vs', 'signature', signature);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
if (result.recoveryParam == null) {
|
|
1683
|
+
if (result.v == null) {
|
|
1684
|
+
logger.throwArgumentError('signature missing v and recoveryParam', 'signature', signature);
|
|
1685
|
+
} else if (result.v === 0 || result.v === 1) {
|
|
1686
|
+
result.recoveryParam = result.v;
|
|
1687
|
+
} else {
|
|
1688
|
+
result.recoveryParam = 1 - result.v % 2;
|
|
1689
|
+
}
|
|
1690
|
+
} else {
|
|
1691
|
+
if (result.v == null) {
|
|
1692
|
+
result.v = 27 + result.recoveryParam;
|
|
1693
|
+
} else {
|
|
1694
|
+
const recId = result.v === 0 || result.v === 1 ? result.v : 1 - result.v % 2;
|
|
1695
|
+
|
|
1696
|
+
if (result.recoveryParam !== recId) {
|
|
1697
|
+
logger.throwArgumentError('signature recoveryParam mismatch v', 'signature', signature);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
if (result.r == null || !isHexString(result.r)) {
|
|
1703
|
+
logger.throwArgumentError('signature missing or invalid r', 'signature', signature);
|
|
1704
|
+
} else {
|
|
1705
|
+
result.r = hexZeroPad(result.r, 32);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
if (result.s == null || !isHexString(result.s)) {
|
|
1709
|
+
logger.throwArgumentError('signature missing or invalid s', 'signature', signature);
|
|
1710
|
+
} else {
|
|
1711
|
+
result.s = hexZeroPad(result.s, 32);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
const vs = arrayify(result.s);
|
|
1715
|
+
|
|
1716
|
+
if (vs[0] >= 128) {
|
|
1717
|
+
logger.throwArgumentError('signature s out of range', 'signature', signature);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
if (result.recoveryParam) {
|
|
1721
|
+
vs[0] |= 0x80;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
const _vs = hexlify(vs);
|
|
1725
|
+
|
|
1726
|
+
if (result._vs) {
|
|
1727
|
+
if (!isHexString(result._vs)) {
|
|
1728
|
+
logger.throwArgumentError('signature invalid _vs', 'signature', signature);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
result._vs = hexZeroPad(result._vs, 32);
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
if (result._vs == null) {
|
|
1735
|
+
result._vs = _vs;
|
|
1736
|
+
} else if (result._vs !== _vs) {
|
|
1737
|
+
logger.throwArgumentError('signature _vs mismatch v and s', 'signature', signature);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
result.yParityAndS = result._vs;
|
|
1742
|
+
result.compact = result.r + result.yParityAndS.substring(2);
|
|
1743
|
+
return result;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
function toUtf8Bytes(data) {
|
|
1747
|
+
return new Uint8Array(Buffer.from(data));
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
function weiToEther(weiQuantity) {
|
|
1751
|
+
validateType(weiQuantity, ['string', 'number', 'object']);
|
|
1752
|
+
|
|
1753
|
+
try {
|
|
1754
|
+
let _weiQuantity = weiQuantity;
|
|
1755
|
+
|
|
1756
|
+
if (typeof weiQuantity === 'string' && weiQuantity.slice(0, 2) === '0x') {
|
|
1757
|
+
_weiQuantity = BigInt(weiQuantity).toString();
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
const result = tinyBig(_weiQuantity).div('1000000000000000000');
|
|
1761
|
+
return tinyBig(result);
|
|
1762
|
+
} catch (error) {
|
|
1763
|
+
throw error;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
const regexBytes = new RegExp('^bytes([0-9]+)$');
|
|
1768
|
+
const regexNumber = new RegExp('^(u?int)([0-9]*)$');
|
|
1769
|
+
const regexArray = new RegExp('^(.*)\\[([0-9]*)\\]$');
|
|
1770
|
+
|
|
1771
|
+
function _pack(type, value, isArray) {
|
|
1772
|
+
switch (type) {
|
|
1773
|
+
case 'address':
|
|
1774
|
+
if (isArray) {
|
|
1775
|
+
return zeroPad(value, 32);
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
return arrayify(value);
|
|
1779
|
+
|
|
1780
|
+
case 'string':
|
|
1781
|
+
return buffer.Buffer.from(value);
|
|
1782
|
+
|
|
1783
|
+
case 'bytes':
|
|
1784
|
+
return arrayify(value);
|
|
1785
|
+
|
|
1786
|
+
case 'bool':
|
|
1787
|
+
value = value ? '0x01' : '0x00';
|
|
1788
|
+
|
|
1789
|
+
if (isArray) {
|
|
1790
|
+
return zeroPad(value, 32);
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
return arrayify(value);
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
let match = type.match(regexNumber);
|
|
1797
|
+
|
|
1798
|
+
if (match) {
|
|
1799
|
+
let size = parseInt(match[2] || '256');
|
|
1800
|
+
|
|
1801
|
+
if (match[2] && String(size) !== match[2] || size % 8 !== 0 || size === 0 || size > 256) {
|
|
1802
|
+
logger.throwArgumentError('invalid number type', 'type', type);
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
if (isArray) {
|
|
1806
|
+
size = 256;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
value = tinyBig(value).toTwos(size).toNumber();
|
|
1810
|
+
const hexValue = hexlify(value);
|
|
1811
|
+
return zeroPad(hexValue, size / 8);
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
match = type.match(regexBytes);
|
|
1815
|
+
|
|
1816
|
+
if (match) {
|
|
1817
|
+
const size = parseInt(match[1]);
|
|
1818
|
+
|
|
1819
|
+
if (String(size) !== match[1] || size === 0 || size > 32) {
|
|
1820
|
+
logger.throwArgumentError('invalid bytes type', 'type', type);
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
if (arrayify(value).byteLength !== size) {
|
|
1824
|
+
logger.throwArgumentError(`invalid value for ${type}`, 'value', value);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
if (isArray) {
|
|
1828
|
+
return arrayify((value + hexFalse).substring(0, 66));
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
return value;
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
match = type.match(regexArray);
|
|
1835
|
+
|
|
1836
|
+
if (match && Array.isArray(value)) {
|
|
1837
|
+
const baseType = match[1];
|
|
1838
|
+
const count = parseInt(match[2] || String(value.length));
|
|
1839
|
+
|
|
1840
|
+
if (count != value.length) {
|
|
1841
|
+
logger.throwArgumentError(`invalid array length for ${type}`, 'value', value);
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
const result = [];
|
|
1845
|
+
value.forEach(function (value) {
|
|
1846
|
+
result.push(_pack(baseType, value, true));
|
|
1847
|
+
});
|
|
1848
|
+
return concat(result);
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
return logger.throwArgumentError('invalid type', 'type', type);
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
function pack(types, values) {
|
|
1855
|
+
if (types.length != values.length) {
|
|
1856
|
+
logger.throwArgumentError('wrong number of values; expected ${ types.length }', 'values', values);
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
const tight = [];
|
|
1860
|
+
types.forEach(function (type, index) {
|
|
1861
|
+
tight.push(_pack(type, values[index]));
|
|
1862
|
+
});
|
|
1863
|
+
return hexlify(concat(tight));
|
|
1864
|
+
}
|
|
1865
|
+
function solidityKeccak256(types, values) {
|
|
1866
|
+
return keccak256(pack(types, values));
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
exports.BaseContract = BaseContract;
|
|
1870
|
+
exports.Contract = Contract;
|
|
1871
|
+
exports.FallthroughProvider = FallthroughProvider;
|
|
1872
|
+
exports.JsonRpcProvider = JsonRpcProvider;
|
|
1873
|
+
exports.TinyBig = TinyBig;
|
|
1874
|
+
exports.arrayify = arrayify;
|
|
1875
|
+
exports.computeAddress = computeAddress;
|
|
1876
|
+
exports.computePublicKey = computePublicKey;
|
|
1877
|
+
exports.concat = concat;
|
|
1878
|
+
exports.etherToGwei = etherToGwei;
|
|
1879
|
+
exports.etherToWei = etherToWei;
|
|
1880
|
+
exports.gweiToEther = gweiToEther;
|
|
1881
|
+
exports.hashMessage = hashMessage;
|
|
1882
|
+
exports.hexConcat = hexConcat;
|
|
1883
|
+
exports.hexDataLength = hexDataLength;
|
|
1884
|
+
exports.hexDataSlice = hexDataSlice;
|
|
1885
|
+
exports.hexStripZeros = hexStripZeros;
|
|
1886
|
+
exports.hexValue = hexValue;
|
|
1887
|
+
exports.hexZeroPad = hexZeroPad;
|
|
1888
|
+
exports.hexlify = hexlify;
|
|
1889
|
+
exports.isAddress = isAddress;
|
|
1890
|
+
exports.isBytes = isBytes;
|
|
1891
|
+
exports.isBytesLike = isBytesLike;
|
|
1892
|
+
exports.isHexString = isHexString;
|
|
1893
|
+
exports.jsonRpcProvider = jsonRpcProvider;
|
|
1894
|
+
exports.keccak256 = keccak256;
|
|
1895
|
+
exports.pack = pack;
|
|
1896
|
+
exports.solidityKeccak256 = solidityKeccak256;
|
|
1897
|
+
exports.splitSignature = splitSignature;
|
|
1898
|
+
exports.stripZeros = stripZeros;
|
|
1899
|
+
exports.tinyBig = tinyBig;
|
|
1900
|
+
exports.toChecksumAddress = toChecksumAddress;
|
|
1901
|
+
exports.toUtf8Bytes = toUtf8Bytes;
|
|
1902
|
+
exports.weiToEther = weiToEther;
|
|
1903
|
+
exports.zeroPad = zeroPad;
|
|
2
1904
|
//# sourceMappingURL=index.js.map
|