Skip to content

Commit

Permalink
chore(script): merge from release/v0.3.5 (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 authored Jun 25, 2024
2 parents d341561 + 6b385d8 commit ec4fdf6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ contract Migration__20240624_MigrateAuctionAndControllerTreasuryAndDeployRNSComm
address private _defaultAdmin;

function run() public {
_controller = RONRegistrarController(loadContract(Contract.RONRegistrarController.key()));
_auction = RNSAuction(loadContract(Contract.RNSAuction.key()));
_controller = RONRegistrarController(_upgradeProxy(Contract.RONRegistrarController.key()));

_rnsCommission = new RNSCommissionDeploy().run();
_defaultAdmin = 0x968D0Cd7343f711216817E617d3f92a23dC91c07;
Expand Down
8 changes: 6 additions & 2 deletions src/RNSCommission.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ contract RNSCommission is Initializable, AccessControlEnumerable, INSCommission
/// @dev Role for accounts that can send RON for this contract.
bytes32 public constant SENDER_ROLE = keccak256("SENDER_ROLE");

/// @dev Gap for upgradability.
/// @dev Gap for upgradeability.
uint256[50] private ____gap;
/// @dev Array of `Commission` structs that store commissions infomation.
/// @dev Array of `Commission` structs that store commissions information.
Commission[] internal _commissionInfos;

constructor() {
Expand Down Expand Up @@ -55,6 +55,8 @@ contract RNSCommission is Initializable, AccessControlEnumerable, INSCommission
onlyRole(DEFAULT_ADMIN_ROLE)
{
if (commissionIdx >= _commissionInfos.length) revert InvalidArrayLength();
// TODO: should fix to not duplicate logic in set commision info
if (newRecipient == address(0)) revert NullAddress();

_commissionInfos[commissionIdx].recipient = newRecipient;
_commissionInfos[commissionIdx].name = newName;
Expand Down Expand Up @@ -98,6 +100,8 @@ contract RNSCommission is Initializable, AccessControlEnumerable, INSCommission
uint256 sum;

for (uint256 i; i < length; ++i) {
if (commissionInfos[i].recipient == address(0)) revert NullAddress();

sum += commissionInfos[i].ratio;
_commissionInfos.push(commissionInfos[i]);
}
Expand Down
6 changes: 4 additions & 2 deletions src/interfaces/INSCommission.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface INSCommission {
event CommissionInfoUpdated(
address indexed updatedBy, uint256 indexed commissionIdx, address payable newRecipient, string newName
);
/// @dev Emiited when transfer RON to commission's recipient.
/// @dev Emitted when transfer RON to commission's recipient.
event Distributed(address indexed recipient, uint256 commissionAmount);

/// @dev Revert when index is out of range
Expand All @@ -23,6 +23,8 @@ interface INSCommission {
error InvalidRatio();
/// @dev Revert when amount of RON is invalid
error InvalidAmountOfRON();
/// @dev Revert when recipient address is null
error NullAddress();

/**
* @dev Maximum commission percentage.
Expand All @@ -35,7 +37,7 @@ interface INSCommission {
function SENDER_ROLE() external pure returns (bytes32);

/**
* @dev Returns comissions information.
* @dev Returns commissions information.
*/
function getCommissions() external view returns (Commission[] memory commissionInfos);

Expand Down

0 comments on commit ec4fdf6

Please sign in to comment.