Files
to_session/text/3.65.22_0/scripts/ui/MetaMaskAdapter-YIWLRR5F.js
Administrator a0720d80dc fefdwef
2025-11-12 12:54:37 +08:00

8 lines
2.6 KiB
JavaScript

import{a as r}from"./chunk-655YVXZ7.js";import{a as m}from"./chunk-644H2MDT.js";import{c as o}from"./chunk-AAPE6FE4.js";import"./chunk-SGNJOSQB.js";import{d as l,e as p}from"./chunk-6MDHMQQH.js";import{a as u}from"./chunk-XIFCFAQW.js";import{b as g}from"./chunk-SE3PRL6Z.js";import"./chunk-NQTLXTUD.js";import"./chunk-E735URDA.js";import"./chunk-YHVKZE66.js";import{o as h,q as w}from"./chunk-QTLWQ5AJ.js";h();w();var y=class extends m{async getWeb3(){return await o()}async sendTransaction({payload:t,cb:a,extraParams:n,externalProvider:e}){let i=await o();return await r.sendTransaction({provider:e||i,payload:t,cb:a})}async getAccount(){let t=await o();return await r.getAccount({provider:t})}async signMessage({message:t}){let a=await o(),n=await this.getAccount();return await r.signMessage({provider:a,message:t,address:n})}async signTypedData({message:t}){let a=await this.getAccount();return await r.signTypedData({message:t,address:a})}async watchAsset({tokenOptions:t}){let a=window?.ethereum;return await r.watchAsset({provider:a,tokenOptions:t})}async getChainId(){let t=await o(),a=await r.getChainId({provider:t});return await p(a)}async switchNetwork({chain:t,externalProvider:a,addNetworkConfig:n}){let e=await l(t),i=a||window.ethereum;try{let s=await this.getChainId();return String(s)===String(e)||await i.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${parseInt(e).toString(16)}`}]}),!0}catch(s){console.log("metamask switch error",s);let{code:c,data:I}=s||{};if([4902,-32602].includes(c)||I?.originalError?.code===4902)try{if(!e&&e!==0)throw new Error("chain parameter is not legal");let d=n||(await u(e))?.data||[];if(d.length>0){await i.request({method:"wallet_addEthereumChain",params:d});let C=await this.getChainId();return String(C)===String(e)}throw new Error("chain info is not exist")}catch(d){return console.log(d),!1}else return!1}}async getAllChainTypeInfoList(){let t=await this.getAccount(),a=await this.getChainId();return[{address:t,chainType:g.EVM,chainId:a}]}async depositWToken({wTokenAddr:t,wTokenAbi:a,amount:n,cb:e}){let i=await this.getAccount(),s=await this.getWeb3(),c=r.depositWToken({wTokenAddr:t,wTokenAbi:a,amount:n,account:i,web3:s});return this.sendTransaction({payload:c,cb:e})}async withdrawWToken({wTokenAddr:t,wTokenAbi:a,amount:n,cb:e}){let i=await this.getAccount(),s=await this.getWeb3(),c=r.withdrawWToken({wTokenAddr:t,wTokenAbi:a,amount:n,account:i,web3:s});return this.sendTransaction({payload:c,cb:e})}};export{y as MetaMaskAdapter};
window.inOKXExtension = true;
window.inMiniApp = false;
window.ASSETS_BUILD_TYPE = "publish";
//# sourceMappingURL=MetaMaskAdapter-YIWLRR5F.js.map