feat: demonstrate state-preserving V2 upgrade

This commit is contained in:
golem
2026-08-21 15:31:40 -06:00
parent ca6a99b913
commit 94f2ad6e09
16 changed files with 1082 additions and 36 deletions
+32
View File
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.35;
import {BankV2} from "../../src/BankV2.sol";
import {MockUSDC} from "../../src/MockUSDC.sol";
import {BankHandler} from "./BankHandler.sol";
contract BankV2Handler is BankHandler {
BankV2 internal immutable bankV2;
uint256 public ghostTransferred;
constructor(MockUSDC token_, BankV2 bank_) BankHandler(token_, bank_) {
bankV2 = bank_;
}
function transfer(uint256 fromSeed, uint256 toSeed, uint256 amount) external {
uint256 count = actorCount();
uint256 fromIndex = fromSeed % count;
address from = actorAt(fromIndex);
uint256 balance = bankV2.balanceOf(from);
if (balance == 0) return;
uint256 toIndex = (fromIndex + 1 + (toSeed % (count - 1))) % count;
address to = actorAt(toIndex);
amount = bound(amount, 1, balance);
vm.prank(from);
bankV2.transferBalance(to, amount);
ghostTransferred += amount;
}
}