Skip to content

Commit 9983e6c

Browse files
[SDK] Improve SIWE chain management for external wallets (#8432)
1 parent 73c924b commit 9983e6c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/sweet-lights-help.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+
Better SIWE chain management for all external wallets

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import type { Ecosystem } from "../wallet/types.js";
1010
import { getLoginCallbackUrl, getLoginUrl } from "./getLoginPath.js";
1111
import type { AuthStoredTokenWithCookieReturnType } from "./types.js";
1212

13+
// wallets that cannot sign with ethereum mainnet, require a specific chain always
14+
const NON_ETHEREUM_WALLETS = ["xyz.abs"];
15+
1316
/**
1417
* @internal
1518
*/
@@ -20,8 +23,10 @@ export async function siweAuthenticate(args: {
2023
ecosystem?: Ecosystem;
2124
}): Promise<AuthStoredTokenWithCookieReturnType> {
2225
const { wallet, client, ecosystem, chain } = args;
23-
const siweChain = chain || getCachedChain(1); // fallback to mainnet for SIWE for wide wallet compatibility
24-
// only connect if the wallet doesn't already have an account
26+
const siweChain = NON_ETHEREUM_WALLETS.includes(wallet.id)
27+
? chain || getCachedChain(1)
28+
: getCachedChain(1); // fallback to mainnet for SIWE for wide wallet compatibility
29+
// only connect if the wallet doesn't alnready have an account
2530
const account =
2631
wallet.getAccount() || (await wallet.connect({ chain: siweChain, client }));
2732
const clientFetch = getClientFetch(client, ecosystem);

0 commit comments

Comments
 (0)