Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web3-react): replace eth_accounts with eth_requestAccounts #377

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pink-pumpkins-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/web3-react-connector': patch
---

fix(web3-react): use eth_requestAccounts replace eth_accounts
10 changes: 4 additions & 6 deletions adapters/web3-react-connector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class BloctoConnector extends Connector {
'connect',
async ({ chainId }: ProviderConnectInfo): Promise<void> => {
const accounts = await this.provider.request({
method: 'eth_accounts',
method: 'eth_requestAccounts',
mordochi marked this conversation as resolved.
Show resolved Hide resolved
});
this.actions.update({ chainId: parseChainId(chainId), accounts });
}
Expand All @@ -56,13 +56,11 @@ export class BloctoConnector extends Connector {
this.onError?.(error);
});
this.provider.on('chainChanged', async (chainId: string): Promise<void> => {
const accounts = await this.provider.request({ method: 'eth_accounts' });
const accounts = await this.provider.request({
method: 'eth_requestAccounts',
});
this.actions.update({ chainId: parseChainId(chainId), accounts });
});
this.provider.on('accountsChanged', (accounts: string[]): void => {
if (accounts.length === 0) this.actions.resetState();
else this.actions.update({ accounts });
});
}

public async activate(
Expand Down
Loading