From 26ad540a55843854b4af2423c9b0a4bedb0d78e3 Mon Sep 17 00:00:00 2001 From: Kristen Pire Date: Tue, 2 Apr 2024 11:23:07 +0200 Subject: [PATCH] feat(script): connect V2 as ctrl for V1 frontend --- script/connectV2toV1.s.sol | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 script/connectV2toV1.s.sol diff --git a/script/connectV2toV1.s.sol b/script/connectV2toV1.s.sol new file mode 100644 index 0000000..f357e95 --- /dev/null +++ b/script/connectV2toV1.s.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: APACHE-2.0 +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "../src/Token.sol"; +import "../src/TokenFrontend.sol"; +import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; + +contract All is Script { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + address tokenAddress = vm.envAddress("TOKEN_ADDRESS"); + address frontend = vm.envAddress("FRONTEND_ADDRESS"); + address owner = vm.envAddress("OWNER_ADDRESS"); + vm.startBroadcast(deployerPrivateKey); + console.log("Configuring with Token:"); + + // Assuming Token and SmartController are already deployed and their ABIs are known + Token token = Token(tokenAddress); + TokenFrontend frontend = TokenFrontend(frontendAddress); + + // Claiming ownership of Token and SmartController + if (token.pendingOwner() == address(this)) { + token.claimOwnership(); + } + frontend.claimOwnership(); + + // Connecting Token proxy as a controller. + token.setFrontend(frontendAddress); + frontend.setController(tokenAddress); + + // Transfer ownership of Token and TokenFrontend to the new owner + frontend.transferOwnership(owner); + token.transferOwnership(owner); + + vm.stopBroadcast(); + } +} +