Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 4 additions & 32 deletions contracts/facets/GBMFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */,
Expand Down
6 changes: 2 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions scripts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const maticGBMDiamondUpgrader =
export const ghstAddress = "0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7";
export const gotchiDiamondAddress =
"0x86935F11C86623deC8a25696E1C19a8659CbF95d";

export const baseGBMDiamond = "0x80320A0000C7A6a34086E2ACAD6915Ff57FfDA31";
14 changes: 2 additions & 12 deletions scripts/gbmBaazaar/toggleBidding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions scripts/gbmBaazaar/toggleContractWhitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions scripts/gbmBaazaar/upgrade-addGetter.ts
Original file line number Diff line number Diff line change
@@ -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);
});
}
41 changes: 19 additions & 22 deletions scripts/helperFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
77 changes: 32 additions & 45 deletions tasks/deployUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;

Expand All @@ -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 = [];
Expand All @@ -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(
Expand Down Expand Up @@ -219,8 +210,6 @@ task(
}
}

console.log(cut);

//Execute the Cut
const diamondCut = (await hre.ethers.getContractAt(
"IDiamondCut",
Expand All @@ -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();
Expand All @@ -259,8 +247,7 @@ task(
const tx: ContractTransaction = await diamondCut.diamondCut(
cut,
initAddress,
initCalldata,
{ gasPrice: gasPrice }
initCalldata
);

const receipt: ContractReceipt = await tx.wait();
Expand Down
Loading