Skip to content

Commit 154403b

Browse files
committed
chore: update connect as well
1 parent f3f8fdd commit 154403b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

packages/thirdweb/src/wallets/in-app/core/wallet/in-app-core.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,26 @@ export function createInAppWallet(args: {
140140
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
141141
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
142142
if (smartAccountOptions) {
143-
const preferredChain = options.chain;
144-
if (!preferredChain) {
143+
const defaultChainId =
144+
ecosystemOptions.smartAccountOptions.chainIds[0];
145+
if (!defaultChainId) {
145146
throw new Error(
146-
"Chain is required for ecosystem smart accounts, pass it via connect() or via UI components",
147+
"No default chain ID found for ecosystem smart accounts. Please reach out to the ecosystem owner.",
147148
);
148149
}
150+
const preferredChain =
151+
options.chain ?? getCachedChain(defaultChainId);
152+
153+
if (
154+
!ecosystemOptions.smartAccountOptions.chainIds.includes(
155+
preferredChain?.id,
156+
)
157+
) {
158+
throw new Error(
159+
`Chain ID ${preferredChain.id} is not supported for ecosystem smart accounts, pass it via connect() or via UI components`,
160+
);
161+
}
162+
149163
createOptions = {
150164
...createOptions,
151165
smartAccount: {

0 commit comments

Comments
 (0)