|
| 1 | +/** |
| 2 | + * Verification script for Dawn Mainnet deployment |
| 3 | + * Checks that all contracts are deployed correctly and accessible |
| 4 | + */ |
| 5 | + |
| 6 | +import { ethers } from "ethers"; |
| 7 | +import fs from "fs"; |
| 8 | +import path from "path"; |
| 9 | +import { fileURLToPath } from "url"; |
| 10 | +import { Provider, Wallet } from "zksync-ethers"; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | + |
| 15 | +const DAWN_MAINNET_RPC = "https://zksync-os-mainnet-dawn.zksync.io"; |
| 16 | +const DEPLOYMENT_FILE = path.join(__dirname, "../packages/auth-server/stores/dawn-mainnet.json"); |
| 17 | + |
| 18 | +async function main() { |
| 19 | + console.log("🔍 Verifying Dawn Mainnet Deployment...\n"); |
| 20 | + |
| 21 | + // Check if deployment file exists |
| 22 | + if (!fs.existsSync(DEPLOYMENT_FILE)) { |
| 23 | + throw new Error(`Deployment file not found: ${DEPLOYMENT_FILE}`); |
| 24 | + } |
| 25 | + |
| 26 | + const contracts = JSON.parse(fs.readFileSync(DEPLOYMENT_FILE, "utf8")); |
| 27 | + const provider = new Provider(DAWN_MAINNET_RPC); |
| 28 | + |
| 29 | + console.log("📋 Checking deployed contracts:\n"); |
| 30 | + |
| 31 | + const contractNames = { |
| 32 | + factory: "Factory", |
| 33 | + webauthnValidator: "WebAuthn Validator", |
| 34 | + sessionValidator: "Session Validator", |
| 35 | + eoaValidator: "EOA Validator", |
| 36 | + guardianExecutor: "Guardian Executor", |
| 37 | + beacon: "Beacon", |
| 38 | + accountImplementation: "Account Implementation", |
| 39 | + entryPoint: "Entry Point", |
| 40 | + }; |
| 41 | + |
| 42 | + let allValid = true; |
| 43 | + |
| 44 | + for (const [key, name] of Object.entries(contractNames)) { |
| 45 | + const address = contracts[key]; |
| 46 | + if (!address) { |
| 47 | + console.log(`❌ ${name}: NOT DEPLOYED`); |
| 48 | + allValid = false; |
| 49 | + continue; |
| 50 | + } |
| 51 | + |
| 52 | + try { |
| 53 | + const code = await provider.getCode(address); |
| 54 | + if (code === "0x" || code === "0x0") { |
| 55 | + console.log(`❌ ${name}: No code at ${address}`); |
| 56 | + allValid = false; |
| 57 | + } else { |
| 58 | + console.log(`✅ ${name}: ${address}`); |
| 59 | + } |
| 60 | + } catch (error) { |
| 61 | + console.log(`❌ ${name}: Error checking ${address} - ${error.message}`); |
| 62 | + allValid = false; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + console.log("\n📊 Network Information:"); |
| 67 | + const blockNumber = await provider.getBlockNumber(); |
| 68 | + console.log(` Current block: ${blockNumber}`); |
| 69 | + |
| 70 | + if (process.env.WALLET_PRIVATE_KEY) { |
| 71 | + const wallet = new Wallet(process.env.WALLET_PRIVATE_KEY, provider); |
| 72 | + const balance = await wallet.getBalance(); |
| 73 | + console.log(` Deployer balance: ${ethers.formatEther(balance)} ETH`); |
| 74 | + } |
| 75 | + |
| 76 | + // Check paymaster balance if deployed |
| 77 | + if (contracts.accountPaymaster) { |
| 78 | + try { |
| 79 | + const paymasterBalance = await provider.getBalance(contracts.accountPaymaster); |
| 80 | + console.log(` Paymaster balance: ${ethers.formatEther(paymasterBalance)} ETH`); |
| 81 | + |
| 82 | + if (paymasterBalance === 0n) { |
| 83 | + console.log(`\n⚠️ Warning: Paymaster has zero balance. Fund it to enable sponsored transactions.`); |
| 84 | + } |
| 85 | + } catch (error) { |
| 86 | + console.log(` ⚠️ Could not check paymaster balance: ${error.message}`); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + if (!allValid) { |
| 91 | + console.log("\n❌ Deployment verification FAILED"); |
| 92 | + process.exit(1); |
| 93 | + } |
| 94 | + |
| 95 | + console.log("\n✅ Deployment verification PASSED"); |
| 96 | + console.log("\n📝 Next steps:"); |
| 97 | + console.log("1. Add these contract addresses to packages/auth-server/stores/client.ts"); |
| 98 | + console.log("2. If paymaster balance is low, fund it with: pnpm hardhat fund-paymaster --network dawnMainnet"); |
| 99 | + console.log("3. Test account creation and transactions"); |
| 100 | + console.log("4. Deploy bundler service with these contract addresses"); |
| 101 | +} |
| 102 | + |
| 103 | +main() |
| 104 | + .then(() => process.exit(0)) |
| 105 | + .catch((error) => { |
| 106 | + console.error("\n❌ Error:", error.message); |
| 107 | + process.exit(1); |
| 108 | + }); |
0 commit comments