-
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.
script: add migration script for v0.3.4
- Loading branch information
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...0215-separate-tier-and-domain-price/01_ResetCommunityNameRenewalFees_RNSDomainPrice.s.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,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { INSDomainPrice, RNSDomainPrice } from "@rns-contracts/RNSDomainPrice.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import "./20240215_Migration.s.sol"; | ||
|
||
contract Migration__01_ResetCommunityNamesRenewalFees_RNSDomainPrice is Migration__20240215 { | ||
bytes32[] internal _lbHashes; | ||
|
||
function run() external { | ||
RNSDomainPrice rnsDomainPrice = RNSDomainPrice(loadContract(Contract.RNSDomainPrice.key())); | ||
|
||
(_labels,) = _parseData(DATA_PATH); | ||
_lbHashes = toLabelHashes(_labels); | ||
|
||
uint256[] memory renewalFees = new uint256[](_lbHashes.length); | ||
|
||
address overrider = rnsDomainPrice.getRoleMember(rnsDomainPrice.OVERRIDER_ROLE(), 0); | ||
vm.startBroadcast(overrider); | ||
rnsDomainPrice.bulkOverrideRenewalFees(_lbHashes, renewalFees); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function _postCheck() internal override { | ||
RNSDomainPrice rnsDomainPrice = RNSDomainPrice(loadContract(Contract.RNSDomainPrice.key())); | ||
|
||
for (uint256 i; i < _lbHashes.length; ++i) { | ||
(INSDomainPrice.UnitPrice memory renewalFee,) = rnsDomainPrice.getRenewalFee(_labels[i], 1); | ||
assertEq(renewalFee.usd, 0, "renewal fee not reset"); | ||
assertEq(renewalFee.ron, 0, "renewal fee not reset"); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...parate-tier-and-domain-price/02_UpgradeRNSDomainPrice_OverrideTierForCommunityNames.s.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,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { IMulticall3 } from "forge-std/interfaces/IMulticall3.sol"; | ||
import { LibString } from "solady/utils/LibString.sol"; | ||
import { DefaultContract } from "foundry-deployment-kit/utils/DefaultContract.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { INSDomainPrice, RNSDomainPrice } from "@rns-contracts/RNSDomainPrice.sol"; | ||
import "./20240215_Migration.s.sol"; | ||
|
||
contract Migration__02_UpgradeRNSDomainPriceAndOverrideTierForCommunityNames_RNSDomainPrice is Migration__20240215 { | ||
using LibString for *; | ||
|
||
RNSDomainPrice internal _domainPrice; | ||
IMulticall3 internal _multicall; | ||
bytes32[] internal _lbHashes; | ||
|
||
function run() external { | ||
_domainPrice = RNSDomainPrice(_upgradeProxy(Contract.RNSDomainPrice.key())); | ||
_multicall = IMulticall3(loadContract(DefaultContract.Multicall3.key())); | ||
|
||
(_labels, _tiers) = _parseData(DATA_PATH); | ||
_lbHashes = toLabelHashes(_labels); | ||
|
||
vm.broadcast(_domainPrice.getRoleMember(_domainPrice.OVERRIDER_ROLE(), 0)); | ||
_domainPrice.bulkOverrideTiers(_lbHashes, _tiers); | ||
} | ||
|
||
function _postCheck() internal override { | ||
IMulticall3.Call[] memory calls = new IMulticall3.Call[](_lbHashes.length); | ||
|
||
for (uint256 i; i < _lbHashes.length; ++i) { | ||
calls[i] = IMulticall3.Call({ | ||
target: address(_domainPrice), | ||
callData: abi.encodeCall(_domainPrice.getTier, (_labels[i])) | ||
}); | ||
} | ||
|
||
(, bytes[] memory returnData) = _multicall.aggregate(calls); | ||
uint256[] memory tiers = new uint256[](_lbHashes.length); | ||
|
||
for (uint256 i; i < _lbHashes.length; ++i) { | ||
tiers[i] = abi.decode(returnData[i], (uint256)); | ||
console.log("label:", _labels[i], "tier:", tiers[i]); | ||
assertEq(tiers[i], _tiers[i], string.concat("tier not set", vm.toString(i))); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
script/20240215-separate-tier-and-domain-price/20240215_Migration.s.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,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
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"; | ||
|
||
contract Migration__20240215 is Migration { | ||
using JSONParserLib for *; | ||
using LibRNSDomain for *; | ||
|
||
string internal constant DATA_PATH = "script/20240215-separate-tier-and-domain-price/data/communityNames.json"; | ||
|
||
uint256[] internal _tiers; | ||
string[] internal _labels; | ||
|
||
function toLabelHashes(string[] memory labels) internal pure returns (bytes32[] memory) { | ||
bytes32[] memory hashes = new bytes32[](labels.length); | ||
for (uint256 i; i < labels.length; ++i) { | ||
hashes[i] = labels[i].hashLabel(); | ||
} | ||
return hashes; | ||
} | ||
|
||
function toNameHashes(string[] memory labels) internal pure returns (uint256[] memory) { | ||
uint256[] memory hashes = new uint256[](labels.length); | ||
for (uint256 i; i < labels.length; ++i) { | ||
hashes[i] = uint256(labels[i].namehash()); | ||
} | ||
return hashes; | ||
} | ||
|
||
function _parseData(string memory path) internal view returns (string[] memory labels, uint256[] memory tiers) { | ||
string memory raw = vm.readFile(path); | ||
JSONParserLib.Item memory communityNames = raw.parse().at('"communityNames"'); | ||
uint256 length = communityNames.size(); | ||
console.log("length", length); | ||
|
||
labels = new string[](length); | ||
tiers = new uint256[](length); | ||
|
||
for (uint256 i; i < length; ++i) { | ||
tiers[i] = vm.parseUint(communityNames.at(i).at('"tier"').value().decodeString()); | ||
labels[i] = (communityNames.at(i).at('"label"').value().decodeString()); | ||
} | ||
} | ||
} |