Skip to content

Commit

Permalink
script: resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Feb 23, 2024
1 parent 7ec1084 commit 138e7a0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ docs/
node_modules/
yarn-error.log
.yarn
.yarnrc.yml
.yarnrc.yml
script/data/*
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ contract Migration__01_UpgradeRNSDomainPriceAndOverrideTierForCommunityNames_RNS
function run() external {
_domainPrice = RNSDomainPrice(_upgradeProxy(Contract.RNSDomainPrice.key()));
_multicall = IMulticall3(loadContract(DefaultContract.Multicall3.key()));

(_labels, _tiers) = _parseData(DATA_PATH);

_lbHashes = toLabelHashes(_labels);

uint256 batchSize = 100;
Expand All @@ -36,7 +39,7 @@ contract Migration__01_UpgradeRNSDomainPriceAndOverrideTierForCommunityNames_RNS
}

bytes32[] memory batchHashes = new bytes32[](end - start);
uint256[] memory batchTiers = new uint256[](end - start);
INSDomainPrice.Tier[] memory batchTiers = new INSDomainPrice.Tier[](end - start);

for (uint256 j = start; j < end; j++) {
batchHashes[j - start] = _lbHashes[j];
Expand All @@ -55,14 +58,16 @@ contract Migration__01_UpgradeRNSDomainPriceAndOverrideTierForCommunityNames_RNS

function _validateOtherDomainTiers() internal logFn("_validating other domain tiers ...") {
if (network() == DefaultNetwork.RoninMainnet.key()) {
assertEq(_domainPrice.getTier("tudo"), 2, "invalid tier for tudo");
assertEq(_domainPrice.getTier("duke"), 2, "invalid tier for duke");
assertEq(_domainPrice.getTier("ace"), 1, "invalid tier for ace");
assertEq(_domainPrice.getTier("dragon"), 2, "invalid tier for dragon");
assertEq(_domainPrice.getTier("tokuda"), 3, "invalid tier for tokuda");
assertEq(_domainPrice.getTier("metaverse"), 2, "invalid tier for metaverse");
assertEq(_domainPrice.getTier("nuke"), 2, "invalid tier for nuke");
assertEq(_domainPrice.getTier("merchandising"), 3, "invalid tier for merchandising");
assertEq(uint8(_domainPrice.getTier("tudo")), uint8(INSDomainPrice.Tier.Tier2), "invalid tier for tudo");
assertEq(uint8(_domainPrice.getTier("duke")), uint8(INSDomainPrice.Tier.Tier2), "invalid tier for duke");
assertEq(uint8(_domainPrice.getTier("ace")), uint8(INSDomainPrice.Tier.Tier1), "invalid tier for ace");
assertEq(uint8(_domainPrice.getTier("dragon")), uint8(INSDomainPrice.Tier.Tier2), "invalid tier for dragon");
assertEq(uint8(_domainPrice.getTier("tokuda")), uint8(INSDomainPrice.Tier.Tier3), "invalid tier for tokuda");
assertEq(uint8(_domainPrice.getTier("metaverse")), uint8(INSDomainPrice.Tier.Tier2), "invalid tier for metaverse");
assertEq(uint8(_domainPrice.getTier("nuke")), uint8(INSDomainPrice.Tier.Tier2), "invalid tier for nuke");
assertEq(
uint8(_domainPrice.getTier("merchandising")), uint8(INSDomainPrice.Tier.Tier3), "invalid tier for merchandising"
);
}
}

Expand All @@ -77,11 +82,11 @@ contract Migration__01_UpgradeRNSDomainPriceAndOverrideTierForCommunityNames_RNS
}

(, bytes[] memory returnData) = _multicall.aggregate(calls);
uint256[] memory tiers = new uint256[](_lbHashes.length);
INSDomainPrice.Tier[] memory tiers = new INSDomainPrice.Tier[](_lbHashes.length);

for (uint256 i; i < _lbHashes.length; ++i) {
tiers[i] = abi.decode(returnData[i], (uint256));
assertEq(tiers[i], _tiers[i], string.concat("tier not set", vm.toString(i)));
tiers[i] = abi.decode(returnData[i], (INSDomainPrice.Tier));
assertEq(uint8(tiers[i]), uint8(_tiers[i]), string.concat("tier not set", vm.toString(i)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract Migration__02_ResetCommunityNamesRenewalFees_RNSDomainPrice is Migratio

for (uint256 i; i < _lbHashes.length; ++i) {
vm.expectRevert(INSDomainPrice.RenewalFeeIsNotOverriden.selector);
uint256 overridenRenewalFee = rnsDomainPrice.getOverriddenRenewalFee(_labels[i]);
rnsDomainPrice.getOverriddenRenewalFee(_labels[i]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { console2 as console } from "forge-std/console2.sol";
import { Contract } from "script/utils/Contract.sol";
import { Migration } from "script/Migration.s.sol";
import { RNSUnified } from "@rns-contracts/RNSUnified.sol";
import { RNSDomainPrice } from "@rns-contracts/RNSDomainPrice.sol";
import { INSDomainPrice, RNSDomainPrice } from "@rns-contracts/RNSDomainPrice.sol";
import { INSAuction, RNSAuction } from "@rns-contracts/RNSAuction.sol";
import { LibRNSDomain } from "@rns-contracts/libraries/LibRNSDomain.sol";
import { RNSOperation, RNSOperationDeploy } from "script/contracts/RNSOperationDeploy.s.sol";
Expand Down Expand Up @@ -58,7 +58,11 @@ contract Migration_03_DeployNewRNSOperation_OverrideTierForAuctionNames_RNSOpera
labels[4] = "slim";

for (uint256 i; i < labels.length; ++i) {
assertEq(domainPrice.getTier(labels[i]), 1, string.concat("invalid tier for auction label ", labels[i]));
assertEq(
uint8(domainPrice.getTier(labels[i])),
uint8(INSDomainPrice.Tier.Tier1),
string.concat("invalid tier for auction label ", labels[i])
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ import { console2 as console } from "forge-std/console2.sol";
import { JSONParserLib } from "solady/utils/JSONParserLib.sol";
import { Migration, ISharedArgument } from "../Migration.s.sol";
import { LibRNSDomain } from "@rns-contracts/libraries/LibRNSDomain.sol";
import { INSDomainPrice } from "@rns-contracts/interfaces/INSDomainPrice.sol";

contract Migration__20240215 is Migration {
using JSONParserLib for *;
using LibRNSDomain for *;

string internal constant DATA_PATH = "script/data/517 Community names (Tier 1) - _3 characters.json";

uint256[] internal _tiers;
INSDomainPrice.Tier[] internal _tiers;
string[] internal _labels;

constructor() {
(_labels, _tiers) = _parseData(DATA_PATH);
}
constructor() { }

function toLabelHashes(string[] memory labels) internal pure returns (bytes32[] memory) {
bytes32[] memory hashes = new bytes32[](labels.length);
Expand All @@ -35,17 +34,21 @@ contract Migration__20240215 is Migration {
return hashes;
}

function _parseData(string memory path) internal view returns (string[] memory labels, uint256[] memory tiers) {
function _parseData(string memory path)
internal
view
returns (string[] memory labels, INSDomainPrice.Tier[] memory tiers)
{
string memory raw = vm.readFile(path);
JSONParserLib.Item memory communityNames = raw.parse();
uint256 length = communityNames.size();
console.log("length", length);

labels = new string[](length);
tiers = new uint256[](length);
tiers = new INSDomainPrice.Tier[](length);

for (uint256 i; i < length; ++i) {
tiers[i] = vm.parseUint(communityNames.at(i).at('"tier"').value().decodeString());
tiers[i] = INSDomainPrice.Tier(uint8(vm.parseUint(communityNames.at(i).at('"tier"').value().decodeString())));
labels[i] = (communityNames.at(i).at('"domain"').value().decodeString());
}
}
Expand Down

0 comments on commit 138e7a0

Please sign in to comment.