move private structs inside bench contract

This commit is contained in:
Ladd Hoffman 2024-06-28 10:46:52 -05:00
parent 282d9478df
commit ed928043ed
1 changed files with 24 additions and 24 deletions

View File

@ -4,13 +4,6 @@ pragma solidity ^0.8.24;
import "./DAO.sol";
import "./Forum.sol";
struct ValidationPoolStake {
uint id;
bool inFavor;
uint amount;
address sender;
}
struct ValidationPoolParams {
uint duration;
uint[2] quorum; // [ Numerator, Denominator ]
@ -28,19 +21,26 @@ struct ValidationPoolProps {
bool outcome;
}
struct ValidationPool {
uint id;
address sender;
mapping(uint => ValidationPoolStake) stakes;
uint stakeCount;
ValidationPoolParams params;
ValidationPoolProps props;
bool callbackOnValidate;
bytes callbackData;
}
contract Bench {
mapping(uint => ValidationPool) public validationPools;
struct Stake {
uint id;
bool inFavor;
uint amount;
address sender;
}
struct Pool {
uint id;
address sender;
mapping(uint => Stake) stakes;
uint stakeCount;
ValidationPoolParams params;
ValidationPoolProps props;
bool callbackOnValidate;
bytes callbackData;
}
mapping(uint => Pool) public validationPools;
uint public validationPoolCount;
DAO dao;
@ -67,14 +67,14 @@ contract Bench {
msg.sender == address(dao),
"Only DAO contract may call stakeOnValidationPool"
);
ValidationPool storage pool = validationPools[poolIndex];
Pool storage pool = validationPools[poolIndex];
require(
block.timestamp <= pool.props.endTime,
"Pool end time has passed"
);
// We don't call _update here; We defer that until evaluateOutcome.
uint stakeIndex = pool.stakeCount++;
ValidationPoolStake storage s = pool.stakes[stakeIndex];
Stake storage s = pool.stakes[stakeIndex];
s.sender = sender;
s.inFavor = inFavor;
s.amount = amount;
@ -107,7 +107,7 @@ contract Bench {
require(winRatio[0] <= winRatio[1], "Win ratio is greater than one");
require(bindingPercent <= 100, "Binding percent must be <= 100");
poolIndex = validationPoolCount++;
ValidationPool storage pool = validationPools[poolIndex];
Pool storage pool = validationPools[poolIndex];
pool.id = poolIndex;
pool.sender = sender;
pool.props.postId = postId;
@ -134,11 +134,11 @@ contract Bench {
msg.sender == address(dao),
"Only DAO contract may call evaluateOutcome"
);
ValidationPool storage pool = validationPools[poolIndex];
Pool storage pool = validationPools[poolIndex];
require(pool.props.resolved == false, "Pool is already resolved");
uint stakedFor;
uint stakedAgainst;
ValidationPoolStake storage s;
Stake storage s;
for (uint i = 0; i < pool.stakeCount; i++) {
s = pool.stakes[i];
// Make sure the sender still has the required balance.