Skip to content

Commit 925313f

Browse files
committed
fix: cleanup tests
1 parent c8e9daa commit 925313f

File tree

6 files changed

+117
-32
lines changed

6 files changed

+117
-32
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ jobs:
190190
191191
# Deploy MSA Factory and infrastructure (nft-quest will read from contracts-anvil.json)
192192
- name: Deploy Demo-App ERC-4337 contracts
193-
continue-on-error: true
194193
run: pnpm nx deploy-msa-factory demo-app
195194

196195
# Start Alto bundler with CORS proxy

examples/nft-quest/public/contracts.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"chainId": 1337,
44
"entryPoint": "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
55
"bundlerUrl": "http://localhost:4337",
6-
"factory": "0x0356cA3d0350858BCac4De0FC1dEa3Bc6e7c3e3a",
7-
"eoaValidator": "0xDd72e46653662b0118A2743574467FAA582D633e",
8-
"sessionValidator": "0xCaec08bfd740F1Ae4300b3ab62B757F99222244b",
9-
"webauthnValidator": "0xd71301c72D03b483F74BA569ff1132af81079858",
10-
"guardianExecutor": "0xD4c76bC6306657FE415Ee6B09Ea61cFA50573848",
11-
"testPaymaster": "0x206C056fE7Bddb5cC54CcB0331bcf2058b2D5BA6",
12-
"mockPaymaster": "0x206C056fE7Bddb5cC54CcB0331bcf2058b2D5BA6",
13-
"nftContract": "0xFF06F4b2ef9F9D9B96238397Db82d5C445B5244f"
6+
"factory": "0xa7146dB81e9E0f3919DA7fbeC4e23b019d2cfc4f",
7+
"eoaValidator": "0x2E4d936CEf58a55E0C3aB5C51113188912AF35D7",
8+
"sessionValidator": "0x8F40F91A9b129de806589161afAD0632992383E7",
9+
"webauthnValidator": "0x8590D0dfFBc86BC19D059474385618bEd01E36C0",
10+
"guardianExecutor": "0xaEb7C09a35f1FD63F510Dce81BffAF9FEEAcd507",
11+
"testPaymaster": "0xD4ad8929d0976E8469C069ef9798BE7E5C1d53F5",
12+
"mockPaymaster": "0xD4ad8929d0976E8469C069ef9798BE7E5C1d53F5",
13+
"nftContract": "0xeB7a64e12c1811f0D3DBB0730c76d2708e179ae0"
1414
}

examples/nft-quest/tests/main.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ test("Create account, session key, and mint NFT", async ({ page }) => {
8989
newCredential = credentialAdded.credential;
9090
});
9191

92-
// Add session
92+
// Step 1: Create account
93+
await expect(popup.getByText("Account Creation")).toBeVisible();
94+
await popup.getByTestId("connect").click();
95+
96+
// Step 2: Authorize session (second passkey approval)
9397
await expect(popup.getByText("Authorize ZK NFT Quest")).toBeVisible();
9498
await expect(popup.getByText("Permissions")).toBeVisible();
9599
await popup.getByTestId("connect").click();

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

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,43 @@
4747
class="mt-1"
4848
/>
4949

