feat: script deterministic V1 demo state
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.35;
|
||||
|
||||
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
|
||||
import {BankV1} from "../src/BankV1.sol";
|
||||
import {MockUSDC} from "../src/MockUSDC.sol";
|
||||
import {DemoScript} from "./lib/DemoScript.sol";
|
||||
|
||||
contract DeployV1 is DemoScript {
|
||||
function run() external returns (address tokenAddress, address proxy, address implementation) {
|
||||
_requireSupportedChain(block.chainid);
|
||||
address sender = vm.envAddress("SCRIPT_SENDER");
|
||||
|
||||
if (block.chainid == ANVIL_CHAIN_ID) {
|
||||
(uint256 ownerKey, address derivedOwner) = _deriveLocalActor(block.chainid, 0);
|
||||
_assertAddress("SCRIPT_SENDER", derivedOwner, sender);
|
||||
vm.startBroadcast(ownerKey);
|
||||
} else {
|
||||
vm.startBroadcast(sender);
|
||||
}
|
||||
|
||||
MockUSDC token = new MockUSDC(sender);
|
||||
proxy =
|
||||
Upgrades.deployUUPSProxy("BankV1.sol:BankV1", abi.encodeCall(BankV1.initialize, (address(token), sender)));
|
||||
vm.stopBroadcast();
|
||||
|
||||
tokenAddress = address(token);
|
||||
implementation = Upgrades.getImplementationAddress(proxy);
|
||||
_requireCode("token", tokenAddress);
|
||||
_requireCode("proxy", proxy);
|
||||
_requireCode("implementation", implementation);
|
||||
_assertAddress("owner", sender, BankV1(proxy).owner());
|
||||
_assertAddress("asset", tokenAddress, address(BankV1(proxy).asset()));
|
||||
_assertUint("version", 1, BankV1(proxy).contractVersion());
|
||||
_assertAddress("implementation", implementation, Upgrades.getImplementationAddress(proxy));
|
||||
|
||||
Manifest memory manifest;
|
||||
manifest.schemaVersion = 1;
|
||||
manifest.network = block.chainid == ANVIL_CHAIN_ID ? "anvil" : "base-sepolia";
|
||||
manifest.chainId = block.chainid;
|
||||
manifest.deploymentBlock = 0;
|
||||
manifest.rpcUrl = block.chainid == ANVIL_CHAIN_ID ? "http://127.0.0.1:8545" : "https://sepolia.base.org";
|
||||
manifest.explorerUrl = block.chainid == ANVIL_CHAIN_ID ? "" : "https://sepolia.basescan.org";
|
||||
manifest.token = tokenAddress;
|
||||
manifest.proxy = proxy;
|
||||
manifest.implementation = implementation;
|
||||
manifest.owner = sender;
|
||||
(manifest.actorLabels, manifest.actors) = _actors(sender);
|
||||
|
||||
_writeManifest(_manifestPath(PENDING_MANIFEST_PATH), manifest);
|
||||
}
|
||||
|
||||
function _actors(address sender) private returns (string[] memory labels, address[] memory actors) {
|
||||
if (block.chainid == ANVIL_CHAIN_ID) {
|
||||
labels = new string[](3);
|
||||
actors = new address[](3);
|
||||
labels[0] = "owner";
|
||||
labels[1] = "Alice";
|
||||
labels[2] = "Bob";
|
||||
actors[0] = sender;
|
||||
(, actors[1]) = _deriveLocalActor(block.chainid, 1);
|
||||
(, actors[2]) = _deriveLocalActor(block.chainid, 2);
|
||||
} else {
|
||||
labels = new string[](1);
|
||||
actors = new address[](1);
|
||||
labels[0] = "owner";
|
||||
actors[0] = sender;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user