| | |
| | | infuraId: '27e484dcd9e3efcfd25a83a78777cdf1', |
| | | rpc: { |
| | | 1: "https://mainnet.infura.io/v3/f54a5887a3894ebb9425920701a97fe0", |
| | | }, |
| | | } |
| | | }); |
| | | await provider.enable(); |
| | | provider.on("accountsChanged", (accounts) => { |
| | |
| | | window.location.reload(); |
| | | }); |
| | | proxy.web3 = new Web3(provider); |
| | | console.log(new Web3(provider)) |
| | | const accounts = await proxy.web3.eth.getAccounts(); |
| | | proxy.walletAddress = accounts[0]; |
| | | console.log('所有的账户,拿得到吗?') |
| | | console.log(accounts) |
| | | proxy.isApprove() |
| | | } |
| | | |
| | |
| | | await window.ethereum.enable(); |
| | | const accounts = await ethereum.request({ method: 'eth_accounts' }); |
| | | address = accounts[0]; |
| | | console.log('dapp环境噢') |
| | | console.log(accounts) |
| | | }else if(window.tronWeb){ |
| | | address = window.tronWeb.defaultAddress.base58; |
| | | } |
| | |
| | | sessionStorage.setItem('address', this.walletAddress); |
| | | }else{ |
| | | this.hasApprove = false; |
| | | this.$toast(this.$t('message.ApproveTip')); |
| | | } |
| | | }).catch(() => { |
| | | this.hasApprove = false; |
| | |
| | | console.log('授权成功') |
| | | console.log(res) |
| | | this.submitApprove() |
| | | }).catch((err) => { |
| | | console.log('授权失败') |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | async tornWebApprove () { |
| | |
| | | shouldPollResponse: false |
| | | }, (err, res) => { |
| | | if (err == null) { |
| | | alert('嘿,授权成功') |
| | | console.log('嘿,授权成功') |
| | | this.submitApprove() |
| | | } |
| | | }); |