Skip to content

Commit 99a341f

Browse files
committed
chore: delay throwing
1 parent 2b65d28 commit 99a341f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ export function createInAppWallet(args: {
7878
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
7979
if (smartAccountOptions) {
8080
const { defaultChainId } = ecosystemOptions.smartAccountOptions;
81-
if (!defaultChainId) {
81+
const preferredChain =
82+
options.chain ??
83+
(defaultChainId ? getCachedChain(defaultChainId) : undefined);
84+
if (!preferredChain) {
8285
throw new Error(
83-
"No default chain ID found for ecosystem smart accounts. Please reach out to the ecosystem owner.",
86+
`A chain must be provided either via 'chain' in connect options or 'defaultChainId' in ecosystem configuration. Please pass it via connect() or update the ecosystem configuration.`,
8487
);
8588
}
86-
const preferredChain =
87-
options.chain ?? getCachedChain(defaultChainId);
8889

8990
createOptions = {
9091
...createOptions,
@@ -130,13 +131,14 @@ export function createInAppWallet(args: {
130131
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
131132
if (smartAccountOptions) {
132133
const { defaultChainId } = ecosystemOptions.smartAccountOptions;
133-
if (!defaultChainId) {
134+
const preferredChain =
135+
options.chain ??
136+
(defaultChainId ? getCachedChain(defaultChainId) : undefined);
137+
if (!preferredChain) {
134138
throw new Error(
135-
"No default chain ID found for ecosystem smart accounts. Please reach out to the ecosystem owner.",
139+
`A chain must be provided either via 'chain' in connect options or 'defaultChainId' in ecosystem configuration. Please pass it via connect() or update the ecosystem configuration.`,
136140
);
137141
}
138-
const preferredChain =
139-
options.chain ?? getCachedChain(defaultChainId);
140142

141143
createOptions = {
142144
...createOptions,

0 commit comments

Comments
 (0)