@dodoex/wallet-web3 0.0.43-16 → 0.0.43-2
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/DefaultJsonRpcProvider-cbd850bc.js +1 -0
- package/dist/__node-resolve_empty-c07e04b2.js +1 -0
- package/dist/__tslib-54b019af.js +1 -0
- package/dist/alchemy-provider-5870b6fa-077754c5.js +1 -0
- package/dist/alchemy-websocket-provider-213da986-3bfbc710.js +1 -0
- package/dist/blocto-46848faf.js +1 -0
- package/dist/bn-27b74013.js +1 -0
- package/dist/browser-ponyfill-9983e3af.js +1 -0
- package/dist/ccip-54b3b540.js +1 -0
- package/dist/cjs/DefaultJsonRpcProvider-4b2cbac3.cjs +1 -0
- package/dist/cjs/__node-resolve_empty-d89e5abe.cjs +1 -0
- package/dist/cjs/__tslib-2cb2dc52.cjs +1 -0
- package/dist/cjs/alchemy-provider-5870b6fa-1e0f04fc.cjs +1 -0
- package/dist/cjs/alchemy-websocket-provider-213da986-14086d26.cjs +1 -0
- package/dist/cjs/blocto-b08bae37.cjs +1 -0
- package/dist/cjs/bn-2fd35ed6.cjs +1 -0
- package/dist/cjs/browser-ponyfill-479139d5.cjs +1 -0
- package/dist/cjs/ccip-ffbee020.cjs +1 -0
- package/dist/cjs/{draggabilly-6ecd1d28.cjs → draggabilly-9347a024.cjs} +1 -1
- package/dist/cjs/ethers-6c134a78.cjs +1 -0
- package/dist/cjs/id-306822a4.cjs +1 -0
- package/dist/cjs/index-0c3f7f0d.cjs +1 -0
- package/dist/cjs/index-0e02422e.cjs +1 -0
- package/dist/{index-0513e323.js → cjs/index-123203f3.cjs} +2 -2
- package/dist/cjs/index-21f1272b.cjs +1 -0
- package/dist/cjs/index-3ee0c164.cjs +15 -0
- package/dist/cjs/index-449eebb0.cjs +1 -0
- package/dist/cjs/index-4b751ebb.cjs +9 -0
- package/dist/cjs/index-584ce2f2.cjs +1 -0
- package/dist/cjs/index-630bda42.cjs +1 -0
- package/dist/cjs/index-891edc27.cjs +6 -0
- package/dist/cjs/{index-cd2ab657.cjs → index-a4d7eb55.cjs} +2 -2
- package/dist/cjs/index-c8612d96.cjs +20 -0
- package/dist/cjs/index-d890bb01.cjs +1 -0
- package/dist/cjs/index-e373c760.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.es-1a08ac77.cjs +9 -0
- package/dist/cjs/{interface-aa401a68.cjs → interface-ca8f7e00.cjs} +1 -1
- package/dist/cjs/{lib-typedarrays-e12c64c0.cjs → lib-typedarrays-b3b1a9b2.cjs} +1 -1
- package/dist/cjs/{portis-bcfda7d2.cjs → portis-2628aa40.cjs} +1 -1
- package/dist/cjs/provider-ed5b8d31.cjs +1 -0
- package/dist/cjs/providers/connector/alchemy/index.d.ts +0 -778
- package/dist/cjs/providers/connector/alchemy/provider.d.ts +45 -819
- package/dist/cjs/providers/connector/index.d.ts +0 -776
- package/dist/cjs/providers/connector/types.d.ts +3 -1
- package/dist/cjs/providers/wallets/standalone.d.ts +0 -1
- package/dist/cjs/rainbow-66ff0e60.cjs +1 -0
- package/dist/cjs/{sha224-e12b762e.cjs → sha224-e08c8475.cjs} +1 -1
- package/dist/cjs/sha256-ff3785f0.cjs +1 -0
- package/dist/cjs/uAuth-1c63d29f.cjs +1 -0
- package/dist/cjs/walletConnect-c94a63a7.cjs +1 -0
- package/dist/cjs/walletLink-24367174.cjs +3 -0
- package/dist/{draggabilly-498d38e9.js → draggabilly-e394dd03.js} +1 -1
- package/dist/ethers-33678100.js +1 -0
- package/dist/id-66098a37.js +1 -0
- package/dist/index-1fae0e53.js +1 -0
- package/dist/index-27bb4d53.js +1 -0
- package/dist/index-493358d6.js +1 -0
- package/dist/index-4f7c4b45.js +1 -0
- package/dist/{index-718c48ae.js → index-578e2937.js} +2 -2
- package/dist/index-5b79ce49.js +1 -0
- package/dist/index-6aa8c5c1.js +1 -0
- package/dist/index-75067bb0.js +15 -0
- package/dist/index-76c2f135.js +9 -0
- package/dist/index-81e6d2c8.js +20 -0
- package/dist/index-9dc69b05.js +1 -0
- package/dist/{cjs/index-0ee34d28.cjs → index-cd748d86.js} +2 -2
- package/dist/index-fb276f03.js +1 -0
- package/dist/{index-c4a6d64e.js → index-fe4c3da3.js} +2 -2
- package/dist/index.es-79e3646d.js +9 -0
- package/dist/index.js +1 -1
- package/dist/{interface-b846e20f.js → interface-2be6959d.js} +1 -1
- package/dist/{lib-typedarrays-76dcbec2.js → lib-typedarrays-0fb1b85c.js} +1 -1
- package/dist/{portis-1045f78a.js → portis-61fd1e59.js} +1 -1
- package/dist/provider-5ae74ef7.js +1 -0
- package/dist/providers/connector/alchemy/index.d.ts +0 -778
- package/dist/providers/connector/alchemy/provider.d.ts +45 -819
- package/dist/providers/connector/index.d.ts +0 -776
- package/dist/providers/connector/types.d.ts +3 -1
- package/dist/providers/wallets/standalone.d.ts +0 -1
- package/dist/rainbow-5edcbe7e.js +1 -0
- package/dist/sha224-ad024e21.js +1 -0
- package/dist/sha256-2a311540.js +1 -0
- package/dist/uAuth-70cae622.js +1 -0
- package/dist/walletConnect-526a0eb4.js +1 -0
- package/dist/{walletLink-84b7e914.js → walletLink-518a0d96.js} +2 -2
- package/package.json +8 -8
- package/dist/__tslib-7e1f95aa.js +0 -1
- package/dist/alchemy-provider-5870b6fa-0a352288.js +0 -1
- package/dist/alchemy-websocket-provider-213da986-395a73e5.js +0 -1
- package/dist/blocto-c9c400e3.js +0 -1
- package/dist/ccip-6bd0c6dd.js +0 -1
- package/dist/cjs/__tslib-65cfee6e.cjs +0 -1
- package/dist/cjs/alchemy-provider-5870b6fa-fcd41853.cjs +0 -1
- package/dist/cjs/alchemy-websocket-provider-213da986-caaf1af8.cjs +0 -1
- package/dist/cjs/blocto-8d29cd04.cjs +0 -1
- package/dist/cjs/ccip-b74ac658.cjs +0 -1
- package/dist/cjs/id-d2c2876b.cjs +0 -1
- package/dist/cjs/index-16cff674.cjs +0 -1
- package/dist/cjs/index-25304bed.cjs +0 -15
- package/dist/cjs/index-3e9b2c6d.cjs +0 -1
- package/dist/cjs/index-69a8663c.cjs +0 -1
- package/dist/cjs/index-85db795c.cjs +0 -6
- package/dist/cjs/index-908bd0e0.cjs +0 -28
- package/dist/cjs/index-bdfc10b7.cjs +0 -1
- package/dist/cjs/index-f3bb4b9f.cjs +0 -1
- package/dist/cjs/index.es-1ee6dff8.cjs +0 -9
- package/dist/cjs/provider-9671b91b.cjs +0 -1
- package/dist/cjs/rainbow-bffeca67.cjs +0 -1
- package/dist/cjs/sha256-87b3a64e.cjs +0 -1
- package/dist/cjs/typed-data-d8785f60.cjs +0 -1
- package/dist/cjs/uAuth-a31a7652.cjs +0 -1
- package/dist/cjs/walletConnect-0dfe31e9.cjs +0 -1
- package/dist/cjs/walletLink-81174e2e.cjs +0 -3
- package/dist/id-63f07629.js +0 -1
- package/dist/index-112c8642.js +0 -15
- package/dist/index-30305fa2.js +0 -1
- package/dist/index-7cb61612.js +0 -1
- package/dist/index-892198b7.js +0 -1
- package/dist/index-8ec766b6.js +0 -28
- package/dist/index-a09a186c.js +0 -1
- package/dist/index-ae7aa0ff.js +0 -1
- package/dist/index.es-37c96e8d.js +0 -9
- package/dist/provider-e830c3fd.js +0 -1
- package/dist/rainbow-ff982597.js +0 -1
- package/dist/sha224-59fa256e.js +0 -1
- package/dist/sha256-523c7af1.js +0 -1
- package/dist/typed-data-0b589cba.js +0 -1
- package/dist/uAuth-1dd65c6f.js +0 -1
- package/dist/walletConnect-f4aa9a5e.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StaticJsonRpcProvider as e}from"@ethersproject/providers";import{f as r}from"./index-1fae0e53.js";import{deepCopy as t}from"@ethersproject/properties";function o(e){if(e.error){const r=new Error(e.error.message);throw r.code=e.error.code,r.data=e.error.data,r}return e.result}class s extends e{getNetwork(){return"object"==typeof this.network&&"number"==typeof this.network.chainId?Promise.resolve(this.network):"number"==typeof this.network&&this.network?Promise.resolve({chainId:this.network,name:"unknown"}):super.getNetwork()}send(e,s){var i;const n={method:e,params:s,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:t(n),provider:this});const h=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(h&&this._cache[e])return this._cache[e];const c=r(Object.assign(Object.assign({},this.connection),{url:this.rpcUrl||(null===(i=this.connection)||void 0===i?void 0:i.url)}),JSON.stringify(n),o).then((e=>(this.emit("debug",{action:"response",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:n,provider:this}),e}));return h&&(this._cache[e]=c,setTimeout((()=>{this._cache[e]=null}),0)),c}}export{s as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./index-76c2f135.js";var r=e(Object.freeze({__proto__:null,default:{}}));export{r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as r,f as a}from"./index-76c2f135.js";var s=r(a);export{s as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e,C as t,a as r,N as n,I as i,V as s,_ as o,l as a,d as c,E as d,g as h,b as u}from"./index-81e6d2c8.js";import{L as l}from"./id-66098a37.js";import{JsonRpcProvider as m}from"@ethersproject/providers";import{f}from"./index-1fae0e53.js";import"@ethersproject/abstract-provider";import"@ethersproject/contracts";const p=new l("networks/5.7.1");function v(e){const t=function(t,r){null==r&&(r={});const n=[];if(t.InfuraProvider&&"-"!==r.infura)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider&&"-"!==r.etherscan)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.AlchemyProvider&&"-"!==r.alchemy)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.PocketProvider&&"-"!==r.pocket){const i=["goerli","ropsten","rinkeby","sepolia"];try{const s=new t.PocketProvider(e,r.pocket);s.network&&-1===i.indexOf(s.network.name)&&n.push(s)}catch(e){}}if(t.CloudflareProvider&&"-"!==r.cloudflare)try{n.push(new t.CloudflareProvider(e))}catch(e){}if(t.AnkrProvider&&"-"!==r.ankr)try{const i=["ropsten"],s=new t.AnkrProvider(e,r.ankr);s.network&&-1===i.indexOf(s.network.name)&&n.push(s)}catch(e){}if(0===n.length)return null;if(t.FallbackProvider){let i=1;return null!=r.quorum?i=r.quorum:"homestead"===e&&(i=2),new t.FallbackProvider(n,i)}return n[0]};return t.renetwork=function(e){return v(e)},t}function w(e,t){const r=function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null};return r.renetwork=function(t){return w(e,t)},r}const k={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:v("homestead")},g={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:v("ropsten")},b={chainId:63,name:"classicMordor",_defaultProvider:w("https://www.ethercluster.com/mordor","classicMordor")},I={unspecified:{chainId:0,name:"unspecified"},homestead:k,mainnet:k,morden:{chainId:2,name:"morden"},ropsten:g,testnet:g,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:v("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:v("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:v("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:v("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:w("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:b,classicTestnet:b,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:w("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:v("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:v("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function y(e){if(null==e)return null;if("number"==typeof e){for(const t in I){const r=I[t];if(r.chainId===e)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){const t=I[e];return null==t?null:{name:t.name,chainId:t.chainId,ensAddress:t.ensAddress,_defaultProvider:t._defaultProvider||null}}const t=I[e.name];if(!t)return"number"!=typeof e.chainId&&p.throwArgumentError("invalid network chainId","network",e),e;0!==e.chainId&&e.chainId!==t.chainId&&p.throwArgumentError("network chainId mismatch","network",e);let r=e._defaultProvider||null;var n;return null==r&&t._defaultProvider&&(r=(n=t._defaultProvider)&&"function"==typeof n.renetwork?t._defaultProvider.renetwork(e):t._defaultProvider),{name:e.name,chainId:t.chainId,ensAddress:e.ensAddress||t.ensAddress||null,_defaultProvider:r}}class P{constructor(e,t=100){this.sendBatchFn=e,this.maxBatchSize=t,this.pendingBatch=[]}enqueueRequest(e){return o(this,void 0,void 0,(function*(){const t={request:e,resolve:void 0,reject:void 0},r=new Promise(((e,r)=>{t.resolve=e,t.reject=r}));return this.pendingBatch.push(t),this.pendingBatch.length===this.maxBatchSize?this.sendBatchRequest():this.pendingBatchTimer||(this.pendingBatchTimer=setTimeout((()=>this.sendBatchRequest()),10)),r}))}sendBatchRequest(){return o(this,void 0,void 0,(function*(){const e=this.pendingBatch;this.pendingBatch=[],this.pendingBatchTimer&&(clearTimeout(this.pendingBatchTimer),this.pendingBatchTimer=void 0);const t=e.map((e=>e.request));return this.sendBatchFn(t).then((t=>{e.forEach(((e,r)=>{const n=t[r];if(n.error){const t=new Error(n.error.message);t.code=n.error.code,t.data=n.error.data,e.reject(t)}else e.resolve(n.result)}))}),(t=>{e.forEach((e=>{e.reject(t)}))}))}))}}class A extends m{constructor(e){const t=A.getApiKey(e.apiKey),r=A.getAlchemyNetwork(e.network),n=A.getAlchemyConnectionInfo(r,t,"http");void 0!==e.url&&(n.url=e.url),n.throttleLimit=e.maxRetries;super(n,d[r]),this.apiKey=e.apiKey,this.maxRetries=e.maxRetries,this.batchRequests=e.batchRequests;const i=Object.assign(Object.assign({},this.connection),{headers:Object.assign(Object.assign({},this.connection.headers),{"Alchemy-Ethers-Sdk-Method":"batchSend"})});this.batcher=new P((e=>f(i,JSON.stringify(e)))),this.modifyFormatter()}static getApiKey(t){if(null==t)return e;if(t&&"string"!=typeof t)throw new Error(`Invalid apiKey '${t}' provided. apiKey must be a string.`);return t}static getNetwork(e){return"string"==typeof e&&e in t?t[e]:y(e)}static getAlchemyNetwork(e){if(void 0===e)return r;if("number"==typeof e)throw new Error(`Invalid network '${e}' provided. Network must be a string.`);if(!Object.values(n).includes(e))throw new Error(`Invalid network '${e}' provided. Network must be one of: ${Object.values(n).join(", ")}.`);return e}static getAlchemyConnectionInfo(e,t,r){const n="http"===r?h(e,t):u(e,t);return{headers:i?{"Alchemy-Ethers-Sdk-Version":s}:{"Alchemy-Ethers-Sdk-Version":s,"Accept-Encoding":"gzip"},allowGzip:!0,url:n}}detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return o(this,void 0,void 0,(function*(){let t=this.network;if(null==t&&(t=yield e.detectNetwork.call(this),!t))throw new Error("No network detected");return t}))}_startPending(){a("WARNING: Alchemy Provider does not support pending filters")}isCommunityResource(){return this.apiKey===e}send(e,t){return this._send(e,t,"send")}_send(e,t,r,n=!1){const i={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};if(Object.assign({},this.connection).headers["Alchemy-Ethers-Sdk-Method"]=r,this.batchRequests||n)return this.batcher.enqueueRequest(i);this.emit("debug",{action:"request",request:c(i),provider:this});const s=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(s&&this._cache[e])return this._cache[e];const o=f(this.connection,JSON.stringify(i),_).then((e=>(this.emit("debug",{action:"response",request:i,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:i,provider:this}),e}));return s&&(this._cache[e]=o,setTimeout((()=>{this._cache[e]=null}),0)),o}modifyFormatter(){this.formatter.formats.receiptLog.removed=e=>{if("boolean"==typeof e)return e}}}function _(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}var E=Object.freeze({__proto__:null,AlchemyProvider:A});export{A,E as a,y as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,n as t,C as s,i as n,v as i,c as o,e as r,D as c,A as l,f as a,h,j as u,k as d,t as p,V as f,E as m}from"./index-81e6d2c8.js";import{A as b,g as v}from"./alchemy-provider-5870b6fa-077754c5.js";import{WebSocketProvider as y}from"@ethersproject/providers";import"@ethersproject/abstract-provider";import"@ethersproject/contracts";import{B as g}from"./id-66098a37.js";import"./index-76c2f135.js";import"zustand";import"events";import"@ethersproject/address";import"@ethersproject/constants";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"./index-6aa8c5c1.js";import"@ethersproject/abstract-signer";import"./index-1fae0e53.js";import"./bn-27b74013.js";import"./__node-resolve_empty-c07e04b2.js";import"./hash-b468659c.js";import"./inherits_browser-51bb8c3c.js";import"@ethersproject/json-wallets";import"./DefaultJsonRpcProvider-cbd850bc.js";import"./browser-ponyfill-9983e3af.js";import"buffer";import"./index-5b79ce49.js";var k={};Object.defineProperty(k,"__esModule",{value:!0});var w=function(){function e(t,s,n){if(void 0===n&&(n={}),this.url=t,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this.ondown=null,this.onreopen=null,this.CONNECTING=e.CONNECTING,this.OPEN=e.OPEN,this.CLOSING=e.CLOSING,this.CLOSED=e.CLOSED,this.hasBeenOpened=!1,this.isClosed=!1,this.messageBuffer=[],this.nextRetryTime=0,this.reconnectCount=0,this.lastKnownExtensions="",this.lastKnownProtocol="",this.listeners={},null==s||"string"==typeof s||Array.isArray(s)?this.protocols=s:n=s,this.options=I(n),!this.options.wsConstructor){if("undefined"==typeof WebSocket)throw new Error("WebSocket not present in global scope and no wsConstructor option was provided.");this.options.wsConstructor=WebSocket}this.openNewWebSocket()}return Object.defineProperty(e.prototype,"binaryType",{get:function(){return this.binaryTypeInternal||"blob"},set:function(e){this.binaryTypeInternal=e,this.ws&&(this.ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var e=this.ws?this.ws.bufferedAmount:0,t=!1;return this.messageBuffer.forEach((function(s){var n=function(e){return"string"==typeof e?2*e.length:e instanceof ArrayBuffer?e.byteLength:e instanceof Blob?e.size:void 0}(s);null!=n?e+=n:t=!0})),t&&this.debugLog("Some buffered data had unknown length. bufferedAmount() return value may be below the correct amount."),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this.ws?this.ws.extensions:this.lastKnownExtensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this.ws?this.ws.protocol:this.lastKnownProtocol},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this.isClosed?e.CLOSED:e.OPEN},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){this.disposeSocket(e,t),this.shutdown(),this.debugLog("WebSocket permanently closed by client.")},e.prototype.send=function(e){if(this.isClosed)throw new Error("WebSocket is already in CLOSING or CLOSED state.");this.ws&&this.ws.readyState===this.OPEN?this.ws.send(e):this.messageBuffer.push(e)},e.prototype.reconnect=function(){if(this.isClosed)throw new Error("Cannot call reconnect() on socket which is permanently closed.");this.disposeSocket(1e3,"Client requested reconnect."),this.handleClose(void 0)},e.prototype.addEventListener=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},e.prototype.dispatchEvent=function(e){return this.dispatchEventOfType(e.type,e)},e.prototype.removeEventListener=function(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter((function(e){return e!==t})))},e.prototype.openNewWebSocket=function(){var e=this;if(!this.isClosed){var t=this.options,s=t.connectTimeout,n=t.wsConstructor;this.debugLog("Opening new WebSocket to "+this.url+".");var i=new n(this.url,this.protocols);i.onclose=function(t){return e.handleClose(t)},i.onerror=function(t){return e.handleError(t)},i.onmessage=function(t){return e.handleMessage(t)},i.onopen=function(t){return e.handleOpen(t)},this.connectTimeoutId=setTimeout((function(){e.clearConnectTimeout(),e.disposeSocket(),e.handleClose(void 0)}),s),this.ws=i}},e.prototype.handleOpen=function(e){var t=this;if(this.ws&&!this.isClosed){var s=this.options.allClearResetTime;this.debugLog("WebSocket opened."),null!=this.binaryTypeInternal?this.ws.binaryType=this.binaryTypeInternal:this.binaryTypeInternal=this.ws.binaryType,this.clearConnectTimeout(),this.hasBeenOpened?this.dispatchEventOfType("reopen",e):(this.dispatchEventOfType("open",e),this.hasBeenOpened=!0),this.messageBuffer.forEach((function(e){return t.send(e)})),this.messageBuffer=[],this.allClearTimeoutId=setTimeout((function(){t.clearAllClearTimeout(),t.nextRetryTime=0,t.reconnectCount=0;var e=s/1e3|0;t.debugLog("WebSocket remained open for "+e+" seconds. Resetting retry time and count.")}),s)}},e.prototype.handleMessage=function(e){this.isClosed||this.dispatchEventOfType("message",e)},e.prototype.handleClose=function(e){var t=this;if(!this.isClosed){var s=this.options,n=s.maxReconnectAttempts,i=s.shouldReconnect;if(this.clearConnectTimeout(),this.clearAllClearTimeout(),this.ws&&(this.lastKnownExtensions=this.ws.extensions,this.lastKnownProtocol=this.ws.protocol,this.disposeSocket()),this.dispatchEventOfType("down",e),this.reconnectCount>=n)this.stopReconnecting(e,this.getTooManyFailedReconnectsMessage());else{var o=!e||i(e);"boolean"==typeof o?this.handleWillReconnect(o,e,"Provided shouldReconnect() returned false. Closing permanently."):o.then((function(s){t.isClosed||t.handleWillReconnect(s,e,"Provided shouldReconnect() resolved to false. Closing permanently.")}))}}},e.prototype.handleError=function(e){this.dispatchEventOfType("error",e),this.debugLog("WebSocket encountered an error.")},e.prototype.handleWillReconnect=function(e,t,s){e?this.reestablishConnection():this.stopReconnecting(t,s)},e.prototype.reestablishConnection=function(){var e=this,t=this.options,s=t.minReconnectDelay,n=t.maxReconnectDelay,i=t.reconnectBackoffFactor;this.reconnectCount++;var o=this.nextRetryTime;this.nextRetryTime=Math.max(s,Math.min(this.nextRetryTime*i,n)),setTimeout((function(){return e.openNewWebSocket()}),o);var r=o/1e3|0;this.debugLog("WebSocket was closed. Re-opening in "+r+" seconds.")},e.prototype.stopReconnecting=function(e,t){this.debugLog(t),this.shutdown(),e&&this.dispatchEventOfType("close",e)},e.prototype.shutdown=function(){this.isClosed=!0,this.clearAllTimeouts(),this.messageBuffer=[],this.disposeSocket()},e.prototype.disposeSocket=function(e,t){this.ws&&(this.ws.onerror=N,this.ws.onclose=N,this.ws.onmessage=N,this.ws.onopen=N,this.ws.close(e,t),this.ws=void 0)},e.prototype.clearAllTimeouts=function(){this.clearConnectTimeout(),this.clearAllClearTimeout()},e.prototype.clearConnectTimeout=function(){null!=this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=void 0)},e.prototype.clearAllClearTimeout=function(){null!=this.allClearTimeoutId&&(clearTimeout(this.allClearTimeoutId),this.allClearTimeoutId=void 0)},e.prototype.dispatchEventOfType=function(e,t){var s=this;switch(e){case"close":this.onclose&&this.onclose(t);break;case"error":this.onerror&&this.onerror(t);break;case"message":this.onmessage&&this.onmessage(t);break;case"open":this.onopen&&this.onopen(t);break;case"down":this.ondown&&this.ondown(t);break;case"reopen":this.onreopen&&this.onreopen(t)}return e in this.listeners&&this.listeners[e].slice().forEach((function(e){return s.callListener(e,t)})),!t||!t.defaultPrevented},e.prototype.callListener=function(e,t){"function"==typeof e?e.call(this,t):e.handleEvent.call(this,t)},e.prototype.debugLog=function(e){this.options.debug&&console.log(e)},e.prototype.getTooManyFailedReconnectsMessage=function(){var e,t=this.options.maxReconnectAttempts;return"Failed to reconnect after "+t+" "+(e="attempt",(1===t?e:e+"s")+". Closing permanently.")},e.DEFAULT_OPTIONS={allClearResetTime:5e3,connectTimeout:5e3,debug:!1,minReconnectDelay:1e3,maxReconnectDelay:3e4,maxReconnectAttempts:Number.POSITIVE_INFINITY,reconnectBackoffFactor:1.5,shouldReconnect:function(){return!0},wsConstructor:void 0},e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}(),E=k.default=w;function I(e){var t={};return Object.keys(w.DEFAULT_OPTIONS).forEach((function(s){var n=e[s];t[s]=void 0===n?w.DEFAULT_OPTIONS[s]:n})),t}function N(){}class B{constructor(e){this.provider=e,this.maxBackfillBlocks=120}getNewHeadsBackfill(t,s,n){return e(this,void 0,void 0,(function*(){O(t);const e=yield this.getBlockNumber();if(O(t),0===s.length)return this.getHeadEventsInRange(Math.max(n,e-this.maxBackfillBlocks)+1,e+1);const i=d(s[s.length-1].number),o=e-this.maxBackfillBlocks+1;if(i<=o)return this.getHeadEventsInRange(o,e+1);const r=yield this.getReorgHeads(t,s);O(t);const c=yield this.getHeadEventsInRange(i+1,e+1);return O(t),[...r,...c]}))}getLogsBackfill(t,s,n,i){return e(this,void 0,void 0,(function*(){O(t);const e=yield this.getBlockNumber();if(O(t),0===n.length)return this.getLogsInRange(s,Math.max(i,e-this.maxBackfillBlocks)+1,e+1);const o=d(n[n.length-1].blockNumber),r=e-this.maxBackfillBlocks+1;if(o<r)return this.getLogsInRange(s,r,e+1);const c=yield this.getCommonAncestor(t,n);O(t);const l=n.filter((e=>d(e.blockNumber)>c.blockNumber)).map((e=>Object.assign(Object.assign({},e),{removed:!0}))),a=c.blockNumber===Number.NEGATIVE_INFINITY?d(n[0].blockNumber):c.blockNumber;let h=yield this.getLogsInRange(s,a,e+1);return h=h.filter((e=>e&&(d(e.blockNumber)>c.blockNumber||d(e.logIndex)>c.logIndex))),O(t),[...l,...h]}))}setMaxBackfillBlock(e){this.maxBackfillBlocks=e}getBlockNumber(){return e(this,void 0,void 0,(function*(){const e=yield this.provider.send("eth_blockNumber");return d(e)}))}getHeadEventsInRange(t,s){return e(this,void 0,void 0,(function*(){if(t>=s)return[];const e=[];for(let n=t;n<s;n++)e.push({method:"eth_getBlockByNumber",params:[p(n),!1]});return(yield this.provider.sendBatch(e)).map(_)}))}getReorgHeads(t,s){return e(this,void 0,void 0,(function*(){const e=[];for(let n=s.length-1;n>=0;n--){const i=s[n],o=yield this.getBlockByNumber(d(i.number));if(O(t),i.hash===o.hash)break;e.push(_(o))}return e.reverse()}))}getBlockByNumber(t){return e(this,void 0,void 0,(function*(){return this.provider.send("eth_getBlockByNumber",[p(t),!1])}))}getCommonAncestor(t,s){return e(this,void 0,void 0,(function*(){let e=yield this.getBlockByNumber(d(s[s.length-1].blockNumber));O(t);for(let t=s.length-1;t>=0;t--){const n=s[t];if(n.blockNumber!==e.number&&(e=yield this.getBlockByNumber(d(n.blockNumber))),n.blockHash===e.hash)return{blockNumber:d(n.blockNumber),logIndex:d(n.logIndex)}}return{blockNumber:Number.NEGATIVE_INFINITY,logIndex:Number.NEGATIVE_INFINITY}}))}getLogsInRange(t,s,n){return e(this,void 0,void 0,(function*(){if(s>=n)return[];const e=Object.assign(Object.assign({},t),{fromBlock:p(s),toBlock:p(n-1)});return this.provider.send("eth_getLogs",[e])}))}}function _(e){const t=Object.assign({},e);return delete t.totalDifficulty,delete t.transactions,delete t.uncles,t}function T(e,t){const s=new Set,n=[];return e.forEach((e=>{const i=t(e);s.has(i)||(s.add(i),n.push(e))})),n}const C=new Error("Cancelled");function O(e){if(e())throw C}const A=10;class S extends y{constructor(s,n){var i;const o=b.getApiKey(s.apiKey),r=b.getAlchemyNetwork(s.network),c=b.getAlchemyConnectionInfo(r,o,"wss"),l=`alchemy-sdk-${f}`;super(new E(null!==(i=s.url)&&void 0!==i?i:c.url,l,{wsConstructor:null!=n?n:"undefined"!=typeof process&&null!=process&&null!=process.versions&&null!=process.versions.node?require("websocket").w3cwebsocket:WebSocket}),m[r]),this._events=[],this.virtualSubscriptionsById=new Map,this.virtualIdsByPhysicalId=new Map,this.handleMessage=e=>{const t=JSON.parse(e.data);if(!function(e){return!function(e){return Array.isArray(e)||"2.0"===e.jsonrpc&&void 0!==e.id}(e)}(t))return;const s=t.params.subscription,n=this.virtualIdsByPhysicalId.get(s);if(!n)return;const i=this.virtualSubscriptionsById.get(n);if("eth_subscribe"===i.method)switch(i.params[0]){case"newHeads":{const e=i,o=t,{isBackfilling:r,backfillBuffer:c}=e,{result:l}=o.params;r?function(e,t){D(e,t,F)}(c,l):s!==n?this.emitAndRememberEvent(n,l,F):this.rememberEvent(n,l,F);break}case"logs":{const e=i,o=t,{isBackfilling:r,backfillBuffer:c}=e,{result:l}=o.params;r?function(e,t){D(e,t,M)}(c,l):n!==s?this.emitAndRememberEvent(n,l,M):this.rememberEvent(n,l,M);break}default:if(s!==n){const{result:e}=t.params;this.emitEvent(n,e)}}},this.handleReopen=()=>{this.virtualIdsByPhysicalId.clear();const{cancel:t,isCancelled:s}=function(){let e=!1;return{cancel:()=>e=!0,isCancelled:()=>e}}();this.cancelBackfill=t;for(const t of this.virtualSubscriptionsById.values())(()=>{e(this,void 0,void 0,(function*(){try{yield this.resubscribeAndBackfill(s,t)}catch(e){s()||console.error(`Error while backfilling "${t.params[0]}" subscription. Some events may be missing.`,e)}}))})();this.startHeartbeat()},this.stopHeartbeatAndBackfill=()=>{null!=this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.cancelBackfill()},this.apiKey=o,this.backfiller=new B(this),this.addSocketListeners(),this.startHeartbeat(),this.cancelBackfill=t}static getNetwork(e){return"string"==typeof e&&e in s?s[e]:v(e)}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}off(e,t){return n(e)?this._off(e,t):super.off(e,t)}removeAllListeners(e){return void 0!==e&&n(e)?this._removeAllListeners(e):super.removeAllListeners(e)}listenerCount(e){return void 0!==e&&n(e)?this._listenerCount(e):super.listenerCount(e)}listeners(e){return void 0!==e&&n(e)?this._listeners(e):super.listeners(e)}_addEventListener(e,t,s){if(n(e)){i(e);const n=new o(r(e),t,s);return this._events.push(n),this._startEvent(n),this}return super._addEventListener(e,t,s)}_startEvent(e){[...l,"block","filter"].includes(e.type)?this.customStartEvent(e):super._startEvent(e)}_subscribe(t,s,n,i){return e(this,void 0,void 0,(function*(){let e=this._subIds[t];const o=yield this.getBlockNumber();null==e&&(e=Promise.all(s).then((e=>this.send("eth_subscribe",e))),this._subIds[t]=e);const r=yield e,c=yield Promise.all(s);this.virtualSubscriptionsById.set(r,{event:i,method:"eth_subscribe",params:c,startingBlockNumber:o,virtualId:r,physicalId:r,sentEvents:[],isBackfilling:!1,backfillBuffer:[]}),this.virtualIdsByPhysicalId.set(r,r),this._subs[r]={tag:t,processFunc:n}}))}emit(e,...t){if(n(e)){let s=!1;const n=[],i=r(e);return this._events=this._events.filter((e=>e.tag!==i||(setTimeout((()=>{e.listener.apply(this,t)}),0),s=!0,!e.once||(n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),s}return super.emit(e,...t)}sendBatch(t){return e(this,void 0,void 0,(function*(){let e=0;const s=t.map((({method:t,params:s})=>({method:t,params:s,jsonrpc:"2.0",id:"alchemy-sdk:"+e++})));return this.sendBatchConcurrently(s)}))}destroy(){return this.removeSocketListeners(),this.stopHeartbeatAndBackfill(),super.destroy()}isCommunityResource(){return this.apiKey===c}_stopEvent(e){let t=e.tag;if(l.includes(e.type)){if(this._events.filter((e=>l.includes(e.type))).length)return}else if("tx"===e.type){if(this._events.filter((e=>"tx"===e.type)).length)return;t="tx"}else if(this.listenerCount(e.event))return;const s=this._subIds[t];s&&(delete this._subIds[t],s.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}addSocketListeners(){this._websocket.addEventListener("message",this.handleMessage),this._websocket.addEventListener("reopen",this.handleReopen),this._websocket.addEventListener("down",this.stopHeartbeatAndBackfill)}removeSocketListeners(){this._websocket.removeEventListener("message",this.handleMessage),this._websocket.removeEventListener("reopen",this.handleReopen),this._websocket.removeEventListener("down",this.stopHeartbeatAndBackfill)}resubscribeAndBackfill(t,s){return e(this,void 0,void 0,(function*(){const{virtualId:e,method:n,params:i,sentEvents:o,backfillBuffer:r,startingBlockNumber:c}=s;s.isBackfilling=!0,r.length=0;try{const l=yield this.send(n,i);switch(O(t),s.physicalId=l,this.virtualIdsByPhysicalId.set(l,e),i[0]){case"newHeads":{const s=yield P((()=>H(this.backfiller.getNewHeadsBackfill(t,o,c),6e4)),5,(()=>!t()));O(t);(function(e){return T(e,(e=>e.hash))})([...s,...r]).forEach((t=>this.emitNewHeadsEvent(e,t)));break}case"logs":{const s=i[1]||{},n=yield P((()=>H(this.backfiller.getLogsBackfill(t,s,o,c),6e4)),5,(()=>!t()));O(t);(function(e){return T(e,(e=>`${e.blockHash}/${e.logIndex}`))})([...n,...r]).forEach((t=>this.emitLogsEvent(e,t)));break}}}finally{s.isBackfilling=!1,r.length=0}}))}emitNewHeadsEvent(e,t){this.emitAndRememberEvent(e,t,F)}emitLogsEvent(e,t){this.emitAndRememberEvent(e,t,M)}emitAndRememberEvent(e,t,s){this.rememberEvent(e,t,s),this.emitEvent(e,t)}emitEvent(e,t){const s=this.virtualSubscriptionsById.get(e);s&&this.emitGenericEvent(s,t)}rememberEvent(e,t,s){const n=this.virtualSubscriptionsById.get(e);n&&D(n.sentEvents,Object.assign({},t),s)}emitGenericEvent(e,t){this.emitProcessFn(e.event)(t)}startHeartbeat(){null==this.heartbeatIntervalId&&(this.heartbeatIntervalId=setInterval((()=>e(this,void 0,void 0,(function*(){try{yield H(this.send("net_version"),1e4)}catch(e){this._websocket.reconnect()}}))),3e4))}sendBatchConcurrently(t){return e(this,void 0,void 0,(function*(){return Promise.all(t.map((e=>this.send(e.method,e.params))))}))}customStartEvent(e){if(e.type===a){const{fromAddress:t,toAddress:s,hashesOnly:n}=e;this._subscribe(e.tag,[h.PENDING_TRANSACTIONS,{fromAddress:t,toAddress:s,hashesOnly:n}],this.emitProcessFn(e),e)}else if(e.type===u){const{addresses:t,includeRemoved:s,hashesOnly:n}=e;this._subscribe(e.tag,[h.MINED_TRANSACTIONS,{addresses:t,includeRemoved:s,hashesOnly:n}],this.emitProcessFn(e),e)}else"block"===e.type?this._subscribe("block",["newHeads"],this.emitProcessFn(e),e):"filter"===e.type&&this._subscribe(e.tag,["logs",this._getFilter(e.filter)],this.emitProcessFn(e),e)}emitProcessFn(e){switch(e.type){case a:return t=>this.emit({method:h.PENDING_TRANSACTIONS,fromAddress:e.fromAddress,toAddress:e.toAddress,hashesOnly:e.hashesOnly},t);case u:return t=>this.emit({method:h.MINED_TRANSACTIONS,addresses:e.addresses,includeRemoved:e.includeRemoved,hashesOnly:e.hashesOnly},t);case"block":return e=>{const t=g.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)};case"filter":return t=>{null==t.removed&&(t.removed=!1),this.emit(e.filter,this.formatter.filterLog(t))};default:throw new Error("Invalid event type to `emitProcessFn()`")}}_off(e,t){if(null==t)return this.removeAllListeners(e);const s=[];let n=!1;const i=r(e);return this._events=this._events.filter((e=>e.tag!==i||e.listener!=t||(!!n||(n=!0,s.push(e),!1)))),s.forEach((e=>{this._stopEvent(e)})),this}_removeAllListeners(e){let t=[];if(null==e)t=this._events,this._events=[];else{const s=r(e);this._events=this._events.filter((e=>e.tag!==s||(t.push(e),!1)))}return t.forEach((e=>{this._stopEvent(e)})),this}_listenerCount(e){if(!e)return this._events.length;const t=r(e);return this._events.filter((e=>e.tag===t)).length}_listeners(e){if(null==e)return this._events.map((e=>e.listener));const t=r(e);return this._events.filter((e=>e.tag===t)).map((e=>e.listener))}}const R=1e3,L=2,x=3e4;function P(t,s,n=(()=>!0)){return e(this,void 0,void 0,(function*(){let e=0,i=0;for(;;)try{return yield t()}catch(t){if(i++,i>=s||!n(t))throw t;if(yield j(e),!n(t))throw t;e=0===e?R:Math.min(x,L*e)}}))}function j(e){return new Promise((t=>setTimeout(t,e)))}function H(e,t){return Promise.race([e,new Promise(((e,s)=>setTimeout((()=>s(new Error("Timeout"))),t)))])}function F(e){return d(e.number)}function M(e){return d(e.blockNumber)}function D(e,t,s){const n=s(t),i=e.findIndex((e=>s(e)>n-A));-1===i?e.length=0:e.splice(0,i),e.push(t)}export{S as AlchemyWebSocketProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,d as t}from"./index-76c2f135.js";import"@ethersproject/providers";import"zustand";import"events";import"@ethersproject/address";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";function r(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))}function n(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function i(e,t){if(!e)throw new Error(t)}var o,s;"function"==typeof SuppressedError&&SuppressedError,function(e){e.prod="BLOCTO_SDK",e.dev="BLOCTO_SDK_DEV",e.staging="BLOCTO_SDK_STAGING"}(o||(o={})),function(e){e.ETHEREUM="ethereum",e.APTOS="aptos"}(s||(s={}));const a={56:"https://bsc-dataseed1.binance.org",97:"https://data-seed-prebsc-1-s1.binance.org:8545",137:"https://rpc-mainnet.maticvigil.com/",80001:"https://rpc-mumbai.matic.today/",43114:"https://api.avax.network/ext/bc/C/rpc",43113:"https://api.avax-test.network/ext/bc/C/rpc",42161:"https://arb1.arbitrum.io/rpc",421613:"https://endpoints.omniatech.io/v1/arbitrum/goerli/public",421614:"https://arbitrum-sepolia.blockpi.network/v1/rpc/public",10:"https://mainnet.optimism.io",420:"https://goerli.optimism.io",11155420:"https://sepolia.optimism.io",8453:"https://mainnet.base.org",84531:"https://goerli.base.org",84532:"https://sepolia.base.org",7777777:"https://rpc.zora.energy",999:"https://testnet.rpc.zora.energy",999999999:"https://sepolia.rpc.zora.energy",534352:"https://rpc.scroll.io",534353:"https://alpha-rpc.scroll.io/l2",534351:"https://sepolia-rpc.scroll.io",59144:"https://rpc.linea.build",59140:"https://rpc.goerli.linea.build",1261120:"https://rpc.startale.com/zkatana"},u={prod:"https://wallet-v2.blocto.app",staging:"https://wallet-v2-staging.blocto.app",dev:"https://wallet-v2-dev.blocto.app"},c={prod:o.prod,staging:o.staging,dev:o.dev},h={1:o.prod,2:o.dev,3:o.dev,4:o.dev,5:o.staging},d={1:"https://wallet-v2.blocto.app",2:"https://wallet-v2-dev.blocto.app",3:"https://wallet-v2-dev.blocto.app",4:"https://wallet-v2-dev.blocto.app",5:"https://wallet-v2-staging.blocto.app"};var l;!function(e){e.Mainnet="mainnet",e.Testnet="testnet",e.Devnet="devnet",e.Testing="testing",e.Premainnet="premainnet"}(l||(l={}));const f={1:l.Mainnet,2:l.Testnet,3:l.Devnet,4:l.Testing,5:l.Premainnet},p={1:"https://fullnode.mainnet.aptoslabs.com/v1",2:"https://fullnode.testnet.aptoslabs.com/v1",3:"https://fullnode.devnet.aptoslabs.com/v1",4:"",5:"https://premainnet.aptosdev.com/v1"},v=["connect","disconnect","message","chainChanged","accountsChanged"],g="00000000-0000-0000-0000-000000000000",y="0.9.1";class m{constructor(){this.isBlocto=!0,this.isConnecting=!1,this.eventListeners={},this.off=this.removeListener,v.forEach((e=>{this.eventListeners[e]=[]})),this.appId=g}request(e){return r(this,void 0,void 0,(function*(){}))}on(e,t){v.includes(e)&&this.eventListeners[e].push(t)}once(){}removeListener(e,t){const r=this.eventListeners[e].findIndex((e=>e===t));-1!==r&&this.eventListeners[e].splice(r,1)}}function w(e){const t=document.createElement("iframe");return t.setAttribute("src",e),t.setAttribute("style","width:100vw;height:100%;position:fixed;top:0;left:0;z-index:2147483646;border:none;box-sizing:border-box;color-scheme:light;inset:0px;display:block;pointer-events:auto;"),t}function b(e){document.body.appendChild(e)}function E(e){const t=e&&e.parentNode;t&&t.removeChild instanceof Function&&t.removeChild(e)}var S=(e,t,r=window)=>{r.addEventListener(e,(function n(i){t(i,(()=>r.removeEventListener(e,n)))}))};const _="undefined"!=typeof window?window.memoryStorage:new class{constructor(){this.storage={}}getItem(e){return this[e]||null}setItem(e,t){this.storage[e]=t}removeItem(e){delete this.storage[e]}},A=(()=>{if("undefined"==typeof window)return!1;try{window.sessionStorage.setItem("local_storage_supported","1");const e=window.sessionStorage.getItem("local_storage_supported");return window.sessionStorage.removeItem("local_storage_supported"),"1"===e}catch(e){return!1}})()?window.sessionStorage:_,O=(e,t=null)=>{const r=A.getItem(e);try{return r&&JSON.parse(r)||t}catch(e){return r||t}},R=(e,t)=>A.setItem(e,"string"==typeof t?t:JSON.stringify(t)),I=e=>{R(e,""),A.removeItem(e)},P=e=>{const t=O(e,null);return t?(new Date).getTime()>t.expiry||t.v!==y?(I(e),null):null==t?void 0:t.data:null},T=(e,t,r)=>{var n,i,o;const s=O(e),a={data:{code:(null==t?void 0:t.code)||(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n.code),accounts:Object.assign(Object.assign({},null===(i=null==s?void 0:s.data)||void 0===i?void 0:i.accounts),null==t?void 0:t.accounts),evm:Object.assign(Object.assign({},null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.evm),null==t?void 0:t.evm)},expiry:r||(null==s?void 0:s.expiry)||(new Date).getTime()+864e5,v:y};R(e,a)},C=(e,t)=>{var r,n,i;return(null===(r=P(e))||void 0===r?void 0:r.code)?(null===(i=null===(n=P(e))||void 0===n?void 0:n.accounts)||void 0===i?void 0:i[t])||null:(I(e),null)},N=(e,t)=>{var r,n,i;return(null===(r=P(e))||void 0===r?void 0:r.code)?(null===(i=null===(n=P(e))||void 0===n?void 0:n.evm)||void 0===i?void 0:i[t])||null:(I(e),null)},j=(e,t,r)=>{T(e,{evm:{[t]:r}})},D=e=>{const t=O(e);t&&(t.data.evm={},R(e,t))};function k(e,t,n){return r(this,void 0,void 0,(function*(){if(403!==e.status&&401!==e.status||(n&&n(),I(t)),!e.ok){const t=yield e.json(),r=new Error((null==t?void 0:t.message)||"unknown error");throw r.error_code=null==t?void 0:t.error_code,r}return e.json()}))}const x=e=>/\S+@\S+\.\S+/.test(e);var L;!function(e){e.INVALID_TRANSACTION="Invalid transaction",e.INVALID_TRANSACTIONS="Invalid transactions",e.INVALID_TRANSACTION_VALUE='Transaction params "value" should be hex-encoded string'}(L||(L={}));var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},U=[],K=[],B="undefined"!=typeof Uint8Array?Uint8Array:Array,q=!1;function $(){q=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)U[t]=e[t],K[e.charCodeAt(t)]=t;K["-".charCodeAt(0)]=62,K["_".charCodeAt(0)]=63}function V(e,t,r){for(var n,i,o=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(U[(i=n)>>18&63]+U[i>>12&63]+U[i>>6&63]+U[63&i]);return o.join("")}function Y(e){var t;q||$();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;a<u;a+=s)o.push(V(e,a,a+s>u?u:a+s));return 1===n?(t=e[r-1],i+=U[t>>2],i+=U[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=U[t>>10],i+=U[t>>4&63],i+=U[t<<2&63],i+="="),o.push(i),o.join("")}function F(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,d=r?i-1:0,l=r?-1:1,f=e[t+d];for(d+=l,o=f&(1<<-h)-1,f>>=-h,h+=a;h>0;o=256*o+e[t+d],d+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+d],d+=l,h-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),o-=c}return(f?-1:1)*s*Math.pow(2,o-n)}function z(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,h=(1<<c)-1,d=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+d>=1?l/u:l*Math.pow(2,1-d))*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+f]=255&s,f+=p,s/=256,c-=8);e[r+f-p]|=128*v}var J={}.toString,G=Array.isArray||function(e){return"[object Array]"==J.call(e)};function H(){return X.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function W(e,t){if(H()<t)throw new RangeError("Invalid typed array length");return X.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=X.prototype:(null===e&&(e=new X(t)),e.length=t),e}function X(e,t,r){if(!(X.TYPED_ARRAY_SUPPORT||this instanceof X))return new X(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return ee(this,e)}return Z(this,e,t,r)}function Z(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);X.TYPED_ARRAY_SUPPORT?(e=t).__proto__=X.prototype:e=te(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!X.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|ie(t,r);e=W(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(ne(t)){var r=0|re(t.length);return 0===(e=W(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?W(e,0):te(e,t);if("Buffer"===t.type&&G(t.data))return te(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Q(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function ee(e,t){if(Q(t),e=W(e,t<0?0:0|re(t)),!X.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function te(e,t){var r=t.length<0?0:0|re(t.length);e=W(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function re(e){if(e>=H())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+H().toString(16)+" bytes");return 0|e}function ne(e){return!(null==e||!e._isBuffer)}function ie(e,t){if(ne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Ne(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return je(e).length;default:if(n)return Ne(e).length;t=(""+t).toLowerCase(),n=!0}}function oe(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return be(this,t,r);case"utf8":case"utf-8":return ge(this,t,r);case"ascii":return me(this,t,r);case"latin1":case"binary":return we(this,t,r);case"base64":return ve(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ee(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function se(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function ae(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=X.from(t,n)),ne(t))return 0===t.length?-1:ue(e,t,r,n,i);if("number"==typeof t)return t&=255,X.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ue(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ue(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===u)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var d=!0,l=0;l<u;l++)if(c(e,o+l)!==c(t,l)){d=!1;break}if(d)return o}return-1}function ce(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function he(e,t,r,n){return De(Ne(t,e.length-r),e,r,n)}function de(e,t,r,n){return De(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function le(e,t,r,n){return de(e,t,r,n)}function fe(e,t,r,n){return De(je(t),e,r,n)}function pe(e,t,r,n){return De(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function ve(e,t,r){return 0===t&&r===e.length?Y(e):Y(e.slice(t,r))}function ge(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],h=null,d=c>239?4:c>223?3:c>191?2:1;if(i+d<=r)switch(d){case 1:c<128&&(h=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,d=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=d}return function(e){var t=e.length;if(t<=ye)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ye));return r}(n)}X.TYPED_ARRAY_SUPPORT=void 0===M.TYPED_ARRAY_SUPPORT||M.TYPED_ARRAY_SUPPORT,H(),X.poolSize=8192,X._augment=function(e){return e.__proto__=X.prototype,e},X.from=function(e,t,r){return Z(null,e,t,r)},X.TYPED_ARRAY_SUPPORT&&(X.prototype.__proto__=Uint8Array.prototype,X.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&X[Symbol.species]),X.alloc=function(e,t,r){return function(e,t,r,n){return Q(t),t<=0?W(e,t):void 0!==r?"string"==typeof n?W(e,t).fill(r,n):W(e,t).fill(r):W(e,t)}(null,e,t,r)},X.allocUnsafe=function(e){return ee(null,e)},X.allocUnsafeSlow=function(e){return ee(null,e)},X.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ke(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ke(e.slice(0,0))}(e))},X.compare=function(e,t){if(!ne(e)||!ne(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},X.isEncoding=function(e){switch(String(e).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}},X.concat=function(e,t){if(!G(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return X.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=X.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!ne(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},X.byteLength=ie,X.prototype._isBuffer=!0,X.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)se(this,t,t+1);return this},X.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)se(this,t,t+3),se(this,t+1,t+2);return this},X.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)se(this,t,t+7),se(this,t+1,t+6),se(this,t+2,t+5),se(this,t+3,t+4);return this},X.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?ge(this,0,e):oe.apply(this,arguments)},X.prototype.equals=function(e){if(!ne(e))throw new TypeError("Argument must be a Buffer");return this===e||0===X.compare(this,e)},X.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},X.prototype.compare=function(e,t,r,n,i){if(!ne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(u[h]!==c[h]){o=u[h],s=c[h];break}return o<s?-1:s<o?1:0},X.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},X.prototype.indexOf=function(e,t,r){return ae(this,e,t,r,!0)},X.prototype.lastIndexOf=function(e,t,r){return ae(this,e,t,r,!1)},X.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return ce(this,e,t,r);case"utf8":case"utf-8":return he(this,e,t,r);case"ascii":return de(this,e,t,r);case"latin1":case"binary":return le(this,e,t,r);case"base64":return fe(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},X.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ye=4096;function me(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function we(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function be(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=Ce(e[o]);return i}function Ee(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function Se(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function _e(e,t,r,n,i,o){if(!ne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function Ae(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function Oe(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function Re(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ie(e,t,r,n,i){return i||Re(e,0,r,4),z(e,t,r,n,23,4),r+4}function Pe(e,t,r,n,i){return i||Re(e,0,r,8),z(e,t,r,n,52,8),r+8}X.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),X.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=X.prototype;else{var i=t-e;r=new X(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},X.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||Se(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},X.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||Se(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},X.prototype.readUInt8=function(e,t){return t||Se(e,1,this.length),this[e]},X.prototype.readUInt16LE=function(e,t){return t||Se(e,2,this.length),this[e]|this[e+1]<<8},X.prototype.readUInt16BE=function(e,t){return t||Se(e,2,this.length),this[e]<<8|this[e+1]},X.prototype.readUInt32LE=function(e,t){return t||Se(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},X.prototype.readUInt32BE=function(e,t){return t||Se(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},X.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Se(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},X.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Se(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},X.prototype.readInt8=function(e,t){return t||Se(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},X.prototype.readInt16LE=function(e,t){t||Se(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},X.prototype.readInt16BE=function(e,t){t||Se(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},X.prototype.readInt32LE=function(e,t){return t||Se(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},X.prototype.readInt32BE=function(e,t){return t||Se(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},X.prototype.readFloatLE=function(e,t){return t||Se(e,4,this.length),F(this,e,!0,23,4)},X.prototype.readFloatBE=function(e,t){return t||Se(e,4,this.length),F(this,e,!1,23,4)},X.prototype.readDoubleLE=function(e,t){return t||Se(e,8,this.length),F(this,e,!0,52,8)},X.prototype.readDoubleBE=function(e,t){return t||Se(e,8,this.length),F(this,e,!1,52,8)},X.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||_e(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},X.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||_e(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},X.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,1,255,0),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},X.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ae(this,e,t,!0),t+2},X.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ae(this,e,t,!1),t+2},X.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Oe(this,e,t,!0),t+4},X.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Oe(this,e,t,!1),t+4},X.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);_e(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},X.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);_e(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},X.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,1,127,-128),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},X.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ae(this,e,t,!0),t+2},X.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ae(this,e,t,!1),t+2},X.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,4,2147483647,-2147483648),X.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Oe(this,e,t,!0),t+4},X.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||_e(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Oe(this,e,t,!1),t+4},X.prototype.writeFloatLE=function(e,t,r){return Ie(this,e,t,!0,r)},X.prototype.writeFloatBE=function(e,t,r){return Ie(this,e,t,!1,r)},X.prototype.writeDoubleLE=function(e,t,r){return Pe(this,e,t,!0,r)},X.prototype.writeDoubleBE=function(e,t,r){return Pe(this,e,t,!1,r)},X.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!X.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},X.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!X.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=ne(e)?e:Ne(new X(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var Te=/[^+\/0-9A-Za-z-_]/g;function Ce(e){return e<16?"0"+e.toString(16):e.toString(16)}function Ne(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function je(e){return function(e){var t,r,n,i,o,s;q||$();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new B(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t<n;t+=4,r+=3)i=K[e.charCodeAt(t)]<<18|K[e.charCodeAt(t+1)]<<12|K[e.charCodeAt(t+2)]<<6|K[e.charCodeAt(t+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=K[e.charCodeAt(t)]<<2|K[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=K[e.charCodeAt(t)]<<10|K[e.charCodeAt(t+1)]<<4|K[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Te,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function De(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function ke(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}const xe=e=>"string"==typeof e&&/^0x[0-9A-Fa-f]*$/.test(e),Le=e=>e&&"object"==typeof e&&"from"in e?e.value&&!xe(e.value)?{isValid:!1,invalidMsg:L.INVALID_TRANSACTION_VALUE}:{isValid:!0}:{isValid:!1,invalidMsg:L.INVALID_TRANSACTION};function Me(){return r(this,void 0,void 0,(function*(){const{networks:e}=yield fetch("https://api.blocto.app/networks/evm").then((e=>e.json()));return e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.chain_id]:t})),{})}))}var Ue={};function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Be(e){return Be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Be(e)}function qe(e){var t=function(e,t){if("object"!==Be(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Be(t)?t:String(t)}function $e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,qe(n.key),n)}}function Ve(e,t,r){return t&&$e(e.prototype,t),r&&$e(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ye(e,t){return Ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ye(e,t)}function Fe(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ye(e,t)}function ze(e,t){if(t&&("object"===Be(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Je(e){return Je=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Je(e)}function Ge(e,t,r){return Ge=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&Ye(i,r.prototype),i},Ge.apply(null,arguments)}function He(e){var t="function"==typeof Map?new Map:void 0;return He=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return Ge(e,arguments,Je(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ye(n,e)},He(e)}var We={},Xe=nt;nt.default=nt,nt.stable=at,nt.stableStringify=at;var Ze="[...]",Qe="[Circular]",et=[],tt=[];function rt(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function nt(e,t,r,n){var i;void 0===n&&(n=rt()),ot(e,"",0,[],void 0,0,n);try{i=0===tt.length?JSON.stringify(e,t,r):JSON.stringify(e,ct(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==et.length;){var o=et.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function it(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);void 0!==i.get?i.configurable?(Object.defineProperty(n,r,{value:e}),et.push([n,r,t,i])):tt.push([t,r,e]):(n[r]=e,et.push([n,r,t]))}function ot(e,t,r,n,i,o,s){var a;if(o+=1,"object"===Be(e)&&null!==e){for(a=0;a<n.length;a++)if(n[a]===e)return void it(Qe,e,t,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void it(Ze,e,t,i);if(void 0!==s.edgesLimit&&r+1>s.edgesLimit)return void it(Ze,e,t,i);if(n.push(e),Array.isArray(e))for(a=0;a<e.length;a++)ot(e[a],a,a,n,e,o,s);else{var u=Object.keys(e);for(a=0;a<u.length;a++){var c=u[a];ot(e[c],c,a,n,e,o,s)}}n.pop()}}function st(e,t){return e<t?-1:e>t?1:0}function at(e,t,r,n){void 0===n&&(n=rt());var i,o=ut(e,"",0,[],void 0,0,n)||e;try{i=0===tt.length?JSON.stringify(o,t,r):JSON.stringify(o,ct(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==et.length;){var s=et.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function ut(e,t,r,n,i,o,s){var a;if(o+=1,"object"===Be(e)&&null!==e){for(a=0;a<n.length;a++)if(n[a]===e)return void it(Qe,e,t,i);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void it(Ze,e,t,i);if(void 0!==s.edgesLimit&&r+1>s.edgesLimit)return void it(Ze,e,t,i);if(n.push(e),Array.isArray(e))for(a=0;a<e.length;a++)ut(e[a],a,a,n,e,o,s);else{var u={},c=Object.keys(e).sort(st);for(a=0;a<c.length;a++){var h=c[a];ut(e[h],h,a,n,e,o,s),u[h]=e[h]}if(void 0===i)return u;et.push([i,t,e]),i[t]=u}n.pop()}}function ct(e){return e=void 0!==e?e:function(e,t){return t},function(t,r){if(tt.length>0)for(var n=0;n<tt.length;n++){var i=tt[n];if(i[1]===t&&i[0]===r){r=i[2],tt.splice(n,1);break}}return e.call(this,t,r)}}function ht(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Je(e);if(t){var i=Je(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return ze(this,r)}}Object.defineProperty(We,"__esModule",{value:!0}),We.EthereumProviderError=We.EthereumRpcError=void 0;var dt=Xe,lt=function(e){Fe(r,He(Error));var t=ht(r);function r(e,n,i){var o;if(Ke(this,r),!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string.');return(o=t.call(this,n)).code=e,void 0!==i&&(o.data=i),o}return Ve(r,[{key:"serialize",value:function(){var e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}},{key:"toString",value:function(){return dt.default(this.serialize(),pt,2)}}]),r}();We.EthereumRpcError=lt;var ft=function(e){Fe(r,lt);var t=ht(r);function r(e,n,i){if(Ke(this,r),!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');return t.call(this,e,n,i)}return Ve(r)}();function pt(e,t){if("[Circular]"!==t)return t}We.EthereumProviderError=ft;var vt={},gt={};function yt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function mt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,s,a=[],u=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return yt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yt(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}Object.defineProperty(gt,"__esModule",{value:!0}),gt.errorValues=gt.errorCodes=void 0,gt.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},gt.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;var t=gt,r=We,n=t.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",o={code:n,message:s(n)};function s(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;if(Number.isInteger(r)){var o=r.toString();if(h(t.errorValues,o))return t.errorValues[o].message;if(u(r))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return n}function a(e){if(!Number.isInteger(e))return!1;var r=e.toString();return!!t.errorValues[r]||!!u(e)}function u(e){return e>=-32099&&e<=-32e3}function c(e){return e&&"object"===Be(e)&&!Array.isArray(e)?Object.assign({},e):e}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",e.getMessageFromCode=s,e.isValidCode=a,e.serializeError=function(e){var t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=i.fallbackError,d=void 0===u?o:u,l=i.shouldIncludeStack,f=void 0!==l&&l;if(!d||!Number.isInteger(d.code)||"string"!=typeof d.message)throw new Error("Must provide fallback error with integer number code and string message.");if(e instanceof r.EthereumRpcError)return e.serialize();var p={};if(e&&"object"===Be(e)&&!Array.isArray(e)&&h(e,"code")&&a(e.code)){var v=e;p.code=v.code,v.message&&"string"==typeof v.message?(p.message=v.message,h(v,"data")&&(p.data=v.data)):(p.message=s(p.code),p.data={originalError:c(e)})}else{p.code=d.code;var g=null===(t=e)||void 0===t?void 0:t.message;p.message=g&&"string"==typeof g?g:d.message,p.data={originalError:c(e)}}var y=null===(n=e)||void 0===n?void 0:n.stack;return f&&e&&y&&"string"==typeof y&&(p.stack=y),p}}(vt);var wt={};Object.defineProperty(wt,"__esModule",{value:!0}),wt.ethErrors=void 0;var bt,Et,St,_t,At,Ot=We,Rt=vt,It=gt;function Pt(e,t){var r=mt(Ct(t),2),n=r[0],i=r[1];return new Ot.EthereumRpcError(e,n||Rt.getMessageFromCode(e),i)}function Tt(e,t){var r=mt(Ct(t),2),n=r[0],i=r[1];return new Ot.EthereumProviderError(e,n||Rt.getMessageFromCode(e),i)}function Ct(e){if(e){if("string"==typeof e)return[e];if("object"===Be(e)&&!Array.isArray(e)){var t=e.message,r=e.data;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,r]}}return[]}function Nt(e){return e?"number"==typeof e?e:e.startsWith("0x")?parseInt(e,16):parseInt(e,10):1}wt.ethErrors={rpc:{parse:function(e){return Pt(It.errorCodes.rpc.parse,e)},invalidRequest:function(e){return Pt(It.errorCodes.rpc.invalidRequest,e)},invalidParams:function(e){return Pt(It.errorCodes.rpc.invalidParams,e)},methodNotFound:function(e){return Pt(It.errorCodes.rpc.methodNotFound,e)},internal:function(e){return Pt(It.errorCodes.rpc.internal,e)},server:function(e){if(!e||"object"!==Be(e)||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");var t=e.code;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return Pt(t,e)},invalidInput:function(e){return Pt(It.errorCodes.rpc.invalidInput,e)},resourceNotFound:function(e){return Pt(It.errorCodes.rpc.resourceNotFound,e)},resourceUnavailable:function(e){return Pt(It.errorCodes.rpc.resourceUnavailable,e)},transactionRejected:function(e){return Pt(It.errorCodes.rpc.transactionRejected,e)},methodNotSupported:function(e){return Pt(It.errorCodes.rpc.methodNotSupported,e)},limitExceeded:function(e){return Pt(It.errorCodes.rpc.limitExceeded,e)}},provider:{userRejectedRequest:function(e){return Tt(It.errorCodes.provider.userRejectedRequest,e)},unauthorized:function(e){return Tt(It.errorCodes.provider.unauthorized,e)},unsupportedMethod:function(e){return Tt(It.errorCodes.provider.unsupportedMethod,e)},disconnected:function(e){return Tt(It.errorCodes.provider.disconnected,e)},chainDisconnected:function(e){return Tt(It.errorCodes.provider.chainDisconnected,e)},custom:function(e){if(!e||"object"!==Be(e)||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");var t=e.code,r=e.message,n=e.data;if(!r||"string"!=typeof r)throw new Error('"message" must be a nonempty string');return new Ot.EthereumProviderError(t,r,n)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;var t=We;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});var r=vt;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});var n=wt;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});var i=gt;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(Ue);class jt extends m{get existedSDK(){if("undefined"!=typeof window)return window.ethereum}constructor(e){var t;if(super(),bt.add(this),this.networkVersion="1",this.off=this.removeListener,this.injectedWalletServer=e.walletServer,this._blocto={sessionKeyEnv:o.prod,walletServer:this.injectedWalletServer||"",blockchainName:"",networkType:"",switchableNetwork:{}},this.appId=e.appId||g,"chainId"in e){const{chainId:t,rpc:r}=e;i(t,"'chainId' is required"),this.networkVersion=`${Nt(t)}`,this.chainId=`0x${Nt(t).toString(16)}`,this.rpc=r||a[this.networkVersion],i(this.rpc,"'rpc' is required")}else{const{defaultChainId:r,switchableChains:n}=e;i(r,"'defaultChainId' is required"),this.networkVersion=`${Nt(r)}`,this.chainId=`0x${Nt(r).toString(16)}`;const o=n.find((e=>Nt(e.chainId)===Nt(r)));if(!o)throw Ue.ethErrors.provider.custom({code:1001,message:`Chain ${r} is not in switchableChains list`});this.rpc=(null===(t=o.rpcUrls)||void 0===t?void 0:t[0])||a[this.networkVersion],i(this.rpc,"'rpc' is required"),this._blocto.unloadedNetwork=n}}send(e,t){return r(this,void 0,void 0,(function*(){switch(!0){case t instanceof Function:return this.sendAsync(e,t);case"string"==typeof e&&Array.isArray(t):return this.sendAsync({jsonrpc:"2.0",method:e,params:t});default:return this.sendAsync(e)}}))}sendAsync(e,t){return r(this,void 0,void 0,(function*(){const r=e=>e.reduce(((e,t)=>{var r;return"eth_sendTransaction"===t.method?e.sendRequests.push(null===(r=t.params)||void 0===r?void 0:r[0]):e.otherRequests.push(this.request(t)),e}),{sendRequests:[],otherRequests:[]});function n(e,t){const r=[];let n=1;return e.forEach((e=>{const i=function(e){return{id:String(e.id),jsonrpc:"2.0",method:e.method}}(e);"eth_sendTransaction"===e.method?(i.result=t[0].value,i.error="fulfilled"!==t[0].status?t[0].reason:void 0):n<t.length&&(i.result=t[n].value,i.error="fulfilled"!==t[n].status?t[n].reason:void 0,n++),r.push(i)})),r}const i=new Promise((t=>{if(Array.isArray(e)){const{sendRequests:i,otherRequests:o}=r(e),s={method:"wallet_sendMultiCallTransaction",params:[i,!1]},a=0===i.length,u=Math.floor(1e4*Math.random()),c=a?[...o]:[this.request(s),...o];Promise.allSettled(c).then((r=>{if(a)return t(r.map(((t,r)=>{var n;return{id:String((null===(n=e[r])||void 0===n?void 0:n.id)||u+r+1),jsonrpc:"2.0",method:e[r].method,result:"fulfilled"===t.status?t.value:void 0,error:"fulfilled"!==t.status?t.reason:void 0}})));const i=n(e,r);return t(i)})).catch((e=>{throw Ue.ethErrors.rpc.internal(null==e?void 0:e.message)}))}else this.request(Object.assign(Object.assign({},e),{id:Number(e.id)})).then(t)}));if("function"!=typeof t)return i;i.then((e=>t(null,e))).catch((e=>t(e)))}))}sendUserOperation(e){return r(this,void 0,void 0,(function*(){return this.request({method:"eth_sendUserOperation",params:[e]})}))}request(e){var t,i,o,s,a,u,c,h;return r(this,void 0,void 0,(function*(){if(Array.isArray(e))return this.sendAsync(e);if(!(null==e?void 0:e.method))throw Ue.ethErrors.rpc.invalidRequest();const{blockchainName:r,switchableNetwork:d,sessionKeyEnv:l}=yield n(this,bt,"m",Et).call(this);if(null===(t=this.existedSDK)||void 0===t?void 0:t.isBlocto){if("wallet_switchEthereumChain"===e.method){if(!(null===(o=null===(i=null==e?void 0:e.params)||void 0===i?void 0:i[0])||void 0===o?void 0:o.chainId))throw Ue.ethErrors.rpc.invalidParams();return this.existedSDK.request(e).then((()=>{var t,r,n;return this.networkVersion=`${Nt(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t[0].chainId)}`,this.chainId=`0x${Nt(null===(r=null==e?void 0:e.params)||void 0===r?void 0:r[0].chainId).toString(16)}`,this.rpc=null===(n=null==d?void 0:d[this.networkVersion])||void 0===n?void 0:n.rpc_url,null}))}return this.existedSDK.request(e)}switch(e.method){case"eth_chainId":return this.chainId;case"net_version":return this.networkVersion;case"wallet_addEthereumChain":return this.loadSwitchableNetwork((null==e?void 0:e.params)||[]);case"eth_blockNumber":case"web3_clientVersion":case"eth_call":{const t=yield this.handleReadRequests(e);if(!t||t&&!t.result&&t.error){const e=(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.message)?t.error.message:"Request failed";throw Ue.ethErrors.rpc.internal(e)}return"function"==typeof(null==e?void 0:e.callback)&&e.callback(null,t.result),t.result}case"wallet_switchEthereumChain":return this.handleSwitchChain(null===(u=null===(a=null==e?void 0:e.params)||void 0===a?void 0:a[0])||void 0===u?void 0:u.chainId);case"wallet_disconnect":return this.handleDisconnect();case"eth_accounts":return N(l,r)||[]}if(!N(l,r)){const t=null===(c=null==e?void 0:e.params)||void 0===c?void 0:c[0];"eth_requestAccounts"===e.method&&x(t)?yield this.enable(t):yield this.enable()}try{let t=null,n=null;switch(e.method){case"eth_requestAccounts":n=yield this.fetchAccounts();break;case"eth_coinbase":n=null===(h=N(l,r))||void 0===h?void 0:h[0];break;case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"personal_sign":n=yield this.handleSign(e);break;case"eth_sign":throw Ue.ethErrors.rpc.methodNotFound("Method Not Supported: eth_sign has been disabled");case"eth_sendTransaction":n=yield this.handleSendTransaction(e);break;case"wallet_sendMultiCallTransaction":n=yield this.handleSendBatchTransaction(e);break;case"eth_signTransaction":case"eth_sendRawTransaction":throw Ue.ethErrors.rpc.methodNotSupported("Method Not Supported: "+e.method);case"eth_sendUserOperation":n=yield this.handleSendUserOperation(e);break;case"eth_estimateUserOperationGas":case"eth_getUserOperationByHash":case"eth_getUserOperationReceipt":case"eth_supportedEntryPoints":n=yield this.handleBundler(e);break;default:t=yield this.handleReadRequests(e)}if(t&&!t.result&&t.error){const e=t.error.message?t.error.message:"Request failed";throw Ue.ethErrors.rpc.internal(e)}return t?t.result:n}catch(e){throw Ue.ethErrors.rpc.internal(null==e?void 0:e.message)}}))}bloctoApi(e,t){var i;return r(this,void 0,void 0,(function*(){const{walletServer:r,blockchainName:o,sessionKeyEnv:s}=yield n(this,bt,"m",Et).call(this),a=(null===(i=P(s))||void 0===i?void 0:i.code)||"";if(!a)throw Ue.ethErrors.provider.unauthorized();return fetch(`${r}/api/${o}${e}`,Object.assign({headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":a}},t)).then((e=>k(e,s,(()=>{var e;null===(e=this.eventListeners)||void 0===e||e.disconnect.forEach((e=>e(Ue.ethErrors.provider.disconnected())))})))).catch((e=>{throw"unsupported_method"===(null==e?void 0:e.error_code)?Ue.ethErrors.rpc.methodNotSupported("Method Not Supported: "+e.message):Ue.ethErrors.rpc.server({code:-32005,message:`Blocto server error: ${e.message}`})}))}))}responseListener(e,t){return r(this,void 0,void 0,(function*(){const{walletServer:r}=yield n(this,bt,"m",Et).call(this);return new Promise(((n,i)=>S("message",((o,s)=>{const a=o;a.origin===r&&"ETH:FRAME:RESPONSE"===a.data.type&&("APPROVED"===a.data.status&&(s(),E(e),n(a.data[t])),"DECLINED"===a.data.status&&(s(),E(e),"incorrect_session_id"===a.data.errorCode&&this.handleDisconnect(),i(Ue.ethErrors.provider.userRejectedRequest(a.data.errorMessage)))),"ETH:FRAME:CLOSE"===a.data.type&&(s(),E(e),i(Ue.ethErrors.provider.userRejectedRequest("User declined the request")))}))))}))}setIframe(e,t){return r(this,void 0,void 0,(function*(){if("undefined"==typeof window)throw Ue.ethErrors.provider.custom({code:1001,message:"Blocto SDK only works in browser environment"});const{walletServer:r,blockchainName:i}=yield n(this,bt,"m",Et).call(this),o=w(`${r}/${this.appId}/${t||i}${e}`);return b(o),o}))}enable(e){var t;return r(this,void 0,void 0,(function*(){if("undefined"==typeof window)throw Ue.ethErrors.provider.custom({code:1001,message:"Blocto SDK only works in browser environment"});const{walletServer:r,blockchainName:i,sessionKeyEnv:o}=yield n(this,bt,"m",Et).call(this);if(null===(t=this.existedSDK)||void 0===t?void 0:t.isBlocto)return this.existedSDK.chainId!==this.chainId&&(yield this.existedSDK.request({method:"wallet_addEthereumChain",params:[{chainId:this.chainId}]}),yield this.existedSDK.request({method:"wallet_switchEthereumChain",params:[{chainId:this.chainId}]}),j(o,i,[this.existedSDK.address])),new Promise(((e,t)=>setTimeout((()=>this.existedSDK.enable().then(e).catch(t)),10)));const a=N(o,i);if(a)return new Promise((e=>{e(a)}));const u=new URLSearchParams;u.set("l6n",window.location.origin),u.set("v",y);const c=e&&x(e)?`/${e}`:"",h=yield this.setIframe(`/authn${c}?${u.toString()}`);return new Promise(((e,t)=>{S("message",((n,a)=>{var u,c;const d=n;d.origin===r&&("ETH:FRAME:RESPONSE"===d.data.type&&(a(),E(h),null===(u=this.eventListeners)||void 0===u||u.connect.forEach((e=>e({chainId:this.chainId}))),T(o,{code:d.data.code,evm:{[i]:[d.data.addr]}},d.data.exp),(null===(c=d.data)||void 0===c?void 0:c.isAccountChanged)&&postMessage({originChain:s.ETHEREUM,type:"BLOCTO_SDK:ACCOUNT_CHANGED"}),S("message",((e,t)=>{var r,n,i;const o=e,a="BLOCTO_SDK:ACCOUNT_CHANGED"===(null===(r=o.data)||void 0===r?void 0:r.type),u=(null===(n=o.data)||void 0===n?void 0:n.originChain)!==s.ETHEREUM;a&&(null===(i=this.eventListeners)||void 0===i||i.accountsChanged.forEach((e=>e([d.data.addr])))),a&&u&&(this.handleDisconnect(),t())})),e([d.data.addr])),"ETH:FRAME:CLOSE"===d.data.type&&(a(),E(h),t(Ue.ethErrors.provider.userRejectedRequest())))}))}))}))}fetchAccounts(){return r(this,void 0,void 0,(function*(){n(this,bt,"m",_t).call(this);const{blockchainName:e,sessionKeyEnv:t}=yield n(this,bt,"m",Et).call(this),{accounts:r}=yield this.bloctoApi("/accounts");return j(t,e,r),r}))}handleReadRequests(e){return r(this,void 0,void 0,(function*(){return n(this,bt,"m",_t).call(this),fetch(this.rpc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({id:1,jsonrpc:"2.0"},e))}).then((e=>e.json())).catch((e=>{throw Ue.ethErrors.rpc.internal(e)}))}))}handleSign({method:e,params:t}){return r(this,void 0,void 0,(function*(){let r="";if(Array.isArray(t))if("personal_sign"===e)r=xe(t[0])?t[0].slice(2):(i=t[0],X.from(i,"utf8").toString("hex"));else if(["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4"].includes(e)){r=t[1];const{domain:e}=JSON.parse(r);if(xe(e.chainId))throw Ue.ethErrors.rpc.invalidParams(`Provided chainId "${e.chainId}" must be a number`);if(Nt(e.chainId)!==Nt(this.chainId))throw Ue.ethErrors.rpc.invalidParams(`Provided chainId "${e.chainId}" must match the active chainId "${Nt(this.chainId)}"`)}var i;n(this,bt,"m",_t).call(this);const{signatureId:o}=yield this.bloctoApi("/user-signature",{method:"POST",body:JSON.stringify({method:e,message:r})}),s=yield this.setIframe(`/user-signature/${o}`);return this.responseListener(s,"signature")}))}handleSwitchChain(e){var t,i;return r(this,void 0,void 0,(function*(){if(!e)throw Ue.ethErrors.rpc.invalidParams();const{walletServer:r,blockchainName:o,sessionKeyEnv:s,switchableNetwork:a}=yield n(this,bt,"m",Et).call(this),u=null===(t=N(s,o))||void 0===t?void 0:t[0],c=Nt(this.chainId),h=Nt(e);if(c===h)return null;if(!a[h])throw Ue.ethErrors.provider.custom({code:4902,message:`Unrecognized chain ID "${h}". Try adding the chain using wallet_addEthereumChain first.`});if(this.networkVersion=`${h}`,this.chainId=`0x${h.toString(16)}`,this.rpc=a[h].rpc_url,this._blocto=Object.assign(Object.assign({},this._blocto),{blockchainName:"",networkType:""}),!u)return null===(i=this.eventListeners)||void 0===i||i.chainChanged.forEach((e=>e(this.chainId))),yield n(this,bt,"m",Et).call(this),null;if(a[h].wallet_web_url!==a[c].wallet_web_url)return this.enable().then((([e])=>{var t;return e!==u&&(null===(t=this.eventListeners)||void 0===t||t.accountsChanged.forEach((t=>t([e])))),this.eventListeners.chainChanged.forEach((e=>e(this.chainId))),null})).catch((e=>{throw this.networkVersion=`${c}`,this.chainId=`0x${c.toString(16)}`,this.rpc=a[c].rpc_url,this._blocto=Object.assign(Object.assign({},this._blocto),{blockchainName:"",networkType:""}),n(this,bt,"m",Et).call(this),e}));const d=yield this.setIframe(`/switch-chain?to=${a[h].name}`,a[c].name);return new Promise(((e,t)=>{S("message",((i,o)=>{var l,f,p,v,g,y,m,w;const b=i;b.origin===r&&("ETH:FRAME:RESPONSE"===b.data.type&&(o(),E(d),(null===(l=b.data)||void 0===l?void 0:l.addr)&&u&&(T(s,{code:null===(f=b.data)||void 0===f?void 0:f.code,evm:{[a[h].name]:[b.data.addr]}},null===(p=b.data)||void 0===p?void 0:p.exp),b.data.addr!==u&&(null===(v=this.eventListeners)||void 0===v||v.accountsChanged.forEach((e=>e([b.data.addr]))))),null===(g=this.eventListeners)||void 0===g||g.chainChanged.forEach((e=>e(this.chainId))),n(this,bt,"m",Et).call(this),e(null)),"ETH:FRAME:CLOSE"===b.data.type&&(o(),E(d),(null===(y=b.data)||void 0===y?void 0:y.hasApprovedSwitchChain)?(null===(m=this.eventListeners)||void 0===m||m.chainChanged.forEach((e=>e(this.chainId))),D(s),null===(w=this.eventListeners)||void 0===w||w.disconnect.forEach((e=>e(Ue.ethErrors.provider.disconnected()))),n(this,bt,"m",Et).call(this),e(null)):(this.networkVersion=`${c}`,this.chainId=`0x${c.toString(16)}`,this.rpc=a[c].rpc_url,this._blocto=Object.assign(Object.assign({},this._blocto),{blockchainName:"",networkType:""}),n(this,bt,"m",Et).call(this),t(Ue.ethErrors.provider.userRejectedRequest()))))}))}))}))}handleSendTransaction(e){var t;return r(this,void 0,void 0,(function*(){n(this,bt,"m",_t).call(this);const{isValid:r,invalidMsg:i}=Le(null===(t=e.params)||void 0===t?void 0:t[0]);if(!r)throw Ue.ethErrors.rpc.invalidParams(i);return n(this,bt,"m",At).call(this,e.params)}))}handleSendBatchTransaction(e){return r(this,void 0,void 0,(function*(){let t,r;n(this,bt,"m",_t).call(this),Array.isArray(e.params)&&e.params.length>=2?[t,r]=e.params:(t=e.params,r=!1);const i=r||!1,{isValid:o,invalidMsg:s}=(e=>{if(!Array.isArray(e))return{isValid:!1,invalidMsg:L.INVALID_TRANSACTIONS};for(let t=0;t<e.length;t++){const{isValid:r,invalidMsg:n}=Le(e[t]);if(!r)return{isValid:r,invalidMsg:n}}return{isValid:!0}})(t);if(!o)throw Ue.ethErrors.rpc.invalidParams(s);return n(this,bt,"m",At).call(this,t,i)}))}handleSendUserOperation(e){return r(this,void 0,void 0,(function*(){n(this,bt,"m",_t).call(this);const{authorizationId:t}=yield this.bloctoApi("/user-operation",{method:"POST",body:JSON.stringify(e.params)}),r=yield this.setIframe(`/user-operation/${t}`);return this.responseListener(r,"userOpHash")}))}handleBundler(e){return r(this,void 0,void 0,(function*(){return n(this,bt,"m",_t).call(this),this.bloctoApi("/rpc/bundler",{method:"POST",body:JSON.stringify(Object.assign({id:1,jsonrpc:"2.0"},e))})}))}handleDisconnect(){var e,t;return r(this,void 0,void 0,(function*(){if(null===(e=this.existedSDK)||void 0===e?void 0:e.isBlocto)return this.existedSDK.request({method:"wallet_disconnect"});const{sessionKeyEnv:r}=yield n(this,bt,"m",Et).call(this);D(r),null===(t=this.eventListeners)||void 0===t||t.disconnect.forEach((e=>e(Ue.ethErrors.provider.disconnected())))}))}loadSwitchableNetwork(e){return r(this,void 0,void 0,(function*(){if(null==e?void 0:e.length){const t=e.map((({chainId:e,rpcUrls:t})=>{if(!e)throw Ue.ethErrors.rpc.invalidParams("Empty chainId");const r=`${Nt(e)}`;if(this._blocto.switchableNetwork[r])return null;const i=(null==t?void 0:t[0])||a[r];if(!i)throw Ue.ethErrors.rpc.invalidParams("rpcUrls required");return n(this,bt,"m",St).call(this,{chainId:r,rpcUrls:[i]})}));return Promise.all(t).then((()=>null))}throw Ue.ethErrors.rpc.invalidParams("Empty networkList")}))}supportChainList(){return r(this,void 0,void 0,(function*(){const e=yield Me().catch((e=>{throw Ue.ethErrors.provider.custom({code:1001,message:`Get blocto server failed: ${e.message}`})}));return Object.keys(e).map((t=>{const{display_name:r}=e[t];return{chainId:t,chainName:r}}))}))}on(e,t){var r;(null===(r=this.existedSDK)||void 0===r?void 0:r.isBlocto)&&this.existedSDK.on(e,t),super.on(e,t)}removeListener(e,t){var r;(null===(r=this.existedSDK)||void 0===r?void 0:r.isBlocto)&&this.existedSDK.off(e,t),super.removeListener(e,t)}}bt=new WeakSet,Et=function(){var e,t;return r(this,void 0,void 0,(function*(){if((null===(e=this._blocto)||void 0===e?void 0:e.unloadedNetwork)&&(yield this.loadSwitchableNetwork(this._blocto.unloadedNetwork),delete this._blocto.unloadedNetwork),this._blocto.sessionKeyEnv&&this._blocto.walletServer&&this._blocto.blockchainName&&this._blocto.networkType&&this._blocto.switchableNetwork)return this._blocto;const r=yield Me().catch((e=>{throw Ue.ethErrors.provider.custom({code:1001,message:`Get blocto server failed: ${e.message}`})})),{chain_id:n,name:i,network_type:o,blocto_service_environment:s,display_name:a}=null!==(t=r[this.networkVersion])&&void 0!==t?t:{};if(!n)throw Ue.ethErrors.provider.unsupportedMethod(`Get support chain failed: ${this.networkVersion} might not be supported yet.`);const h=this.injectedWalletServer||u[s];return this._blocto=Object.assign(Object.assign({},this._blocto),{sessionKeyEnv:c[s],walletServer:h,blockchainName:i,networkType:o,switchableNetwork:Object.assign(Object.assign({},this._blocto.switchableNetwork),{[n]:{name:i,display_name:a,network_type:o,wallet_web_url:h,rpc_url:this.rpc}})}),this._blocto}))},St=function({chainId:e,rpcUrls:t}){var i;return r(this,void 0,void 0,(function*(){yield n(this,bt,"m",Et).call(this);const r=yield Me().catch((e=>{throw Ue.ethErrors.provider.custom({code:1001,message:`Get blocto server failed: ${e.message}`})})),{chain_id:o,name:s,display_name:a,network_type:c,blocto_service_environment:h}=null!==(i=r[e])&&void 0!==i?i:{};if(!o)throw Ue.ethErrors.provider.unsupportedMethod(`Get support chain failed: ${e} might not be supported yet.`);const d=u[h];this._blocto.switchableNetwork[o]={name:s,display_name:a,network_type:c,wallet_web_url:d,rpc_url:t[0]}}))},_t=function(){var e;if((null===(e=this.existedSDK)||void 0===e?void 0:e.isBlocto)&&Nt(this.existedSDK.chainId)!==Nt(this.chainId))throw Ue.ethErrors.provider.chainDisconnected()},At=function(e,t=!0){return r(this,void 0,void 0,(function*(){const{authorizationId:r}=yield this.bloctoApi("/authz",{method:"POST",body:JSON.stringify([e,t])}),n=yield this.setIframe(`/authz/${r}`);return this.responseListener(n,"txHash")}))};class Dt extends m{get existedSDK(){if("undefined"!=typeof window)return window.bloctoAptos}constructor({chainId:e,server:t,appId:r}){super(),this.publicKey=[],this.authKey="",this.off=this.removeListener,i(e,"'chainId' is required"),i(r,"It is necessary to interact with Blocto wallet via your app id. Please visit https://developers.blocto.app for more details."),this.chainId=e,this.networkName=f[e],this.api=p[e],this.sessionKey=h[e];const n=d[e];this.appId=r||g,this.server=t||n||""}get publicAccount(){var e;return{address:(null===(e=C(this.sessionKey,s.APTOS))||void 0===e?void 0:e[0])||null,publicKey:this.publicKey.length?this.publicKey:null,authKey:null,minKeysRequired:2}}network(){return r(this,void 0,void 0,(function*(){return{name:this.networkName,api:this.api,chainId:this.chainId.toString()}}))}isConnected(){var e;return r(this,void 0,void 0,(function*(){return!!(null===(e=C(this.sessionKey,s.APTOS))||void 0===e?void 0:e.length)}))}signTransaction(e){var t;return r(this,void 0,void 0,(function*(){if(this.existedSDK)return this.existedSDK.signTransaction(e);if((yield this.isConnected())||(yield this.connect()),!(null===(t=C(this.sessionKey,s.APTOS))||void 0===t?void 0:t.length))throw new Error("Fail to get account");throw new Error("signTransaction method not supported.")}))}disconnect(){var e;return r(this,void 0,void 0,(function*(){var t,r;this.existedSDK?yield this.existedSDK.disconnect():(t=this.sessionKey,r=s.APTOS,T(t,{accounts:{[r]:void 0}}),null===(e=this.eventListeners)||void 0===e||e.disconnect.forEach((e=>e({code:4900,message:"Wallet disconnected"}))))}))}signAndSubmitTransaction(e,t={}){var n,i;return r(this,void 0,void 0,(function*(){if(this.existedSDK)return this.existedSDK.signAndSubmitTransaction(e,t);if((yield this.isConnected())||(yield this.connect()),!(null===(n=C(this.sessionKey,s.APTOS))||void 0===n?void 0:n.length))throw new Error("Fail to get account");const r=(null===(i=P(this.sessionKey))||void 0===i?void 0:i.code)||"",{authorizationId:o}=yield fetch(`${this.server}/api/aptos/authz`,{method:"POST",headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":r},body:JSON.stringify(Object.assign(Object.assign({},e),t))}).then((e=>k(e,this.sessionKey)));if("undefined"==typeof window)throw new Error("Currently only supported in browser");const a=w(`${this.server}/${this.appId}/aptos/authz/${o}`);return b(a),new Promise(((e,t)=>S("message",((r,n)=>{const i=r;i.origin===this.server&&"APTOS:FRAME:RESPONSE"===i.data.type&&("APPROVED"===i.data.status&&(n(),E(a),e({hash:i.data.txHash})),"DECLINED"===i.data.status&&(n(),E(a),"incorrect_session_id"===i.data.errorCode&&this.disconnect(),t(new Error(i.data.errorMessage))))}))))}))}signMessage(e){var t,n;return r(this,void 0,void 0,(function*(){const r=(e=>{var t,r;const n=Object.assign({},e),{message:i,nonce:o,address:s,application:a,chainId:u}=e;return"string"!=typeof i&&(n.message=null!==(t=String(i))&&void 0!==t?t:""),"string"!=typeof o&&(n.nonce=null!==(r=String(o))&&void 0!==r?r:""),s&&"boolean"!=typeof s&&(n.address=!!s),a&&"boolean"!=typeof a&&(n.application=!!a),u&&"boolean"!=typeof u&&(n.chainId=!!u),n})(e);if(this.existedSDK)return this.existedSDK.signMessage(r);if((yield this.isConnected())||(yield this.connect()),!(null===(t=C(this.sessionKey,s.APTOS))||void 0===t?void 0:t.length))throw new Error("Fail to get account");if("undefined"==typeof window)throw new Error("Currently only supported in browser");const i=(null===(n=P(this.sessionKey))||void 0===n?void 0:n.code)||"",{signatureId:o}=yield fetch(`${this.server}/api/aptos/user-signature`,{method:"POST",headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":i},body:JSON.stringify(r)}).then((e=>k(e,this.sessionKey))),a=w(`${this.server}/${this.appId}/aptos/user-signature/${o}`);return b(a),new Promise(((e,t)=>S("message",((r,n)=>{const i=r;i.origin===this.server&&"APTOS:FRAME:RESPONSE"===i.data.type&&("APPROVED"===i.data.status&&(n(),E(a),e(i.data)),"DECLINED"===i.data.status&&(n(),E(a),"incorrect_session_id"===i.data.errorCode&&this.disconnect(),t(new Error(i.data.errorMessage))))}))))}))}connect(){return r(this,void 0,void 0,(function*(){return this.existedSDK?new Promise(((e,t)=>setTimeout((()=>this.existedSDK.connect().then(e).catch(t)),10))):new Promise(((e,t)=>{var n,i;if("undefined"==typeof window)return t("Currently only supported in browser");if(null===(n=C(this.sessionKey,s.APTOS))||void 0===n?void 0:n.length)return e({address:(null===(i=C(this.sessionKey,s.APTOS))||void 0===i?void 0:i[0])||null,publicKey:this.publicKey,authKey:null,minKeysRequired:2});const o=encodeURIComponent(window.location.origin),a=w(`${this.server}/${this.appId}/aptos/authn?l6n=${o}&v=${y}}`);b(a),S("message",((n,i)=>r(this,void 0,void 0,(function*(){var r,o,u,c;const h=n;if(h.origin===this.server){if("APTOS:FRAME:RESPONSE"===h.data.type){if(i(),E(a),T(this.sessionKey,{code:h.data.code,accounts:{[s.APTOS]:[h.data.addr]}},h.data.exp),(null===(r=h.data)||void 0===r?void 0:r.isAccountChanged)&&postMessage({originChain:s.APTOS,type:"BLOCTO_SDK:ACCOUNT_CHANGED"}),S("message",((e,t)=>{var r,n;const i=e;"BLOCTO_SDK:ACCOUNT_CHANGED"===(null===(r=i.data)||void 0===r?void 0:r.type)&&(null===(n=i.data)||void 0===n?void 0:n.originChain)!==s.APTOS&&(this.disconnect(),t())})),!(null===(o=C(this.sessionKey,s.APTOS))||void 0===o?void 0:o.length))return t();try{const{public_keys:t}=yield fetch(`${this.server}/blocto/aptos/accounts/${null===(u=C(this.sessionKey,s.APTOS))||void 0===u?void 0:u[0]}`).then((e=>e.json()));this.publicKey=t||[],e({address:(null===(c=C(this.sessionKey,s.APTOS))||void 0===c?void 0:c[0])||"",publicKey:this.publicKey,authKey:null,minKeysRequired:2})}catch(e){return t(h)}}"APTOS:FRAME:CLOSE"===h.data.type&&(i(),E(a),t(new Error("User declined the login request")))}}))))}))}))}fetchAddress(){var e;return r(this,void 0,void 0,(function*(){const t=(null===(e=P(this.sessionKey))||void 0===e?void 0:e.code)||"",{accounts:r}=yield fetch(`${this.server}/api/aptos/accounts`,{headers:{"Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":t}}).then((e=>k(e,this.sessionKey)));var n,i;return n=this.sessionKey,i=s.APTOS,T(n,{accounts:{[i]:r}}),(null==r?void 0:r[0])||""}))}on(e,t){this.existedSDK&&this.existedSDK.on(e,t),super.on(e,t)}removeListener(e,t){this.existedSDK&&this.existedSDK.off(e,t),super.removeListener(e,t)}}class kt{constructor({appId:e,ethereum:t,aptos:r}){t&&(this.ethereum=new jt(Object.assign(Object.assign({},t),{appId:e}))),r&&(this.aptos=new Dt(Object.assign(Object.assign({},r),{appId:e})))}}function xt({chainId:r,rpcUrl:n,rpc:i,bloctoParams:o},s){return e(this,void 0,void 0,(function*(){let e;if(!r)throw new Error("chainId is required");n?e=n:r&&i&&(e=i[r]),e||(e="null");const a=new kt({appId:null==o?void 0:o.appId,ethereum:{chainId:r,rpc:e}}).ethereum;if(!a)throw new Error("No provider");return a.on("connect",s.connect),a.on("disconnect",s.disconnect),a.on("accountsChanged",s.accountsChanged),a.on("chainChanged",s.chainChanged),yield a.request({method:"eth_requestAccounts"}),t(a)}))}export{xt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as t}from"./index-76c2f135.js";import{r as i}from"./__node-resolve_empty-c07e04b2.js";var r={exports:{}};!function(t,r){function h(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function e(t,i,r){if(e.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var o;"object"==typeof t?t.exports=e:r.BN=e,e.BN=e,e.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:i.Buffer}catch(t){}function s(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void h(!1,"Invalid character in "+t)}function u(t,i,r){var h=s(t,r);return r-1>=i&&(h|=s(t,r-1)<<4),h}function l(t,i,r,n){for(var e=0,o=0,s=Math.min(t.length,r),u=i;u<s;u++){var l=t.charCodeAt(u)-48;e*=n,o=l>=49?l-49+10:l>=17?l-17+10:l,h(l>=0&&o<n,"Invalid character"),e+=o}return e}function a(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(e.isBN=function(t){return t instanceof e||null!==t&&"object"==typeof t&&t.constructor.wordSize===e.wordSize&&Array.isArray(t.words)},e.max=function(t,i){return t.cmp(i)>0?t:i},e.min=function(t,i){return t.cmp(i)<0?t:i},e.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),h(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},e.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(h(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},e.prototype._initArray=function(t,i,r){if(h("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var e,o,s=0;if("be"===r)for(n=t.length-1,e=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===r)for(n=0,e=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this._strip()},e.prototype._parseHex=function(t,i,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var n,e=0,o=0;if("be"===r)for(h=t.length-1;h>=i;h-=2)n=u(t,i,h)<<e,this.words[o]|=67108863&n,e>=18?(e-=18,o+=1,this.words[o]|=n>>>26):e+=8;else for(h=(t.length-i)%2==0?i+1:i;h<t.length;h+=2)n=u(t,i,h)<<e,this.words[o]|=67108863&n,e>=18?(e-=18,o+=1,this.words[o]|=n>>>26):e+=8;this._strip()},e.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,s=Math.min(e,e-o)+r,u=0,a=r;a<s;a+=h)u=l(t,a,a+h,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var m=1;for(u=l(t,a,t.length,i),a=0;a<o;a++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},e.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},e.prototype._move=function(t){a(t,this)},e.prototype.clone=function(){var t=new e(null);return this.copy(t),t},e.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},e.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{e.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){e.prototype.inspect=m}else e.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function M(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var l=1;l<h;l++){for(var a=u>>>26,m=67108863&u,f=Math.min(l,i.length-1),d=Math.max(0,l-t.length+1);d<=f;d++){var p=l-d|0;a+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[l]=0|m,u=0|a}return 0!==u?r.words[l]=0|u:r.length--,r._strip()}e.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,e=0,o=0;o<this.length;o++){var s=this.words[o],u=(16777215&(s<<n|e)).toString(16);e=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==e||o!==this.length-1?f[6-u.length]+u+r:u+r}for(0!==e&&(r=e.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var l=d[t],a=p[t];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var M=m.modrn(a).toString(t);r=(m=m.idivn(a)).isZero()?M+r:f[l-M.length]+M+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}h(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&h(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},e.prototype.toJSON=function(){return this.toString(16,2)},o&&(e.prototype.toBuffer=function(t,i){return this.toArrayLike(o,t,i)}),e.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},e.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),e=r||Math.max(1,n);h(n<=e,"byte array longer than desired length"),h(e>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,e);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},e.prototype._toArrayLikeLE=function(t,i){for(var r=0,h=0,n=0,e=0;n<this.length;n++){var o=this.words[n]<<e|h;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===e?(r<t.length&&(t[r++]=o>>24&255),h=0,e=0):(h=o>>>24,e+=2)}if(r<t.length)for(t[r++]=h;r<t.length;)t[r++]=0},e.prototype._toArrayLikeBE=function(t,i){for(var r=t.length-1,h=0,n=0,e=0;n<this.length;n++){var o=this.words[n]<<e|h;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===e?(r>=0&&(t[r--]=o>>24&255),h=0,e=0):(h=o>>>24,e+=2)}if(r>=0)for(t[r--]=h;r>=0;)t[r--]=0},Math.clz32?e.prototype._countBits=function(t){return 32-Math.clz32(t)}:e.prototype._countBits=function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},e.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},e.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var r=this._zeroBits(this.words[i]);if(t+=r,26!==r)break}return t},e.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},e.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},e.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},e.prototype.isNeg=function(){return 0!==this.negative},e.prototype.neg=function(){return this.clone().ineg()},e.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},e.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},e.prototype.ior=function(t){return h(0==(this.negative|t.negative)),this.iuor(t)},e.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},e.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},e.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;r<i.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=i.length,this._strip()},e.prototype.iand=function(t){return h(0==(this.negative|t.negative)),this.iuand(t)},e.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},e.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},e.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;h<r.length;h++)this.words[h]=i.words[h]^r.words[h];if(this!==i)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=i.length,this._strip()},e.prototype.ixor=function(t){return h(0==(this.negative|t.negative)),this.iuxor(t)},e.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},e.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},e.prototype.inotn=function(t){h("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},e.prototype.notn=function(t){return this.clone().inotn(t)},e.prototype.setn=function(t,i){h("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},e.prototype.iadd=function(t){var i,r,h;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e<h.length;e++)i=(0|r.words[e])+(0|h.words[e])+n,this.words[e]=67108863&i,n=i>>>26;for(;0!==n&&e<r.length;e++)i=(0|r.words[e])+n,this.words[e]=67108863&i,n=i>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;e<r.length;e++)this.words[e]=r.words[e];return this},e.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},e.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o<h.length;o++)e=(i=(0|r.words[o])-(0|h.words[o])+e)>>26,this.words[o]=67108863&i;for(;0!==e&&o<r.length;o++)e=(i=(0|r.words[o])+e)>>26,this.words[o]=67108863&i;if(0===e&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},e.prototype.sub=function(t){return this.clone().isub(t)};var v=function(t,i,r){var h,n,e,o=t.words,s=i.words,u=r.words,l=0,a=0|o[0],m=8191&a,f=a>>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,S=0|o[5],x=8191&S,q=S>>>13,Z=0|o[6],B=8191&Z,R=Z>>>13,L=0|o[7],N=8191&L,E=L>>>13,I=0|o[8],z=8191&I,O=I>>>13,T=0|o[9],j=8191&T,K=T>>>13,F=0|s[0],U=8191&F,C=F>>>13,D=0|s[1],H=8191&D,P=D>>>13,J=0|s[2],G=8191&J,Q=J>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,lt=st>>>13,at=0|s[8],mt=8191&at,ft=at>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(l+(h=Math.imul(m,U))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,U)|0))<<13)|0;l=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,U),n=(n=Math.imul(p,C))+Math.imul(M,U)|0,e=Math.imul(M,C);var gt=(l+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,P)|0)+Math.imul(f,H)|0))<<13)|0;l=((e=e+Math.imul(f,P)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,U),n=(n=Math.imul(g,C))+Math.imul(c,U)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,P)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,P)|0;var ct=(l+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;l=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,U),n=(n=Math.imul(y,C))+Math.imul(b,U)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,P)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,P)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(l+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;l=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,U),n=(n=Math.imul(k,C))+Math.imul(A,U)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,P)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,P)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(l+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;l=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(x,U),n=(n=Math.imul(x,C))+Math.imul(q,U)|0,e=Math.imul(q,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,P)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,P)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(l+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;l=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(B,U),n=(n=Math.imul(B,C))+Math.imul(R,U)|0,e=Math.imul(R,C),h=h+Math.imul(x,H)|0,n=(n=n+Math.imul(x,P)|0)+Math.imul(q,H)|0,e=e+Math.imul(q,P)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(l+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;l=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(N,U),n=(n=Math.imul(N,C))+Math.imul(E,U)|0,e=Math.imul(E,C),h=h+Math.imul(B,H)|0,n=(n=n+Math.imul(B,P)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,P)|0,h=h+Math.imul(x,G)|0,n=(n=n+Math.imul(x,Q)|0)+Math.imul(q,G)|0,e=e+Math.imul(q,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(l+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,lt)|0)+Math.imul(f,ut)|0))<<13)|0;l=((e=e+Math.imul(f,lt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(z,U),n=(n=Math.imul(z,C))+Math.imul(O,U)|0,e=Math.imul(O,C),h=h+Math.imul(N,H)|0,n=(n=n+Math.imul(N,P)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,P)|0,h=h+Math.imul(B,G)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,h=h+Math.imul(x,W)|0,n=(n=n+Math.imul(x,X)|0)+Math.imul(q,W)|0,e=e+Math.imul(q,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,lt)|0;var At=(l+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;l=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,U),n=(n=Math.imul(j,C))+Math.imul(K,U)|0,e=Math.imul(K,C),h=h+Math.imul(z,H)|0,n=(n=n+Math.imul(z,P)|0)+Math.imul(O,H)|0,e=e+Math.imul(O,P)|0,h=h+Math.imul(N,G)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(B,W)|0,n=(n=n+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,h=h+Math.imul(x,$)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(q,$)|0,e=e+Math.imul(q,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,lt)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,lt)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var St=(l+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;l=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,P))+Math.imul(K,H)|0,e=Math.imul(K,P),h=h+Math.imul(z,G)|0,n=(n=n+Math.imul(z,Q)|0)+Math.imul(O,G)|0,e=e+Math.imul(O,Q)|0,h=h+Math.imul(N,W)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(B,$)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,h=h+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,ht)|0)+Math.imul(q,rt)|0,e=e+Math.imul(q,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,lt)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var xt=(l+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;l=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(z,W)|0,n=(n=n+Math.imul(z,X)|0)+Math.imul(O,W)|0,e=e+Math.imul(O,X)|0,h=h+Math.imul(N,$)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,ht)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,ht)|0,h=h+Math.imul(x,et)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(q,et)|0,e=e+Math.imul(q,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,lt)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var qt=(l+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(z,$)|0,n=(n=n+Math.imul(z,tt)|0)+Math.imul(O,$)|0,e=e+Math.imul(O,tt)|0,h=h+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(B,et)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,h=h+Math.imul(x,ut)|0,n=(n=n+Math.imul(x,lt)|0)+Math.imul(q,ut)|0,e=e+Math.imul(q,lt)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var Zt=(l+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;l=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(z,rt)|0,n=(n=n+Math.imul(z,ht)|0)+Math.imul(O,rt)|0,e=e+Math.imul(O,ht)|0,h=h+Math.imul(N,et)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(B,ut)|0,n=(n=n+Math.imul(B,lt)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,lt)|0,h=h+Math.imul(x,mt)|0,n=(n=n+Math.imul(x,ft)|0)+Math.imul(q,mt)|0,e=e+Math.imul(q,ft)|0;var Bt=(l+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;l=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(z,et)|0,n=(n=n+Math.imul(z,ot)|0)+Math.imul(O,et)|0,e=e+Math.imul(O,ot)|0,h=h+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,lt)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,lt)|0,h=h+Math.imul(B,mt)|0,n=(n=n+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(l+(h=h+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,Mt)|0)+Math.imul(q,pt)|0))<<13)|0;l=((e=e+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(z,ut)|0,n=(n=n+Math.imul(z,lt)|0)+Math.imul(O,ut)|0,e=e+Math.imul(O,lt)|0,h=h+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(l+(h=h+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;l=((e=e+Math.imul(R,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,lt))+Math.imul(K,ut)|0,e=Math.imul(K,lt),h=h+Math.imul(z,mt)|0,n=(n=n+Math.imul(z,ft)|0)+Math.imul(O,mt)|0,e=e+Math.imul(O,ft)|0;var Nt=(l+(h=h+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var Et=(l+(h=h+Math.imul(z,pt)|0)|0)+((8191&(n=(n=n+Math.imul(z,Mt)|0)+Math.imul(O,pt)|0))<<13)|0;l=((e=e+Math.imul(O,Mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863;var It=(l+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return l=((e=Math.imul(K,Mt))+(n>>>13)|0)+(It>>>26)|0,It&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=St,u[10]=xt,u[11]=qt,u[12]=Zt,u[13]=Bt,u[14]=Rt,u[15]=Lt,u[16]=Nt,u[17]=Et,u[18]=It,0!==l&&(u[19]=l,r.length++),r};function g(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e<r.length-1;e++){var o=n;n=0;for(var s=67108863&h,u=Math.min(e,i.length-1),l=Math.max(0,e-t.length+1);l<=u;l++){var a=e-l,m=(0|t.words[a])*(0|i.words[l]),f=67108863&m;s=67108863&(f=f+s|0),n+=(o=(o=o+(m/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r._strip()}function c(t,i,r){return g(t,i,r)}Math.imul||(v=M),e.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?v(this,t,i):r<63?M(this,t,i):r<1024?g(this,t,i):c(this,t,i)},e.prototype.mul=function(t){var i=new e(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},e.prototype.mulf=function(t){var i=new e(null);return i.words=new Array(this.length+t.length),c(this,t,i)},e.prototype.imul=function(t){return this.clone().mulTo(t,this)},e.prototype.imuln=function(t){var i=t<0;i&&(t=-t),h("number"==typeof t),h(t<67108864);for(var r=0,n=0;n<this.length;n++){var e=(0|this.words[n])*t,o=(67108863&e)+(67108863&r);r>>=26,r+=e/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},e.prototype.muln=function(t){return this.clone().imuln(t)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r<i.length;r++){var h=r/26|0,n=r%26;i[r]=t.words[h]>>>n&1}return i}(t);if(0===i.length)return new e(1);for(var r=this,h=0;h<i.length&&0===i[h];h++,r=r.sqr());if(++h<i.length)for(var n=r.sqr();h<i.length;h++,n=n.sqr())0!==i[h]&&(r=r.mul(n));return r},e.prototype.iushln=function(t){h("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,e=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var s=this.words[i]&e,u=(0|this.words[i])-s<<r;this.words[i]=u|o,o=s>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},e.prototype.ishln=function(t){return h(0===this.negative),this.iushln(t)},e.prototype.iushrn=function(t,i,r){var n;h("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<<e,u=r;if(n-=o,n=Math.max(0,n),u){for(var l=0;l<o;l++)u.words[l]=this.words[l];u.length=o}if(0===o);else if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var a=0;for(l=this.length-1;l>=0&&(0!==a||l>=n);l--){var m=0|this.words[l];this.words[l]=a<<26-e|m>>>e,a=m&s}return u&&0!==a&&(u.words[u.length++]=a),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},e.prototype.ishrn=function(t,i,r){return h(0===this.negative),this.iushrn(t,i,r)},e.prototype.shln=function(t){return this.clone().ishln(t)},e.prototype.ushln=function(t){return this.clone().iushln(t)},e.prototype.shrn=function(t){return this.clone().ishrn(t)},e.prototype.ushrn=function(t){return this.clone().iushrn(t)},e.prototype.testn=function(t){h("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},e.prototype.imaskn=function(t){h("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(h(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},e.prototype.maskn=function(t){return this.clone().imaskn(t)},e.prototype.iaddn=function(t){return h("number"==typeof t),h(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},e.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},e.prototype.isubn=function(t){if(h("number"==typeof t),h(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},e.prototype.addn=function(t){return this.clone().iaddn(t)},e.prototype.subn=function(t){return this.clone().isubn(t)},e.prototype.iabs=function(){return this.negative=0,this},e.prototype.abs=function(){return this.clone().iabs()},e.prototype._ishlnsubmul=function(t,i,r){var n,e,o=t.length+r;this._expand(o);var s=0;for(n=0;n<t.length;n++){e=(0|this.words[n+r])+s;var u=(0|t.words[n])*i;s=((e-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&e}for(;n<this.length-r;n++)s=(e=(0|this.words[n+r])+s)>>26,this.words[n+r]=67108863&e;if(0===s)return this._strip();for(h(-1===s),s=0,n=0;n<this.length;n++)s=(e=-(0|this.words[n])+s)>>26,this.words[n]=67108863&e;return this.negative=1,this._strip()},e.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),h.iushln(r),o=0|n.words[n.length-1]);var s,u=h.length-n.length;if("mod"!==i){(s=new e(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l<s.length;l++)s.words[l]=0}var a=h.clone()._ishlnsubmul(n,1,u);0===a.negative&&(h=a,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|h.words[n.length+m])+(0|h.words[n.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(n,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(n,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),h._strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},e.prototype.divmod=function(t,i,r){return h(!t.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(n=s.div.neg()),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new e(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new e(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new e(this.modrn(t.words[0]))}:this._wordDiv(t,i);var n,o,s},e.prototype.div=function(t){return this.divmod(t,"div",!1).div},e.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},e.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},e.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},e.prototype.modrn=function(t){var i=t<0;i&&(t=-t),h(t<=67108863);for(var r=(1<<26)%t,n=0,e=this.length-1;e>=0;e--)n=(r*n+(0|this.words[e]))%t;return i?-n:n},e.prototype.modn=function(t){return this.modrn(t)},e.prototype.idivn=function(t){var i=t<0;i&&(t=-t),h(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var e=(0|this.words[n])+67108864*r;this.words[n]=e/t|0,r=e%t}return this._strip(),i?this.ineg():this},e.prototype.divn=function(t){return this.clone().idivn(t)},e.prototype.egcd=function(t){h(0===t.negative),h(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n=new e(1),o=new e(0),s=new e(0),u=new e(1),l=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++l;for(var a=r.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(a),o.isub(m)),n.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(r.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(a),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(r)>=0?(i.isub(r),n.isub(s),o.isub(u)):(r.isub(i),s.isub(n),u.isub(o))}return{a:s,b:u,gcd:r.iushln(l)}},e.prototype._invmp=function(t){h(0===t.negative),h(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n,o=new e(1),s=new e(0),u=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,a=1;0==(i.words[0]&a)&&l<26;++l,a<<=1);if(l>0)for(i.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(r.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(r.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(s)):(r.isub(i),s.isub(o))}return(n=0===i.cmpn(1)?o:s).cmpn(0)<0&&n.iadd(t),n},e.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},e.prototype.invm=function(t){return this.egcd(t).a.umod(t)},e.prototype.isEven=function(){return 0==(1&this.words[0])},e.prototype.isOdd=function(){return 1==(1&this.words[0])},e.prototype.andln=function(t){return this.words[0]&t},e.prototype.bincn=function(t){h("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var e=n,o=r;0!==e&&o<this.length;o++){var s=0|this.words[o];e=(s+=e)>>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),h(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},e.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},e.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,r=this.length-1;r>=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){h<n?i=-1:h>n&&(i=1);break}}return i},e.prototype.gtn=function(t){return 1===this.cmpn(t)},e.prototype.gt=function(t){return 1===this.cmp(t)},e.prototype.gten=function(t){return this.cmpn(t)>=0},e.prototype.gte=function(t){return this.cmp(t)>=0},e.prototype.ltn=function(t){return-1===this.cmpn(t)},e.prototype.lt=function(t){return-1===this.cmp(t)},e.prototype.lten=function(t){return this.cmpn(t)<=0},e.prototype.lte=function(t){return this.cmp(t)<=0},e.prototype.eqn=function(t){return 0===this.cmpn(t)},e.prototype.eq=function(t){return 0===this.cmp(t)},e.red=function(t){return new S(t)},e.prototype.toRed=function(t){return h(!this.red,"Already a number in reduction context"),h(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},e.prototype.fromRed=function(){return h(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(t){return this.red=t,this},e.prototype.forceRed=function(t){return h(!this.red,"Already a number in reduction context"),this._forceRed(t)},e.prototype.redAdd=function(t){return h(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},e.prototype.redIAdd=function(t){return h(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},e.prototype.redSub=function(t){return h(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},e.prototype.redISub=function(t){return h(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},e.prototype.redShl=function(t){return h(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},e.prototype.redMul=function(t){return h(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},e.prototype.redIMul=function(t){return h(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},e.prototype.redSqr=function(){return h(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return h(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return h(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return h(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return h(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(t){return h(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new e(i,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(t){if("string"==typeof t){var i=e._prime(t);this.m=i.p,this.prime=i}else h(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new e(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i<this.n?-1:r.ucmp(this.p);return 0===h?(r.words[0]=0,r.length=1):h>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.prototype.split=function(t,i){for(var r=4194303,h=Math.min(t.length,9),n=0;n<h;n++)i.words[n]=t.words[n];if(i.length=h,t.length<=9)return t.words[0]=0,void(t.length=1);var e=t.words[9];for(i.words[i.length++]=e&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|e>>>22,e=o}e>>>=22,t.words[n-10]=e,0===e&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r<t.length;r++){var h=0|t.words[r];i+=977*h,t.words[r]=67108863&i,i=64*h+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,y),n(k,y),n(A,y),A.prototype.imulK=function(t){for(var i=0,r=0;r<t.length;r++){var h=19*(0|t.words[r])+i,n=67108863&h;h>>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},e._prime=function(t){if(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new _;else if("p192"===t)i=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new A}return w[t]=i,i},S.prototype._verify1=function(t){h(0===t.negative,"red works only with positives"),h(t.red,"red works only with red numbers")},S.prototype._verify2=function(t,i){h(0==(t.negative|i.negative),"red works only with positives"),h(t.red&&t.red===i.red,"red works only with red numbers")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},S.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},S.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(h(i%2==1),3===i){var r=this.m.add(new e(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);h(!n.isZero());var s=new e(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new e(2*a*a).toRed(this);0!==this.pow(a,l).cmp(u);)a.redIAdd(u);for(var m=this.pow(a,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();h(v<p);var g=this.pow(m,new e(1).iushln(p-v-1));f=f.redMul(g),m=g.redSqr(),d=d.redMul(m),p=v}return f},S.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},S.prototype.pow=function(t,i){if(i.isZero())return new e(1).toRed(this);if(0===i.cmpn(1))return t.clone();var r=new Array(16);r[0]=new e(1).toRed(this),r[1]=t;for(var h=2;h<r.length;h++)r[h]=this.mul(r[h-1],t);var n=r[0],o=0,s=0,u=i.bitLength()%26;for(0===u&&(u=26),h=i.length-1;h>=0;h--){for(var l=i.words[h],a=u-1;a>=0;a--){var m=l>>a&1;n!==r[0]&&(n=this.sqr(n)),0!==m||0!==o?(o<<=1,o|=m,(4==++s||0===h&&0===a)&&(n=this.mul(n,r[o]),s=0,o=0)):s=0}u=26}return n},S.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},S.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},e.mont=function(t){return new x(t)},n(x,S),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},x.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},x.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new e(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(r,t);var h=r.exports;export{h as B,r as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as t,b as e}from"./index-76c2f135.js";var r={exports:{}};!function(e,r){var o="undefined"!=typeof self?self:t,n=function(){function t(){this.fetch=!1,this.DOMException=o.DOMException}return t.prototype=o,new t}();!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&o.indexOf(Object.prototype.toString.call(t))>-1};function i(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function c(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(c)}),this.text=function(){var t,e,r,o=f(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=i(t),e=s(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[i(t)]},h.prototype.get=function(t){return t=i(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(i(t))},h.prototype.set=function(t,e){this.map[i(t)]=s(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),a(t)},r.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function l(t,e){var r,o,n=(e=e||{}).body;if(t instanceof l){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",o=r.toUpperCase(),y.indexOf(o)>-1?o:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function m(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}l.prototype.clone=function(){return new l(this,{body:this._bodyInit})},p.call(l.prototype),p.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];m.redirect=function(t,e){if(-1===w.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function v(t,o){return new Promise((function(n,i){var s=new l(t,o);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function f(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new m(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",f),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",f)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=h,t.Request=l,t.Response=m),e.Headers=h,e.Request=l,e.Response=m,e.fetch=v,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(r=i.fetch).default=i.fetch,r.fetch=i.fetch,r.Headers=i.Headers,r.Request=i.Request,r.Response=i.Response,e.exports=r}(r,r.exports);var o=e(r.exports);export{r as b,o as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,m as t,s as r,o as a,p as s,q as o,r as n,u as c,w as i,H as d,x as p}from"./index-81e6d2c8.js";import"./index-76c2f135.js";import"@ethersproject/providers";import"zustand";import"events";import"@ethersproject/address";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"@ethersproject/abstract-provider";import"./index-6aa8c5c1.js";import"@ethersproject/abstract-signer";import"./id-66098a37.js";import"./bn-27b74013.js";import"./__node-resolve_empty-c07e04b2.js";import"./index-1fae0e53.js";import"./hash-b468659c.js";import"./inherits_browser-51bb8c3c.js";import"@ethersproject/json-wallets";import"./DefaultJsonRpcProvider-cbd850bc.js";import"./browser-ponyfill-9983e3af.js";import"buffer";import"./index-5b79ce49.js";class l extends e{constructor({callbackSelector:e,cause:r,data:a,extraData:s,sender:o,urls:n}){super(r.shortMessage||"An error occurred while fetching for an offchain result.",{cause:r,metaMessages:[...r.metaMessages||[],r.metaMessages?.length?"":[],"Offchain Gateway Call:",n&&[" Gateway URL(s):",...n.map((e=>` ${t(e)}`))],` Sender: ${o}`,` Data: ${a}`,` Callback selector: ${e}`,` Extra data: ${s}`].flat()}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupError"})}}class u extends e{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t(a)}`,`Response: ${r(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupResponseMalformedError"})}}class m extends e{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupSenderMismatchError"})}}const b="0x556f1830",f={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function h(e,{blockNumber:t,blockTag:r,data:d,to:p}){const{args:u}=o({data:d,abi:[f]}),[b,h,y,j,g]=u;try{if(!function(e,t){if(!a(e,{strict:!1}))throw new s({address:e});if(!a(t,{strict:!1}))throw new s({address:t});return e.toLowerCase()===t.toLowerCase()}(p,b))throw new m({sender:b,to:p});const o=await w({data:y,sender:b,urls:h}),{data:d}=await n(e,{blockNumber:t,blockTag:r,data:c([j,i([{type:"bytes"},{type:"bytes"}],[o,g])]),to:p});return d}catch(e){throw new l({callbackSelector:j,cause:e,data:d,extraData:g,sender:b,urls:h})}}async function w({data:e,sender:t,urls:a}){let s=new Error("An unknown error occurred.");for(let o=0;o<a.length;o++){const n=a[o],c=n.includes("{data}")?"GET":"POST",i="POST"===c?{data:e,sender:t}:void 0;try{const a=await fetch(n.replace("{sender}",t).replace("{data}",e),{body:JSON.stringify(i),method:c});let o;if(o=a.headers.get("Content-Type")?.startsWith("application/json")?(await a.json()).data:await a.text(),!a.ok){s=new d({body:i,details:o?.error?r(o.error):a.statusText,headers:a.headers,status:a.status,url:n});continue}if(!p(o)){s=new u({result:o,url:n});continue}return o}catch(e){s=new d({body:i,details:e.message,url:n})}}throw s}export{w as ccipFetch,h as offchainLookup,f as offchainLookupAbiItem,b as offchainLookupSignature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@ethersproject/providers"),r=require("./index-584ce2f2.cjs"),t=require("@ethersproject/properties");function s(e){if(e.error){const r=new Error(e.error.message);throw r.code=e.error.code,r.data=e.error.data,r}return e.result}class o extends e.StaticJsonRpcProvider{getNetwork(){return"object"==typeof this.network&&"number"==typeof this.network.chainId?Promise.resolve(this.network):"number"==typeof this.network&&this.network?Promise.resolve({chainId:this.network,name:"unknown"}):super.getNetwork()}send(e,o){var i;const n={method:e,params:o,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:t.deepCopy(n),provider:this});const c=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(c&&this._cache[e])return this._cache[e];const h=r.fetchJson(Object.assign(Object.assign({},this.connection),{url:this.rpcUrl||(null===(i=this.connection)||void 0===i?void 0:i.url)}),JSON.stringify(n),s).then((e=>(this.emit("debug",{action:"response",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:n,provider:this}),e}));return c&&(this._cache[e]=h,setTimeout((()=>{this._cache[e]=null}),0)),h}}exports.DefaultJsonRpcProvider=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-4b751ebb.cjs"),r=Object.freeze({__proto__:null,default:{}}),t=e.getAugmentedNamespace(r);exports.require$$1=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-4b751ebb.cjs"),r=e.getAugmentedNamespace(e._tslib);exports.require$$0=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-c8612d96.cjs"),r=require("./id-306822a4.cjs"),t=require("@ethersproject/providers"),n=require("./index-584ce2f2.cjs");require("@ethersproject/abstract-provider"),require("@ethersproject/contracts");const i=new r.Logger("networks/5.7.1");function o(e){const r=function(r,t){null==t&&(t={});const n=[];if(r.InfuraProvider&&"-"!==t.infura)try{n.push(new r.InfuraProvider(e,t.infura))}catch(e){}if(r.EtherscanProvider&&"-"!==t.etherscan)try{n.push(new r.EtherscanProvider(e,t.etherscan))}catch(e){}if(r.AlchemyProvider&&"-"!==t.alchemy)try{n.push(new r.AlchemyProvider(e,t.alchemy))}catch(e){}if(r.PocketProvider&&"-"!==t.pocket){const i=["goerli","ropsten","rinkeby","sepolia"];try{const o=new r.PocketProvider(e,t.pocket);o.network&&-1===i.indexOf(o.network.name)&&n.push(o)}catch(e){}}if(r.CloudflareProvider&&"-"!==t.cloudflare)try{n.push(new r.CloudflareProvider(e))}catch(e){}if(r.AnkrProvider&&"-"!==t.ankr)try{const i=["ropsten"],o=new r.AnkrProvider(e,t.ankr);o.network&&-1===i.indexOf(o.network.name)&&n.push(o)}catch(e){}if(0===n.length)return null;if(r.FallbackProvider){let i=1;return null!=t.quorum?i=t.quorum:"homestead"===e&&(i=2),new r.FallbackProvider(n,i)}return n[0]};return r.renetwork=function(e){return o(e)},r}function s(e,r){const t=function(t,n){return t.JsonRpcProvider?new t.JsonRpcProvider(e,r):null};return t.renetwork=function(r){return s(e,r)},t}const a={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:o("homestead")},c={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:o("ropsten")},d={chainId:63,name:"classicMordor",_defaultProvider:s("https://www.ethercluster.com/mordor","classicMordor")},h={unspecified:{chainId:0,name:"unspecified"},homestead:a,mainnet:a,morden:{chainId:2,name:"morden"},ropsten:c,testnet:c,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:o("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:o("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:o("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:o("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:s("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:d,classicTestnet:d,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:s("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:o("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:o("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function u(e){if(null==e)return null;if("number"==typeof e){for(const r in h){const t=h[r];if(t.chainId===e)return{name:t.name,chainId:t.chainId,ensAddress:t.ensAddress||null,_defaultProvider:t._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){const r=h[e];return null==r?null:{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress,_defaultProvider:r._defaultProvider||null}}const r=h[e.name];if(!r)return"number"!=typeof e.chainId&&i.throwArgumentError("invalid network chainId","network",e),e;0!==e.chainId&&e.chainId!==r.chainId&&i.throwArgumentError("network chainId mismatch","network",e);let t=e._defaultProvider||null;var n;return null==t&&r._defaultProvider&&(t=(n=r._defaultProvider)&&"function"==typeof n.renetwork?r._defaultProvider.renetwork(e):r._defaultProvider),{name:e.name,chainId:r.chainId,ensAddress:e.ensAddress||r.ensAddress||null,_defaultProvider:t}}class l{constructor(e,r=100){this.sendBatchFn=e,this.maxBatchSize=r,this.pendingBatch=[]}enqueueRequest(r){return e.__awaiter$1(this,void 0,void 0,(function*(){const e={request:r,resolve:void 0,reject:void 0},t=new Promise(((r,t)=>{e.resolve=r,e.reject=t}));return this.pendingBatch.push(e),this.pendingBatch.length===this.maxBatchSize?this.sendBatchRequest():this.pendingBatchTimer||(this.pendingBatchTimer=setTimeout((()=>this.sendBatchRequest()),10)),t}))}sendBatchRequest(){return e.__awaiter$1(this,void 0,void 0,(function*(){const e=this.pendingBatch;this.pendingBatch=[],this.pendingBatchTimer&&(clearTimeout(this.pendingBatchTimer),this.pendingBatchTimer=void 0);const r=e.map((e=>e.request));return this.sendBatchFn(r).then((r=>{e.forEach(((e,t)=>{const n=r[t];if(n.error){const r=new Error(n.error.message);r.code=n.error.code,r.data=n.error.data,e.reject(r)}else e.resolve(n.result)}))}),(r=>{e.forEach((e=>{e.reject(r)}))}))}))}}class m extends t.JsonRpcProvider{constructor(r){const t=m.getApiKey(r.apiKey),i=m.getAlchemyNetwork(r.network),o=m.getAlchemyConnectionInfo(i,t,"http");void 0!==r.url&&(o.url=r.url),o.throttleLimit=r.maxRetries;super(o,e.EthersNetwork[i]),this.apiKey=r.apiKey,this.maxRetries=r.maxRetries,this.batchRequests=r.batchRequests;const s=Object.assign(Object.assign({},this.connection),{headers:Object.assign(Object.assign({},this.connection.headers),{"Alchemy-Ethers-Sdk-Method":"batchSend"})});this.batcher=new l((e=>n.fetchJson(s,JSON.stringify(e)))),this.modifyFormatter()}static getApiKey(r){if(null==r)return e.DEFAULT_ALCHEMY_API_KEY;if(r&&"string"!=typeof r)throw new Error(`Invalid apiKey '${r}' provided. apiKey must be a string.`);return r}static getNetwork(r){return"string"==typeof r&&r in e.CustomNetworks?e.CustomNetworks[r]:u(r)}static getAlchemyNetwork(r){if(void 0===r)return e.DEFAULT_NETWORK;if("number"==typeof r)throw new Error(`Invalid network '${r}' provided. Network must be a string.`);if(!Object.values(e.Network).includes(r))throw new Error(`Invalid network '${r}' provided. Network must be one of: ${Object.values(e.Network).join(", ")}.`);return r}static getAlchemyConnectionInfo(r,t,n){const i="http"===n?e.getAlchemyHttpUrl(r,t):e.getAlchemyWsUrl(r,t);return{headers:e.IS_BROWSER?{"Alchemy-Ethers-Sdk-Version":e.VERSION}:{"Alchemy-Ethers-Sdk-Version":e.VERSION,"Accept-Encoding":"gzip"},allowGzip:!0,url:i}}detectNetwork(){const r=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return e.__awaiter$1(this,void 0,void 0,(function*(){let e=this.network;if(null==e&&(e=yield r.detectNetwork.call(this),!e))throw new Error("No network detected");return e}))}_startPending(){e.logWarn("WARNING: Alchemy Provider does not support pending filters")}isCommunityResource(){return this.apiKey===e.DEFAULT_ALCHEMY_API_KEY}send(e,r){return this._send(e,r,"send")}_send(r,t,i,o=!1){const s={method:r,params:t,id:this._nextId++,jsonrpc:"2.0"};if(Object.assign({},this.connection).headers["Alchemy-Ethers-Sdk-Method"]=i,this.batchRequests||o)return this.batcher.enqueueRequest(s);this.emit("debug",{action:"request",request:e.deepCopy(s),provider:this});const a=["eth_chainId","eth_blockNumber"].indexOf(r)>=0;if(a&&this._cache[r])return this._cache[r];const c=n.fetchJson(this.connection,JSON.stringify(s),f).then((e=>(this.emit("debug",{action:"response",request:s,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:s,provider:this}),e}));return a&&(this._cache[r]=c,setTimeout((()=>{this._cache[r]=null}),0)),c}modifyFormatter(){this.formatter.formats.receiptLog.removed=e=>{if("boolean"==typeof e)return e}}}function f(e){if(e.error){const r=new Error(e.error.message);throw r.code=e.error.code,r.data=e.error.data,r}return e.result}var p=Object.freeze({__proto__:null,AlchemyProvider:m});exports.AlchemyProvider=m,exports.alchemyProvider5870b6fa=p,exports.getNetwork=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-c8612d96.cjs"),t=require("./alchemy-provider-5870b6fa-1e0f04fc.cjs"),s=require("@ethersproject/providers");require("@ethersproject/abstract-provider"),require("@ethersproject/contracts");var n=require("./id-306822a4.cjs");require("./index-4b751ebb.cjs"),require("zustand"),require("events"),require("@ethersproject/address"),require("@ethersproject/constants"),require("@ethersproject/properties"),require("@ethersproject/transactions"),require("@ethersproject/bytes"),require("./index-d890bb01.cjs"),require("@ethersproject/abstract-signer"),require("./index-584ce2f2.cjs"),require("./bn-2fd35ed6.cjs"),require("./__node-resolve_empty-d89e5abe.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs"),require("@ethersproject/json-wallets"),require("./DefaultJsonRpcProvider-4b2cbac3.cjs"),require("./browser-ponyfill-479139d5.cjs"),require("buffer"),require("./index-e373c760.cjs");var i={};Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(t,s,n){if(void 0===n&&(n={}),this.url=t,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this.ondown=null,this.onreopen=null,this.CONNECTING=e.CONNECTING,this.OPEN=e.OPEN,this.CLOSING=e.CLOSING,this.CLOSED=e.CLOSED,this.hasBeenOpened=!1,this.isClosed=!1,this.messageBuffer=[],this.nextRetryTime=0,this.reconnectCount=0,this.lastKnownExtensions="",this.lastKnownProtocol="",this.listeners={},null==s||"string"==typeof s||Array.isArray(s)?this.protocols=s:n=s,this.options=c(n),!this.options.wsConstructor){if("undefined"==typeof WebSocket)throw new Error("WebSocket not present in global scope and no wsConstructor option was provided.");this.options.wsConstructor=WebSocket}this.openNewWebSocket()}return Object.defineProperty(e.prototype,"binaryType",{get:function(){return this.binaryTypeInternal||"blob"},set:function(e){this.binaryTypeInternal=e,this.ws&&(this.ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var e=this.ws?this.ws.bufferedAmount:0,t=!1;return this.messageBuffer.forEach((function(s){var n=function(e){return"string"==typeof e?2*e.length:e instanceof ArrayBuffer?e.byteLength:e instanceof Blob?e.size:void 0}(s);null!=n?e+=n:t=!0})),t&&this.debugLog("Some buffered data had unknown length. bufferedAmount() return value may be below the correct amount."),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this.ws?this.ws.extensions:this.lastKnownExtensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this.ws?this.ws.protocol:this.lastKnownProtocol},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this.isClosed?e.CLOSED:e.OPEN},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){this.disposeSocket(e,t),this.shutdown(),this.debugLog("WebSocket permanently closed by client.")},e.prototype.send=function(e){if(this.isClosed)throw new Error("WebSocket is already in CLOSING or CLOSED state.");this.ws&&this.ws.readyState===this.OPEN?this.ws.send(e):this.messageBuffer.push(e)},e.prototype.reconnect=function(){if(this.isClosed)throw new Error("Cannot call reconnect() on socket which is permanently closed.");this.disposeSocket(1e3,"Client requested reconnect."),this.handleClose(void 0)},e.prototype.addEventListener=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},e.prototype.dispatchEvent=function(e){return this.dispatchEventOfType(e.type,e)},e.prototype.removeEventListener=function(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter((function(e){return e!==t})))},e.prototype.openNewWebSocket=function(){var e=this;if(!this.isClosed){var t=this.options,s=t.connectTimeout,n=t.wsConstructor;this.debugLog("Opening new WebSocket to "+this.url+".");var i=new n(this.url,this.protocols);i.onclose=function(t){return e.handleClose(t)},i.onerror=function(t){return e.handleError(t)},i.onmessage=function(t){return e.handleMessage(t)},i.onopen=function(t){return e.handleOpen(t)},this.connectTimeoutId=setTimeout((function(){e.clearConnectTimeout(),e.disposeSocket(),e.handleClose(void 0)}),s),this.ws=i}},e.prototype.handleOpen=function(e){var t=this;if(this.ws&&!this.isClosed){var s=this.options.allClearResetTime;this.debugLog("WebSocket opened."),null!=this.binaryTypeInternal?this.ws.binaryType=this.binaryTypeInternal:this.binaryTypeInternal=this.ws.binaryType,this.clearConnectTimeout(),this.hasBeenOpened?this.dispatchEventOfType("reopen",e):(this.dispatchEventOfType("open",e),this.hasBeenOpened=!0),this.messageBuffer.forEach((function(e){return t.send(e)})),this.messageBuffer=[],this.allClearTimeoutId=setTimeout((function(){t.clearAllClearTimeout(),t.nextRetryTime=0,t.reconnectCount=0;var e=s/1e3|0;t.debugLog("WebSocket remained open for "+e+" seconds. Resetting retry time and count.")}),s)}},e.prototype.handleMessage=function(e){this.isClosed||this.dispatchEventOfType("message",e)},e.prototype.handleClose=function(e){var t=this;if(!this.isClosed){var s=this.options,n=s.maxReconnectAttempts,i=s.shouldReconnect;if(this.clearConnectTimeout(),this.clearAllClearTimeout(),this.ws&&(this.lastKnownExtensions=this.ws.extensions,this.lastKnownProtocol=this.ws.protocol,this.disposeSocket()),this.dispatchEventOfType("down",e),this.reconnectCount>=n)this.stopReconnecting(e,this.getTooManyFailedReconnectsMessage());else{var r=!e||i(e);"boolean"==typeof r?this.handleWillReconnect(r,e,"Provided shouldReconnect() returned false. Closing permanently."):r.then((function(s){t.isClosed||t.handleWillReconnect(s,e,"Provided shouldReconnect() resolved to false. Closing permanently.")}))}}},e.prototype.handleError=function(e){this.dispatchEventOfType("error",e),this.debugLog("WebSocket encountered an error.")},e.prototype.handleWillReconnect=function(e,t,s){e?this.reestablishConnection():this.stopReconnecting(t,s)},e.prototype.reestablishConnection=function(){var e=this,t=this.options,s=t.minReconnectDelay,n=t.maxReconnectDelay,i=t.reconnectBackoffFactor;this.reconnectCount++;var r=this.nextRetryTime;this.nextRetryTime=Math.max(s,Math.min(this.nextRetryTime*i,n)),setTimeout((function(){return e.openNewWebSocket()}),r);var o=r/1e3|0;this.debugLog("WebSocket was closed. Re-opening in "+o+" seconds.")},e.prototype.stopReconnecting=function(e,t){this.debugLog(t),this.shutdown(),e&&this.dispatchEventOfType("close",e)},e.prototype.shutdown=function(){this.isClosed=!0,this.clearAllTimeouts(),this.messageBuffer=[],this.disposeSocket()},e.prototype.disposeSocket=function(e,t){this.ws&&(this.ws.onerror=l,this.ws.onclose=l,this.ws.onmessage=l,this.ws.onopen=l,this.ws.close(e,t),this.ws=void 0)},e.prototype.clearAllTimeouts=function(){this.clearConnectTimeout(),this.clearAllClearTimeout()},e.prototype.clearConnectTimeout=function(){null!=this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=void 0)},e.prototype.clearAllClearTimeout=function(){null!=this.allClearTimeoutId&&(clearTimeout(this.allClearTimeoutId),this.allClearTimeoutId=void 0)},e.prototype.dispatchEventOfType=function(e,t){var s=this;switch(e){case"close":this.onclose&&this.onclose(t);break;case"error":this.onerror&&this.onerror(t);break;case"message":this.onmessage&&this.onmessage(t);break;case"open":this.onopen&&this.onopen(t);break;case"down":this.ondown&&this.ondown(t);break;case"reopen":this.onreopen&&this.onreopen(t)}return e in this.listeners&&this.listeners[e].slice().forEach((function(e){return s.callListener(e,t)})),!t||!t.defaultPrevented},e.prototype.callListener=function(e,t){"function"==typeof e?e.call(this,t):e.handleEvent.call(this,t)},e.prototype.debugLog=function(e){this.options.debug&&console.log(e)},e.prototype.getTooManyFailedReconnectsMessage=function(){var e,t=this.options.maxReconnectAttempts;return"Failed to reconnect after "+t+" "+(e="attempt",(1===t?e:e+"s")+". Closing permanently.")},e.DEFAULT_OPTIONS={allClearResetTime:5e3,connectTimeout:5e3,debug:!1,minReconnectDelay:1e3,maxReconnectDelay:3e4,maxReconnectAttempts:Number.POSITIVE_INFINITY,reconnectBackoffFactor:1.5,shouldReconnect:function(){return!0},wsConstructor:void 0},e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}(),o=i.default=r;function c(e){var t={};return Object.keys(r.DEFAULT_OPTIONS).forEach((function(s){var n=e[s];t[s]=void 0===n?r.DEFAULT_OPTIONS[s]:n})),t}function l(){}class a{constructor(e){this.provider=e,this.maxBackfillBlocks=120}getNewHeadsBackfill(t,s,n){return e.__awaiter$1(this,void 0,void 0,(function*(){f(t);const i=yield this.getBlockNumber();if(f(t),0===s.length)return this.getHeadEventsInRange(Math.max(n,i-this.maxBackfillBlocks)+1,i+1);const r=e.fromHex(s[s.length-1].number),o=i-this.maxBackfillBlocks+1;if(r<=o)return this.getHeadEventsInRange(o,i+1);const c=yield this.getReorgHeads(t,s);f(t);const l=yield this.getHeadEventsInRange(r+1,i+1);return f(t),[...c,...l]}))}getLogsBackfill(t,s,n,i){return e.__awaiter$1(this,void 0,void 0,(function*(){f(t);const r=yield this.getBlockNumber();if(f(t),0===n.length)return this.getLogsInRange(s,Math.max(i,r-this.maxBackfillBlocks)+1,r+1);const o=e.fromHex(n[n.length-1].blockNumber),c=r-this.maxBackfillBlocks+1;if(o<c)return this.getLogsInRange(s,c,r+1);const l=yield this.getCommonAncestor(t,n);f(t);const a=n.filter((t=>e.fromHex(t.blockNumber)>l.blockNumber)).map((e=>Object.assign(Object.assign({},e),{removed:!0}))),h=l.blockNumber===Number.NEGATIVE_INFINITY?e.fromHex(n[0].blockNumber):l.blockNumber;let u=yield this.getLogsInRange(s,h,r+1);return u=u.filter((t=>t&&(e.fromHex(t.blockNumber)>l.blockNumber||e.fromHex(t.logIndex)>l.logIndex))),f(t),[...a,...u]}))}setMaxBackfillBlock(e){this.maxBackfillBlocks=e}getBlockNumber(){return e.__awaiter$1(this,void 0,void 0,(function*(){const t=yield this.provider.send("eth_blockNumber");return e.fromHex(t)}))}getHeadEventsInRange(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){if(t>=s)return[];const n=[];for(let i=t;i<s;i++)n.push({method:"eth_getBlockByNumber",params:[e.toHex(i),!1]});return(yield this.provider.sendBatch(n)).map(h)}))}getReorgHeads(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){const n=[];for(let i=s.length-1;i>=0;i--){const r=s[i],o=yield this.getBlockByNumber(e.fromHex(r.number));if(f(t),r.hash===o.hash)break;n.push(h(o))}return n.reverse()}))}getBlockByNumber(t){return e.__awaiter$1(this,void 0,void 0,(function*(){return this.provider.send("eth_getBlockByNumber",[e.toHex(t),!1])}))}getCommonAncestor(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){let n=yield this.getBlockByNumber(e.fromHex(s[s.length-1].blockNumber));f(t);for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.blockNumber!==n.number&&(n=yield this.getBlockByNumber(e.fromHex(i.blockNumber))),i.blockHash===n.hash)return{blockNumber:e.fromHex(i.blockNumber),logIndex:e.fromHex(i.logIndex)}}return{blockNumber:Number.NEGATIVE_INFINITY,logIndex:Number.NEGATIVE_INFINITY}}))}getLogsInRange(t,s,n){return e.__awaiter$1(this,void 0,void 0,(function*(){if(s>=n)return[];const i=Object.assign(Object.assign({},t),{fromBlock:e.toHex(s),toBlock:e.toHex(n-1)});return this.provider.send("eth_getLogs",[i])}))}}function h(e){const t=Object.assign({},e);return delete t.totalDifficulty,delete t.transactions,delete t.uncles,t}function u(e,t){const s=new Set,n=[];return e.forEach((e=>{const i=t(e);s.has(i)||(s.add(i),n.push(e))})),n}const d=new Error("Cancelled");function f(e){if(e())throw d}const m=10;class p extends s.WebSocketProvider{constructor(s,n){var i;const r=t.AlchemyProvider.getApiKey(s.apiKey),c=t.AlchemyProvider.getAlchemyNetwork(s.network),l=t.AlchemyProvider.getAlchemyConnectionInfo(c,r,"wss"),h=`alchemy-sdk-${e.VERSION}`;super(new o(null!==(i=s.url)&&void 0!==i?i:l.url,h,{wsConstructor:null!=n?n:"undefined"!=typeof process&&null!=process&&null!=process.versions&&null!=process.versions.node?require("websocket").w3cwebsocket:WebSocket}),e.EthersNetwork[c]),this._events=[],this.virtualSubscriptionsById=new Map,this.virtualIdsByPhysicalId=new Map,this.handleMessage=e=>{const t=JSON.parse(e.data);if(!function(e){return!function(e){return Array.isArray(e)||"2.0"===e.jsonrpc&&void 0!==e.id}(e)}(t))return;const s=t.params.subscription,n=this.virtualIdsByPhysicalId.get(s);if(!n)return;const i=this.virtualSubscriptionsById.get(n);if("eth_subscribe"===i.method)switch(i.params[0]){case"newHeads":{const e=i,r=t,{isBackfilling:o,backfillBuffer:c}=e,{result:l}=r.params;o?function(e,t){N(e,t,_)}(c,l):s!==n?this.emitAndRememberEvent(n,l,_):this.rememberEvent(n,l,_);break}case"logs":{const e=i,r=t,{isBackfilling:o,backfillBuffer:c}=e,{result:l}=r.params;o?function(e,t){N(e,t,w)}(c,l):n!==s?this.emitAndRememberEvent(n,l,w):this.rememberEvent(n,l,w);break}default:if(s!==n){const{result:e}=t.params;this.emitEvent(n,e)}}},this.handleReopen=()=>{this.virtualIdsByPhysicalId.clear();const{cancel:t,isCancelled:s}=function(){let e=!1;return{cancel:()=>e=!0,isCancelled:()=>e}}();this.cancelBackfill=t;for(const t of this.virtualSubscriptionsById.values())(()=>{e.__awaiter$1(this,void 0,void 0,(function*(){try{yield this.resubscribeAndBackfill(s,t)}catch(e){s()||console.error(`Error while backfilling "${t.params[0]}" subscription. Some events may be missing.`,e)}}))})();this.startHeartbeat()},this.stopHeartbeatAndBackfill=()=>{null!=this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.cancelBackfill()},this.apiKey=r,this.backfiller=new a(this),this.addSocketListeners(),this.startHeartbeat(),this.cancelBackfill=e.noop}static getNetwork(s){return"string"==typeof s&&s in e.CustomNetworks?e.CustomNetworks[s]:t.getNetwork(s)}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}off(t,s){return e.isAlchemyEvent(t)?this._off(t,s):super.off(t,s)}removeAllListeners(t){return void 0!==t&&e.isAlchemyEvent(t)?this._removeAllListeners(t):super.removeAllListeners(t)}listenerCount(t){return void 0!==t&&e.isAlchemyEvent(t)?this._listenerCount(t):super.listenerCount(t)}listeners(t){return void 0!==t&&e.isAlchemyEvent(t)?this._listeners(t):super.listeners(t)}_addEventListener(t,s,n){if(e.isAlchemyEvent(t)){e.verifyAlchemyEventName(t);const i=new e.EthersEvent(e.getAlchemyEventTag(t),s,n);return this._events.push(i),this._startEvent(i),this}return super._addEventListener(t,s,n)}_startEvent(t){[...e.ALCHEMY_EVENT_TYPES,"block","filter"].includes(t.type)?this.customStartEvent(t):super._startEvent(t)}_subscribe(t,s,n,i){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=this._subIds[t];const r=yield this.getBlockNumber();null==e&&(e=Promise.all(s).then((e=>this.send("eth_subscribe",e))),this._subIds[t]=e);const o=yield e,c=yield Promise.all(s);this.virtualSubscriptionsById.set(o,{event:i,method:"eth_subscribe",params:c,startingBlockNumber:r,virtualId:o,physicalId:o,sentEvents:[],isBackfilling:!1,backfillBuffer:[]}),this.virtualIdsByPhysicalId.set(o,o),this._subs[o]={tag:t,processFunc:n}}))}emit(t,...s){if(e.isAlchemyEvent(t)){let n=!1;const i=[],r=e.getAlchemyEventTag(t);return this._events=this._events.filter((e=>e.tag!==r||(setTimeout((()=>{e.listener.apply(this,s)}),0),n=!0,!e.once||(i.push(e),!1)))),i.forEach((e=>{this._stopEvent(e)})),n}return super.emit(t,...s)}sendBatch(t){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=0;const s=t.map((({method:t,params:s})=>({method:t,params:s,jsonrpc:"2.0",id:"alchemy-sdk:"+e++})));return this.sendBatchConcurrently(s)}))}destroy(){return this.removeSocketListeners(),this.stopHeartbeatAndBackfill(),super.destroy()}isCommunityResource(){return this.apiKey===e.DEFAULT_ALCHEMY_API_KEY}_stopEvent(t){let s=t.tag;if(e.ALCHEMY_EVENT_TYPES.includes(t.type)){if(this._events.filter((t=>e.ALCHEMY_EVENT_TYPES.includes(t.type))).length)return}else if("tx"===t.type){if(this._events.filter((e=>"tx"===e.type)).length)return;s="tx"}else if(this.listenerCount(t.event))return;const n=this._subIds[s];n&&(delete this._subIds[s],n.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}addSocketListeners(){this._websocket.addEventListener("message",this.handleMessage),this._websocket.addEventListener("reopen",this.handleReopen),this._websocket.addEventListener("down",this.stopHeartbeatAndBackfill)}removeSocketListeners(){this._websocket.removeEventListener("message",this.handleMessage),this._websocket.removeEventListener("reopen",this.handleReopen),this._websocket.removeEventListener("down",this.stopHeartbeatAndBackfill)}resubscribeAndBackfill(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){const{virtualId:e,method:n,params:i,sentEvents:r,backfillBuffer:o,startingBlockNumber:c}=s;s.isBackfilling=!0,o.length=0;try{const l=yield this.send(n,i);switch(f(t),s.physicalId=l,this.virtualIdsByPhysicalId.set(l,e),i[0]){case"newHeads":{const s=yield g((()=>k(this.backfiller.getNewHeadsBackfill(t,r,c),6e4)),5,(()=>!t()));f(t);(function(e){return u(e,(e=>e.hash))})([...s,...o]).forEach((t=>this.emitNewHeadsEvent(e,t)));break}case"logs":{const s=i[1]||{},n=yield g((()=>k(this.backfiller.getLogsBackfill(t,s,r,c),6e4)),5,(()=>!t()));f(t);(function(e){return u(e,(e=>`${e.blockHash}/${e.logIndex}`))})([...n,...o]).forEach((t=>this.emitLogsEvent(e,t)));break}}}finally{s.isBackfilling=!1,o.length=0}}))}emitNewHeadsEvent(e,t){this.emitAndRememberEvent(e,t,_)}emitLogsEvent(e,t){this.emitAndRememberEvent(e,t,w)}emitAndRememberEvent(e,t,s){this.rememberEvent(e,t,s),this.emitEvent(e,t)}emitEvent(e,t){const s=this.virtualSubscriptionsById.get(e);s&&this.emitGenericEvent(s,t)}rememberEvent(e,t,s){const n=this.virtualSubscriptionsById.get(e);n&&N(n.sentEvents,Object.assign({},t),s)}emitGenericEvent(e,t){this.emitProcessFn(e.event)(t)}startHeartbeat(){null==this.heartbeatIntervalId&&(this.heartbeatIntervalId=setInterval((()=>e.__awaiter$1(this,void 0,void 0,(function*(){try{yield k(this.send("net_version"),1e4)}catch(e){this._websocket.reconnect()}}))),3e4))}sendBatchConcurrently(t){return e.__awaiter$1(this,void 0,void 0,(function*(){return Promise.all(t.map((e=>this.send(e.method,e.params))))}))}customStartEvent(t){if(t.type===e.ALCHEMY_PENDING_TRANSACTIONS_EVENT_TYPE){const{fromAddress:s,toAddress:n,hashesOnly:i}=t;this._subscribe(t.tag,[e.AlchemySubscription.PENDING_TRANSACTIONS,{fromAddress:s,toAddress:n,hashesOnly:i}],this.emitProcessFn(t),t)}else if(t.type===e.ALCHEMY_MINED_TRANSACTIONS_EVENT_TYPE){const{addresses:s,includeRemoved:n,hashesOnly:i}=t;this._subscribe(t.tag,[e.AlchemySubscription.MINED_TRANSACTIONS,{addresses:s,includeRemoved:n,hashesOnly:i}],this.emitProcessFn(t),t)}else"block"===t.type?this._subscribe("block",["newHeads"],this.emitProcessFn(t),t):"filter"===t.type&&this._subscribe(t.tag,["logs",this._getFilter(t.filter)],this.emitProcessFn(t),t)}emitProcessFn(t){switch(t.type){case e.ALCHEMY_PENDING_TRANSACTIONS_EVENT_TYPE:return s=>this.emit({method:e.AlchemySubscription.PENDING_TRANSACTIONS,fromAddress:t.fromAddress,toAddress:t.toAddress,hashesOnly:t.hashesOnly},s);case e.ALCHEMY_MINED_TRANSACTIONS_EVENT_TYPE:return s=>this.emit({method:e.AlchemySubscription.MINED_TRANSACTIONS,addresses:t.addresses,includeRemoved:t.includeRemoved,hashesOnly:t.hashesOnly},s);case"block":return e=>{const t=n.BigNumber.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)};case"filter":return e=>{null==e.removed&&(e.removed=!1),this.emit(t.filter,this.formatter.filterLog(e))};default:throw new Error("Invalid event type to `emitProcessFn()`")}}_off(t,s){if(null==s)return this.removeAllListeners(t);const n=[];let i=!1;const r=e.getAlchemyEventTag(t);return this._events=this._events.filter((e=>e.tag!==r||e.listener!=s||(!!i||(i=!0,n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),this}_removeAllListeners(t){let s=[];if(null==t)s=this._events,this._events=[];else{const n=e.getAlchemyEventTag(t);this._events=this._events.filter((e=>e.tag!==n||(s.push(e),!1)))}return s.forEach((e=>{this._stopEvent(e)})),this}_listenerCount(t){if(!t)return this._events.length;const s=e.getAlchemyEventTag(t);return this._events.filter((e=>e.tag===s)).length}_listeners(t){if(null==t)return this._events.map((e=>e.listener));const s=e.getAlchemyEventTag(t);return this._events.filter((e=>e.tag===s)).map((e=>e.listener))}}const b=1e3,v=2,y=3e4;function g(t,s,n=(()=>!0)){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=0,i=0;for(;;)try{return yield t()}catch(t){if(i++,i>=s||!n(t))throw t;if(yield E(e),!n(t))throw t;e=0===e?b:Math.min(y,v*e)}}))}function E(e){return new Promise((t=>setTimeout(t,e)))}function k(e,t){return Promise.race([e,new Promise(((e,s)=>setTimeout((()=>s(new Error("Timeout"))),t)))])}function _(t){return e.fromHex(t.number)}function w(t){return e.fromHex(t.blockNumber)}function N(e,t,s){const n=s(t),i=e.findIndex((e=>s(e)>n-m));-1===i?e.length=0:e.splice(0,i),e.push(t)}exports.AlchemyWebSocketProvider=p;
|