Skip to content

Commit

Permalink
chore: add upgradeBuyNowFor script
Browse files Browse the repository at this point in the history
  • Loading branch information
BromeRST committed May 9, 2024
1 parent 05272b1 commit fc6a7d5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
63 changes: 63 additions & 0 deletions scripts/gbmBaazaar/upgrade-buyNowFor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//@ts-ignore
import { run, ethers, network } from "hardhat";
import {
convertFacetAndSelectorsToString,
DeployUpgradeTaskArgs,
FacetsAndAddSelectors,
} from "../../tasks/deployUpgrade";
import { gasPrice, impersonate } from "../helperFunctions";
import { maticGBMDiamond, maticGBMDiamondUpgrader } from "../constants";

export async function upgradeBuyNowFor() {
const facets: FacetsAndAddSelectors[] = [
{
facetName: "GBMFacet",
addSelectors: [
`function buyNowFor(uint256 _auctionID, address _recepient) public`,
`function _buyNowImplementation(uint256 _auctionID, address _recipient) internal`,
],
removeSelectors: [],
},
];

const joined = convertFacetAndSelectorsToString(facets);

const args: DeployUpgradeTaskArgs = {
diamondUpgrader: maticGBMDiamondUpgrader,
diamondAddress: maticGBMDiamond,
facetsAndAddSelectors: joined,
useLedger: true,
useMultisig: false,
initAddress: ethers.constants.AddressZero,
initCalldata: "0x",
};

await run("deployUpgrade", args);

let gbmFacet = await ethers.getContractAt("GBMFacet", maticGBMDiamond);
gbmFacet = await impersonate(
maticGBMDiamondUpgrader,
gbmFacet,
ethers,
network
);
const tx = await gbmFacet.setBuyItNowInvalidationThreshold(70, {
gasPrice: gasPrice,
});
console.log("Preset corrected successfully at hash", tx.hash);
console.log(
"BuyItNowInvalidationThreshold:",
await gbmFacet.getBuyItNowInvalidationThreshold()
);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
if (require.main === module) {
upgradeBuyNowFor()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
}
3 changes: 2 additions & 1 deletion test/buyNowAndStartBidPriceTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
gotchiDiamondAddress,
maticGBMDiamond,
} from "../scripts/constants";
import { upgradeBuyNowFor } from "../scripts/gbmBaazaar/upgrade-buyNowFor";

describe("Testing start bid price and buy now logic", async function () {
this.timeout(30000000);
Expand Down Expand Up @@ -61,7 +62,7 @@ describe("Testing start bid price and buy now logic", async function () {
let auctionInfo;

before(async function () {
await upgradeBuyNow();
await upgradeBuyNowFor();

const ownershipFacet = (await ethers.getContractAt(
"OwnershipFacet",
Expand Down

0 comments on commit fc6a7d5

Please sign in to comment.