feat: script deterministic V1 demo state

This commit is contained in:
golem
2026-08-21 02:17:18 -06:00
parent 6dcbb03f3c
commit 52935acf5e
10 changed files with 1010 additions and 1 deletions
+45
View File
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.35;
import {BankV1} from "../src/BankV1.sol";
import {MockUSDC} from "../src/MockUSDC.sol";
import {DemoScript} from "./lib/DemoScript.sol";
contract SeedV1Demo is DemoScript {
function run() external {
if (block.chainid != ANVIL_CHAIN_ID) revert UnsupportedChain(block.chainid);
Manifest memory manifest = _readManifest(_manifestPath(ACTIVE_MANIFEST_PATH), true);
if (manifest.actors.length != 3 || manifest.actorLabels.length != 3) revert InvalidManifestSchema(1);
(uint256 ownerKey, address owner) = _deriveLocalActor(block.chainid, 0);
(uint256 aliceKey, address alice) = _deriveLocalActor(block.chainid, 1);
(uint256 bobKey, address bob) = _deriveLocalActor(block.chainid, 2);
_assertAddress("owner actor", manifest.owner, owner);
_assertAddress("Alice actor", manifest.actors[1], alice);
_assertAddress("Bob actor", manifest.actors[2], bob);
MockUSDC token = MockUSDC(manifest.token);
BankV1 bank = BankV1(manifest.proxy);
vm.startBroadcast(ownerKey);
token.mint(alice, 2_000e6);
token.mint(bob, 1_000e6);
vm.stopBroadcast();
vm.startBroadcast(aliceKey);
token.approve(manifest.proxy, 1_000e6);
bank.deposit(1_000e6);
vm.stopBroadcast();
vm.startBroadcast(bobKey);
token.approve(manifest.proxy, 500e6);
bank.deposit(500e6);
vm.stopBroadcast();
vm.startBroadcast(aliceKey);
bank.withdraw(100e6);
vm.stopBroadcast();
_assertV1State(manifest);
}
}