// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {Script, console} from "forge-std/Script.sol"; import {UniversalAssetRegistry} from "../../contracts/registry/UniversalAssetRegistry.sol"; /** * @title UpgradeUniversalAssetRegistry * @notice Deploy a new UniversalAssetRegistry implementation and upgrade the proxy to it. * @dev Caller must have UPGRADER_ROLE on the proxy. Env: UNIVERSAL_ASSET_REGISTRY (proxy address), PRIVATE_KEY. * Use when the current implementation does not expose registerGRUCompliantAsset (e.g. older deployment). */ contract UpgradeUniversalAssetRegistry is Script { function run() external { address proxyAddr = vm.envAddress("UNIVERSAL_ASSET_REGISTRY"); uint256 pk = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(pk); UniversalAssetRegistry newImpl = new UniversalAssetRegistry(); console.log("New implementation deployed at:", address(newImpl)); UniversalAssetRegistry proxy = UniversalAssetRegistry(proxyAddr); proxy.upgradeToAndCall(address(newImpl), ""); console.log("Proxy", proxyAddr, "upgraded to", address(newImpl)); vm.stopBroadcast(); } }