Skip to content

Nft-quest-setup#233

Open
cpb8010 wants to merge 10 commits intomainfrom
nft-quest-setup
Open

Nft-quest-setup#233
cpb8010 wants to merge 10 commits intomainfrom
nft-quest-setup

Conversation

@cpb8010
Copy link
Contributor

@cpb8010 cpb8010 commented Nov 22, 2025

Description

This PR implements NFT Quest using ERC-4337 account abstraction with passkey authentication, eliminating the dependency on the Auth Server. The implementation transitions from ZKsync-specific infrastructure to a standard Anvil/Alto bundler setup for local testing.

Key Changes

NFT Quest Application (examples/nft-quest/)

  • Removed Auth Server dependency - NFT Quest now works directly with passkeys and ERC-4337 bundler
  • New stores architecture:
    • stores/account.ts - Account state management (address, credentialId)
    • stores/client.ts - Viem client management (public, bundler, passkey clients)
    • stores/connector.ts - Complete rewrite for direct passkey registration and smart account deployment
  • Updated useMintNft composable - Now uses passkey client instead of wagmi
  • Added deployment scripts - scripts/deploy-msa-anvil.sh for deploying ERC-4337 contracts to Anvil
  • Added WASM support - Vite plugins for WebAssembly (top-level-await, wasm)
  • Simplified E2E tests - Single passkey flow without Auth Server popup handling

NFT Quest Contracts (examples/nft-quest-contracts/)

  • Added localhost network config for Anvil deployment (chain ID 1337)
  • New deploy/deploy-anvil.ts script for deploying NFT contracts to local Anvil
  • Added deploy:anvil nx target

SDK-4337 (packages/sdk-4337/)

  • Session proof generation - Added getSessionHash utility function in session/utils.ts
  • Improved error messages - More descriptive errors for ABI lookup failures
  • LimitType enum - Changed from string to numeric enum for proper serialization
  • Fixed deploy.ts - Pass null for eoaSigners when empty to prevent validation errors
  • Added /account export path in package.json

Rust SDK (packages/sdk-platforms/)

  • Added session proof generation in session creation and management
  • Added data parameter to finalize recovery function
  • Changed deployment to install session validator post-deployment
  • Made contract module public

CI/CD (.github/workflows/ci.yml)

  • Re-enabled NFT Quest E2E tests with proper Anvil + Alto bundler setup
  • Added Foundry toolchain installation
  • Added Rust/WASM build steps
  • Added ERC-4337 contract deployment step
  • Improved bundler health check using eth_chainId RPC call

Auth Server Updates

  • Various improvements to config handling and client setup
  • Updated chain ID handling for consistency

Testing

The NFT Quest E2E test flow:

  1. Start Anvil (chain ID 1337)
  2. Deploy ERC-4337 contracts (MSAFactory, validators)
  3. Deploy NFT contract
  4. Start Alto bundler with CORS proxy
  5. Run Playwright tests with virtual WebAuthn authenticator

Technical Details

  • Chain ID: 1337 (Anvil default, matches erc4337-contracts setup)
  • EntryPoint: v0.8 at 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108
  • Account deployment: Deploy first, extract address from AccountCreated event logs
  • Passkey auth: Uses @simplewebauthn/browser for WebAuthn registration

@cpb8010 cpb8010 changed the base branch from test4337fix to main November 22, 2025 08:01
@cpb8010 cpb8010 requested a review from itsacoyote November 24, 2025 20:06
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Visit the preview URL for this PR (updated for commit b3ebc2f):

https://zksync-auth-server-staging--pr233-nft-quest-setup-ae5ugd7r.web.app

