const hre = require("hardhat"); async function main() { const [admin] = await hre.ethers.getSigners(); const provider = hre.ethers.provider; const userA = hre.ethers.Wallet.createRandom().connect(provider); const fundTx = await admin.sendTransaction({ to: userA.address, value: hre.ethers.parseEther("1"), }); await fundTx.wait(); const AstralAccess = await hre.ethers.getContractFactory("AstralAccess", admin); const contract = await AstralAccess.deploy(); await contract.waitForDeployment(); const loraHash = "Actor_ShahRukh_V1"; const userALabel = "User_A"; await (await contract.grantAccess(userA.address, loraHash, 3600)).wait(); const firstLogTx = await contract .connect(userA) .logGeneration(loraHash, "ipfs://output-shahrukh-v1-001"); await firstLogTx.wait(); console.log(`Step 3 OK: ${userALabel} generation logged before revoke.`); await (await contract.revokeAccess(userA.address, loraHash)).wait(); try { const secondLogTx = await contract .connect(userA) .logGeneration(loraHash, "ipfs://output-shahrukh-v1-002"); await secondLogTx.wait(); console.error("Kill switch failed: post-revoke generation unexpectedly succeeded."); process.exitCode = 1; return; } catch (error) { const message = (error && error.message ? error.message : String(error)).toLowerCase(); if (message.includes("access denied") || message.includes("revert")) { console.log("✅ KILL SWITCH CONFIRMED: Access successfully blocked on-chain."); return; } console.error("Kill switch test failed with unexpected error:"); console.error(error); process.exitCode = 1; } } main().catch((error) => { console.error(error); process.exitCode = 1; });