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/sweet-lights-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Better SIWE chain management for all external wallets
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import { getLoginCallbackUrl, getLoginUrl } from "./getLoginPath.js";
import type { AuthStoredTokenWithCookieReturnType } from "./types.js";

// wallets that cannot sign with ethereum mainnet, require a specific chain always
const NON_ETHEREUM_WALLETS = ["xyz.abs"];

/**
* @internal
*/
Expand All @@ -20,8 +23,10 @@
ecosystem?: Ecosystem;
}): Promise<AuthStoredTokenWithCookieReturnType> {
const { wallet, client, ecosystem, chain } = args;
const siweChain = chain || getCachedChain(1); // fallback to mainnet for SIWE for wide wallet compatibility
// only connect if the wallet doesn't already have an account
const siweChain = NON_ETHEREUM_WALLETS.includes(wallet.id)
? chain || getCachedChain(1)
: getCachedChain(1); // fallback to mainnet for SIWE for wide wallet compatibility

Check warning on line 28 in packages/thirdweb/src/wallets/in-app/core/authentication/siwe.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/core/authentication/siwe.ts#L26-L28

Added lines #L26 - L28 were not covered by tests
// only connect if the wallet doesn't alnready have an account
const account =
wallet.getAccount() || (await wallet.connect({ chain: siweChain, client }));
const clientFetch = getClientFetch(client, ecosystem);
Expand Down
Loading