-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(script): connect V2 as ctrl for V1 frontend
- Loading branch information
1 parent
187561a
commit 26ad540
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
|