-
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
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...1123-upgrade-auction-claim-unbidded-names/20231123_UpgradeAuctionClaimUnbiddedNames.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,53 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 as console } from "forge-std/console2.sol"; | ||
import { ContractKey } from "foundry-deployment-kit/configs/ContractConfig.sol"; | ||
import { RNSDeploy } from "script/RNSDeploy.s.sol"; | ||
import { RNSUnified } from "@rns-contracts/RNSUnified.sol"; | ||
import { INSAuction, RNSAuction } from "@rns-contracts/RNSAuction.sol"; | ||
|
||
contract Migration__20231123_UpgradeAuctionClaimeUnbiddedNames is RNSDeploy { | ||
function run() public trySetUp { | ||
_upgradeProxy(ContractKey.RNSAuction, EMPTY_ARGS); | ||
_validataBulkClaimUnbiddedNames({ size: 50 }); | ||
} | ||
|
||
function _validataBulkClaimUnbiddedNames(uint256 size) internal logFn("_validataBulkClaimUnbiddedNames") { | ||
RNSAuction auction = RNSAuction(_config.getAddressFromCurrentNetwork(ContractKey.RNSAuction)); | ||
RNSUnified rns = RNSUnified(_config.getAddressFromCurrentNetwork(ContractKey.RNSUnified)); | ||
|
||
uint256 auctionBalance = size; | ||
console.log("auctionBalance", auctionBalance); | ||
INSAuction.DomainAuction[] memory domainAuctions = new INSAuction.DomainAuction[](auctionBalance); | ||
uint256[] memory reservedIds = new uint256[](auctionBalance); | ||
for (uint256 i; i < auctionBalance; ++i) { | ||
reservedIds[i] = rns.tokenOfOwnerByIndex(address(auction), i); | ||
(domainAuctions[i],) = auction.getAuction(reservedIds[i]); | ||
console.log(reservedIds[i], domainAuctions[i].bid.bidder); | ||
} | ||
|
||
address to = makeAddr("to"); | ||
address[] memory tos = new address[](reservedIds.length); | ||
for (uint256 i; i < tos.length; ++i) { | ||
tos[i] = to; | ||
} | ||
|
||
address operator = auction.getRoleMember(auction.OPERATOR_ROLE(), 0); | ||
uint256 snapshotId = vm.snapshot(); | ||
// allowFailure | ||
vm.prank(operator); | ||
bool[] memory claimeds = auction.bulkClaimUnbiddedNames(tos, reservedIds, true); | ||
for (uint256 i; i < claimeds.length; ++i) { | ||
// flag claimed is true if bidder is null | ||
assertTrue(claimeds[i] == (domainAuctions[i].bid.bidder == address(0x0))); | ||
if (claimeds[i]) assertEq(rns.ownerOf(reservedIds[i]), to); | ||
} | ||
|
||
vm.revertTo(snapshotId); | ||
// !allowFailure | ||
vm.prank(operator); | ||
vm.expectRevert(INSAuction.AlreadyBidding.selector); | ||
claimeds = auction.bulkClaimUnbiddedNames(tos, reservedIds, false); | ||
} | ||
} |
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
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