Skip to content

Commit 47dc301

Browse files
committed
optimize zksync check position
1 parent 2d2bfc8 commit 47dc301

File tree

1 file changed

+14
-21
lines changed
  • packages/thirdweb/src/wallets/smart

1 file changed

+14
-21
lines changed

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

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,22 @@ export async function connectSmartAccount(
9595

9696
const options = creationOptions;
9797
const chain = connectChain ?? options.chain;
98-
const isZksyncChain = await isZkSyncChain(chain);
98+
const sponsorGas =
99+
"gasless" in options ? options.gasless : options.sponsorGas;
100+
if (await isZkSyncChain(chain)) {
101+
return [
102+
createZkSyncAccount({
103+
creationOptions,
104+
connectionOptions,
105+
chain,
106+
sponsorGas,
107+
}),
108+
chain,
109+
];
110+
}
99111

100112
// if factory is passed, but no entrypoint, try to resolve entrypoint from factory
101-
if (
102-
!isZksyncChain &&
103-
options.factoryAddress &&
104-
!options.overrides?.entrypointAddress
105-
) {
113+
if (options.factoryAddress && !options.overrides?.entrypointAddress) {
106114
const entrypointAddress = await getEntrypointFromFactory(
107115
options.factoryAddress,
108116
client,
@@ -127,21 +135,6 @@ export async function connectSmartAccount(
127135
};
128136
}
129137

130-
const sponsorGas =
131-
"gasless" in options ? options.gasless : options.sponsorGas;
132-
133-
if (isZksyncChain) {
134-
return [
135-
createZkSyncAccount({
136-
creationOptions,
137-
connectionOptions,
138-
chain,
139-
sponsorGas,
140-
}),
141-
chain,
142-
];
143-
}
144-
145138
const factoryAddress =
146139
options.factoryAddress ??
147140
getDefaultAccountFactory(options.overrides?.entrypointAddress);

0 commit comments

Comments
 (0)