|
|
|
@ -24,7 +24,7 @@ export class WalletConnectRemixClient extends PluginClient { |
|
|
|
|
chains: Chain[] |
|
|
|
|
currentChain: number |
|
|
|
|
internalEvents: EventManager |
|
|
|
|
connected: boolean |
|
|
|
|
currentAcount: string |
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
|
super() |
|
|
|
@ -77,16 +77,18 @@ export class WalletConnectRemixClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
subscribeToEvents() { |
|
|
|
|
this.wagmiConfig.subscribe((event) => { |
|
|
|
|
if (event.status === 'connected' && !this.connected) { |
|
|
|
|
this.connected = true |
|
|
|
|
this.emit('accountsChanged', [event.data.account]) |
|
|
|
|
if (event.status === 'connected') { |
|
|
|
|
if (event.data.account !== this.currentAcount) { |
|
|
|
|
this.currentAcount = event.data.account |
|
|
|
|
this.emit('accountsChanged', [event.data.account])
|
|
|
|
|
} |
|
|
|
|
if (this.currentChain !== event.data.chain.id) { |
|
|
|
|
this.currentChain = event.data.chain.id |
|
|
|
|
this.emit('chainChanged', event.data.chain.id) |
|
|
|
|
} |
|
|
|
|
} else if (event.status === 'disconnected' && this.connected) { |
|
|
|
|
this.connected = false |
|
|
|
|
} else if (event.status === 'disconnected') { |
|
|
|
|
this.emit('accountsChanged', []) |
|
|
|
|
this.currentAcount = '' |
|
|
|
|
this.emit('chainChanged', 0) |
|
|
|
|
this.currentChain = 0 |
|
|
|
|
} |
|
|
|
|