Skip to content
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/early-spoons-say.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix Safe wallet connection issues with WalletConnect
5 changes: 3 additions & 2 deletions packages/thirdweb/src/wallets/wallet-connect/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
);
const currentChainId = chainsToRequest[0]?.split(":")[1] || 1;
const providerChainId = normalizeChainId(currentChainId);
const account = firstAccountOn(provider.session, `eip155:1`); // grab the address from mainnet
const account = firstAccountOn(provider.session, `eip155:1`); // grab the address from mainnet if available

Check warning on line 160 in packages/thirdweb/src/wallets/wallet-connect/controller.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L160 was not covered by tests
const address = account;
if (!address) {
throw new Error("No accounts found on provider.");
Expand Down Expand Up @@ -291,7 +291,8 @@
}
function firstAccountOn(session: WCSession, caip: string): string | null {
const ns = getNS(session);
const hit = ns?.accounts?.find((a) => a.startsWith(`${caip}:`));
const hit =
ns?.accounts?.find((a) => a.startsWith(`${caip}:`)) || ns?.accounts[0];

Check warning on line 295 in packages/thirdweb/src/wallets/wallet-connect/controller.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/wallet-connect/controller.ts#L294-L295

Added lines #L294 - L295 were not covered by tests
return hit ? (hit.split(":")[2] ?? null) : null;
}
function anyRoutableChain(session: WCSession): string | null {
Expand Down
Loading