Skip to content

Commit 5b21171

Browse files
authored
Merge pull request #122 from lista-dao/fix/pre-ipo-audit
chore(dao): add PreIPODistributor impl-only deploy script for BSC
2 parents c32347a + f4db2a6 commit 5b21171

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
pragma solidity ^0.8.10;
2+
3+
import { Script, console } from "forge-std/Script.sol";
4+
import { PreIPODistributor } from "../../../contracts/dao/PreIPODistributor.sol";
5+
6+
/**
7+
* Deploy a new PreIPODistributor implementation on BSC (impl only — no proxy, no upgrade call).
8+
*
9+
* Usage:
10+
* forge script scripts/foundry/dao/deploy_PreIPO_impl.sol:PreIPODistributorImplDeploy \
11+
* --rpc-url bsc --broadcast --verify -vvvv
12+
*
13+
* Requires env: DEPLOYER_BSC_PRIVATE_KEY / DEPLOYER_TESTNET_PRIVATE_KEY, BSCSCAN_API_KEY (--verify).
14+
*/
15+
contract PreIPODistributorImplDeploy is Script {
16+
uint256 constant BSC_MAINNET = 56;
17+
uint256 constant BSC_TESTNET = 97;
18+
19+
function run() public {
20+
uint256 pk = _deployerKey();
21+
address deployer = vm.addr(pk);
22+
console.log("Chain id:", block.chainid);
23+
console.log("Deployer:", deployer);
24+
25+
vm.startBroadcast(pk);
26+
PreIPODistributor impl = new PreIPODistributor();
27+
vm.stopBroadcast();
28+
29+
console.log("PreIPODistributor implementation:", address(impl));
30+
console.log("--- upgrade calldata for the admin multisig (target = the proxy) ---");
31+
console.log("[first settlement upgrade] upgradeToAndCall(impl, initializeV2()):");
32+
console.logBytes(
33+
abi.encodeWithSignature(
34+
"upgradeToAndCall(address,bytes)",
35+
address(impl),
36+
abi.encodeCall(PreIPODistributor.initializeV2, ())
37+
)
38+
);
39+
console.log("[subsequent impl swap] upgradeTo(impl):");
40+
console.logBytes(abi.encodeWithSignature("upgradeTo(address)", address(impl)));
41+
}
42+
43+
function _deployerKey() internal view returns (uint256) {
44+
if (block.chainid == BSC_MAINNET) {
45+
return vm.envUint("DEPLOYER_BSC_PRIVATE_KEY");
46+
} else if (block.chainid == BSC_TESTNET) {
47+
return vm.envUint("DEPLOYER_TESTNET_PRIVATE_KEY");
48+
} else {
49+
revert("Unsupported chain (expected BSC 56 or BSC testnet 97)");
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)