1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8872,5664],{95664:function(t,e,n){n.r(e),n.d(e,{InjectedConnector:function(){return l}});var i=n(46795),s=n(83287),o=n(99312),r=n(24528),c=n(81764),a=n(19485),h=n(241),d=n(16441),u=n(59014);n(54146);class l extends s.W{constructor(t){const e={...{shimDisconnect:!0,getProvider:()=>{if((0,r.a)(globalThis.window))return globalThis.window.ethereum}},...t.options};super({chains:t.chains,options:e}),(0,i._)(this,"shimDisconnectKey","injected.shimDisconnect"),(0,i._)(this,"onAccountsChanged",(async t=>{0===t.length?this.emit("disconnect"):this.emit("change",{account:a.getAddress(t[0])})})),(0,i._)(this,"onChainChanged",(t=>{const e=(0,u.n)(t),n=this.isChainUnsupported(e);this.emit("change",{chain:{id:e,unsupported:n}})})),(0,i._)(this,"onDisconnect",(async t=>{if(1013===t.code){if(await this.getProvider())try{if(await this.getAccount())return}catch{}}this.emit("disconnect"),this.options.shimDisconnect&&await this.connectorStorage.removeItem(this.shimDisconnectKey)}));const n=e.getProvider();if("string"===typeof e.name)this.name=e.name;else if(n){const t=function(t){if(!t)return"Injected";const e=t=>t.isAvalanche?"Core Wallet":t.isBitKeep?"BitKeep":t.isBraveWallet?"Brave Wallet":t.isCoinbaseWallet?"Coinbase Wallet":t.isExodus?"Exodus":t.isFrame?"Frame":t.isKuCoinWallet?"KuCoin Wallet":t.isMathWallet?"MathWallet":t.isOneInchIOSWallet||t.isOneInchAndroidWallet?"1inch Wallet":t.isOpera?"Opera":t.isPortal?"Ripio Portal":t.isTally?"Tally":t.isTokenPocket?"TokenPocket":t.isTokenary?"Tokenary":t.isTrust||t.isTrustWallet?"Trust Wallet":t.isMetaMask?"MetaMask":t.isImToken?"imToken":void 0;if(t.providers?.length){const n=new Set;let i=1;for(const o of t.providers){let t=e(o);t||(t=`Unknown Wallet #${i}`,i+=1),n.add(t)}const s=[...n];return s.length?s:s[0]??"Injected"}return e(t)??"Injected"}(n);e.name?this.name=e.name(t):this.name="string"===typeof t?t:t[0]}else this.name="Injected";this.id="injected",this.ready=!!n,this.connectorStorage=t.connectorStorage}async connect(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const n=await this.getProvider();if(!n)throw new o.a;this.setupListeners(),this.emit("message",{type:"connecting"});const i=await n.request({method:"eth_requestAccounts"}),s=a.getAddress(i[0]);let r=await this.getChainId(),c=this.isChainUnsupported(r);if(t.chainId&&r!==t.chainId)try{await this.switchChain(t.chainId),r=t.chainId,c=this.isChainUnsupported(t.chainId)}catch(e){console.error(`Could not switch to chain id: ${t.chainId}`,e)}this.options.shimDisconnect&&await this.connectorStorage.setItem(this.shimDisconnectKey,"true");const h={account:s,chain:{id:r,unsupported:c},provider:n};return this.emit("connect",h),h}catch(n){if(this.isUserRejectedRequestError(n))throw new o.U(n);if(-32002===n.code)throw new o.R(n);throw n}}async disconnect(){const t=await this.getProvider();t?.removeListener&&(t.removeListener("accountsChanged",this.onAccountsChanged),t.removeListener("chainChanged",this.onChainChanged),t.removeListener("disconnect",this.onDisconnect),this.options.shimDisconnect&&await this.connectorStorage.removeItem(this.shimDisconnectKey))}async getAccount(){const t=await this.getProvider();if(!t)throw new o.a;const e=await t.request({method:"eth_accounts"});return a.getAddress(e[0])}async getChainId(){const t=await this.getProvider();if(!t)throw new o.a;return t.request({method:"eth_chainId"}).then(u.n)}async getProvider(){const t=this.options.getProvider();return t&&(this._provider=t),this._provider}async getSigner(){let{chainId:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[e,n]=await Promise.all([this.getProvider(),this.getAccount()]);return new h.Q(e,t).getSigner(n)}async isAuthorized(){try{if(this.options.shimDisconnect&&!Boolean(await this.connectorStorage.getItem(this.shimDisconnectKey)))return!1;if(!(await this.getProvider()))throw new o.a;return!!(await this.getAccount())}catch{return!1}}async switchChain(t){const e=await this.getProvider();if(!e)throw new o.a;const n=d.hexValue(t);try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]});const i=this.chains.find((e=>e.chainId===t));return i||{chainId:t,name:`Chain ${n}`,slug:`${n}
1`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpc:[""],chain:"",shortName:"",testnet:!0}}catch(i){const r=this.chains.find((e=>e.chainId===t));if(!r)throw new o.C({chainId:t,connectorId:this.id});if(4902===i.code||4902===i?.data?.originalError?.code)try{return await e.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:r.name,nativeCurrency:r.nativeCurrency,rpcUrls:(0,c.g)(r),blockExplorerUrls:this.getBlockExplorerUrls(r)}]}),r}catch(s){if(this.isUserRejectedRequestError(s))throw new o.U(i);throw new o.A}if(this.isUserRejectedRequestError(i))throw new o.U(i);throw new o.S(i)}}async setupListeners(){const t=await this.getProvider();t.on&&(t.on("accountsChanged",this.onAccountsChanged),t.on("chainChanged",this.onChainChanged),t.on("disconnect",this.onDisconnect))}isUserRejectedRequestError(t){return 4001===t.code}}},88872:function(t,e,n){n.r(e),n.d(e,{TrustConnector:function(){return o}});var i=n(95664),s=n(24528);n(54146);class o extends i.InjectedConnector{constructor(t){const e={...{name:"Trust",getProvider(){function t(t){if(!!t?.isTrust)return t}if((0,s.a)(globalThis.window))return globalThis.window.ethereum?.providers?globalThis.window.ethereum.providers.find(t):t(globalThis.window.ethereum)}},...t.options};super({chains:t.chains,options:e,connectorStorage:t.connectorStorage})}}}}]);
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.