Skip to content

Commit 88685ca

Browse files
committed
Merge branch 'main' of https://github.com/matter-labs/zksync-sso into new-prividium-support
2 parents 5ac4280 + 82a73df commit 88685ca

File tree

84 files changed

+3256
-555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3256
-555
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ jobs:
116116
path: examples/demo-app/playwright-report/
117117
retention-days: 3
118118

119+
# Run Guardian E2E tests (reuses same Anvil + bundler setup)
120+
- name: Install Playwright Chromium Browser for Guardian tests
121+
run: pnpm exec playwright install chromium
122+
working-directory: packages/auth-server
123+
- name: Run Guardian e2e tests
124+
run: pnpm nx e2e:guardian auth-server
125+
- uses: actions/upload-artifact@v4
126+
if: ${{ !cancelled() }}
127+
with:
128+
name: auth-server-guardian-playwright-report
129+
path: packages/auth-server/playwright-report/
130+
retention-days: 3
131+
119132
# e2e-nft-quest:
120133
# runs-on: ubuntu-latest
121134
# defaults:

cspell-config/cspell-packages.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ levischuck
88
ofetch
99
reown
1010
jose
11+
pinia

examples/demo-app/project.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@
120120
},
121121
"dependsOn": ["e2e:setup"]
122122
},
123+
"e2e:guardian": {
124+
"executor": "nx:run-commands",
125+
"options": {
126+
"cwd": "examples/demo-app",
127+
"command": "PW_TEST_HTML_REPORT_OPEN=never playwright test tests/guardian.spec.ts --config=playwright-erc4337.config.ts"
128+
},
129+
"dependsOn": ["e2e:setup:erc4337"]
130+
},
123131
"e2e:demo-only": {
124132
"executor": "nx:run-commands",
125133
"options": {

examples/demo-app/scripts/deploy-msa-anvil.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ cast send "$PAYMASTER" --value 10ether --private-key "$ANVIL_ACCOUNT_0_KEY" --rp
6060
echo "💳 Depositing 10 ETH into EntryPoint for paymaster..."
6161
cast send "$PAYMASTER" "deposit()" --value 10ether --private-key "$ANVIL_ACCOUNT_0_KEY" --rpc-url "$RPC_URL" 2>&1 || echo "Deposit initiated"
6262

63+
# Add stake to the paymaster (required for ERC-4337)
64+
echo "🔒 Adding stake to paymaster (1 day unlock delay)..."
65+
cast send "$PAYMASTER" "addStake(uint32)" 86400 --value 1ether --private-key "$ANVIL_ACCOUNT_0_KEY" --rpc-url "$RPC_URL" 2>&1 || echo "Stake added"
66+
6367
# Verify all addresses were extracted
6468
if [ -z "$EOA_VALIDATOR" ] || [ -z "$SESSION_VALIDATOR" ] || [ -z "$WEBAUTHN_VALIDATOR" ] || \
6569
[ -z "$GUARDIAN_EXECUTOR" ] || [ -z "$ACCOUNT_IMPL" ] || [ -z "$BEACON" ] || [ -z "$FACTORY" ] || [ -z "$PAYMASTER" ]; then

packages/auth-server-api/src/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ let contractsFromFile: {
1717
eoaValidator?: string;
1818
webauthnValidator?: string;
1919
sessionValidator?: string;
20+
guardianExecutor?: string;
2021
} = {};
2122

2223
try {
@@ -38,6 +39,7 @@ const envSchema = z.object({
3839
EOA_VALIDATOR_ADDRESS: z.string().optional(),
3940
WEBAUTHN_VALIDATOR_ADDRESS: z.string().optional(),
4041
SESSION_VALIDATOR_ADDRESS: z.string().optional(),
42+
GUARDIAN_EXECUTOR_ADDRESS: z.string().optional(),
4143
// Prividium Mode Configuration
4244
PRIVIDIUM_MODE: z.string().transform((v) => v === "true").default("false"),
4345
PRIVIDIUM_PERMISSIONS_BASE_URL: z.string().optional(),
@@ -79,6 +81,7 @@ const FACTORY_ADDRESS = env.FACTORY_ADDRESS || contractsFromFile.factory;
7981
const EOA_VALIDATOR_ADDRESS = env.EOA_VALIDATOR_ADDRESS || contractsFromFile.eoaValidator;
8082
const WEBAUTHN_VALIDATOR_ADDRESS = env.WEBAUTHN_VALIDATOR_ADDRESS || contractsFromFile.webauthnValidator;
8183
const SESSION_VALIDATOR_ADDRESS = env.SESSION_VALIDATOR_ADDRESS || contractsFromFile.sessionValidator;
84+
const GUARDIAN_EXECUTOR_ADDRESS = env.GUARDIAN_EXECUTOR_ADDRESS || contractsFromFile.guardianExecutor;
8285

8386
// Validate that we have all required contract addresses
8487
if (!FACTORY_ADDRESS || !EOA_VALIDATOR_ADDRESS || !WEBAUTHN_VALIDATOR_ADDRESS || !SESSION_VALIDATOR_ADDRESS) {
@@ -162,4 +165,4 @@ const rateLimitConfig = {
162165
deployWindowMs: parseInt(env.RATE_LIMIT_DEPLOY_WINDOW_MS, 10),
163166
};
164167

165-
export { env, EOA_VALIDATOR_ADDRESS, FACTORY_ADDRESS, getChain, prividiumConfig, rateLimitConfig, SESSION_VALIDATOR_ADDRESS, SUPPORTED_CHAINS, WEBAUTHN_VALIDATOR_ADDRESS };
168+
export { env, EOA_VALIDATOR_ADDRESS, FACTORY_ADDRESS, getChain, GUARDIAN_EXECUTOR_ADDRESS, prividiumConfig, rateLimitConfig, SESSION_VALIDATOR_ADDRESS, SUPPORTED_CHAINS, WEBAUTHN_VALIDATOR_ADDRESS };

packages/auth-server-api/src/handlers/deploy-account.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { privateKeyToAccount } from "viem/accounts";
44
import { waitForTransactionReceipt } from "viem/actions";
55
import { getAccountAddressFromLogs, prepareDeploySmartAccount } from "zksync-sso-4337/client";
66

7-
import { env, EOA_VALIDATOR_ADDRESS, FACTORY_ADDRESS, getChain, prividiumConfig, SESSION_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS } from "../config.js";
7+
import { env, EOA_VALIDATOR_ADDRESS, FACTORY_ADDRESS, getChain, GUARDIAN_EXECUTOR_ADDRESS, prividiumConfig, SESSION_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS } from "../config.js";
88
import { deployAccountSchema } from "../schemas.js";
99
import { addAddressToUser, createProxyTransport, getAdminAuthService, whitelistContract } from "../services/prividium/index.js";
1010

@@ -79,6 +79,8 @@ export const deployAccountHandler = async (req: Request, res: Response): Promise
7979
}
8080

8181
// Prepare deployment transaction
82+
const executorModulesToInstall = GUARDIAN_EXECUTOR_ADDRESS ? [GUARDIAN_EXECUTOR_ADDRESS as Address] : [];
83+
8284
const { transaction, accountId } = prepareDeploySmartAccount({
8385
contracts: {
8486
factory: FACTORY_ADDRESS as Address,
@@ -96,6 +98,7 @@ export const deployAccountHandler = async (req: Request, res: Response): Promise
9698
eoaSigners: body.eoaSigners,
9799
userId: body.userId,
98100
installSessionValidator: true,
101+
executorModules: executorModulesToInstall,
99102
});
100103

101104
console.log("Deploying account with ID:", accountId);

0 commit comments

Comments
 (0)