-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6397bef
commit 7833277
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
...pgrade-rnscommission-mainnet /20240704_UpgradeControllerAndDeployRNSCommissionMainnet.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// 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__20241105_UpgradeRNSCommissionMainnet is Migration { | ||
RONRegistrarController private _controller; | ||
RNSCommission private _rnsCommission; | ||
RNSAuction _auction; | ||
|
||
function run() public { | ||
_auction = RNSAuction(loadContract(Contract.RNSAuction.key())); | ||
_controller = RONRegistrarController(loadContract(Contract.RONRegistrarController.key())); | ||
_rnsCommission = RNSCommission(_upgradeProxy(Contract.RNSCommission.key())); | ||
} | ||
|
||
function _postCheck() internal override { | ||
_validateCommissionInfo(); | ||
_validateSendersAddress(); | ||
_validateSendMoneyFromSenders_NonZeroRonAmount(); | ||
_validateSendMoneyFromSenders_ZeroRonAmount(); | ||
} | ||
|
||
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_NonZeroRonAmount() | ||
internal | ||
logFn("_validateSendMoneyFromSenders_NonZeroRonAmount") | ||
{ | ||
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 _validateSendMoneyFromSenders_ZeroRonAmount() internal logFn("_validateSendMoneyFromSenders_ZeroRonAmount") { | ||
uint256 balanceBefore = address(_rnsCommission).balance; | ||
|
||
vm.prank(address(_auction)); | ||
address(_rnsCommission).call{ value: 0 }(""); | ||
vm.prank(address(_controller)); | ||
address(_rnsCommission).call{ value: 0 }(""); | ||
|
||
assertEq(address(_rnsCommission).balance, balanceBefore); | ||
} | ||
|
||
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))); | ||
} | ||
} |