Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add forgewearable2 raffle #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
111 changes: 111 additions & 0 deletions scripts/startForgeWearableRaffle2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/* global ethers */
// import { LedgerSigner } from "@ethersproject/hardware-wallets";
import * as hre from "hardhat";
import {
gasPrice,
getSigner,
maticRafflesAddress as rafflesAddress,
maticTicketAddress as ticketAddress,
} from "../helpers";
import { Signer } from "@ethersproject/abstract-signer";

const prizeAddress = "0x4fDfc1B53Fd1D80d969C984ba7a8CE4c7bAaD442"; // forge diamond
const itemManager = "0x8D46fd7160940d89dA026D59B2e819208E714E82";

async function main() {
let signer: Signer = await getSigner(hre, itemManager); // should be forge schematic owner
// console.log("signer:", signer);

const rafflesContract = await hre.ethers.getContractAt(
"RafflesContract",
rafflesAddress,
signer
);

let prizeContract = await hre.ethers.getContractAt(
"ERC1155Voucher",
prizeAddress,
signer
);

const time = 3600 * 72; /* 72 hours */

const common = [370, 371, 372, 375]; //
const uncommon = [373, 377]; //
const rare = [374, 376, 378, 379]; //
const legendary: number[] = [380, 381, 382, 383]; //
const mythical = [384]; //
const godlike = [385, 386, 387]; //
const quantities = [400, 200, 100, 40, 20, 2];
const prizes = [common, uncommon, rare, legendary, mythical, godlike];

const prizeQuantities: number[] = [];
const raffleItems: any[] = [];

for (let ticketId = 0; ticketId < prizes.length; ticketId++) {
const itemIds = prizes[ticketId];
let prizeQuantity = quantities[ticketId];
if (prizeQuantity === 0) {
continue;
}
const prizeItems: any[] = [];
for (let j = 0; j < itemIds.length; j++) {
const prizeId = itemIds[j];

console.log("prize id:", prizeId);

prizeQuantity = quantities[ticketId];

console.log("ticket id:", ticketId);

prizeQuantities.push(prizeQuantity);
prizeItems.push({
prizeAddress: prizeAddress,
prizeId: prizeId,
prizeQuantity: prizeQuantity,
});
}

raffleItems.push({
ticketAddress: ticketAddress,
ticketId: ticketId,
raffleItemPrizes: prizeItems,
});
}

raffleItems.forEach((item) => {
console.log(item.raffleItemPrizes);
});

const owner = await rafflesContract.owner();
console.log("owner:", owner);

console.log("Execute startRaffle function");

console.log("Set Approval");
let tx = await prizeContract.setApprovalForAll(rafflesAddress, true, {
gasPrice: gasPrice,
});
await tx.wait();

console.log("Deploy Raffle");
tx = await rafflesContract.startRaffle(time, raffleItems, {
gasPrice: gasPrice,
});
await tx.wait();

console.log("Raffle started");
}

exports.startRaffle = main;

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
if (require.main === module) {
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
}
26 changes: 5 additions & 21 deletions scripts/testEndRaffle.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
/* global ethers hre */
import { run, ethers, network } from "hardhat";
import {
impersonate,
maticRafflesAddress,
maticTicketAddress,
} from "../helpers";
import { DeployRaffleVoucherArgs } from "../tasks/deployRaffleVoucher";
import { DeployRealmConverterTaskArgs } from "../tasks/deployRealmConverter";
import { StartRealmRaffleTaskArgs } from "../tasks/startRealmRaffle";
import { ethers, network } from "hardhat";
import { impersonate, maticRafflesAddress } from "../helpers";
import { RafflesContract } from "../typechain-types/RafflesContract";
import { getWins, getWinsInfo } from "./getWins";
import { SelfDestructooor__factory } from "../typechain-types/factories/SelfDestructooor__factory";
import { IERC20 } from "../typechain-types/IERC20";
import { TransferRealm } from "../typechain-types/TransferRealm";
import { ERC1155Voucher } from "../typechain-types/ERC1155Voucher";

import { TestERC721__factory } from "../typechain-types/factories/TestERC721__factory";
import { TestERC721 } from "../typechain-types/TestERC721";

export async function main() {
//Setup the variables
Expand All @@ -37,7 +25,7 @@ export async function main() {
ethers.provider.send("evm_increaseTime", [86401 * 3]);

//draw number
await raffle.drawRandomNumber("10");
await raffle.drawRandomNumber("12");

//fulfill randomness
const vrfCoordinator = "0x3d2341ADb2D31f1c5530cDC622016af293177AE0";
Expand All @@ -49,7 +37,7 @@ export async function main() {

const encodedVrfSeed = ethers.utils.defaultAbiCoder.encode(
["bytes32", "uint256", "address", "uint256"],
[keyhash, "0", "0x6c723cac1E35FE29a175b287AE242d424c52c1CE", "7"]
[keyhash, "0", "0x6c723cac1E35FE29a175b287AE242d424c52c1CE", "10"]
);

const vrfSeed = ethers.utils.keccak256(encodedVrfSeed);
Expand Down Expand Up @@ -94,11 +82,7 @@ export async function main() {
await raffle?.rawFulfillRandomness(requestId, "10000");

//claim tickets
const winsInfo = await getWinsInfo(
raffle,
"9",
"0x51208e5cC9215c6360210C48F81C8270637a5218"
);
const winsInfo = await getWinsInfo(raffle, "12", "your address");

console.log("wins info:", winsInfo);

Expand Down