Skip to content

Commit

Permalink
Detect window.ethereum (ProxeusApp#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
loleg committed Apr 30, 2021
1 parent 8a2cf5e commit 71a5272
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
5 changes: 3 additions & 2 deletions deploy/linode/stackscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -88,6 +87,7 @@ ufw allow ssh
ufw allow https
ufw allow http
ufw allow 1323
ufw allow 2115

ufw enable

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ui/core/src/components/user/ProfileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions ui/core/src/views/AdminLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default {
}
},
created () {
if (typeof window.web3 !== 'undefined' && window.web3 !== undefined) {
if (typeof window.ethereum !== 'undefined') {
this.metamaskLoginAvailable = true
}
},
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ui/core/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
}
},
created () {
if (typeof window.web3 !== "undefined" && window.web3 !== undefined) {
if (typeof window.ethereum !== 'undefined') {
this.metamaskLoginAvailable = true
}
},
Expand Down
4 changes: 2 additions & 2 deletions ui/core/src/views/RegisterRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
}
},
created () {
if (typeof window.web3 !== 'undefined' && window.web3 !== undefined) {
if (typeof window.ethereum !== 'undefined') {
this.metamaskLoginAvailable = true
}
},
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions ui/wallet/src/ProxeusEthereum/WalletInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
}
}

Expand Down

0 comments on commit 71a5272

Please sign in to comment.