Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aliarbak committed Oct 10, 2024
1 parent 9d2292f commit f6b67a6
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions contracts/compliance/modular/modules/TimeTransfersLimitsModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,6 @@ contract TimeTransfersLimitsModule is AbstractModuleUpgradeable {
__AbstractModule_init();
}

/**
* @dev Sets the limit of tokens allowed to be transferred in the given time frame.
* @param _limit The limit time and value
* Only the owner of the Compliance smart contract can call this function
*/
function setTimeTransferLimit(Limit calldata _limit) public onlyComplianceCall {
bool limitIsAttributed = limitValues[msg.sender][_limit.limitTime].attributedLimit;
uint8 limitCount = uint8(transferLimits[msg.sender].length);
if (!limitIsAttributed && limitCount >= 4) {
revert LimitsArraySizeExceeded(msg.sender, limitCount);
}
if (!limitIsAttributed && limitCount < 4) {
transferLimits[msg.sender].push(_limit);
limitValues[msg.sender][_limit.limitTime] = IndexLimit(true, limitCount);
} else {
transferLimits[msg.sender][limitValues[msg.sender][_limit.limitTime].limitIndex] = _limit;
}

emit TimeTransferLimitUpdated(msg.sender, _limit.limitTime, _limit.limitValue);
}

/**
* @dev Sets multiple limit of tokens allowed to be transferred in the given time frame.
* @param _limits The array of limit time and values
Expand All @@ -154,35 +133,6 @@ contract TimeTransfersLimitsModule is AbstractModuleUpgradeable {
}
}

/**
* @dev Removes the limit for the given limit time value.
* @param _limitTime The limit time
* Only the owner of the Compliance smart contract can call this function
*/
function removeTimeTransferLimit(uint32 _limitTime) public onlyComplianceCall {
bool limitFound = false;
uint256 index;
for (uint256 i = 0; i < transferLimits[msg.sender].length; i++) {
if (transferLimits[msg.sender][i].limitTime == _limitTime) {
limitFound = true;
index = i;
break;
}
}

if (!limitFound) {
revert LimitTimeNotFound(msg.sender, _limitTime);
}

if (transferLimits[msg.sender].length > 1 && index != transferLimits[msg.sender].length - 1) {
transferLimits[msg.sender][index] = transferLimits[msg.sender][transferLimits[msg.sender].length - 1];
}

transferLimits[msg.sender].pop();
delete limitValues[msg.sender][_limitTime];
emit TimeTransferLimitRemoved(msg.sender, _limitTime);
}

/**
* @dev Removes multiple limits for the given limit time values.
* @param _limitTimes The array of limit times
Expand Down Expand Up @@ -269,6 +219,56 @@ contract TimeTransfersLimitsModule is AbstractModuleUpgradeable {
return true;
}

/**
* @dev Sets the limit of tokens allowed to be transferred in the given time frame.
* @param _limit The limit time and value
* Only the owner of the Compliance smart contract can call this function
*/
function setTimeTransferLimit(Limit calldata _limit) public onlyComplianceCall {
bool limitIsAttributed = limitValues[msg.sender][_limit.limitTime].attributedLimit;
uint8 limitCount = uint8(transferLimits[msg.sender].length);
if (!limitIsAttributed && limitCount >= 4) {
revert LimitsArraySizeExceeded(msg.sender, limitCount);
}
if (!limitIsAttributed && limitCount < 4) {
transferLimits[msg.sender].push(_limit);
limitValues[msg.sender][_limit.limitTime] = IndexLimit(true, limitCount);
} else {
transferLimits[msg.sender][limitValues[msg.sender][_limit.limitTime].limitIndex] = _limit;
}

emit TimeTransferLimitUpdated(msg.sender, _limit.limitTime, _limit.limitValue);
}

/**
* @dev Removes the limit for the given limit time value.
* @param _limitTime The limit time
* Only the owner of the Compliance smart contract can call this function
*/
function removeTimeTransferLimit(uint32 _limitTime) public onlyComplianceCall {
bool limitFound = false;
uint256 index;
for (uint256 i = 0; i < transferLimits[msg.sender].length; i++) {
if (transferLimits[msg.sender][i].limitTime == _limitTime) {
limitFound = true;
index = i;
break;
}
}

if (!limitFound) {
revert LimitTimeNotFound(msg.sender, _limitTime);
}

if (transferLimits[msg.sender].length > 1 && index != transferLimits[msg.sender].length - 1) {
transferLimits[msg.sender][index] = transferLimits[msg.sender][transferLimits[msg.sender].length - 1];
}

transferLimits[msg.sender].pop();
delete limitValues[msg.sender][_limitTime];
emit TimeTransferLimitRemoved(msg.sender, _limitTime);
}

/**
* @dev See {IModule-name}.
*/
Expand Down

0 comments on commit f6b67a6

Please sign in to comment.