Skip to content

Commit

Permalink
fix bug event onConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
vdg committed Oct 5, 2019
1 parent d45ce4a commit 8721713
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/vue-example/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1 v-else-if="$eth.walletDetected">
Your wallet is not connected to an Ethereum network
<br>
<span>error:{{ $eth.error }}</span>
<span v-if="$eth.error">error:{{ $eth.error }}</span>
</h1>
<h1 v-else>
You are not connected to an Ethereum network
Expand Down
13 changes: 7 additions & 6 deletions src/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,26 @@ const Web3Watcher = () => {
...$.state,
isConnected: await $.instance.eth.net.isListening()
}
updateState({ init: $.state.init + 1 })
} catch (error) {
$.state = { ...$.state, error: error.message, isConnected: false }
updateState({})
}
updateState({ init: $.state.init + 1 })
$.walletType = await $.getWalletType()
updateState({})
return Promise.resolve($.state)
} else {
try {
// commit('setInjected', true)
if (window.web3.currentProvider) {
$.injected = window.web3
$.instance = new Web3(window.web3.currentProvider)
}
updateState({ init: $.state.init + 1 })
} catch (error) {
console.log(error)
$.state = { ...$.state, error: error.message, isConnected: false }
updateState({})
}
}
typeof eventHandler.connected === 'function' && $.state.isConnected && eventHandler.connected($)
$.walletType = await $.getWalletType()
updateState({})
return Promise.resolve($.state)
}

Expand Down

0 comments on commit 8721713

Please sign in to comment.