Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
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
1 change: 1 addition & 0 deletions cspell-config/cspell-misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ethereum
sepolia
foundryup
unpermitted
gwei

// auth-server
oidc
Expand Down
14 changes: 1 addition & 13 deletions packages/auth-server/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,7 @@
</template>

<script lang="ts" setup>
import { createAppKit } from "@reown/appkit/vue";

const { defaultChain } = useClientStore();
const { metadata, projectId, wagmiAdapter } = useAppKit();

createAppKit({
adapters: [wagmiAdapter],
networks: [defaultChain],
projectId,
metadata,
});

// BigInt polyfill
// BigInt polyfill for JSON serialization
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(BigInt.prototype as any).toJSON = function () {
return this.toString();
Expand Down
6 changes: 4 additions & 2 deletions packages/auth-server/composables/useAppKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export const useAppKit = () => {
const { defaultChain } = useClientStore();

const projectId = runtimeConfig.public.appKitProjectId;
const origin = runtimeConfig.public.appUrl;

const metadata = {
name: "ZKsync SSO Auth Server",
description: "ZKsync SSO Auth Server",
url: window.location.origin,
icons: [new URL("/icon-512.png", window.location.origin).toString()],
url: origin,
icons: [new URL("/icon-512.png", origin).toString()],
};

const wagmiAdapter = new WagmiAdapter({
Expand Down
55 changes: 55 additions & 0 deletions packages/auth-server/plugins/appkit.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { createAppKit } from "@reown/appkit/vue";

export default defineNuxtPlugin(async () => {
const { defaultChain } = useClientStore();

// Dynamic import to ensure browser globals are available
const { WagmiAdapter } = await import("@reown/appkit-adapter-wagmi");
const runtimeConfig = useRuntimeConfig();

const projectId = runtimeConfig.public.appKitProjectId;
const origin = window.location.origin;

const metadata = {
name: "ZKsync SSO Auth Server",
description: "ZKsync SSO Auth Server",
url: origin,
icons: [new URL("/icon-512.png", origin).toString()],
};

// Create plain chain object to avoid Viem Proxy issues
const plainChain = {
id: defaultChain.id,
name: defaultChain.name,
nativeCurrency: {
name: defaultChain.nativeCurrency.name,
symbol: defaultChain.nativeCurrency.symbol,
decimals: defaultChain.nativeCurrency.decimals,
},
rpcUrls: {
default: {
http: [...defaultChain.rpcUrls.default.http],
},
},
blockExplorers: defaultChain.blockExplorers
? {
default: {
name: defaultChain.blockExplorers.default.name,
url: defaultChain.blockExplorers.default.url,
},
}
: undefined,
};

const wagmiAdapter = new WagmiAdapter({
networks: [plainChain],
projectId,
});

createAppKit({
adapters: [wagmiAdapter],
networks: [plainChain],
projectId,
metadata,
});
});
37 changes: 36 additions & 1 deletion packages/auth-server/stores/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,40 @@ const zksyncOsLocal = defineChain({
},
});

export const supportedChains = [localhost, zksyncOsTestnet, zksyncOsLocal];
const dawnMainnet = defineChain({
id: 30715,
name: "Dawn Mainnet",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
rpcUrls: {
default: {
http: ["https://zksync-os-mainnet-dawn.zksync.io"],
},
},
blockExplorers: {
default: {
name: "Dawn Mainnet Explorer",
url: "https://zksync-os-mainnet-dawn.staging-scan-v2.zksync.dev",
},
},
});

export const supportedChains = [localhost, zksyncOsTestnet, zksyncOsLocal, dawnMainnet];
export type SupportedChainId = (typeof supportedChains)[number]["id"];
export const blockExplorerUrlByChain: Record<SupportedChainId, string> = {
[localhost.id]: "http://localhost:3010",
[zksyncOsTestnet.id]: "https://zksync-os-testnet-alpha.staging-scan-v2.zksync.dev",
[zksyncOsLocal.id]: "",
[dawnMainnet.id]: "https://zksync-os-mainnet-dawn.staging-scan-v2.zksync.dev",
};
export const blockExplorerApiByChain: Record<SupportedChainId, string> = {
[localhost.id]: "http://localhost:3020",
[zksyncOsTestnet.id]: "https://block-explorer-api.zksync-os-testnet-alpha.zksync.dev/api",
[zksyncOsLocal.id]: "",
[dawnMainnet.id]: "https://block-explorer-api.zksync-os-mainnet-dawn.zksync.io",
};

type ChainContracts = {
Expand All @@ -79,6 +102,15 @@ export const contractsByChain: Record<SupportedChainId, ChainContracts> = {
bundlerUrl: "https://bundler-api.stage-sso.zksync.dev",
beacon: "0x1D779D791B55a093dE60da664C3F301a87f96C62",
},
[dawnMainnet.id]: {
bundlerUrl: "https://bundler-api.dawn-mainnet.zksync.io", // Update with actual bundler URL when available
eoaValidator: "0x6f9861381E67DA7B26E7112cb1098027DD9e3dc6",
webauthnValidator: "0xe11bCfC99754CA38e1c0b0EE48E1C54C9e5B006B",
sessionValidator: "0x8Bd9da9021734fa962a57900ef6d626531158419",
guardianExecutor: "0xA1454A0cE96A52A3c8082675FE8C8Be7D620eF0E",
beacon: "0xF0a5f0f274aAfd2cA649a3B00b1d9FA22BD7d39A",
factory: "0x6F652864bDe910565beA169B89e133d70e2A9770",
},
};

export const chainParameters: Record<SupportedChainId, { blockTime: number }> = {
Expand All @@ -91,6 +123,9 @@ export const chainParameters: Record<SupportedChainId, { blockTime: number }> =
[zksyncOsTestnet.id]: {
blockTime: 1,
},
[dawnMainnet.id]: {
blockTime: 1,
},
};

export const useClientStore = defineStore("client", () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/auth-server/stores/dawn-mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"eoaValidator": "0x6f9861381E67DA7B26E7112cb1098027DD9e3dc6",
"webauthnValidator": "0xe11bCfC99754CA38e1c0b0EE48E1C54C9e5B006B",
"sessionValidator": "0x8Bd9da9021734fa962a57900ef6d626531158419",
"guardianExecutor": "0xA1454A0cE96A52A3c8082675FE8C8Be7D620eF0E",
"accountImplementation": "0x223406537f502d3dC3Da23804b2c9F0E635267ad",
"beacon": "0xF0a5f0f274aAfd2cA649a3B00b1d9FA22BD7d39A",
"factory": "0x6F652864bDe910565beA169B89e133d70e2A9770",
"entryPoint": "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
}
160 changes: 160 additions & 0 deletions scripts/check-dawn-deployment-readiness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/bin/bash

# Dawn Mainnet Pre-Deployment Checklist
# Run this before deploying to ensure everything is ready

set -e

echo "🔍 Dawn Mainnet Pre-Deployment Checklist"
echo "========================================="
echo ""

ISSUES=0

# Check 1: Environment variables
echo "1. Checking environment variables..."
if [ -z "$WALLET_PRIVATE_KEY" ]; then
echo " ❌ WALLET_PRIVATE_KEY not set"
ISSUES=$((ISSUES + 1))
else
echo " ✅ WALLET_PRIVATE_KEY set"
fi

if [ -z "$KEY_REGISTRY_OWNER_PRIVATE_KEY" ]; then
echo " ❌ KEY_REGISTRY_OWNER_PRIVATE_KEY not set"
ISSUES=$((ISSUES + 1))
else
echo " ✅ KEY_REGISTRY_OWNER_PRIVATE_KEY set"
fi
echo ""

# Check 2: Cast CLI installed
echo "2. Checking for cast CLI..."
if command -v cast &> /dev/null; then
echo " ✅ cast installed ($(cast --version | head -n1))"
else
echo " ❌ cast not installed"
echo " Install with: curl -L https://foundry.paradigm.xyz | bash && foundryup"
ISSUES=$((ISSUES + 1))
fi
echo ""

# Check 3: pnpm installed
echo "3. Checking for pnpm..."
if command -v pnpm &> /dev/null; then
echo " ✅ pnpm installed ($(pnpm --version))"
else
echo " ❌ pnpm not installed"
echo " Install with: npm install -g pnpm"
ISSUES=$((ISSUES + 1))
fi
echo ""

# Check 4: Network connectivity
echo "4. Checking Dawn Mainnet connectivity..."
if curl -s -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
https://zksync-os-mainnet-dawn.zksync.io | grep -q "result"; then
echo " ✅ Dawn Mainnet RPC accessible"
else
echo " ❌ Cannot connect to Dawn Mainnet RPC"
ISSUES=$((ISSUES + 1))
fi
echo ""

# Check 5: Deployer balance
if [ ! -z "$WALLET_PRIVATE_KEY" ]; then
echo "5. Checking deployer wallet balance..."
DEPLOYER_ADDRESS=$(cast wallet address --private-key $WALLET_PRIVATE_KEY 2>/dev/null || echo "")

if [ ! -z "$DEPLOYER_ADDRESS" ]; then
echo " 📍 Deployer address: $DEPLOYER_ADDRESS"

BALANCE=$(cast balance $DEPLOYER_ADDRESS --rpc-url https://zksync-os-mainnet-dawn.zksync.io 2>/dev/null || echo "0")
BALANCE_ETH=$(cast --to-unit $BALANCE ether 2>/dev/null || echo "0")

echo " 💰 Balance: $BALANCE_ETH ETH"

# Check if balance is sufficient (at least 0.5 ETH recommended)
BALANCE_GWEI=$(cast --to-unit $BALANCE gwei 2>/dev/null | cut -d. -f1)
if [ "$BALANCE_GWEI" -lt 500000000 ]; then
echo " ⚠️ Low balance. Recommended: at least 1 ETH"
echo " Transfer ETH to: $DEPLOYER_ADDRESS"
ISSUES=$((ISSUES + 1))
else
echo " ✅ Sufficient balance for deployment"
fi
else
echo " ❌ Invalid WALLET_PRIVATE_KEY"
ISSUES=$((ISSUES + 1))
fi
else
echo "5. Skipping balance check (WALLET_PRIVATE_KEY not set)"
fi
echo ""

# Check 6: Key registry owner balance
if [ ! -z "$KEY_REGISTRY_OWNER_PRIVATE_KEY" ]; then
echo "6. Checking key registry owner wallet balance..."
OWNER_ADDRESS=$(cast wallet address --private-key $KEY_REGISTRY_OWNER_PRIVATE_KEY 2>/dev/null || echo "")

if [ ! -z "$OWNER_ADDRESS" ]; then
echo " 📍 Owner address: $OWNER_ADDRESS"

BALANCE=$(cast balance $OWNER_ADDRESS --rpc-url https://zksync-os-mainnet-dawn.zksync.io 2>/dev/null || echo "0")
BALANCE_ETH=$(cast --to-unit $BALANCE ether 2>/dev/null || echo "0")

echo " 💰 Balance: $BALANCE_ETH ETH"

# Check if balance is sufficient (at least 0.01 ETH recommended)
BALANCE_GWEI=$(cast --to-unit $BALANCE gwei 2>/dev/null | cut -d. -f1)
if [ "$BALANCE_GWEI" -lt 10000000 ]; then
echo " ⚠️ Low balance. Recommended: at least 0.1 ETH"
echo " Transfer ETH to: $OWNER_ADDRESS"
ISSUES=$((ISSUES + 1))
else
echo " ✅ Sufficient balance"
fi
else
echo " ❌ Invalid KEY_REGISTRY_OWNER_PRIVATE_KEY"
ISSUES=$((ISSUES + 1))
fi
else
echo "6. Skipping owner balance check (KEY_REGISTRY_OWNER_PRIVATE_KEY not set)"
fi
echo ""

# Check 7: Contracts build
echo "7. Checking if contracts are built..."
if [ -d "packages/contracts/artifacts-zk" ]; then
echo " ✅ Contracts appear to be built"
else
echo " ⚠️ Contracts not built yet"
echo " Run: cd packages/contracts && pnpm build"
fi
echo ""

# Check 8: Dependencies installed
echo "8. Checking if dependencies are installed..."
if [ -d "node_modules" ] && [ -d "packages/contracts/node_modules" ]; then
echo " ✅ Dependencies installed"
else
echo " ⚠️ Dependencies not fully installed"
echo " Run: pnpm install -r"
fi
echo ""

# Summary
echo "========================================="
if [ $ISSUES -eq 0 ]; then
echo "✅ All checks passed! Ready for deployment."
echo ""
echo "To deploy, run:"
echo " ./scripts/deploy-dawn-mainnet.sh"
exit 0
else
echo "❌ Found $ISSUES issue(s). Please fix them before deploying."
echo ""
echo "Need help? See: docs/DAWN_MAINNET_DEPLOYMENT.md"
exit 1
fi
Loading
Loading