Skip to content

Commit ae675db

Browse files
committed
[Wagmi Adapter] Fix: use smart account chain in getProvider (#6117)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on fixing the `getProvider` function in the `wagmi-adapter` package to improve the autoconnection behavior with the account factory by enhancing the chain selection logic. ### Detailed summary - Updated `getProvider` function to include `args.smartAccount?.chain?.id` in chain selection. - Changed the logic for defining `chain` to prioritize `params?.chainId`, followed by the smart account's chain ID, the last stored chain ID, and defaulting to `1`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 54c9333 commit ae675db

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/fair-trains-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/wagmi-adapter": patch
3+
---
4+
5+
Fixes getProvider autoconnections with account factory

packages/wagmi-adapter/src/connector.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ export function inAppWalletConnector(
148148
},
149149
getProvider: async (params) => {
150150
const lastChainId = await config.storage?.getItem("tw.lastChainId");
151-
const chain = defineChain(params?.chainId || lastChainId || 1);
151+
const chain = defineChain(
152+
params?.chainId || args.smartAccount?.chain?.id || lastChainId || 1,
153+
);
152154
if (!wallet.getAccount()) {
153155
const { autoConnect } = await import("thirdweb/wallets");
154156
await autoConnect({

0 commit comments

Comments
 (0)