46 lines
1.6 KiB
Solidity
46 lines
1.6 KiB
Solidity
// 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);
|
|
}
|
|
}
|