// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Script, console} from "forge-std/Script.sol";
import {TransactionMirror} from "../contracts/mirror/TransactionMirror.sol";

contract DeployTransactionMirror is Script {
    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address deployer = vm.addr(pk);
        // Use MIRROR_ADMIN from .env, or fall back to deployer address
        address admin = vm.envOr("MIRROR_ADMIN", deployer);

        // Optional: skip stuck nonce (e.g. NEXT_NONCE=13370 when 13369 is stuck)
        uint64 nextNonce = uint64(vm.envOr("NEXT_NONCE", uint256(0)));
        if (nextNonce > 0) {
            vm.setNonce(deployer, nextNonce);
        }

        vm.startBroadcast(pk);
        TransactionMirror mirror = new TransactionMirror(admin);
        console.log("TransactionMirror deployed at:", address(mirror));
        console.log("Admin:", admin);
        vm.stopBroadcast();
    }
}

