Skip to content

Commit

Permalink
fix: fix the collector and add the missing tests
Browse files Browse the repository at this point in the history
Fix the collector updateRemainderAddress
Include the missing test for the stakeForAddress method
  • Loading branch information
antomor committed Nov 30, 2022
1 parent 9d8bd23 commit 867c2d4
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 291 deletions.
26 changes: 16 additions & 10 deletions contracts/Collector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ contract Collector is ICollector {
uint256 balance = token.balanceOf(address(this));
address tokenAddr = address(token);

if(balance != 0) {
if (balance != 0) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory ret ) = tokenAddr.call{gas: 200000}(abi.encodeWithSelector(
hex"a9059cbb",
remainderAddress,
balance));
(bool success, bytes memory ret) = tokenAddr.call{gas: 200000}(
abi.encodeWithSelector(
hex"a9059cbb",
_remainderAddress,
balance
)
);

require(
success && (ret.length == 0 || abi.decode(ret, (bool))),
Expand All @@ -98,12 +101,15 @@ contract Collector is ICollector {

address tokenAddr = address(token);

for(uint256 i = 0; i < partners.length; i++){
for (uint256 i = 0; i < _partners.length; i++) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory ret ) = tokenAddr.call(abi.encodeWithSelector(
hex"a9059cbb",
partners[i].beneficiary,
SafeMath.div(SafeMath.mul(balance, partners[i].share), 100)));
(bool success, bytes memory ret) = tokenAddr.call(
abi.encodeWithSelector(
hex"a9059cbb",
_partners[i].beneficiary,
SafeMath.div(SafeMath.mul(balance, _partners[i].share), 100)
)
);

require(
success && (ret.length == 0 || abi.decode(ret, (bool))),
Expand Down
Loading

0 comments on commit 867c2d4

Please sign in to comment.