Skip to content

Commit

Permalink
feat(protocol): add UpgradeTierProvider script (#16017)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Feb 23, 2024
1 parent e1f21c1 commit a01da46
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions packages/protocol/script/upgrade/UpgradeTierProvider.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/
//
// Email: [email protected]
// Website: https://taiko.xyz
// GitHub: https://github.com/taikoxyz
// Discord: https://discord.gg/taikoxyz
// Twitter: https://twitter.com/taikoxyz
// Blog: https://mirror.xyz/labs.taiko.eth
// Youtube: https://www.youtube.com/@taikoxyz

pragma solidity 0.8.24;

import "../../test/DeployCapability.sol";
import "../../contracts/L1/gov/TaikoTimelockController.sol";
import "../../contracts/L1/tiers/ITierProvider.sol";
import "../../contracts/L1/tiers/TaikoA6TierProvider.sol";

contract UpgradeTierProvider is DeployCapability {
uint256 public privateKey = vm.envUint("PRIVATE_KEY");
address public timelockAddress = vm.envAddress("TIMELOCK_ADDRESS");
address public addressManagerAddress = vm.envAddress("ADDRESS_MANAGER_ADDRESS");

function run() external {
vm.startBroadcast(privateKey);

ITierProvider newTierProvider = new TaikoA6TierProvider();

registerByTimelock(
addressManagerAddress, "tier_provider", address(newTierProvider), uint64(block.chainid)
);

vm.stopBroadcast();
}

function registerByTimelock(
address registerTo,
string memory name,
address addr,
uint64 chainId
)
internal
{
bytes32 salt = bytes32(block.timestamp);

bytes memory payload =
abi.encodeCall(AddressManager.setAddress, (chainId, bytes32(bytes(name)), addr));

TaikoTimelockController timelock = TaikoTimelockController(payable(timelockAddress));

timelock.schedule(registerTo, 0, payload, bytes32(0), salt, 0);

timelock.execute(registerTo, 0, payload, bytes32(0), salt);

console2.log("> ", name, "@", registerTo);
console2.log("\t addr : ", addr);
}
}

0 comments on commit a01da46

Please sign in to comment.