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