From a18da7dac1f84c7eb91fa69fe5ac83783e6a7c8c Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Sat, 20 Apr 2024 22:09:12 -0500 Subject: [PATCH] let forum, rather than VP, update members list --- ethereum/contracts/core/Forum.sol | 12 ++++++++++++ ethereum/contracts/core/Reputation.sol | 4 ++++ ethereum/contracts/core/ValidationPools.sol | 13 ------------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ethereum/contracts/core/Forum.sol b/ethereum/contracts/core/Forum.sol index ffdbd5d..b0f8d46 100644 --- a/ethereum/contracts/core/Forum.sol +++ b/ethereum/contracts/core/Forum.sol @@ -137,6 +137,14 @@ contract Forum is Reputation { int amount ) internal returns (int refund) { int allocated; + + for (uint i = 0; i < post.authors.length; i++) { + address authorAddress = post.authors[i].authorAddress; + if (!isMember[authorAddress]) { + members[memberCount++] = authorAddress; + isMember[authorAddress] = true; + } + } for (uint i = 0; i < post.authors.length; i++) { Author memory author = post.authors[i]; int share; @@ -149,6 +157,10 @@ contract Forum is Reputation { } if (share > 0) { _update(address(this), author.authorAddress, uint(share)); + if (!isMember[author.authorAddress]) { + members[memberCount++] = author.authorAddress; + isMember[author.authorAddress] = true; + } } else if (balanceOf(author.authorAddress) < uint(-share)) { // Author has already lost some REP gained from this post. // That means other DAO members have earned it for policing. diff --git a/ethereum/contracts/core/Reputation.sol b/ethereum/contracts/core/Reputation.sol index f9eabc4..c17e201 100644 --- a/ethereum/contracts/core/Reputation.sol +++ b/ethereum/contracts/core/Reputation.sol @@ -4,6 +4,10 @@ pragma solidity ^0.8.24; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract Reputation is ERC20("Reputation", "REP") { + mapping(uint => address) public members; + uint public memberCount; + mapping(address => bool) public isMember; + function decimals() public pure override returns (uint8) { return 9; } diff --git a/ethereum/contracts/core/ValidationPools.sol b/ethereum/contracts/core/ValidationPools.sol index 0ca9ae1..3c46b97 100644 --- a/ethereum/contracts/core/ValidationPools.sol +++ b/ethereum/contracts/core/ValidationPools.sol @@ -41,10 +41,6 @@ contract ValidationPools is Reputation, Forum { mapping(uint => ValidationPool) public validationPools; uint public validationPoolCount; - mapping(uint => address) public members; - uint public memberCount; - mapping(address => bool) public isMember; - uint constant minDuration = 1; // 1 second uint constant maxDuration = 365_000_000 days; // 1 million years uint[2] minQuorum = [1, 10]; @@ -196,15 +192,6 @@ contract ValidationPools is Reputation, Forum { votePasses = stakedFor * pool.params.winRatio[1] >= (stakedFor + stakedAgainst) * pool.params.winRatio[0]; - if (votePasses) { - for (uint i = 0; i < post.authors.length; i++) { - address authorAddress = post.authors[i].authorAddress; - if (!isMember[authorAddress]) { - members[memberCount++] = authorAddress; - isMember[authorAddress] = true; - } - } - } pool.resolved = true; pool.outcome = votePasses; emit ValidationPoolResolved(poolIndex, votePasses, true);