1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4295],{53374:function(e,t,n){n.d(t,{W:function(){return s}});var i=n(42321),r=n(36393);class s extends r.Z{constructor(e){let{chains:t=i.gL9,options:n}=e;super(),this.chains=t,this.options=n}getBlockExplorerUrls(e){let t=e.explorers?.map(e=>e.url)??[];return t.length>0?t:void 0}isChainUnsupported(e){return!this.chains.some(t=>t.chainId===e)}updateChains(e){this.chains=e}}},71244:function(e,t,n){n.d(t,{A:function(){return o},C:function(){return a},R:function(){return h},S:function(){return u},U:function(){return d},a:function(){return c}});var i=n(31929);class r extends Error{constructor(e,t){let{cause:n,code:i,data:r}=t;if(!Number.isInteger(i))throw Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw Error('"message" must be a nonempty string.');super(`${e}. Cause: ${JSON.stringify(n)}`),this.cause=n,this.code=i,this.data=r}}class s extends r{constructor(e,t){let{cause:n,code:i,data:r}=t;if(!(Number.isInteger(i)&&i>=1e3&&i<=4999))throw Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,{cause:n,code:i,data:r})}}class o extends Error{constructor(){super(...arguments),(0,i._)(this,"name","AddChainError"),(0,i._)(this,"message","Error adding chain")}}class a extends Error{constructor(e){let{chainId:t,connectorId:n}=e;super(`Chain "${t}" not configured for connector "${n}".`),(0,i._)(this,"name","ChainNotConfigured")}}class c extends Error{constructor(){super(...arguments),(0,i._)(this,"name","ConnectorNotFoundError"),(0,i._)(this,"message","Connector not found")}}class h extends r{constructor(e){super("Resource unavailable",{cause:e,code:-32002}),(0,i._)(this,"name","ResourceUnavailable")}}class u extends s{constructor(e){super("Error switching chain",{cause:e,code:4902}),(0,i._)(this,"name","SwitchChainError")}}class d extends s{constructor(e){super("User rejected request",{cause:e,code:4001}),(0,i._)(this,"name","UserRejectedRequestError")}}},31562:function(e,t,n){n.d(t,{n:function(){return i}});function i(e){return"string"==typeof e?Number.parseInt(e,"0x"===e.trim().substring(0,2)?16:10):"bigint"==typeof e?Number(e):e}},44295:function(e,t,n){n.d(t,{InjectedConnector:function(){return l}});var i=n(31929),r=n(53374),s=n(71244),o=n(2975),a=n(60874),c=n(89005),h=n(68893),u=n(9784),d=n(31562);n(36393);class l extends r.W{constructor(e){let t={shimDisconnect:!0,getProvider:()=>{if((0,o.a)(globalThis.window))return globalThis.window.ethereum},...e.options};super({chains:e.chains,options:t}),(0,i._)(this,"shimDisconnectKey","injected.shimDisconnect"),(0,i._)(this,"onAccountsChanged",async e=>{0===e.length?this.emit("disconnect"):this.emit("change",{account:c.getAddress(e[0])})}),(0,i._)(this,"onChainChanged",e=>{let t=(0,d.n)(e),n=this.isChainUnsupported(t);this.emit("change",{chain:{id:t,unsupported:n}})}),(0,i._)(this,"onDisconnect",async e=>
1{if(1013===e.code&&await this.getProvider())try{if(await this.getAccount())return}catch{}this.emit("disconnect"),this.options.shimDisconnect&&await this.connectorStorage.removeItem(this.shimDisconnectKey)});let n=t.getProvider();if("string"==typeof t.name)this.name=t.name;else if(n){let e=function(e){if(!e)return"Injected";let t=e=>e.isAvalanche?"Core Wallet":e.isBitKeep?"BitKeep":e.isBraveWallet?"Brave Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isExodus?"Exodus":e.isFrame?"Frame":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOpera?"Opera":e.isPortal?"Ripio Portal":e.isTally?"Tally":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isMetaMask?"MetaMask":e.isImToken?"imToken":void 0;if(e.providers?.length){let n=new Set,i=1;for(let r of e.providers){let e=t(r);e||(e=`Unknown Wallet #${i}`,i+=1),n.add(e)}let r=[...n];return r.length?r:r[0]??"Injected"}return t(e)??"Injected"}(n);t.name?this.name=t.name(e):"string"==typeof e?this.name=e:this.name=e[0]}else this.name="Injected";this.id="injected",this.ready=!!n,this.connectorStorage=e.connectorStorage}async connect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let t=await this.getProvider();if(!t)throw new s.a;this.setupListeners(),this.emit("message",{type:"connecting"});let n=await t.request({method:"eth_requestAccounts"}),i=c.getAddress(n[0]),r=await this.getChainId(),o=this.isChainUnsupported(r);if(e.chainId&&r!==e.chainId)try{await this.switchChain(e.chainId),r=e.chainId,o=this.isChainUnsupported(e.chainId)}catch(t){console.error(`Could not switch to chain id: ${e.chainId}`,t)}this.options.shimDisconnect&&await this.connectorStorage.setItem(this.shimDisconnectKey,"true");let a={account:i,chain:{id:r,unsupported:o},provider:t};return this.emit("connect",a),a}catch(e){if(this.isUserRejectedRequestError(e))throw new s.U(e);if(-32002===e.code)throw new s.R(e);throw e}}async disconnect(){let e=await this.getProvider();e?.removeListener&&(e.removeListener("accountsChanged",this.onAccountsChanged),e.removeListener("chainChanged",this.onChainChanged),e.removeListener("disconnect",this.onDisconnect),this.options.shimDisconnect&&await this.connectorStorage.removeItem(this.shimDisconnectKey))}async getAccount(){let e=await this.getProvider();if(!e)throw new s.a;let t=await e.request({method:"eth_accounts"});return c.getAddress(t[0])}async getChainId(){let e=await this.getProvider();if(!e)throw new s.a;return e.request({method:"eth_chainId"}).then(d.n)}async getProvider(){let e=this.options.getProvider();return e&&(this._provider=e),this._provider}async getSigner(){let{chainId:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,n]=await Promise.all([this.getProvider(),this.getAccount()]);return new h.Q(t,e).getSigner(n)}async isAuthorized(){try{if(this.options.shimDisconnect&&!await this.connectorStorage.getItem(this.shimDisconnectKey))return!1;if(!await this.getProvider())throw new s.a;return!!await this.getAccount()}catch{return!1}}async switchChain(e){let t=await this.getProvider();if(!t)throw new s.a;let n=u.hexValue(e);try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]});let i=this.chains.find(t=>t.chainId===e);if(i)return i;return{chainId:e,name:`Chain ${n}`,slug:`${n}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpc:[""],chain:"",shortName:"",testnet:!0}}catch(r){let i=this.chains.find(t=>t.chainId===e);if(!i)throw new s.C({chainId:e,connectorId:this.id});if(4902===r.code||r?.data?.originalError?.code===4902)try{return await t.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:i.name,nativeCurrency:i.nativeCurrency,rpcUrls:(0,a.g)(i),blockExplorerUrls:this.getBlockExplorerUrls(i)}]}),i}catch(e){if(this.isUserRejectedRequestError(e))throw new s.U(r);throw new s.A}if(this.isUserRejectedRequestError(r))throw new s.U(r);throw new s.S(r)}}async setupListeners(){let e=await this.getProvider();e.on&&(e.on("accountsChanged",this.onAccountsChanged),e.on("chainChanged",this.onChainChanged),e.on("disconnect",this.onDisconnect))}isUserRejectedRequestError(e){return 4001===e.code}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.