add disconnect

pull/3674/head
yann300 4 years ago committed by Aniket
parent d8d92d6601
commit d0f8814824
  1. 11
      src/App.js
  2. 5
      src/RemixClient.js

@ -7,11 +7,6 @@ function App() {
const openModal = () => {
p.onConnect()
}
const clearLocalStorage = () => {
localStorage.clear()
document.getElementById('accounts').innerHTML = ''
document.getElementById('chain').innerHTML = ''
}
p.internalEvents.on('accountsChanged', (accounts) => {
document.getElementById('accounts').innerHTML = JSON.stringify(accounts)
})
@ -19,11 +14,15 @@ function App() {
p.internalEvents.on('chainChanged', (chain) => {
document.getElementById('chain').innerHTML = chain
})
p.internalEvents.on('disconnect', (chain) => {
document.getElementById('accounts').innerHTML = ''
document.getElementById('chain').innerHTML = ''
})
return (
<div className="App">
<div className="btn-group mt-5" role="group">
<button type="button" onClick={openModal} className="btn btn-primary">Connect</button>
<button type="button" onClick={clearLocalStorage} className="btn btn-primary">Clear Local Sessions</button>
</div>
<div><label><b>Accounts: </b></label><label className="ml-1" id="accounts"> - </label></div>
<div><label><b>ChainId: </b></label><label className="ml-1" id="chain"> - </label></div>

@ -65,6 +65,11 @@ export class RemixClient extends PluginClient {
this.provider.on("networkChanged", (networkId) => {
this.internalEvents.emit('networkChanged', networkId)
});
// Subscribe to networkId change
this.provider.on("disconnect", () => {
this.internalEvents.emit('disconnect')
});
}
getProviderOptions () {

Loading…
Cancel
Save