Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): add DeployTaikoToken script #16771

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 26 additions & 29 deletions packages/protocol/script/DeployOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,43 +168,40 @@ contract DeployOnL1 is DeployCapability {
internal
returns (address sharedAddressManager, address timelock, address governor)
{
sharedAddressManager = vm.envAddress("SHARED_ADDRESS_MANAGER");
if (sharedAddressManager != address(0)) {
return (
sharedAddressManager,
vm.envAddress("TIMELOCK_CONTROLLER"),
vm.envAddress("TAIKO_GOVERNOR")
);
}

// Deploy the timelock
timelock = deployProxy({
name: "timelock_controller",
impl: address(new TaikoTimelockController()),
data: abi.encodeCall(TaikoTimelockController.init, (address(0), 7 days))
});

sharedAddressManager = deployProxy({
name: "shared_address_manager",
impl: address(new AddressManager()),
data: abi.encodeCall(AddressManager.init, (address(0)))
});
sharedAddressManager = vm.envAddress("SHARED_ADDRESS_MANAGER");
if (sharedAddressManager == address(0)) {
sharedAddressManager = deployProxy({
name: "shared_address_manager",
impl: address(new AddressManager()),
data: abi.encodeCall(AddressManager.init, (address(0)))
});
}

address taikoToken = deployProxy({
name: "taiko_token",
impl: address(new TaikoToken()),
data: abi.encodeCall(
TaikoToken.init,
(
timelock,
vm.envString("TAIKO_TOKEN_NAME"),
vm.envString("TAIKO_TOKEN_SYMBOL"),
vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT"),
address(sharedAddressManager)
)
),
registerTo: sharedAddressManager
});
address taikoToken = vm.envAddress("TAIKO_TOKEN");
if (taikoToken == address(0)) {
taikoToken = deployProxy({
name: "taiko_token",
impl: address(new TaikoToken()),
data: abi.encodeCall(
TaikoToken.init,
(
timelock,
vm.envString("TAIKO_TOKEN_NAME"),
vm.envString("TAIKO_TOKEN_SYMBOL"),
vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT"),
address(sharedAddressManager)
)
),
registerTo: sharedAddressManager
});
}

governor = deployProxy({
name: "taiko_governor",
Expand Down
47 changes: 47 additions & 0 deletions packages/protocol/script/DeployTaikoToken.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "../test/DeployCapability.sol";
import "../contracts/L1/TaikoToken.sol";

contract DeployTaikoToken is DeployCapability {
uint256 public privateKey = vm.envUint("PRIVATE_KEY");
// MAINNET_SECURITY_COUNCIL: council.taiko.eth (0x7C50d60743D3FCe5a39FdbF687AFbAe5acFF49Fd)
address public securityCouncil = vm.envAddress("SECURITY_COUNCIL");
string public tokenName = vm.envString("TAIKO_TOKEN_NAME");
string public tokenSymbol = vm.envString("TAIKO_TOKEN_SYMBOL");
address public premintRecipient = vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT");

modifier broadcast() {
require(privateKey != 0, "invalid private key");
vm.startBroadcast();
_;
vm.stopBroadcast();
}

function run() external broadcast {
// Deploy the shared address manager at first.
address sharedAddressManager = deployProxy({
name: "shared_address_manager",
impl: address(new AddressManager()),
data: abi.encodeCall(AddressManager.init, (address(0)))
});

// Deploy the TaikoToken contract, use securityCouncil address as the owner.
deployProxy({
name: "taiko_token",
impl: address(new TaikoToken()),
data: abi.encodeCall(
TaikoToken.init,
(
securityCouncil,
tokenName,
tokenSymbol,
premintRecipient,
address(sharedAddressManager)
)
),
registerTo: sharedAddressManager
});
}
}
14 changes: 14 additions & 0 deletions packages/protocol/script/test_deploy_on_l1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e

export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
PROPOSER=0x0000000000000000000000000000000000000000 \
TAIKO_TOKEN=0x0000000000000000000000000000000000000000 \
PROPOSER_ONE=0x0000000000000000000000000000000000000000 \
GUARDIAN_PROVERS="0x1000777700000000000000000000000000000001,0x1000777700000000000000000000000000000002,0x1000777700000000000000000000000000000003,0x1000777700000000000000000000000000000004,0x1000777700000000000000000000000000000005" \
MIN_GUARDIANS=3 \
Expand All @@ -24,3 +25,16 @@ forge script script/DeployOnL1.s.sol:DeployOnL1 \
-vvvv \
--private-key $PRIVATE_KEY \
--block-gas-limit 100000000

export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
SECURITY_COUNCIL=0x60997970C51812dc3A010C7d01b50e0d17dc79C8 \
TAIKO_TOKEN_PREMINT_RECIPIENT=0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 \
TAIKO_TOKEN_NAME="Taiko Token" \
TAIKO_TOKEN_SYMBOL=TTKO \
forge script script/DeployTaikoToken.s.sol:DeployTaikoToken \
--fork-url http://localhost:8545 \
--broadcast \
--ffi \
-vvvv \
--private-key $PRIVATE_KEY \
--block-gas-limit 100000000
Loading