Skip to content

Commit 1dd91ba

Browse files
committed
fix: address code comments
1 parent 81d87e6 commit 1dd91ba

File tree

8 files changed

+17
-78
lines changed

8 files changed

+17
-78
lines changed

examples/demo-app/pages/index.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ const sessionConfig = {
168168
const buildConnector = (mode: "regular" | "session" | "paymaster" | "session-paymaster") => {
169169
const baseConfig: Parameters<typeof zksyncSsoConnector>[0] = {
170170
authServerUrl: "http://localhost:3002/confirm",
171+
// Add unique timestamp to ensure each connector is truly fresh
172+
// This prevents Wagmi from reusing cached connector instances
171173
connectorMetadata: {
172-
id: `zksync-sso-${mode}`,
174+
id: `zksync-sso-${mode}-${Date.now()}`,
173175
name: "ZKsync",
174176
icon: "https://zksync.io/favicon.ico",
175177
type: "zksync-sso",
@@ -193,12 +195,7 @@ const publicClient = createPublicClient({
193195
});
194196
const wagmiConfig = createConfig({
195197
chains: [chain],
196-
connectors: [
197-
buildConnector("regular"),
198-
buildConnector("session"),
199-
buildConnector("paymaster"),
200-
buildConnector("session-paymaster"),
201-
],
198+
connectors: [buildConnector("regular")],
202199
transports: {
203200
[chain.id]: http(),
204201
},
@@ -283,21 +280,13 @@ watch(address, async () => {
283280
const connectWallet = async (mode: "regular" | "session" | "paymaster" | "session-paymaster") => {
284281
try {
285282
errorMessage.value = "";
283+
const connector = buildConnector(mode);
286284
287285
if ((mode === "paymaster" || mode === "session-paymaster") && !testPaymasterAddress) {
288286
errorMessage.value = "Paymaster address is not configured.";
289287
return;
290288
}
291289
292-
// Find the pre-configured connector for this mode by ID
293-
const connectorId = `zksync-sso-${mode}`;
294-
const connector = wagmiConfig.connectors.find((c) => c.id === connectorId);
295-
296-
if (!connector) {
297-
errorMessage.value = `Connector for mode "${mode}" not found.`;
298-
return;
299-
}
300-
301290
// Track which mode was used for connection
302291
connectionMode.value = mode;
303292

examples/demo-app/tests/create-account.spec.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ test.beforeEach(async ({ page }) => {
5252
await expect(page.getByText("ZKsync SSO Demo")).toBeVisible();
5353
});
5454

55-
// Session transactions with eth_sendTransaction don't work on Anvil (standard EVM)
56-
// because smart accounts need ERC-4337 bundler, but sessions use native tx signing
57-
// This works fine on ZKsync Era but not on the Anvil testnet used in CI
5855
test.skip("Create account with session and send ETH", async ({ page }) => {
5956
// Step 1: regular connect to create account with passkey
6057
await page.getByRole("button", { name: "Connect", exact: true }).click();
@@ -253,12 +250,7 @@ test("Create passkey account and send ETH", async ({ page }) => {
253250
.toBeGreaterThan(endBalance + 0.1);
254251
});
255252

256-
// TODO: Paymaster for non-session transactions requires additional implementation
257-
// Currently, paymaster only works for session transactions because they use the bundler.
258-
// Non-session transactions use auth-server popup flow which doesn't convert to UserOperations.
259-
// To fix: Either convert non-session transactions to UserOperations, or implement paymaster
260-
// support in the auth-server transaction flow.
261-
test.skip("Create passkey account and send ETH with paymaster", async ({ page }) => {
253+
test("Create passkey account and send ETH with paymaster", async ({ page }) => {
262254
// Create account with paymaster connect (paymaster sponsors all gas)
263255
await page.getByRole("button", { name: "Connect (Paymaster)", exact: true }).click();
264256

@@ -338,20 +330,9 @@ test.skip("Create passkey account and send ETH with paymaster", async ({ page })
338330

339331
// CRITICAL: Verify that fees are shown as sponsored (paymaster covers them)
340332
await expect(popup.getByText("Fees")).toBeVisible();
341-
342-
// Check if sponsored text is visible (give it some time to appear)
343333
const sponsoredText = popup.getByText("0 ETH (Sponsored)");
344-
const hasSponsoredText = await sponsoredText.isVisible().catch(() => false);
345-
346-
if (!hasSponsoredText) {
347-
// Debug: log what fee text is actually showing
348-
const feeSection = await popup.locator("text=Fees").locator("..").textContent();
349-
console.log("Fee section content:", feeSection);
350-
console.log("⚠️ Warning: Expected '0 ETH (Sponsored)' but not found. Continuing test...");
351-
// For now, don't fail the test - just warn. The transaction should still work.
352-
} else {
353-
console.log("✓ Auth server shows fees are sponsored by paymaster");
354-
}
334+
await expect(sponsoredText, "Paymaster should cover fees - expecting '0 ETH (Sponsored)' to be shown").toBeVisible();
335+
console.log("✓ Auth server shows fees are sponsored by paymaster");
355336

356337
// Confirm the transfer
357338
await popup.getByTestId("confirm").click();

packages/auth-server/components/views/confirmation/Send.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,15 @@ const confirmTransaction = async () => {
254254
throw new Error("Transaction parameters are not available");
255255
}
256256
const usePaymasterFlag = !!requestPaymaster.value;
257-
console.log("[Send.vue] requestPaymaster.value:", requestPaymaster.value);
258-
console.log("[Send.vue] usePaymaster flag:", usePaymasterFlag);
259-
// Extract address - handle both string and PaymasterConfig object
260257
const paymasterAddr = typeof requestPaymaster.value === "string"
261258
? requestPaymaster.value
262259
: requestPaymaster.value?.address;
263-
console.log("[Send.vue] passing paymasterAddress:", paymasterAddr);
264260
const client = getClient({
265261
chainId: requestChain.value!.id,
266262
usePaymaster: usePaymasterFlag,
267263
paymasterAddress: paymasterAddr,
268264
});
269-
console.log("[Send.vue] client created, sending transaction...");
270265
const transactionHash = await client.sendTransaction(transactionParams.value);
271-
console.log("[Send.vue] transaction hash:", transactionHash);
272266
return {
273267
result: transactionHash,
274268
};

packages/auth-server/stores/client.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,7 @@ export const useClientStore = defineStore("client", () => {
140140
const contracts = contractsByChain[chainId];
141141
const bundlerClient = getBundlerClient({ chainId });
142142

143-
console.log("[client.ts getClient] usePaymaster:", usePaymaster);
144-
console.log("[client.ts getClient] passed paymasterAddress:", paymasterAddress);
145-
console.log("[client.ts getClient] contracts.testPaymaster:", contracts.testPaymaster);
146-
// Use passed address, fallback to contracts.testPaymaster if usePaymaster is true
147143
const finalPaymasterAddress = paymasterAddress ?? (usePaymaster ? contracts.testPaymaster : undefined);
148-
console.log("[client.ts getClient] final paymaster address being passed:", finalPaymasterAddress);
149144

150145
const client = createPasskeyClient({
151146
account: {

packages/auth-server/stores/local-node.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"rpcUrl": "http://localhost:8545",
33
"chainId": 1337,
44
"deployer": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
5-
"eoaValidator": "0x403CFc9A133a54B9CDC2E070BB811b8a68ff1250",
6-
"sessionValidator": "0x9bbaCAB8739Fa0041A6906b51FE46E90756dA455",
7-
"webauthnValidator": "0xC025Ea0F10dcE91d14a3473fc60ff1F23BCe8c19",
8-
"guardianExecutor": "0x1a317D3c55D729a83D7d8F1E18690AD12A655515",
9-
"accountImplementation": "0x37faAe901e81d7ae49fc914E66cCD8dfA6543C4A",
10-
"beacon": "0x9AE4d06a96cac1Fd90119ef4126E69eE8cdBBc6e",
11-
"factory": "0x5DeeB04262d1f402a5b1D50eC537b3657ea2b18D",
12-
"testPaymaster": "0x6cFA08b105a8674B3249CaA3B4405783A0D8a58B",
13-
"mockPaymaster": "0x6cFA08b105a8674B3249CaA3B4405783A0D8a58B",
5+
"eoaValidator": "0x7079ade5d4C71aE7868E6AC8553148FfC3D8d660",
6+
"sessionValidator": "0xE619369f26285FEd402bd0c3526aEb1faf2BE2C0",
7+
"webauthnValidator": "0x85ed36BD17265a4eb2f6d87FAd3E6277066986f0",
8+
"guardianExecutor": "0xb3b3496CC339d80b2182a3985FeF5EBE60bc896C",
9+
"accountImplementation": "0xddfa09697bCe57712B5365ff573c3e6b3C8FFDDb",
10+
"beacon": "0x197072f17a5e1A35C1909999e6f3cFEDe5A42BB8",
11+
"factory": "0xF9e4C9Cfec57860d82e6B41Cd50DEF2b3826D5CF",
12+
"testPaymaster": "0xf8C803b1378C96557381f43F86f77D72D79BeE95",
13+
"mockPaymaster": "0xf8C803b1378C96557381f43F86f77D72D79BeE95",
1414
"entryPoint": "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
1515
"bundlerUrl": "http://localhost:4337"
1616
}

packages/sdk-4337/src/client/common/smart-account-client-actions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ export function smartAccountClientActions<
188188
}
189189
: {};
190190

191-
console.log("[smart-account-client-actions.ts sendTransaction] About to call bundler.sendUserOperation with paymaster params:", paymasterParams);
192-
193191
// Send user operation through bundler
194192
const userOpHash = await config.bundler.sendUserOperation({
195193
account,

packages/sdk-4337/src/client/passkey/account.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,6 @@ export async function toPasskeySmartAccount<
146146
const paymasterVerificationGasLimit = (params as any).paymasterVerificationGasLimit as bigint | undefined;
147147
const paymasterPostOpGasLimit = (params as any).paymasterPostOpGasLimit as bigint | undefined;
148148

149-
console.log("[passkey/account.ts] signUserOperation called with:", {
150-
hasPaymaster,
151-
paymaster,
152-
paymasterData,
153-
paymasterVerificationGasLimit: paymasterVerificationGasLimit?.toString(),
154-
paymasterPostOpGasLimit: paymasterPostOpGasLimit?.toString(),
155-
nonce: params.nonce?.toString(),
156-
});
157-
158149
// Compute user operation hash for v0.8
159150
// IMPORTANT: For v0.8, DO NOT use paymasterAndData - use the separate fields directly
160151
const userOp: any = {
@@ -170,7 +161,6 @@ export async function toPasskeySmartAccount<
170161
signature: "0x",
171162
};
172163

173-
// Add paymaster fields if present (v0.8 uses separate fields, not paymasterAndData)
174164
if (hasPaymaster && paymaster) {
175165
userOp.paymaster = paymaster;
176166
userOp.paymasterVerificationGasLimit = paymasterVerificationGasLimit;
@@ -185,9 +175,6 @@ export async function toPasskeySmartAccount<
185175
userOperation: userOp,
186176
} as any) as Hex;
187177

188-
console.log("[passkey/account.ts] Computed UserOp hash:", userOpHash);
189-
console.log("[passkey/account.ts] Hash includes paymaster fields:", hasPaymaster);
190-
191178
// Sign with WebAuthn (browser API) and get complete signature
192179
// signWithPasskey handles:
193180
// 1. Converting hash to WebAuthn challenge
@@ -203,9 +190,6 @@ export async function toPasskeySmartAccount<
203190
origin,
204191
});
205192

206-
console.log("[passkey/account.ts] Generated signature:", signature);
207-
console.log("[passkey/account.ts] Signature includes paymaster:", hasPaymaster);
208-
209193
return signature;
210194
},
211195
});

packages/sdk-4337/src/connector/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ export const getConnectedSsoSessionClient = async<
276276
config: config,
277277
parameters: GetConnectorClientParameters<config, chainId> = {},
278278
): Promise<GetConnectedSsoClientReturnType<config, chainId>> => {
279-
// Get the current connection
280279
const connections = getConnections(config);
281280
const connection = connections.find((c) => c.accounts.length > 0);
282281

@@ -289,7 +288,6 @@ export const getConnectedSsoSessionClient = async<
289288
throw new Error("Connector does not support getClient method. Make sure you're using the ZKsync SSO connector.");
290289
}
291290

292-
// Use the custom _getClient method to get our custom client
293291
const client = await (connection.connector as any)._getClient(parameters);
294292

295293
if (!isSsoSessionClient(client)) {

0 commit comments

Comments
 (0)