listen on chainChanged / account changed for trust wallet

pull/3454/head
yann300 2 years ago
parent 552967bee8
commit d479fd7758
  1. 8
      apps/remix-ide/src/blockchain/blockchain.js
  2. 6
      libs/remix-ui/run-tab/src/lib/actions/events.ts

@ -66,10 +66,18 @@ export class Blockchain extends Plugin {
this._triggerEvent('networkStatus', [this.networkStatus])
})
})
this.on('injected-trustwallet', 'chainChanged', () => {
this.detectNetwork((error, network) => {
this.networkStatus = { network, error }
this._triggerEvent('networkStatus', [this.networkStatus])
})
})
}
onDeactivation () {
this.off('injected', 'chainChanged')
this.off('injected-trustwallet', 'chainChanged')
}
setupEvents () {

@ -129,6 +129,12 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => {
dispatch(fetchAccountsListSuccess(accountsMap))
})
plugin.on('injected-trustwallet', 'accountsChanged', (accounts: Array<string>) => {
const accountsMap = {}
accounts.map(account => { accountsMap[account] = shortenAddress(account, '0')})
dispatch(fetchAccountsListSuccess(accountsMap))
})
setInterval(() => {
fillAccountsList(plugin, dispatch)
updateInstanceBalance(plugin, dispatch)

Loading…
Cancel
Save