50-
<!-- For new accounts, show a simple message -->
50+
<!-- For new accounts creating session in two steps -->
5151
<div
52-
v-if="!isLoggedIn"
52+
v-if="accountCreated && hasSessionParams"
53+
class="space-y-2 mt-2"
54+
>
55+
<div class="bg-neutral-975 rounded-[28px]">
56+
<div class="px-5 py-2 text-neutral-400">
57+
Permissions
58+
</div>
59+
<CommonLine class="text-neutral-100">
60+
<div class="divide-y divide-neutral-800">
61+
<div class="flex items-center gap-2 py-3 px-3">
62+
<IconsFingerprint class="w-7 h-7" />
63+
<div>Act on your behalf</div>
64+
</div>
65+
<div class="flex items-center gap-2 py-3 px-3">
66+
<IconsClock class="w-7 h-7" />
67+
<div>{{ sessionExpiry }}</div>
68+
</div>
69+
</div>
70+
</CommonLine>
71+
</div>
72+
</div>
73+
<SessionTokens
74+
v-if="accountCreated && hasSessionParams"
75+
:onchain-actions-count="onchainActionsCount"
76+
:fetch-tokens-error="fetchTokensError"
77+
:tokens-loading="tokensLoading"
78+
:spend-limit-tokens="spendLimitTokens"
79+
:has-unlimited-spend="hasUnlimitedSpend"
80+
:total-usd="totalUsd"
81+
class="mt-1"
82+
/>
83+
84+
<!-- For new accounts without session yet, show a simple message -->
85+
<div
86+
v-if="!isLoggedIn && !accountCreated"
5387
class="space-y-2 mt-2"
5488
>
5589
<div class="bg-neutral-975 rounded-[28px]">
@@ -59,7 +93,9 @@
5993
<CommonLine class="text-neutral-100">
6094
<div class="py-3 px-3">
6195
<p class="text-sm text-neutral-300">
62-
A new smart account will be created for you. You can add spending permissions later when needed.
96+
A new smart account will be created for you.
97+
<span v-if="hasSessionParams">After that, you'll set up spending permissions.</span>
98+
<span v-else>You can add spending permissions later when needed.</span>
6399
</p>
64100
</div>
65101
</CommonLine>
@@ -168,12 +204,18 @@ const props = defineProps({
168204
const { appMeta, appOrigin } = useAppMeta();
169205
const { login } = useAccountStore();
170206
const { isLoggedIn } = storeToRefs(useAccountStore());
171-
const { responseInProgress, requestChainId } = storeToRefs(useRequestsStore());
172-
const { createAccount } = useAccountCreate(requestChainId);
207+
const { responseInProgress, requestChainId, requestPaymaster } = storeToRefs(useRequestsStore());
208+
const { createAccount, registerInProgress: accountCreationInProgress } = useAccountCreate(requestChainId);
173209
const { respond, deny } = useRequestsStore();
174210
const { getClient } = useClientStore();
175211
const runtimeConfig = useRuntimeConfig();
176212
213+
// Track if we just created an account and need to create session
214+
const accountCreated = ref(false);
215+
const hasSessionParams = computed(() => {
216+
return props.sessionPreferences.contractCalls && props.sessionPreferences.contractCalls.length > 0;
217+
});
218+
177219
const defaults = {
178220
expiresAt: BigInt(Math.floor(Date.now() / 1000) + 60 * 60 * 24), // 24 hours
179221
feeLimit: {
@@ -284,7 +326,7 @@ const scrollDown = () => {
284326
behavior: "smooth",
285327
});
286328
};
287-
const isButtonLoading = computed(() => !appMeta.value || responseInProgress.value || tokensLoading.value);
329+
const isButtonLoading = computed(() => !appMeta.value || responseInProgress.value || tokensLoading.value || accountCreationInProgress.value);
288330
const confirmButtonAvailable = computed(() => arrivedAtBottom.value);
289331
const transitionName = ref("slide-up");
290332
const previousConfirmAvailable = ref(confirmButtonAvailable.value);
@@ -294,36 +336,53 @@ watch(confirmButtonAvailable, (newVal, oldVal) => {
294336
previousConfirmAvailable.value = newVal;
295337
}
296338
});
297-
const mainButtonText = computed(() => isLoggedIn.value ? "Connect" : "Create");
339+
const mainButtonText = computed(() => {
340+
if (isLoggedIn.value) return "Connect";
341+
if (accountCreated.value) return "Authorize";
342+
return "Create";
343+
});
298344
299345
const confirmConnection = async () => {
300346
let response: RPCResponseMessage<ExtractReturnType<Method>>["content"];
301347
sessionError.value = "";
302348
303349
try {
304-
if (!isLoggedIn.value) {
305-
// Just create the account - session will be created by the dapp separately
350+
if (!isLoggedIn.value && !accountCreated.value) {
351+
// Step 1: Create the account
306352
const accountData = await createAccount();
307353
if (!accountData) return;
354+
308355
// Login with the new account
309356
login({
310357
address: accountData.address,
311358
credentialId: accountData.credentialId,
312359
});
313360
314-
// Return account info without session - dapp will create session separately
361+
// If session params were provided, show session creation UI
362+
if (hasSessionParams.value) {
363+
accountCreated.value = true;
364+
// Force a UI update before returning
365+
await nextTick();
366+
return; // Don't respond yet, wait for session creation
367+
}
368+
369+
// No session params, return account info only
315370
response = {
316371
result: constructReturn({
317372
address: accountData.address,
318373
chainId: accountData.chainId,
319-
// No session in response - dapp needs to create it separately
320374
prividiumMode: runtimeConfig.public.prividiumMode,
321375
prividiumProxyUrl: runtimeConfig.public.prividium?.rpcUrl || "",
322376
}),
323377
};
324-
} else {
378+
} else if (accountCreated.value || isLoggedIn.value) {
325379
// create a new session for the existing account
326-
const client = getClient({ chainId: requestChainId.value });
380+
// Use paymaster if provided (needed for newly created accounts with no ETH)
381+
const client = getClient({
382+
chainId: requestChainId.value,
383+
usePaymaster: !!requestPaymaster.value,
384+
paymasterAddress: requestPaymaster.value,
385+
});
327386
const sessionKey = generatePrivateKey();
328387
const session = {
329388
sessionKey,

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": "0xDd72e46653662b0118A2743574467FAA582D633e",
6-
"sessionValidator": "0xCaec08bfd740F1Ae4300b3ab62B757F99222244b",
7-
"webauthnValidator": "0xd71301c72D03b483F74BA569ff1132af81079858",
8-
"guardianExecutor": "0xD4c76bC6306657FE415Ee6B09Ea61cFA50573848",
9-
"accountImplementation": "0xB69ae22EE1F1141Cb8Fd6d465CC0f8eB5813C615",
10-
"beacon": "0x809eBD30a2357012E6cBaB8776682318568556c1",
11-
"factory": "0x0356cA3d0350858BCac4De0FC1dEa3Bc6e7c3e3a",
12-
"testPaymaster": "0x206C056fE7Bddb5cC54CcB0331bcf2058b2D5BA6",
13-
"mockPaymaster": "0x206C056fE7Bddb5cC54CcB0331bcf2058b2D5BA6",
5+
"eoaValidator": "0x2E4d936CEf58a55E0C3aB5C51113188912AF35D7",
6+
"sessionValidator": "0x8F40F91A9b129de806589161afAD0632992383E7",
7+
"webauthnValidator": "0x8590D0dfFBc86BC19D059474385618bEd01E36C0",
8+
"guardianExecutor": "0xaEb7C09a35f1FD63F510Dce81BffAF9FEEAcd507",
9+
"accountImplementation": "0x3465ee19A11F3Bbf4eB341DB943cbbF1A77Cc145",
10+
"beacon": "0x7f052D5a131E90147D33573D01f406A8181A0F4d",
11+
"factory": "0xa7146dB81e9E0f3919DA7fbeC4e23b019d2cfc4f",
12+
"testPaymaster": "0xD4ad8929d0976E8469C069ef9798BE7E5C1d53F5",
13+
"mockPaymaster": "0xD4ad8929d0976E8469C069ef9798BE7E5C1d53F5",
1414
"entryPoint": "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
1515
"bundlerUrl": "http://localhost:4337"
1616
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,28 @@ export function passkeyClientActions<
101101
const smartAccount = await toPasskeySmartAccount(config.passkeyAccount);
102102
const sessionSpecJSON = sessionSpecToJSON(params.sessionSpec);
103103
const callData = encode_create_session_call_data(sessionSpecJSON, params.proof) as unknown as `0x${string}`;
104+
// Normalize paymaster config (same logic as smartAccountClientActions)
105+
const normalizedPaymaster = config.paymaster
106+
? typeof config.paymaster === "string"
107+
? {
108+
address: config.paymaster as Address,
109+
verificationGasLimit: 500_000n,
110+
postOpGasLimit: 1_000_000n,
111+
data: "0x" as `0x${string}`,
112+
}
113+
: config.paymaster
114+
: undefined;
115+
116+
// For v0.8 EntryPoint, pass separate paymaster fields (not packed paymasterAndData)
117+
const paymasterParams = normalizedPaymaster
118+
? {
119+
paymaster: normalizedPaymaster.address,
120+
paymasterData: normalizedPaymaster.data ?? ("0x" as Hex),
121+
paymasterVerificationGasLimit: normalizedPaymaster.verificationGasLimit ?? 500_000n,
122+
paymasterPostOpGasLimit: normalizedPaymaster.postOpGasLimit ?? 1_000_000n,
123+
}
124+
: {};
125+
104126
const userOpHash = await config.bundler.sendUserOperation({
105127
account: smartAccount,
106128
calls: [
@@ -110,6 +132,7 @@ export function passkeyClientActions<
110132
value: 0n,
111133
},
112134
],
135+
...paymasterParams,
113136
});
114137
return userOpHash;
115138
},

0 commit comments

Comments
 (0)