Skip to content

Commit 709af11

Browse files
committed
SDK: Fix Safe wallet connection issues with WalletConnect
1 parent 68cca6f commit 709af11

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changeset/early-spoons-say.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix Safe wallet connection issues with WalletConnect

packages/thirdweb/src/wallets/wallet-connect/controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export async function connectWC(
157157
);
158158
const currentChainId = chainsToRequest[0]?.split(":")[1] || 1;
159159
const providerChainId = normalizeChainId(currentChainId);
160-
const account = firstAccountOn(provider.session, `eip155:1`); // grab the address from mainnet
160+
const account = firstAccountOn(provider.session, `eip155:1`); // grab the address from mainnet if available
161161
const address = account;
162162
if (!address) {
163163
throw new Error("No accounts found on provider.");
@@ -291,7 +291,8 @@ function hasChainEnabled(session: WCSession, caip: string) {
291291
}
292292
function firstAccountOn(session: WCSession, caip: string): string | null {
293293
const ns = getNS(session);
294-
const hit = ns?.accounts?.find((a) => a.startsWith(`${caip}:`));
294+
const hit =
295+
ns?.accounts?.find((a) => a.startsWith(`${caip}:`)) || ns?.accounts[0];
295296
return hit ? (hit.split(":")[2] ?? null) : null;
296297
}
297298
function anyRoutableChain(session: WCSession): string | null {

0 commit comments

Comments
 (0)