Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/early-adults-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Skip factory entrypoint lookup for ZKsync chains
16 changes: 11 additions & 5 deletions packages/thirdweb/src/wallets/smart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ export async function connectSmartAccount(

const options = creationOptions;
const chain = connectChain ?? options.chain;
const isZksyncChain = await isZkSyncChain(chain);

// if factory is passed, but no entrypoint, try to resolve entrypoint from factory
if (options.factoryAddress && !options.overrides?.entrypointAddress) {
if (
!isZksyncChain &&
options.factoryAddress &&
!options.overrides?.entrypointAddress
) {
const entrypointAddress = await getEntrypointFromFactory(
options.factoryAddress,
client,
Expand All @@ -122,13 +127,10 @@ export async function connectSmartAccount(
};
}

const factoryAddress =
options.factoryAddress ??
getDefaultAccountFactory(options.overrides?.entrypointAddress);
const sponsorGas =
"gasless" in options ? options.gasless : options.sponsorGas;

if (await isZkSyncChain(chain)) {
if (isZksyncChain) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be cleaner to just move this block at the very top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was the paymaster and entrypoint address configs were still valid for ZKsync chains, but if that's not the case then yes the conditions can be moved around

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no entrypoint is only for non-zk chains, so makes sense to check zk chain first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! In that case, I've pushed an update that simplifies the ZKsync chain check

return [
createZkSyncAccount({
creationOptions,
Expand All @@ -140,6 +142,10 @@ export async function connectSmartAccount(
];
}

const factoryAddress =
options.factoryAddress ??
getDefaultAccountFactory(options.overrides?.entrypointAddress);

const factoryContract = getContract({
client: client,
address: factoryAddress,
Expand Down
Loading