Skip to content

Commit e28ae1a

Browse files
[SDK] Fix ecosystem wallet connection with default chains
1 parent 1607229 commit e28ae1a

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

.changeset/slimy-pigs-rest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix ecosystem wallet connection with default chains

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function createInAppWallet(args: {
5757
let client: ThirdwebClient | undefined;
5858
let authToken: string | null = null;
5959

60-
const resolveSmartAccountOptionsFromEcosystem = async (options: {
60+
const resolveSmartAccountOptionsFromEcosystem = async (options?: {
6161
chain?: Chain;
6262
}) => {
6363
if (ecosystem) {
@@ -78,7 +78,7 @@ export function createInAppWallet(args: {
7878
// default to 4337
7979
const { defaultChainId } = ecosystemOptions.smartAccountOptions;
8080
const preferredChain =
81-
options.chain ??
81+
options?.chain ??
8282
(defaultChainId ? getCachedChain(defaultChainId) : undefined);
8383
if (!preferredChain) {
8484
throw new Error(
@@ -108,7 +108,7 @@ export function createInAppWallet(args: {
108108
ecosystem,
109109
);
110110

111-
await resolveSmartAccountOptionsFromEcosystem(options);
111+
await resolveSmartAccountOptionsFromEcosystem();
112112

113113
const {
114114
account: connectedAccount,
@@ -145,7 +145,7 @@ export function createInAppWallet(args: {
145145
ecosystem,
146146
);
147147

148-
await resolveSmartAccountOptionsFromEcosystem(options);
148+
await resolveSmartAccountOptionsFromEcosystem();
149149

150150
const {
151151
account: connectedAccount,

packages/thirdweb/src/wallets/smart/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function connectSmartAccount(
8080
connectionOptions: SmartWalletConnectionOptions,
8181
creationOptions: SmartWalletOptions,
8282
): Promise<[Account, Chain]> {
83-
const { personalAccount, client, chain: connectChain } = connectionOptions;
83+
const { personalAccount, client } = connectionOptions;
8484

8585
if (!personalAccount) {
8686
throw new Error(
@@ -89,7 +89,7 @@ export async function connectSmartAccount(
8989
}
9090

9191
const options = creationOptions;
92-
const chain = connectChain ?? options.chain;
92+
const chain = creationOptions.chain;
9393
const sponsorGas =
9494
"gasless" in options ? options.gasless : options.sponsorGas;
9595
if (await isZkSyncChain(chain)) {

packages/thirdweb/src/wallets/smart/smart-wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export function smartWallet(
229229
const { connectSmartAccount } = await import("./index.js");
230230
const [connectedAccount, connectedChain] = await connectSmartAccount(
231231
{ ...lastConnectOptions, chain: newChain },
232-
createOptions,
232+
{ ...createOptions, chain: newChain },
233233
);
234234
// set the states
235235
account = connectedAccount;

0 commit comments

Comments
 (0)