Skip to content

Commit

Permalink
feat(multi-treasury): implement `upgrade-controller-and-deploy-rnscom…
Browse files Browse the repository at this point in the history
…mission-script` (#261)
  • Loading branch information
tringuyenskymavis authored Jul 4, 2024
2 parents 4b9a596 + f9ce5ef commit df900d9
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { RNSAuction, RNSAuctionDeploy } from "script/contracts/RNSAuctionDeploy.s.sol";
import {
RONRegistrarController, RONRegistrarControllerDeploy
} from "script/contracts/RONRegistrarControllerDeploy.s.sol";
import { Contract } from "script/utils/Contract.sol";
import { RNSCommission, RNSCommissionDeploy } from "script/contracts/RNSCommissionDeploy.s.sol";
import { Migration } from "script/Migration.s.sol";

contract Migration__20240407_UpgradeControllerAndDeployRNSCommissionMainnet is Migration {
RONRegistrarController private _controller;
RNSCommission private _rnsCommission;
RNSAuction _auction;

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

function _postCheck() internal override {
_validateSendMoneyFromSenders();
_validateCommissionInfo();
_validateSendersAddress();
}

function _validateCommissionInfo() internal logFn("_validateSetCommissionInfo") {
assertEq(_rnsCommission.getCommissions().length, 2);

assertEq(_rnsCommission.getCommissions()[0].recipient, payable(0xFf43f5Ef28EcB7c1f219751fc793deB40ef07A53));
assertEq(_rnsCommission.getCommissions()[1].recipient, payable(0x22cEfc91E9b7c0f3890eBf9527EA89053490694e));

assertEq(_rnsCommission.getCommissions()[0].ratio, 70_00);
assertEq(_rnsCommission.getCommissions()[1].ratio, 30_00);

assertEq(_rnsCommission.getCommissions()[0].name, "Sky Mavis");
assertEq(_rnsCommission.getCommissions()[1].name, "Ronin");
}

function _validateSendMoneyFromSenders() internal logFn("_validateSendMoneyFromSenders") {
vm.deal(address(_auction), 100 ether);
vm.prank(address(_auction));
address(_rnsCommission).call{ value: 100 ether }("");

vm.deal(address(_controller), 100 ether);
vm.prank(address(_controller));
address(_rnsCommission).call{ value: 100 ether }("");

assertEq(address(_rnsCommission).balance, 0 ether);

address randomAddr = makeAddr("random address");
vm.deal(address(randomAddr), 100 ether);
vm.prank(randomAddr);
address(_rnsCommission).call{ value: 100 ether }("");

assertEq(address(_rnsCommission).balance, 100 ether);
}

function _validateSendersAddress() internal logFn("_validateSendersAddress") {
bytes32 SENDER_ROLE = keccak256("SENDER_ROLE");

require(_rnsCommission.hasRole(SENDER_ROLE, address(_auction)));
require(_rnsCommission.hasRole(SENDER_ROLE, address(_controller)));
}
}
16 changes: 16 additions & 0 deletions script/Migration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ abstract contract Migration is BaseMigration {
param.rnsUnified.protectedSettler = temporaryAdmin;
param.rnsUnified.gracePeriod = 90 days;
param.rnsUnified.baseTokenURI = "https://metadata-rns.roninchain.com/ronin/";

// RNSCommission
param.rnsCommission.admin = 0x9D05D1F5b0424F8fDE534BC196FFB6Dd211D902a;
param.rnsCommission.commissionSetters = new address[](1);
param.rnsCommission.commissionSetters[0] = 0x9D05D1F5b0424F8fDE534BC196FFB6Dd211D902a;

param.rnsCommission.allowedSenders = new address[](2);

param.rnsCommission.treasuryCommission = new INSCommission.Commission[](2);
param.rnsCommission.treasuryCommission[0].recipient = payable(0xFf43f5Ef28EcB7c1f219751fc793deB40ef07A53);
param.rnsCommission.treasuryCommission[0].ratio = 70_00;
param.rnsCommission.treasuryCommission[0].name = "Sky Mavis";

param.rnsCommission.treasuryCommission[1].recipient = payable(0x22cEfc91E9b7c0f3890eBf9527EA89053490694e);
param.rnsCommission.treasuryCommission[1].ratio = 30_00;
param.rnsCommission.treasuryCommission[1].name = "Ronin";
} else {
revert("Missing param");
}
Expand Down

0 comments on commit df900d9

Please sign in to comment.