Skip to content

Commit 12d56f9

Browse files
committed
fix: check that eth_requestAccounts returns an array
1 parent d8ca7d0 commit 12d56f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/rln/src/utils/rpcClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ export const createViemClientFromWindow = async (): Promise<RpcClient> => {
2727
);
2828
}
2929

30-
const [account] = await ethereum.request({ method: "eth_requestAccounts" });
30+
const accounts = await ethereum.request({ method: "eth_requestAccounts" });
31+
if (!Array.isArray(accounts)) {
32+
throw Error("Failed to get accounts");
33+
}
34+
const account = accounts[0] as Address;
3135

3236
const rpcClient: RpcClient = createWalletClient({
3337
account: account as Address,

0 commit comments

Comments
 (0)