Skip to content

Commit

Permalink
Set up storage for direct domain funding in anticipation of proxy col…
Browse files Browse the repository at this point in the history
…onies
  • Loading branch information
area committed Oct 21, 2024
1 parent 21bd7bc commit bea8896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions contracts/colony/ColonyFunding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ contract ColonyFunding is

fundingPots[0].balance[_token] += feeToPay;

uint256 approvedAmount = domainReputationTokenApprovals[_domainId][_token];
uint256 approvedAmount = domainReputationTokenApprovals[block.chainid][_domainId][_token];
if (!tokenEarnsReputationOnPayout(_token) || approvedAmount >= remainder) {
// Either the token doesn't earn reputation or there is enough approval
// Either way, the domain gets all the funds
fundingPots[fundingPotId].balance[_token] += remainder;
if (tokenEarnsReputationOnPayout(_token)) {
// If it does earn reputation, deduct the approved amount
domainReputationTokenApprovals[_domainId][_token] -= remainder;
domainReputationTokenApprovals[block.chainid][_domainId][_token] -= remainder;
}
emit DomainFundsClaimed(msgSender(), _token, _domainId, feeToPay, remainder);
} else {
Expand All @@ -148,7 +148,7 @@ contract ColonyFunding is
// And the rest goes to the root pot
Domain storage rootDomain = domains[1];
fundingPots[rootDomain.fundingPotId].balance[_token] += remainder - approvedAmount;
domainReputationTokenApprovals[_domainId][_token] = 0;
domainReputationTokenApprovals[block.chainid][_domainId][_token] = 0;
emit DomainFundsClaimed(msgSender(), _token, _domainId, feeToPay, approvedAmount);
emit ColonyFundsClaimed(msgSender(), _token, 0, remainder - approvedAmount);
}
Expand All @@ -172,17 +172,17 @@ contract ColonyFunding is
require(tokenEarnsReputationOnPayout(_token), "colony-funding-token-does-not-earn-reputation");
require(_domainId > 1, "colony-funding-root-domain");
if (_add) {
domainReputationTokenApprovals[_domainId][_token] += _amount;
domainReputationTokenApprovals[block.chainid][_domainId][_token] += _amount;
} else {
domainReputationTokenApprovals[_domainId][_token] -= _amount;
domainReputationTokenApprovals[block.chainid][_domainId][_token] -= _amount;
}
}

function getAllowedDomainTokenReceipt(
uint256 _domainId,
address _token
) public view returns (uint256) {
return domainReputationTokenApprovals[_domainId][_token];
return domainReputationTokenApprovals[block.chainid][_domainId][_token];
}

function getNonRewardPotsTotal(address _token) public view returns (uint256) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/colony/ColonyStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ contract ColonyStorage is ColonyDataTypes, ColonyNetworkDataTypes, DSMath, Commo
mapping(uint256 => bool) DEPRECATED_localSkills; // Storage slot 37
mapping(uint256 => LocalSkill) localSkills; // Storage slot 38

// Mapping of domain id => token address => approval to receive if reputation-earning
mapping(uint256 => mapping(address => uint256)) domainReputationTokenApprovals; // Storage slot 39
// Mapping of domain id => chainid => token address => approval to receive if reputation-earning
mapping(uint256 => mapping(uint256 => mapping(address => uint256))) domainReputationTokenApprovals; // Storage slot 39

// Constants

Expand Down

0 comments on commit bea8896

Please sign in to comment.