Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-pigs-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix ecosystem wallet connection with default chains
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function createInAppWallet(args: {
let client: ThirdwebClient | undefined;
let authToken: string | null = null;

const resolveSmartAccountOptionsFromEcosystem = async (options: {
const resolveSmartAccountOptionsFromEcosystem = async (options?: {
chain?: Chain;
}) => {
if (ecosystem) {
Expand All @@ -78,7 +78,7 @@ export function createInAppWallet(args: {
// default to 4337
const { defaultChainId } = ecosystemOptions.smartAccountOptions;
const preferredChain =
options.chain ??
options?.chain ??
(defaultChainId ? getCachedChain(defaultChainId) : undefined);
if (!preferredChain) {
throw new Error(
Expand Down Expand Up @@ -108,7 +108,7 @@ export function createInAppWallet(args: {
ecosystem,
);

await resolveSmartAccountOptionsFromEcosystem(options);
await resolveSmartAccountOptionsFromEcosystem();

const {
account: connectedAccount,
Expand Down Expand Up @@ -145,7 +145,7 @@ export function createInAppWallet(args: {
ecosystem,
);

await resolveSmartAccountOptionsFromEcosystem(options);
await resolveSmartAccountOptionsFromEcosystem();

const {
account: connectedAccount,
Expand Down
4 changes: 2 additions & 2 deletions packages/thirdweb/src/wallets/smart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function connectSmartAccount(
connectionOptions: SmartWalletConnectionOptions,
creationOptions: SmartWalletOptions,
): Promise<[Account, Chain]> {
const { personalAccount, client, chain: connectChain } = connectionOptions;
const { personalAccount, client } = connectionOptions;

if (!personalAccount) {
throw new Error(
Expand All @@ -89,7 +89,7 @@ export async function connectSmartAccount(
}

const options = creationOptions;
const chain = connectChain ?? options.chain;
const chain = creationOptions.chain;
const sponsorGas =
"gasless" in options ? options.gasless : options.sponsorGas;
if (await isZkSyncChain(chain)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/wallets/smart/smart-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export function smartWallet(
const { connectSmartAccount } = await import("./index.js");
const [connectedAccount, connectedChain] = await connectSmartAccount(
{ ...lastConnectOptions, chain: newChain },
createOptions,
{ ...createOptions, chain: newChain },
);
// set the states
account = connectedAccount;
Expand Down
Loading