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

Respect passed chain when doing SIWE for in-app/ecosystem wallet
2 changes: 1 addition & 1 deletion apps/playground-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@abstract-foundation/agw-react": "^1.6.4",
"@abstract-foundation/agw-react": "^1.10.0",
"@ai-sdk/react": "^2.0.25",
"@hookform/resolvers": "^3.9.1",
"@radix-ui/react-avatar": "^1.1.10",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { signLoginPayload } from "../../../../auth/core/sign-login-payload.js";
import type { LoginPayload } from "../../../../auth/core/types.js";
import type { Chain } from "../../../../chains/types.js";
import { getCachedChain } from "../../../../chains/utils.js";
import type { ThirdwebClient } from "../../../../client/client.js";
import { getClientFetch } from "../../../../utils/fetch.js";
Expand All @@ -15,10 +16,11 @@
export async function siweAuthenticate(args: {
wallet: Wallet;
client: ThirdwebClient;
chain?: Chain;
ecosystem?: Ecosystem;
}): Promise<AuthStoredTokenWithCookieReturnType> {
const { wallet, client, ecosystem } = args;
const siweChain = getCachedChain(1); // always use mainnet for SIWE for wide wallet compatibility
const { wallet, client, ecosystem, chain } = args;
const siweChain = chain || getCachedChain(1); // fallback to mainnet for SIWE for wide wallet compatibility

Check warning on line 23 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#L22-L23

Added lines #L22 - L23 were not covered by tests
// only connect if the wallet doesn't already have an account
const account =
wallet.getAccount() || (await wallet.connect({ chain: siweChain, client }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export type SingleStepAuthArgsType =
| {
strategy: "wallet";
wallet: Wallet;
chain: Chain;
chain?: Chain;
}
| {
strategy: "guest";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class InAppNativeConnector implements InAppConnector {
client: this.client,
ecosystem: params.ecosystem,
wallet: params.wallet,
chain: params.chain,
});
}
case "github":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe("InAppWebConnector.connect", () => {
client: TEST_CLIENT,
ecosystem: undefined,
wallet: mockWallet,
chain: ethereum,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ export class InAppWebConnector implements InAppConnector {
client: this.client,
ecosystem: this.ecosystem,
wallet: args.wallet,
chain: args.chain,
});
}
}
Expand Down
57 changes: 16 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading