Skip to content

Commit

Permalink
feat(script): connect V2 as ctrl for V1 frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
KristenPire committed Apr 2, 2024
1 parent 187561a commit 26ad540
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions script/connectV2toV1.s.sol
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 26ad540

Please sign in to comment.