|
|
@ -11,6 +11,7 @@ export class RemixClient extends PluginClient { |
|
|
|
wagmiClient |
|
|
|
wagmiClient |
|
|
|
ethereumClient: EthereumClient |
|
|
|
ethereumClient: EthereumClient |
|
|
|
chains: Chain[] |
|
|
|
chains: Chain[] |
|
|
|
|
|
|
|
currentChain: number |
|
|
|
internalEvents: EventManager |
|
|
|
internalEvents: EventManager |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
@ -32,11 +33,6 @@ export class RemixClient extends PluginClient { |
|
|
|
console.log('initializing walletconnect plugin...') |
|
|
|
console.log('initializing walletconnect plugin...') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async deactivate(){ |
|
|
|
|
|
|
|
console.log('deactivating walletconnect plugin...') |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async initClient () { |
|
|
|
async initClient () { |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.chains = [arbitrum, arbitrumGoerli, mainnet, polygon, polygonMumbai, optimism, optimismGoerli, goerli, sepolia] |
|
|
|
this.chains = [arbitrum, arbitrumGoerli, mainnet, polygon, polygonMumbai, optimism, optimismGoerli, goerli, sepolia] |
|
|
@ -57,11 +53,14 @@ export class RemixClient extends PluginClient { |
|
|
|
this.wagmiClient.subscribe((event) => { |
|
|
|
this.wagmiClient.subscribe((event) => { |
|
|
|
if (event.status === 'connected') { |
|
|
|
if (event.status === 'connected') { |
|
|
|
this.emit('accountsChanged', [event.data.account]) |
|
|
|
this.emit('accountsChanged', [event.data.account]) |
|
|
|
this.emit('chainChanged', event.data.chain.id) |
|
|
|
if (this.currentChain !== event.data.chain.id) { |
|
|
|
console.log('this.wagmiClient: ', this.wagmiClient) |
|
|
|
this.currentChain = event.data.chain.id |
|
|
|
|
|
|
|
this.emit('chainChanged', event.data.chain.id) |
|
|
|
|
|
|
|
} |
|
|
|
} else if (event.status === 'disconnected') { |
|
|
|
} else if (event.status === 'disconnected') { |
|
|
|
this.emit('accountsChanged', []) |
|
|
|
this.emit('accountsChanged', []) |
|
|
|
this.emit('chainChanged', 0) |
|
|
|
this.emit('chainChanged', 0) |
|
|
|
|
|
|
|
this.currentChain = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.on('theme', 'themeChanged', (theme: any) => { |
|
|
|
this.on('theme', 'themeChanged', (theme: any) => { |
|
|
@ -78,11 +77,15 @@ export class RemixClient extends PluginClient { |
|
|
|
resolve(message) |
|
|
|
resolve(message) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else if (this.wagmiClient.data && this.wagmiClient.data.provider && this.wagmiClient.data.provider.jsonRpcFetchFunc) { |
|
|
|
} else if (this.wagmiClient.data && this.wagmiClient.data.provider && this.wagmiClient.data.provider.jsonRpcFetchFunc) { |
|
|
|
this.wagmiClient.data.provider.jsonRpcFetchFunc(data.method, data.params).then((message) => { |
|
|
|
if (data.method === 'net_version' || data.method === 'eth_chainId') { |
|
|
|
resolve({"jsonrpc": "2.0", "result": message, "id": data.id}) |
|
|
|
resolve({"jsonrpc": "2.0", "result": this.currentChain, "id": data.id}) |
|
|
|
}).catch((error) => { |
|
|
|
} else { |
|
|
|
reject(error) |
|
|
|
this.wagmiClient.data.provider.jsonRpcFetchFunc(data.method, data.params).then((message) => { |
|
|
|
}) |
|
|
|
resolve({"jsonrpc": "2.0", "result": message, "id": data.id}) |
|
|
|
|
|
|
|
}).catch((error) => { |
|
|
|
|
|
|
|
reject(error) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.wagmiClient.provider.send(data.method, data.params).then((message) => { |
|
|
|
this.wagmiClient.provider.send(data.method, data.params).then((message) => { |
|
|
|
resolve({"jsonrpc": "2.0", "result": message, "id": data.id}) |
|
|
|
resolve({"jsonrpc": "2.0", "result": message, "id": data.id}) |
|
|
@ -97,8 +100,8 @@ export class RemixClient extends PluginClient { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onDeactivation () { |
|
|
|
async deactivate(){ |
|
|
|
console.log('deactivating walletconnect plugin...') |
|
|
|
console.log('deactivating walletconnect plugin...') |
|
|
|
this.ethereumClient.disconnect() |
|
|
|
await this.ethereumClient.disconnect() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |