diff --git a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol index 9b022a2..0d53065 100644 --- a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol +++ b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol @@ -2,12 +2,12 @@ pragma solidity ^0.8.20; import "@openzeppelin/contracts/security/Pausable.sol"; -import "@openzeppelin/contracts/access/Ownable2Step.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; -contract InstantRewards is Ownable2Step, Pausable, ReentrancyGuard, EIP712 { +contract InstantRewards is Ownable, Pausable, ReentrancyGuard, EIP712 { bytes32 private constant CLAIM_TYPEHASH = keccak256("Claim(address to,uint256 sigExpiration,bytes32 taskId,uint256 amount)"); diff --git a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol index 1a64f77..48e5514 100644 --- a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol +++ b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol @@ -13,7 +13,7 @@ contract InstantRewardsFactory is Ownable { error StartTimeInPast(); error EndTimeBeforeStart(); - event InstantRewardsCreated(address indexed instantRewards, address indexed owner, string indexed name); + event InstantRewardsCreated(address indexed instantRewards, address indexed owner, string name); constructor(address owner) Ownable() { transferOwnership(owner); @@ -50,7 +50,6 @@ contract InstantRewardsFactory is Ownable { avatarUrl, description ); - instantRewards.transferOwnership(owner()); emit InstantRewardsCreated(address(instantRewards), owner(), name); return address(instantRewards); } diff --git a/packages/zevm-app-contracts/data/addresses.json b/packages/zevm-app-contracts/data/addresses.json index 29ef608..876e59c 100644 --- a/packages/zevm-app-contracts/data/addresses.json +++ b/packages/zevm-app-contracts/data/addresses.json @@ -13,7 +13,7 @@ "TimelockController": "0x44139C2150c11c25f517B8a8F974b59C82aEe709", "ZetaXPGov": "0x854032d484aE21acC34F36324E55A8080F21Af12", "invitationManagerV2": "0xb80f6360194Dd6B47B80bd8730b3dBb05a39e723", - "InstantRewardsFactory": "0x02F054A5BeeB2653d1c2403cBe9B262356fdD5E4" + "InstantRewardsFactory": "0xe79fA3b72278AdaE6d4B43cfFDACd6446F41d03f" }, "zeta_mainnet": { "disperse": "0x23ce409Ea60c3d75827d04D9db3d52F3af62e44d", @@ -24,7 +24,8 @@ "withdrawERC20": "0xa349B9367cc54b47CAb8D09A95836AE8b4D1d84E", "ZetaXP": "0x9A4e8bB5FFD8088ecF1DdE823e97Be8080BD38cb", "InstantRewards": "0xfD5dcBf68c81274B48593Cb4b0322e965741392b", - "ProofOfLiveness": "0x327c9837B183e69C522a30E6f91A42c86e057432" + "ProofOfLiveness": "0x327c9837B183e69C522a30E6f91A42c86e057432", + "InstantRewardsFactory": "0x03Cdd980eFe1EBfc0eC814C823e2f52c3704c8D9" } } } \ No newline at end of file diff --git a/packages/zevm-app-contracts/scripts/explorer.helpers.ts b/packages/zevm-app-contracts/scripts/explorer.helpers.ts index b88dfc8..078c8ca 100644 --- a/packages/zevm-app-contracts/scripts/explorer.helpers.ts +++ b/packages/zevm-app-contracts/scripts/explorer.helpers.ts @@ -1,13 +1,21 @@ import { run } from "hardhat"; -export const verifyContract = async (contractAddress: string, constructorArguments: any[]) => { +export const verifyContract = async (contractAddress: string, constructorArguments: any[], contract?: string) => { // Verification process console.log(`Verifying contract ${contractAddress}...`); try { - await run("verify:verify", { - address: contractAddress, - constructorArguments, - }); + if (contract) { + await run("verify:verify", { + address: contractAddress, + constructorArguments, + contract, + }); + } else { + await run("verify:verify", { + address: contractAddress, + constructorArguments, + }); + } console.log("Verification successful"); } catch (error) { console.error("Verification failed:", error); diff --git a/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts b/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts index 240977c..74cf021 100644 --- a/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts +++ b/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts @@ -1,13 +1,55 @@ import { isProtocolNetworkName } from "@zetachain/protocol-contracts"; import { ethers, network } from "hardhat"; -import { InstantRewardsFactory__factory } from "../../typechain-types"; +import { InstantRewardsFactory, InstantRewardsFactory__factory } from "../../typechain-types"; +import { instantRewards } from "../../typechain-types/contracts"; import { saveAddress } from "../address.helpers"; import { verifyContract } from "../explorer.helpers"; const networkName = network.name; -const owner = "0xD7E8bD37db625a4856E056D2617C9d140dB99182"; +const OWNERS = { + zeta_mainnet: "0xD7E8bD37db625a4856E056D2617C9d140dB99182", + zeta_testnet: "0xD7E8bD37db625a4856E056D2617C9d140dB99182", +}; + +//@ts-ignore +const owner = OWNERS[networkName]; + +const deployInstantRewardsSample = async (instantRewards: InstantRewardsFactory) => { + // get current timestamp from ethers + const block = await ethers.provider.getBlock("latest"); + const timestamp = block.timestamp; + const start = timestamp + 60 * 60 * 24 * 7; // 1 week from now + const end = start + 60 * 60 * 24 * 7 * 4; // 4 weeks from start + + const params = [ + owner, + start, + end, + "ZetaChain", + "https://zetachain.io", + "https://zetachain.io/logo.png", + "ZetaChain description", + ]; + + const tx = await instantRewards.createInstantRewards(...params, { + gasLimit: 25000000, + }); + + const rec = await tx.wait(); + console.log(rec); + // query event InstantRewardsCreated to get the address + const event = rec.events?.find((event) => event.event === "InstantRewardsCreated"); + + if (!event) throw new Error("InstantRewardsCreated event not found"); + //@ts-ignore + const instantRewardsAddress = event.args[0]; + if (!instantRewardsAddress) throw new Error("InstantRewards address not found"); + console.log("InstantRewards deployed to:", instantRewardsAddress); + + await verifyContract(instantRewardsAddress, [owner, ...params]); +}; const deployInstantRewards = async () => { if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); @@ -15,20 +57,27 @@ const deployInstantRewards = async () => { const InstantRewardsFactory = (await ethers.getContractFactory( "InstantRewardsFactory" )) as InstantRewardsFactory__factory; - const InstantRewards = await InstantRewardsFactory.deploy(owner); + const instantRewards = await InstantRewardsFactory.deploy(owner); + + await instantRewards.deployed(); - await InstantRewards.deployed(); + console.log("InstantRewards deployed to:", instantRewards.address); - console.log("InstantRewards deployed to:", InstantRewards.address); + saveAddress("InstantRewardsFactory", instantRewards.address, networkName); - saveAddress("InstantRewardsFactory", InstantRewards.address, networkName); + await verifyContract( + instantRewards.address, + [owner], + "contracts/instant-rewards/InstantRewardsV2.sol:InstantRewardsV2" + ); - await verifyContract(InstantRewards.address, [owner]); + return instantRewards; }; const main = async () => { if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); - await deployInstantRewards(); + const instantRewards = await deployInstantRewards(); + await deployInstantRewardsSample(instantRewards); }; main().catch((error) => {