Skip to content

Commit

Permalink
Fix halloween 2024 promotion, should have have 1 random reward specified
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSamWitch committed Oct 22, 2024
1 parent ae231d3 commit a75ead7
Show file tree
Hide file tree
Showing 9 changed files with 465 additions and 17 deletions.
444 changes: 444 additions & 0 deletions .openzeppelin/unknown-250-beta.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ItemNFTLibrary [0x2d0b79a4d76d6fd86b8ba08acc68d3f35430aa7a](https://ftmscan.com/
ItemNFT [0x1dae89b469d15b0ded980007dfdc8e68c363203d](https://ftmscan.com/address/0x1dae89b469d15b0ded980007dfdc8e68c363203d)
EstforLibrary [0xAD4Fe5A1d43F986659F548Cc899dCD4045FA9974](https://ftmscan.com/address/0xAD4Fe5A1d43F986659F548Cc899dCD4045FA9974)
PlayerNFT [0xde70e49756322afdf7714d3aca963abcb4547b8d](https://ftmscan.com/address/0xde70e49756322afdf7714d3aca963abcb4547b8d)
PromotionsLibrary [0x684c6e254df63b9d5a28b29b7e4d0850d158f9f9](https://ftmscan.com/address/0x684c6e254df63b9d5a28b29b7e4d0850d158f9f9)
PromotionsLibrary [0x13af205b631928f0ccb582cf6c5cae4d92470d2a](https://ftmscan.com/address/0x13af205b631928f0ccb582cf6c5cae4d92470d2a)
Promotions [0xf28cab48e29be56fcc68574b5c147b780c35647c](https://ftmscan.com/address/0xf28cab48e29be56fcc68574b5c147b780c35647c)
Quests [0x96948a6df3a64cc2eb0a1825fccd26f0c93bfce9](https://ftmscan.com/address/0x96948a6df3a64cc2eb0a1825fccd26f0c93bfce9)
Clans [0xd35410f526db135f09bb8e2bb066c8a63135d812](https://ftmscan.com/address/0xd35410f526db135f09bb8e2bb066c8a63135d812)
Expand Down
2 changes: 1 addition & 1 deletion contracts/Promotions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
}
}

// TODO: Only really supporting xmas 2023 so far with tiered rewards
// TODO: Only really supporting xmas 2023 so far with tiered rewards (and halloween 2024)
function _handleMultidayPromotion(
uint _playerId,
Promotion _promotion,
Expand Down
6 changes: 3 additions & 3 deletions contracts/PromotionsLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ library PromotionsLibrary {
revert StartTimeMustBeHigherEndTime();
}

if (_promotionInfoInput.numDailyRandomItemsToPick == 0) {
if (_promotionInfoInput.numDailyRandomItemsToPick == 0 && _promotionInfoInput.guaranteedItemTokenIds.length == 0) {
revert NoNumItemsToPick();
}

if (_promotionInfoInput.numDailyRandomItemsToPick != 1) {
// TODO: Special handling for now, only allowing 1 item to be picked
if (_promotionInfoInput.guaranteedItemTokenIds.length == 0 && _promotionInfoInput.numDailyRandomItemsToPick != 1) {
// TODO: Special handling for now, only allowing 1 random item to be picked
revert InvalidPromotion();
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/addPromotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function main() {
startTime,
endTime: startTime + 24 * 3600 * numDays,
minTotalXP: 0,
numDailyRandomItemsToPick: 1,
numDailyRandomItemsToPick: 0,
isMultiday: true,
brushCostMissedDay: "0",
brushCost: "0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if (!isBeta) {
estforLibrary = "0xAD4Fe5A1d43F986659F548Cc899dCD4045FA9974";
playerNFT = "0xde70e49756322afdf7714d3aca963abcb4547b8d";
promotions = "0xf28cab48e29be56fcc68574b5c147b780c35647c";
promotionsLibrary = "0x684c6e254df63b9d5a28b29b7e4d0850d158f9f9";
promotionsLibrary = "0x13af205b631928f0ccb582cf6c5cae4d92470d2a";
quests = "0x96948a6df3a64cc2eb0a1825fccd26f0c93bfce9";
clans = "0xd35410f526db135f09bb8e2bb066c8a63135d812";
wishingWell = "0xdd1131f57e5e416622fa2b61d4108822e8cc38dc";
Expand Down
13 changes: 7 additions & 6 deletions scripts/deployUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,12 @@ async function main() {
await adminAccess.deployed();
console.log(`adminAccess = "${adminAccess.address.toLowerCase()}"`);
*/
const newPromotionsLibrary = false;
const newPromotionsLibrary = true;
const PromotionsLibrary = await ethers.getContractFactory("PromotionsLibrary");
let promotionsLibrary: PromotionsLibrary;
if (newPromotionsLibrary) {
promotionsLibrary = await PromotionsLibrary.deploy();
await promotionsLibrary.deployed();
if (network.chainId == 250) {
await verifyContracts([promotionsLibrary.address]);
}
} else {
promotionsLibrary = await PromotionsLibrary.attach(PROMOTIONS_LIBRARY_ADDRESS);
}
Expand Down Expand Up @@ -264,6 +261,7 @@ async function main() {
await eggInstantVRFActionStrategy.deployed();
console.log(`eggInstantVRFActionStrategy = "${eggInstantVRFActionStrategy.address.toLowerCase()}"`);
*/

const newPetNFTLibrary = true;
let petNFTLibrary: PetNFTLibrary;
if (newPetNFTLibrary) {
Expand All @@ -286,6 +284,7 @@ async function main() {
});
await petNFT.deployed();
console.log(`petNFT = "${petNFT.address.toLowerCase()}"`);

/*
const VRFRequestInfo = (await ethers.getContractFactory("VRFRequestInfo")).connect(owner);
const vrfRequestInfo = await upgrades.upgradeProxy(VRF_REQUEST_INFO_ADDRESS, VRFRequestInfo, {
Expand Down Expand Up @@ -384,13 +383,15 @@ async function main() {
await verifyContracts([estforLibrary.address]);
await verifyContracts([adminAccess.address]);
await verifyContracts([wishingWell.address]); */
await verifyContracts([promotions.address]); /*
await verifyContracts([promotions.address]);
await verifyContracts([promotionsLibrary.address]);
/*
await verifyContracts([instantActions.address]);
await verifyContracts([vrfRequestInfo.address]);
await verifyContracts([instantVRFActions.address]);
await verifyContracts([genericInstantVRFActionStrategy.address]);
await verifyContracts([eggInstantVRFActionStrategy.address]);
*/
*/
await verifyContracts([petNFT.address]);
await verifyContracts([petNFTLibrary.address]);
/* await verifyContracts([lockedBankVaults.address]);
Expand Down
4 changes: 2 additions & 2 deletions scripts/editPromotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ async function main() {
randomAmounts: [],
}); */

const startTime = 1729513530; // Thur Oct 24th 09:00 UTC
const startTime = 1729513530; // Mon Oct 21th 12:25:30 UTC
const numDays = 2;
await promotions.connect(owner).editPromotion({
promotion: Promotion.HALLOWEEN_2024,
startTime,
endTime: startTime + 24 * 3600 * numDays,
minTotalXP: 0,
numDailyRandomItemsToPick: 1,
numDailyRandomItemsToPick: 0,
isMultiday: true,
brushCostMissedDay: "0",
brushCost: "0",
Expand Down
7 changes: 5 additions & 2 deletions test/Promotions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,17 @@ describe("Promotions", function () {
promotion = {
...promotion,
endTime: NOW + 3 * 24 * 3600,
numDailyRandomItemsToPick: 0,
guaranteedItemTokenIds: [EstforConstants.COIN],
guaranteedAmounts: [5],
};

await promotions.addPromotion(promotion);

// Doesn't not need oracle to be called
await promotions.connect(alice).mintPromotion(playerId, Promotion.XMAS_2023);
// Doesn't need oracle to be called
await expect(promotions.connect(alice).mintPromotion(playerId, Promotion.XMAS_2023))
.to.emit(itemNFT, "TransferBatch")
.withArgs(promotions.address, ethers.constants.AddressZero, alice.address, [EstforConstants.COIN], [5]);
await ethers.provider.send("evm_increaseTime", [3600 * 24]);
await promotions.connect(alice).mintPromotion(playerId, Promotion.XMAS_2023);
await ethers.provider.send("evm_increaseTime", [3600 * 24]);
Expand Down

0 comments on commit a75ead7

Please sign in to comment.