(expires Fri, 19 Dec 2025 07:16:00 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 509a9c9ea42583076f531c53cf2979c544d5d0b7

Copilot AI review requested due to automatic review settings December 5, 2025 08:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a proof-of-concept for NFT Quest using ERC-4337 account abstraction with passkey authentication and session keys, eliminating the need for the Auth Server. The implementation transitions from ZKsync-specific infrastructure to a standard Anvil/Alto setup for testing and deployment.

Key Changes:

  • Added session proof generation and validation using cryptographic signatures
  • Refactored NFT Quest to use direct passkey registration and ERC-4337 bundler
  • Updated test infrastructure to use Anvil + Alto bundler instead of ZKsync test node

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/sdk-platforms/rust/.../transaction.rs Fixed type ambiguity by aliasing SessionSpec import
packages/sdk-platforms/rust/.../ffi-web/src/lib.rs Added proof parameter to createSession WASM binding
packages/sdk-platforms/rust/.../session/send.rs Added session proof generation in tests
packages/sdk-platforms/rust/.../session/revoke.rs Added session proof generation in tests
packages/sdk-platforms/rust/.../session/create.rs Added proof parameter and helper function for session creation
packages/sdk-platforms/rust/.../session/active.rs Refactored to use generated signers for session proofs
packages/sdk-platforms/rust/.../session.rs Made contract module public
packages/sdk-platforms/rust/.../guardian/.../finalize.rs Added data parameter to finalize recovery
packages/sdk-platforms/rust/.../deploy.rs Changed deployment to install session validator post-deployment
packages/sdk-4337/src/client/session/utils.ts Added getSessionHash utility function
packages/sdk-4337/src/client/session/types.ts Changed LimitType from string to numeric enum
packages/sdk-4337/src/client/session/session.test.ts Updated tests for LimitType string serialization
packages/sdk-4337/src/client/passkey/client-actions.ts Added proof parameter to createSession action
packages/sdk-4337/src/client/actions/sessions.ts Added proof parameter to createSession
packages/sdk-4337/src/client/actions/deploy.ts Fixed conditional logic for EOA signers
packages/sdk-4337/src/abi/SessionKeyValidator.ts Added proof field to ABI
packages/sdk-4337/package.json Added account export path
packages/erc4337-contracts Updated submodule reference
examples/nft-quest/tests/main.spec.ts Simplified test to single passkey flow without Auth Server
examples/nft-quest/stores/connector.ts Complete rewrite for direct passkey registration and deployment
examples/nft-quest/stores/client.ts New store for managing viem clients
examples/nft-quest/stores/account.ts New store for account state management
examples/nft-quest/scripts/deploy-msa-anvil.sh New deployment script for Anvil setup
examples/nft-quest/project.json Updated build and dev tasks for Anvil
examples/nft-quest/playwright.config.ts Removed Auth Server from test config
examples/nft-quest/pages/mint/index.vue Updated to use new store structure
examples/nft-quest/package.json Added SimpleWebAuthn and WASM dependencies
examples/nft-quest/nuxt.config.ts Added WASM plugins and Anvil chain config
examples/nft-quest/contracts-anvil.json New config file with deployed addresses
examples/nft-quest/composables/useMintNft.ts Refactored to use passkey client
examples/nft-quest-contracts/project.json Added Anvil deployment task
examples/nft-quest-contracts/hardhat.config.ts Added localhost network and optimizer settings
examples/nft-quest-contracts/deploy/deploy-anvil.ts New Anvil deployment script
examples/demo-app/components/SessionCreator.vue Added proof generation for session creation
.github/workflows/deploy-preview.yml Updated chain ID
.github/workflows/deploy-auth-server.yml Updated chain ID
.github/workflows/ci.yml Re-enabled NFT Quest E2E tests with Anvil setup
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

examples/nft-quest/stores/connector.ts:1

  • The variable name 'randomRecipient' is misleading as this is actually a hardcoded address, not a random one. Consider renaming to 'recipientAddress' or generating an actual random address.
import { startRegistration } from "@simplewebauthn/browser";

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cpb8010 cpb8010 added the enhancement New feature or request label Dec 5, 2025
for consistent test setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants