Connector is not emitting "change" event #1514
-
|
We are trying to create a Zero Wallet connector for wagmi. Zero wallet is an SDK that allows users to make on chain-interactions without having to install a wallet or pay gas fees. You can read more about Zero Wallet here. The repo can be found here. We also are trying to make zero wallet recoverable using MetaMask. Recovery basically changes the zero wallet address to a new one derived from a signed message by an MM account. We are creating our own signer and provider for this connector. However, we're not able to change accounts upon recovery. After initiating recovery the following method is called: // In signer
async changeZeroWallet(newZeroWallet: ethers.Wallet) {
this.zeroWallet = newZeroWallet.connect(this.provider);
await this.store.set('zeroWalletPrivateKey', newZeroWallet.privateKey);
this.provider.emit('accountsChanged', [this.zeroWallet.address]);
}We emit // In connector
protected onAccountsChanged(accounts: string[]) {
if (accounts.length === 0) this.emit('disconnect');
else {
const newObj = {
account: getAddress(accounts[0] as string)
}
console.log('from connector', newObj)
this.emit('change', newObj);
}
}Now the wagmi client should be listening to I was wondering if anyone can help with this issue. Any ideas are much welcome. Thanks a ton! P.S. There's an example NextJS app in the repo, please checkout the metamask-recovery branch (here). If you're planning to run the whole thing locally, please let me know in case you need any help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
|
Beta Was this translation helpful? Give feedback.
thisin theonAccountsChangedmethod was referring to the provider rather than the connector. Feel free to delete this discussion.