Skip to content

Commit 411895c

Browse files
authored
[Wagmi Adapter] Fix: Fallback to smart account chain in autoconnect (#6100)
1 parent cfa1c20 commit 411895c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/thick-vans-do.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+
Fix wagmi adapter usage with account factories

packages/wagmi-adapter/src/connector.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ export function inAppWalletConnector(
9595
const lastChainId = await config.storage?.getItem("tw.lastChainId");
9696
if (params?.isReconnecting) {
9797
const { autoConnect } = await import("thirdweb/wallets");
98+
const chainId = lastChainId || args.smartAccount?.chain?.id || 1;
9899
await autoConnect({
99100
client,
100-
chain: defineChain(lastChainId || 1),
101+
chain: defineChain(chainId),
101102
wallets: [wallet],
102103
});
103104

@@ -108,7 +109,7 @@ export function inAppWalletConnector(
108109

109110
return {
110111
accounts: [getAddress(account.address)],
111-
chainId: lastChainId || 1,
112+
chainId: chainId,
112113
};
113114
}
114115
const inAppOptions = params && "strategy" in params ? params : undefined;
@@ -117,7 +118,12 @@ export function inAppWalletConnector(
117118
"Missing strategy prop, pass it to connect() when connecting to this connector",
118119
);
119120
}
120-
const chain = defineChain(inAppOptions?.chainId || lastChainId || 1);
121+
const chain = defineChain(
122+
inAppOptions?.chainId ||
123+
lastChainId ||
124+
args.smartAccount?.chain?.id ||
125+
1,
126+
);
121127
const decoratedOptions = {
122128
...inAppOptions,
123129
client,

0 commit comments

Comments
 (0)