diff --git a/script/DeployRiseTestnet.s.sol b/script/DeployRiseTestnet.s.sol new file mode 100644 index 0000000..5601654 --- /dev/null +++ b/script/DeployRiseTestnet.s.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import {Script} from "forge-std/Script.sol"; +import {console2} from "forge-std/console2.sol"; +import {Delveworn} from "../src/Delveworn.sol"; +import {LegacyVRFAdapter} from "../src/adapters/LegacyVRFAdapter.sol"; + +/// @notice Deploys Delveworn on RISE Testnet behind the compatibility VRF adapter. +/// @dev RISE_VRF_COORDINATOR must point to the existing RISE VRF-style coordinator/provider contract. +contract DeployRiseTestnet is Script { + function run() external returns (LegacyVRFAdapter adapter, Delveworn dungeon) { + address upstreamCoordinator = vm.envAddress("RISE_VRF_COORDINATOR"); + require(upstreamCoordinator != address(0), "Invalid RISE VRF coordinator"); + + vm.startBroadcast(); + + adapter = new LegacyVRFAdapter(upstreamCoordinator); + dungeon = new Delveworn(address(adapter)); + + vm.stopBroadcast(); + + console2.log("RISE upstream VRF coordinator:", upstreamCoordinator); + console2.log("LegacyVRFAdapter:", address(adapter)); + console2.log("Delveworn:", address(dungeon)); + } +} diff --git a/scripts/deploy-rise-testnet.sh b/scripts/deploy-rise-testnet.sh new file mode 100644 index 0000000..f7fc7b0 --- /dev/null +++ b/scripts/deploy-rise-testnet.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euo pipefail + +RPC_URL="${RISE_RPC_URL:-https://testnet.riselabs.xyz}" +CURRENT_DUNGEON="${RISE_EXISTING_DUNGEON_ADDRESS:-}" + +if [[ -z "$CURRENT_DUNGEON" && -f ../frontend/.env.local ]]; then + CURRENT_DUNGEON="$(sed -n 's/^NEXT_PUBLIC_DUNGEON_ADDRESS=//p' ../frontend/.env.local | tail -n 1 | tr -d "'\"[:space:]")" +fi + +if [[ -z "$CURRENT_DUNGEON" ]]; then + cat >&2 <<'EOF' +Could not determine the existing RISE dungeon address. +Set RISE_EXISTING_DUNGEON_ADDRESS or keep NEXT_PUBLIC_DUNGEON_ADDRESS in ../frontend/.env.local. +EOF + exit 1 +fi + +CURRENT_DUNGEON="$(cast to-check-sum-address "$CURRENT_DUNGEON")" + +echo "Existing RISE dungeon: $CURRENT_DUNGEON" +echo "Reading its coordinator from $RPC_URL ..." + +RISE_VRF_COORDINATOR="$(cast call "$CURRENT_DUNGEON" 'coordinator()(address)' --rpc-url "$RPC_URL")" +RISE_VRF_COORDINATOR="$(cast to-check-sum-address "$RISE_VRF_COORDINATOR")" +export RISE_VRF_COORDINATOR + +echo "RISE VRF coordinator: $RISE_VRF_COORDINATOR" +echo "Deploying fresh LegacyVRFAdapter + Delveworn V2 ..." + +forge script script/DeployRiseTestnet.s.sol:DeployRiseTestnet \ + --rpc-url "$RPC_URL" \ + --broadcast \ + "$@" + +cat <<'EOF' + +Deployment broadcast completed. +Use the Delveworn address printed above as NEXT_PUBLIC_DUNGEON_ADDRESS in the frontend/Vercel deployment, then redeploy the frontend. +EOF