From 71a5272b3dab61bcc669f231d1872f1e3b028c73 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Fri, 30 Apr 2021 23:47:26 +0200 Subject: [PATCH] Detect window.ethereum (#203) --- deploy/linode/stackscript.sh | 5 +++-- ui/core/src/components/user/ProfileModal.vue | 2 +- ui/core/src/views/AdminLogin.vue | 4 ++-- ui/core/src/views/Login.vue | 2 +- ui/core/src/views/RegisterRequest.vue | 4 ++-- ui/wallet/src/ProxeusEthereum/WalletInterface.js | 7 +------ 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/deploy/linode/stackscript.sh b/deploy/linode/stackscript.sh index acde63058..bbf5b6077 100644 --- a/deploy/linode/stackscript.sh +++ b/deploy/linode/stackscript.sh @@ -77,8 +77,7 @@ cp jail.conf jail.local systemctl start fail2ban systemctl enable fail2ban -## Set up firewall with port 1323 open to default Proxeus platform -# Set up nginx separately to proxy to 443 +## Set up firewall with defaults ports of Proxeus platform log "Configuring firewall" apt-get install ufw -y ufw default allow outgoing @@ -88,6 +87,7 @@ ufw allow ssh ufw allow https ufw allow http ufw allow 1323 +ufw allow 2115 ufw enable @@ -115,6 +115,7 @@ END log "Warning: you should disable port 80 in production by removing the PROXEUS_ALLOW_HTTP line in your .env" +# Commence Proxeus installation wget https://raw.githubusercontent.com/ProxeusApp/proxeus-core/master/bootstrap.sh; bash bootstrap.sh diff --git a/ui/core/src/components/user/ProfileModal.vue b/ui/core/src/components/user/ProfileModal.vue index b1130bd68..a0bcce77d 100644 --- a/ui/core/src/components/user/ProfileModal.vue +++ b/ui/core/src/components/user/ProfileModal.vue @@ -125,7 +125,7 @@ export default { updateEthereumAddress () { this.walletErrorMessage = '' if (!this.challenge) { - if (typeof window.web3 !== 'undefined' && window.web3 !== undefined) { + if (typeof window.ethereum !== 'undefined') { axios.get('/api/challenge').then((response) => { this.challenge = response.data this.metamaskLogin() diff --git a/ui/core/src/views/AdminLogin.vue b/ui/core/src/views/AdminLogin.vue index ce2f4db4c..12d2b9d71 100644 --- a/ui/core/src/views/AdminLogin.vue +++ b/ui/core/src/views/AdminLogin.vue @@ -78,7 +78,7 @@ export default { } }, created () { - if (typeof window.web3 !== 'undefined' && window.web3 !== undefined) { + if (typeof window.ethereum !== 'undefined') { this.metamaskLoginAvailable = true } }, @@ -129,7 +129,7 @@ export default { }, loginWithSignature () { if (!this.challenge) { - if (window.web3 !== undefined) { + if (typeof window.ethereum !== 'undefined') { this.metamaskLoginAvailable = true axios.get('/api/challenge').then((response) => { this.challenge = response.data diff --git a/ui/core/src/views/Login.vue b/ui/core/src/views/Login.vue index 4f803eced..42625acfa 100644 --- a/ui/core/src/views/Login.vue +++ b/ui/core/src/views/Login.vue @@ -60,7 +60,7 @@ export default { } }, created () { - if (typeof window.web3 !== "undefined" && window.web3 !== undefined) { + if (typeof window.ethereum !== 'undefined') { this.metamaskLoginAvailable = true } }, diff --git a/ui/core/src/views/RegisterRequest.vue b/ui/core/src/views/RegisterRequest.vue index 8a79dbb32..f7d0b0e41 100644 --- a/ui/core/src/views/RegisterRequest.vue +++ b/ui/core/src/views/RegisterRequest.vue @@ -73,7 +73,7 @@ export default { } }, created () { - if (typeof window.web3 !== 'undefined' && window.web3 !== undefined) { + if (typeof window.ethereum !== 'undefined') { this.metamaskLoginAvailable = true } }, @@ -128,7 +128,7 @@ export default { }, loginWithSignature () { if (!this.challenge) { - if (typeof window.web3 !== 'undefined' && window.web3 !== undefined) { + if (typeof window.ethereum !== 'undefined') { this.metamaskLoginAvailable = true axios.get('/api/challenge').then((response) => { this.challenge = response.data diff --git a/ui/wallet/src/ProxeusEthereum/WalletInterface.js b/ui/wallet/src/ProxeusEthereum/WalletInterface.js index ecf0111fd..cdbf50c6f 100644 --- a/ui/wallet/src/ProxeusEthereum/WalletInterface.js +++ b/ui/wallet/src/ProxeusEthereum/WalletInterface.js @@ -15,7 +15,7 @@ class WalletInterface { // TODO improve checking that current network matches what is expected // TODO: network param only for compatibility reasons with blockchain/dapp constructor (network = 'ropsten', proxeusFSAddress, forceProxeusWallet = false) { - this.useProxeusWallet = forceProxeusWallet || typeof window.web3 === 'undefined' || window.web3 === undefined + this.useProxeusWallet = forceProxeusWallet || typeof window.ethereum !== 'undefined' // make sure we are using the web3 we want and not the one provided by metamask this.web3 = new Web3(Web3.givenProvider || 'ws://localhost:8545') @@ -32,14 +32,9 @@ class WalletInterface { this.web3.setProvider( new this.web3.providers.HttpProvider( 'https://' + network + '.infura.io/')) - - // overwrite the provided web3 for what we load - window.web3 = this.web3 } else { if (window.ethereum) { this.web3.setProvider(window.ethereum) - } else { - this.web3.setProvider(window.web3.currentProvider) } }