@@ -131,25 +131,26 @@ contract ColonyFunding is
131
131
132
132
fundingPots[0 ].balance[_token] += feeToPay;
133
133
134
- if (tokenEarnsReputationOnPayout (_token)) {
135
- // If token earns reputation, we only allow up to the approved amount to be received
136
- uint256 approvedAmount = domainReputationTokenApprovals[_domainId][_token];
137
- if (approvedAmount < remainder) {
138
- fundingPots[fundingPotId].balance[_token] += approvedAmount;
139
- Domain storage rootDomain = domains[1 ];
140
- // And the rest goes to the root pot
141
- fundingPots[rootDomain.fundingPotId].balance[_token] += remainder - approvedAmount;
142
- domainReputationTokenApprovals[_domainId][_token] = 0 ;
143
- emit DomainFundsClaimed (msgSender (), _token, _domainId, feeToPay, approvedAmount);
144
- emit ColonyFundsClaimed (msgSender (), _token, 0 , remainder - approvedAmount);
145
- } else {
146
- fundingPots[fundingPotId].balance[_token] += remainder;
134
+ uint256 approvedAmount = domainReputationTokenApprovals[_domainId][_token];
135
+ if (! tokenEarnsReputationOnPayout (_token) || approvedAmount >= remainder) {
136
+ // Either the token doesn't earn reputation or there is enough approval
137
+ // Either way, the domain gets all the funds
138
+ fundingPots[fundingPotId].balance[_token] += remainder;
139
+ if (tokenEarnsReputationOnPayout (_token)) {
140
+ // If it does earn reputation, deduct the approved amount
147
141
domainReputationTokenApprovals[_domainId][_token] -= remainder;
148
- emit DomainFundsClaimed (msgSender (), _token, _domainId, feeToPay, remainder);
149
142
}
150
- } else {
151
- fundingPots[fundingPotId].balance[_token] += remainder;
152
143
emit DomainFundsClaimed (msgSender (), _token, _domainId, feeToPay, remainder);
144
+ } else {
145
+ // The token earns reputation and there is not enough approvalable
146
+ // The domain gets what was approved
147
+ fundingPots[fundingPotId].balance[_token] += approvedAmount;
148
+ // And the rest goes to the root pot
149
+ Domain storage rootDomain = domains[1 ];
150
+ fundingPots[rootDomain.fundingPotId].balance[_token] += remainder - approvedAmount;
151
+ domainReputationTokenApprovals[_domainId][_token] = 0 ;
152
+ emit DomainFundsClaimed (msgSender (), _token, _domainId, feeToPay, approvedAmount);
153
+ emit ColonyFundsClaimed (msgSender (), _token, 0 , remainder - approvedAmount);
153
154
}
154
155
155
156
// Claim funds
0 commit comments