Skip to content

Commit 6187e31

Browse files
committed
fix(wagmi-adapter): fallback to user specified smart account chain
1 parent eef52df commit 6187e31

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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)