Skip to content

Commit

Permalink
feat: add overrider role to set & override name price, renewal fee (#101
Browse files Browse the repository at this point in the history
)
  • Loading branch information
TuDo1403 authored Oct 24, 2023
2 parents f1d8a86 + 422f5e5 commit 35340bf
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
17 changes: 17 additions & 0 deletions script/20231024-upgrade-domain-price/20231024_Config.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { Network, RNSDeploy } from "script/RNSDeploy.s.sol";

abstract contract Config__20231024 is RNSDeploy {
function _buildMigrationConfig() internal view virtual override returns (Config memory config) {
config = super._buildMigrationConfig();
if (_network == Network.RoninTestnet) {
config.overrider = config.operator;
} else if (_network == Network.RoninMainnet) {
revert("Missing config");
} else {
revert("Missing config");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { console2 } from "forge-std/console2.sol";
import { ContractKey } from "foundry-deployment-kit/configs/ContractConfig.sol";
import { RNSDomainPrice } from "@rns-contracts/RNSDomainPrice.sol";
import { Config__20231024 } from "./20231024_Config.s.sol";

contract Migration__20231024_UpgradeDomainPrice is Config__20231024 {
function run() public trySetUp {
Config memory config = getConfig();
_upgradeProxy(ContractKey.RNSDomainPrice, EMPTY_ARGS);

console2.log("operator", config.operator);
console2.log("overrider", config.overrider);

RNSDomainPrice domainPrice = RNSDomainPrice(_config.getAddressFromCurrentNetwork(ContractKey.RNSDomainPrice));
address admin = domainPrice.getRoleMember(0x00, 0);
bytes32 overriderRole = domainPrice.OVERRIDER_ROLE();
vm.broadcast(admin);
domainPrice.grantRole(overriderRole, config.overrider);
}
}
1 change: 1 addition & 0 deletions script/RNSDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ abstract contract RNSDeploy is BaseDeploy {
IPyth pyth;
address admin;
address pauser;
address overrider;
address controller;
uint8 minWord;
uint8 maxWord;
Expand Down
6 changes: 4 additions & 2 deletions src/RNSDomainPrice.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ contract RNSDomainPrice is Initializable, AccessControlEnumerable, INSDomainPric
uint64 public constant MAX_PERCENTAGE = 100_00;
/// @inheritdoc INSDomainPrice
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
/// @inheritdoc INSDomainPrice
bytes32 public constant OVERRIDER_ROLE = keccak256("OVERRIDER_ROLE");

/// @dev Gap for upgradeability.
uint256[50] private ____gap;
Expand Down Expand Up @@ -170,7 +172,7 @@ contract RNSDomainPrice is Initializable, AccessControlEnumerable, INSDomainPric
*/
function bulkOverrideRenewalFees(bytes32[] calldata lbHashes, uint256[] calldata usdPrices)
external
onlyRole(OPERATOR_ROLE)
onlyRole(OVERRIDER_ROLE)
{
uint256 length = lbHashes.length;
if (length == 0 || length != usdPrices.length) revert InvalidArrayLength();
Expand Down Expand Up @@ -218,7 +220,7 @@ contract RNSDomainPrice is Initializable, AccessControlEnumerable, INSDomainPric
uint256[] calldata ronPrices,
bytes32[] calldata proofHashes,
uint256[] calldata setTypes
) external onlyRole(OPERATOR_ROLE) {
) external onlyRole(OVERRIDER_ROLE) {
uint256 length = _requireBulkSetDomainPriceArgumentsValid(lbHashes, ronPrices, proofHashes, setTypes);
address operator = _msgSender();

Expand Down
5 changes: 5 additions & 0 deletions src/interfaces/INSDomainPrice.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ interface INSDomainPrice {
*/
function OPERATOR_ROLE() external pure returns (bytes32);

/**
* @dev Returns the overrider role.
*/
function OVERRIDER_ROLE() external pure returns (bytes32);

/**
* @dev Max percentage 100%. Values [0; 100_00] reflexes [0; 100%]
*/
Expand Down

0 comments on commit 35340bf

Please sign in to comment.