diff --git a/contracts/facets/GBMFacet.sol b/contracts/facets/GBMFacet.sol index 85dadf6..d214311 100644 --- a/contracts/facets/GBMFacet.sol +++ b/contracts/facets/GBMFacet.sol @@ -144,38 +144,6 @@ contract GBMFacet is IGBM, IERC1155TokenReceiver, IERC721TokenReceiver, Modifier _calculateRoyaltyAndSend(_auctionID, recipient, a.highestBid, 0); } - //to be called after diamond is paused - function claimAll(uint256[] calldata _auctionIds) external onlyOwner { - for (uint256 i = 0; i < _auctionIds.length; i++) { - Auction storage a = s.auctions[_auctionIds[i]]; - if (a.owner == address(0)) revert("NoAuction"); - if (a.claimed == true) revert("AuctionClaimed"); - - //Prevents re-entrancy - a.claimed = true; - - address recipient = a.highestBidder == address(0) ? a.owner : a.highestBidder; - - _calculateRoyaltyAndSend(_auctionIds[i], recipient, a.highestBid, 0); - } - } - - function getAllUnclaimedAuctions() public view returns (uint256[] memory) { - uint256[] memory unclaimedAuctions = new uint256[](s.auctionNonce); - uint256 unclaimedCount = 0; - for (uint256 i = 0; i < s.auctionNonce; i++) { - if (s.auctions[i].claimed == false) { - unclaimedAuctions[unclaimedCount] = i; - unclaimedCount++; - } - } - - assembly { - mstore(unclaimedAuctions, unclaimedCount) - } - return unclaimedAuctions; - } - /// @notice Attribute a token to the caller and distribute the proceeds to the owner of this contract. /// throw if bidding is disabled or if the auction is not finished. /// @param _auctionID The auctionId of the auction to complete @@ -642,6 +610,10 @@ contract GBMFacet is IGBM, IERC1155TokenReceiver, IERC721TokenReceiver, Modifier return s.contractBiddingAllowed[_contract]; } + function isWhitelisted(address _contract) public view returns (bool) { + return s.contractAllowed[_contract]; + } + function onERC721Received( address /* _operator */, address /* _from */, diff --git a/hardhat.config.ts b/hardhat.config.ts index 9ce1dc7..f19156f 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -32,11 +32,9 @@ module.exports = { networks: { hardhat: { forking: { - url: process.env.MATIC_URL, + url: process.env.BASE_RPC_URL, accounts: [process.env.SECRET], - // timeout: 1200000, - // blockNumber: 26200790, - // blockNumber: 13024371 + blockNumber: 34524730, }, blockGasLimit: 200000000, timeout: 120000, diff --git a/scripts/constants.ts b/scripts/constants.ts index ca6df3f..4162f9b 100644 --- a/scripts/constants.ts +++ b/scripts/constants.ts @@ -6,3 +6,5 @@ export const maticGBMDiamondUpgrader = export const ghstAddress = "0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7"; export const gotchiDiamondAddress = "0x86935F11C86623deC8a25696E1C19a8659CbF95d"; + +export const baseGBMDiamond = "0x80320A0000C7A6a34086E2ACAD6915Ff57FfDA31"; diff --git a/scripts/gbmBaazaar/toggleBidding.ts b/scripts/gbmBaazaar/toggleBidding.ts index 9640a78..074561b 100644 --- a/scripts/gbmBaazaar/toggleBidding.ts +++ b/scripts/gbmBaazaar/toggleBidding.ts @@ -64,19 +64,9 @@ export async function toggleContractWhitelist() { // Define the tokens you want to whitelist/unwhitelist const tokensToToggle: WhitelistConfig[] = [ { - tokenAddress: "0xebba5b725A2889f7f089a6cAE0246A32cad4E26b", + tokenAddress: "0xF6c1b83977DE3dEffC476f5048A0a84d3375d498", enabled: true, - description: "Installations", - }, - { - tokenAddress: "0x4B0040c3646D3c44B8a28Ad7055cfCF536c05372", - enabled: true, - description: "REALM Parcels", - }, - { - tokenAddress: "0x617fdB8093b309e4699107F48812b407A7c37938", - enabled: true, - description: "Tiles", + description: "Unstoppable Domains", }, // Add more tokens as needed diff --git a/scripts/gbmBaazaar/toggleContractWhitelist.ts b/scripts/gbmBaazaar/toggleContractWhitelist.ts index a454232..fd64e4e 100644 --- a/scripts/gbmBaazaar/toggleContractWhitelist.ts +++ b/scripts/gbmBaazaar/toggleContractWhitelist.ts @@ -100,19 +100,9 @@ export async function toggleContractWhitelist() { // Define the tokens you want to whitelist/unwhitelist const tokensToToggle: WhitelistConfig[] = [ { - tokenAddress: "0xebba5b725A2889f7f089a6cAE0246A32cad4E26b", + tokenAddress: "0xF6c1b83977DE3dEffC476f5048A0a84d3375d498", enabled: true, - description: "Installations", - }, - { - tokenAddress: "0x4B0040c3646D3c44B8a28Ad7055cfCF536c05372", - enabled: true, - description: "REALM Parcels", - }, - { - tokenAddress: "0x617fdB8093b309e4699107F48812b407A7c37938", - enabled: true, - description: "Tiles", + description: "Unstoppable Domains", }, // Add more tokens as needed diff --git a/scripts/gbmBaazaar/upgrade-addGetter.ts b/scripts/gbmBaazaar/upgrade-addGetter.ts new file mode 100644 index 0000000..a2005ae --- /dev/null +++ b/scripts/gbmBaazaar/upgrade-addGetter.ts @@ -0,0 +1,46 @@ +//@ts-ignore +import { run, ethers } from "hardhat"; +import { + convertFacetAndSelectorsToString, + DeployUpgradeTaskArgs, + FacetsAndAddSelectors, +} from "../../tasks/deployUpgrade"; +import { baseGBMDiamond } from "../constants"; + +export async function upgradeAddClaimAll() { + const facets: FacetsAndAddSelectors[] = [ + { + facetName: "GBMFacet", + addSelectors: ["function isWhitelisted(address) returns (bool)"], + removeSelectors: [ + "function claimAll(uint256[] calldata _auctionIds) external", + "function getAllUnclaimedAuctions() public view returns (uint256[] memory)", + ], + }, + ]; + + const joined = convertFacetAndSelectorsToString(facets); + + const args: DeployUpgradeTaskArgs = { + diamondUpgrader: "0xf52398257A254D541F392667600901f710a006eD", + diamondAddress: baseGBMDiamond, + facetsAndAddSelectors: joined, + useLedger: false, + useMultisig: false, + initAddress: ethers.constants.AddressZero, + initCalldata: "0x", + }; + + await run("deployUpgrade", args); +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +if (require.main === module) { + upgradeAddClaimAll() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); +} diff --git a/scripts/helperFunctions.ts b/scripts/helperFunctions.ts index e3c5115..d0a6228 100644 --- a/scripts/helperFunctions.ts +++ b/scripts/helperFunctions.ts @@ -158,11 +158,8 @@ export async function warp(timeInSeconds: number) { return newTime; } -export const xpRelayerAddress = "0xb6384935d68e9858f8385ebeed7db84fc93b1420"; -export const xpRelayerAddressBaseSepolia = - "0x9343363e8e6518ba7166ce702a7589e7bbd1fd81"; -export const xpRelayerAddressBase = - "0xf52398257A254D541F392667600901f710a006eD"; +export const relayerBaseSepolia = "0x9343363e8e6518ba7166ce702a7589e7bbd1fd81"; +export const baseRelayerAddress = "0xf52398257A254D541F392667600901f710a006eD"; export interface RelayerInfo { apiKey: string; @@ -173,27 +170,27 @@ export async function getRelayerSigner(hre: HardhatRuntimeEnvironment) { const testing = ["hardhat", "localhost"].includes(hre.network.name); let xpRelayer; if (hre.network.config.chainId === 8453) { - xpRelayer = xpRelayerAddressBase; + xpRelayer = baseRelayerAddress; } else if (hre.network.config.chainId === 84532) { - xpRelayer = xpRelayerAddressBaseSepolia; + xpRelayer = relayerBaseSepolia; + } else { + xpRelayer = baseRelayerAddress; } if (testing) { - if (hre.network.config.chainId !== 31337) { - console.log("Using Hardhat"); - - await hre.network.provider.request({ - method: "hardhat_impersonateAccount", - params: [xpRelayer], - }); - await hre.network.provider.request({ - method: "hardhat_setBalance", - params: [xpRelayerAddress, "0x100000000000000000000000"], - }); - return await hre.ethers.provider.getSigner(xpRelayerAddress); - } else { - return (await hre.ethers.getSigners())[0]; - } + console.log("Using Hardhat"); + + await hre.network.provider.request({ + method: "hardhat_impersonateAccount", + params: [xpRelayer], + }); + await hre.network.provider.request({ + method: "hardhat_setBalance", + params: [xpRelayer, "0x100000000000000000000000"], + }); + + return await hre.ethers.provider.getSigner(xpRelayer); + //we assume same defender for base mainnet } else if (hre.network.name === "matic" || hre.network.name === "base") { console.log("USING MAINNET RELAYER"); diff --git a/tasks/deployUpgrade.ts b/tasks/deployUpgrade.ts index 175354e..2ae36c0 100644 --- a/tasks/deployUpgrade.ts +++ b/tasks/deployUpgrade.ts @@ -7,16 +7,13 @@ import { ContractTransaction, PopulatedTransaction, } from "@ethersproject/contracts"; -import { Signer } from "@ethersproject/abstract-signer"; -import { OwnershipFacet } from "../typechain/OwnershipFacet"; import { IDiamondCut } from "../typechain/IDiamondCut"; import { - gasPrice, + getRelayerSigner, getSelectors, getSighashes, } from "../scripts/helperFunctions"; -import { LedgerSigner } from "@anders-t/ethers-ledger"; import { HardhatRuntimeEnvironment } from "hardhat/types"; @@ -112,7 +109,7 @@ task( const diamondUpgrader: string = taskArgs.diamondUpgrader; const diamondAddress: string = taskArgs.diamondAddress; const useMultisig = taskArgs.useMultisig; - const useLedger = taskArgs.useLedger; + const initAddress = taskArgs.initAddress; const initCalldata = taskArgs.initCalldata; @@ -122,36 +119,31 @@ task( await mine(); } - //Instantiate the Signer - let signer: Signer; - const owner = await ( - (await hre.ethers.getContractAt( - "OwnershipFacet", - diamondAddress - )) as OwnershipFacet - ).owner(); - - if (testing) { - await hre.network.provider.request({ - method: "hardhat_impersonateAccount", - params: [owner], - }); - signer = await hre.ethers.getSigner(owner); - } else if (hre.network.name === "matic" || "mumbai") { - if (useLedger) { - console.log("use ledger"); - signer = new LedgerSigner(hre.ethers.provider, "m/44'/60'/1'/0/0"); - } else signer = (await hre.ethers.getSigners())[0]; - } else { - throw Error("Incorrect network selected"); - } - - console.log( - `Deploying address: ${await signer.getAddress()} with gas: ${hre.ethers.utils.formatUnits( - gasPrice, - "gwei" - )}` - ); + const signer = await getRelayerSigner(hre); + + // //Instantiate the Signer + // let signer: Signer; + // const owner = await ( + // (await hre.ethers.getContractAt( + // "OwnershipFacet", + // diamondAddress + // )) as OwnershipFacet + // ).owner(); + + // if (testing) { + // await hre.network.provider.request({ + // method: "hardhat_impersonateAccount", + // params: [owner], + // }); + // signer = await hre.ethers.getSigner(owner); + // } else if (hre.network.name === "matic" || "mumbai") { + // if (useLedger) { + // console.log("use ledger"); + // signer = new LedgerSigner(hre.ethers.provider, "m/44'/60'/1'/0/0"); + // } else signer = (await hre.ethers.getSigners())[0]; + // } else { + // throw Error("Incorrect network selected"); + // } //Create the cut const deployedFacets = []; @@ -162,11 +154,10 @@ task( console.log("Deploying facet:", facet); const factory = (await hre.ethers.getContractFactory( - facet.facetName + facet.facetName, + signer )) as ContractFactory; - const deployedFacet: Contract = await factory.deploy({ - gasPrice: gasPrice, - }); + const deployedFacet: Contract = await factory.deploy(); await deployedFacet.deployed(); console.log( @@ -219,8 +210,6 @@ task( } } - console.log(cut); - //Execute the Cut const diamondCut = (await hre.ethers.getContractAt( "IDiamondCut", @@ -233,8 +222,7 @@ task( const tx: ContractTransaction = await diamondCut.diamondCut( cut, initAddress, - initCalldata, - { gasLimit: 8000000 } + initCalldata ); console.log("Diamond cut tx:", tx.hash); const receipt: ContractReceipt = await tx.wait(); @@ -259,8 +247,7 @@ task( const tx: ContractTransaction = await diamondCut.diamondCut( cut, initAddress, - initCalldata, - { gasPrice: gasPrice } + initCalldata ); const receipt: ContractReceipt = await tx.wait();