Skip to content

Commit

Permalink
add players address to promotions (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
doublesharp authored Nov 1, 2024
1 parent ad26d6a commit 9e0853c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
8 changes: 4 additions & 4 deletions contracts/Promotions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
error PercentNotTotal100();

AdminAccess private _adminAccess;
IPlayers private _players;
ItemNFT private _itemNFT;
PlayerNFT private _playerNFT;
IBrushToken private _brush;
Expand All @@ -85,10 +86,7 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
uint256 public constant FINAL_PROMOTION_DAY_INDEX = 31;

modifier isOwnerOfPlayerAndActive(uint256 playerId) {
require(
IPlayers(_itemNFT.getPlayersAddress()).isOwnerOfPlayerAndActive(_msgSender(), playerId),
NotOwnerOfPlayerAndActive()
);
require(_players.isOwnerOfPlayerAndActive(_msgSender(), playerId), NotOwnerOfPlayerAndActive());
_;
}

Expand All @@ -98,6 +96,7 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
}

function initialize(
IPlayers players,
ItemNFT itemNFT,
PlayerNFT playerNFT,
IBrushToken brush,
Expand All @@ -109,6 +108,7 @@ contract Promotions is UUPSUpgradeable, OwnableUpgradeable {
__UUPSUpgradeable_init();
__Ownable_init(_msgSender());

_players = players;
_itemNFT = itemNFT;
_playerNFT = playerNFT;
_brush = brush;
Expand Down
5 changes: 5 additions & 0 deletions data/abi/Promotions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,11 @@
},
{
"inputs": [
{
"internalType": "contract IPlayers",
"name": "players",
"type": "address"
},
{
"internalType": "contract ItemNFT",
"name": "itemNFT",
Expand Down
47 changes: 24 additions & 23 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,29 +366,6 @@ async function main() {
await promotionsLibrary.waitForDeployment();
console.log(`promotionsLibrary = "${(await promotionsLibrary.getAddress()).toLowerCase()}"`);

const Promotions = await ethers.getContractFactory("Promotions", {
libraries: {PromotionsLibrary: await promotionsLibrary.getAddress()}
});
const promotions = (await upgrades.deployProxy(
Promotions,
[
await itemNFT.getAddress(),
await playerNFT.getAddress(),
await brush.getAddress(),
await treasury.getAddress(),
DEV_ADDRESS,
await adminAccess.getAddress(),
isBeta
],
{
kind: "uups",
unsafeAllow: ["external-library-linking"],
timeout
}
)) as unknown as Promotions;
await promotions.waitForDeployment();
console.log(`promotions = "${(await promotions.getAddress()).toLowerCase()}"`);

const buyPath: [string, string] = [await wftm.getAddress(), await brush.getAddress()];
const Quests = await ethers.getContractFactory("Quests");
const quests = (await upgrades.deployProxy(Quests, [await world.getAddress(), await router.getAddress(), buyPath], {
Expand Down Expand Up @@ -511,6 +488,30 @@ async function main() {
await players.waitForDeployment();
console.log(`players = "${(await players.getAddress()).toLowerCase()}"`);

const Promotions = await ethers.getContractFactory("Promotions", {
libraries: {PromotionsLibrary: await promotionsLibrary.getAddress()}
});
const promotions = (await upgrades.deployProxy(
Promotions,
[
await players.getAddress(),
await itemNFT.getAddress(),
await playerNFT.getAddress(),
await brush.getAddress(),
await treasury.getAddress(),
DEV_ADDRESS,
await adminAccess.getAddress(),
isBeta
],
{
kind: "uups",
unsafeAllow: ["external-library-linking"],
timeout
}
)) as unknown as Promotions;
await promotions.waitForDeployment();
console.log(`promotions = "${(await promotions.getAddress()).toLowerCase()}"`);

const PassiveActions = await ethers.getContractFactory("PassiveActions", {
libraries: {WorldLibrary: await worldLibrary.getAddress()}
});
Expand Down
43 changes: 22 additions & 21 deletions test/Players/PlayersFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,6 @@ export const playersFixture = async function () {
}
)) as unknown as PlayerNFT;

const promotionsLibrary = (await ethers.deployContract("PromotionsLibrary")) as PromotionsLibrary;
const Promotions = await ethers.getContractFactory("Promotions", {
libraries: {PromotionsLibrary: await promotionsLibrary.getAddress()}
});
const promotions = (await upgrades.deployProxy(
Promotions,
[
await itemNFT.getAddress(),
await playerNFT.getAddress(),
await brush.getAddress(),
await treasury.getAddress(),
await dev.getAddress(),
await adminAccess.getAddress(),
isBeta
],
{
kind: "uups",
unsafeAllow: ["external-library-linking"]
}
)) as unknown as Promotions;

const buyPath: [string, string] = [alice.address, await brush.getAddress()];
const Quests = await ethers.getContractFactory("Quests");
const quests = (await upgrades.deployProxy(Quests, [await world.getAddress(), await router.getAddress(), buyPath], {
Expand Down Expand Up @@ -290,6 +269,28 @@ export const playersFixture = async function () {
}
)) as unknown as Players;

const promotionsLibrary = (await ethers.deployContract("PromotionsLibrary")) as PromotionsLibrary;
const Promotions = await ethers.getContractFactory("Promotions", {
libraries: {PromotionsLibrary: await promotionsLibrary.getAddress()}
});
const promotions = (await upgrades.deployProxy(
Promotions,
[
await players.getAddress(),
await itemNFT.getAddress(),
await playerNFT.getAddress(),
await brush.getAddress(),
await treasury.getAddress(),
await dev.getAddress(),
await adminAccess.getAddress(),
isBeta
],
{
kind: "uups",
unsafeAllow: ["external-library-linking"]
}
)) as unknown as Promotions;

const InstantActions = await ethers.getContractFactory("InstantActions");
const instantActions = (await upgrades.deployProxy(
InstantActions,
Expand Down

0 comments on commit 9e0853c

Please sign in to comment.