From 908d0981ccefb053bf2ca5541a9d991e979c84e7 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Tue, 10 Dec 2024 10:03:36 -0300 Subject: [PATCH 1/4] feat: add params to IR factory --- .../instant-rewards/InstantRewardsFactory.sol | 24 +++++++++++++----- .../instant-rewards/InstantRewardsV2.sol | 12 +++++++-- .../zevm-app-contracts/data/addresses.json | 5 ++-- packages/zevm-app-contracts/hardhat.config.ts | 11 ++++++-- .../scripts/instant-rewards/deploy-v2.ts | 4 +-- .../instant-rewards-v2-compatibility.ts | 16 +++++++++--- .../instant-rewards/instant-rewards-v2.ts | 25 ++++++++++++++++--- 7 files changed, 75 insertions(+), 22 deletions(-) diff --git a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol index 3a0560f..1a64f77 100644 --- a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol +++ b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; -import "@openzeppelin/contracts/access/Ownable2Step.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; import "./InstantRewardsV2.sol"; -contract InstantRewardsFactory is Ownable2Step { +contract InstantRewardsFactory is Ownable { bool public allowPublicCreation = false; error AccessDenied(); @@ -13,7 +13,7 @@ contract InstantRewardsFactory is Ownable2Step { error StartTimeInPast(); error EndTimeBeforeStart(); - event InstantRewardsCreated(address indexed instantRewards, address indexed owner); + event InstantRewardsCreated(address indexed instantRewards, address indexed owner, string indexed name); constructor(address owner) Ownable() { transferOwnership(owner); @@ -27,7 +27,10 @@ contract InstantRewardsFactory is Ownable2Step { address signerAddress, uint256 start, uint256 end, - string memory name + string memory name, + string memory promoUrl, + string memory avatarUrl, + string memory description ) external returns (address) { if (signerAddress == address(0)) revert InvalidSignerAddress(); if (bytes(name).length == 0) revert EmptyName(); @@ -37,9 +40,18 @@ contract InstantRewardsFactory is Ownable2Step { bool isOwner = owner() == msg.sender; if (!allowPublicCreation && !isOwner) revert AccessDenied(); - InstantRewardsV2 instantRewards = new InstantRewardsV2(signerAddress, owner(), start, end, name); + InstantRewardsV2 instantRewards = new InstantRewardsV2( + signerAddress, + owner(), + start, + end, + name, + promoUrl, + avatarUrl, + description + ); instantRewards.transferOwnership(owner()); - emit InstantRewardsCreated(address(instantRewards), owner()); + emit InstantRewardsCreated(address(instantRewards), owner(), name); return address(instantRewards); } } diff --git a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsV2.sol b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsV2.sol index 145eeeb..80df1aa 100644 --- a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsV2.sol +++ b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsV2.sol @@ -8,6 +8,9 @@ contract InstantRewardsV2 is InstantRewards { uint256 public start; uint256 public end; + string public promoUrl; + string public avatarUrl; + string public description; event TimeframeUpdated(uint256 start, uint256 end); @@ -20,13 +23,19 @@ contract InstantRewardsV2 is InstantRewards { address owner, uint256 start_, uint256 end_, - string memory name_ + string memory name_, + string memory promoUrl_, + string memory avatarUrl_, + string memory description_ ) InstantRewards(signerAddress_, owner) { if (signerAddress_ == address(0)) revert InvalidAddress(); if (start_ > end_) revert InvalidTimeframe(); start = start_; end = end_; name = name_; + promoUrl = promoUrl_; + avatarUrl = avatarUrl_; + description = description_; } function isActive() public view returns (bool) { @@ -48,7 +57,6 @@ contract InstantRewardsV2 is InstantRewards { } function withdraw(address wallet, uint256 amount) public override onlyOwner { - if (isActive()) revert InstantRewardStillActive(); super.withdraw(wallet, amount); } } diff --git a/packages/zevm-app-contracts/data/addresses.json b/packages/zevm-app-contracts/data/addresses.json index acfec2f..29ef608 100644 --- a/packages/zevm-app-contracts/data/addresses.json +++ b/packages/zevm-app-contracts/data/addresses.json @@ -12,7 +12,8 @@ "ProofOfLiveness": "0x981EB6fD19717Faf293Fba0cBD05C6Ac97b8C808", "TimelockController": "0x44139C2150c11c25f517B8a8F974b59C82aEe709", "ZetaXPGov": "0x854032d484aE21acC34F36324E55A8080F21Af12", - "invitationManagerV2": "0xb80f6360194Dd6B47B80bd8730b3dBb05a39e723" + "invitationManagerV2": "0xb80f6360194Dd6B47B80bd8730b3dBb05a39e723", + "InstantRewardsFactory": "0x02F054A5BeeB2653d1c2403cBe9B262356fdD5E4" }, "zeta_mainnet": { "disperse": "0x23ce409Ea60c3d75827d04D9db3d52F3af62e44d", @@ -22,7 +23,7 @@ "invitationManager": "0x3649C03C472B698213926543456E9c21081e529d", "withdrawERC20": "0xa349B9367cc54b47CAb8D09A95836AE8b4D1d84E", "ZetaXP": "0x9A4e8bB5FFD8088ecF1DdE823e97Be8080BD38cb", - "InstantRewards": "0x018412ec1D5bBb864eAe0A4BECaa683052890238", + "InstantRewards": "0xfD5dcBf68c81274B48593Cb4b0322e965741392b", "ProofOfLiveness": "0x327c9837B183e69C522a30E6f91A42c86e057432" } } diff --git a/packages/zevm-app-contracts/hardhat.config.ts b/packages/zevm-app-contracts/hardhat.config.ts index 6a7320b..05120c4 100644 --- a/packages/zevm-app-contracts/hardhat.config.ts +++ b/packages/zevm-app-contracts/hardhat.config.ts @@ -40,8 +40,8 @@ const config: HardhatUserConfig = { chainId: 7001, network: "zeta_testnet", urls: { - apiURL: "https://zetachain-athens-3.blockscout.com/api", - browserURL: "https://zetachain-athens-3.blockscout.com", + apiURL: "https://zetachain-testnet.blockscout.com/api", + browserURL: "https://zetachain-testnet.blockscout.com", }, }, ], @@ -52,6 +52,13 @@ const config: HardhatUserConfig = { }, networks: { ...getHardhatConfigNetworks(), + zeta_mainnet: { + accounts: PRIVATE_KEYS, + chainId: 7000, + gas: "auto", + gasMultiplier: 3, + url: `https://zetachain-evm.blockpi.network/v1/rpc/public`, + }, }, solidity: { compilers: [ 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 67319f3..240977c 100644 --- a/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts +++ b/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts @@ -7,7 +7,7 @@ import { verifyContract } from "../explorer.helpers"; const networkName = network.name; -const owner = "0x1d24d94520B94B26351f6573de5ef9731c48531A"; +const owner = "0xD7E8bD37db625a4856E056D2617C9d140dB99182"; const deployInstantRewards = async () => { if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); @@ -21,7 +21,7 @@ const deployInstantRewards = async () => { console.log("InstantRewards deployed to:", InstantRewards.address); - saveAddress("InstantRewards", InstantRewards.address, networkName); + saveAddress("InstantRewardsFactory", InstantRewards.address, networkName); await verifyContract(InstantRewards.address, [owner]); }; diff --git a/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2-compatibility.ts b/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2-compatibility.ts index 7ac1ff1..87dfb31 100644 --- a/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2-compatibility.ts +++ b/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2-compatibility.ts @@ -48,7 +48,16 @@ describe("Instant Rewards V2 Contract Compatibility test", () => { const start = (await ethers.provider.getBlock("latest")).timestamp + 1; const end = start + 1000; - instantRewards = await instantRewardsFactory.deploy(signer.address, owner.address, start, end, "Instant Rewards"); + instantRewards = await instantRewardsFactory.deploy( + signer.address, + owner.address, + start, + end, + "Instant Rewards", + "http://img.com", + "http://avatar.com", + "Description" + ); await instantRewards.deployed(); }); @@ -322,7 +331,7 @@ describe("Instant Rewards V2 Contract Compatibility test", () => { expect(balanceOfUser).to.be.eq(userBalanceBefore.add(amountToWithdraw)); }); - it("Should fail if try to withdraw an active IR", async () => { + it("Should be able to withdraw an active IR", async () => { const amount = utils.parseEther("2"); const amountToWithdraw = utils.parseEther("1"); // transfer some funds to the contract @@ -331,7 +340,6 @@ describe("Instant Rewards V2 Contract Compatibility test", () => { value: amount, }); - const tx = instantRewards.withdraw(user.address, amountToWithdraw); - await expect(tx).to.revertedWith("InstantRewardStillActive"); + await instantRewards.withdraw(user.address, amountToWithdraw); }); }); diff --git a/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2.ts b/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2.ts index 41009c6..1395d82 100644 --- a/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2.ts +++ b/packages/zevm-app-contracts/test/instant-rewards/instant-rewards-v2.ts @@ -17,7 +17,6 @@ describe("Instant Rewards Contract test", () => { const instantRewardsFactoryF = await ethers.getContractFactory("InstantRewardsFactory"); instantRewardsFactory = (await instantRewardsFactoryF.deploy(owner.address)) as InstantRewardsFactory; await instantRewardsFactory.deployed(); - await instantRewardsFactory.connect(owner).acceptOwnership(); }); it("Should deploy an IR instance", async () => { @@ -25,7 +24,9 @@ describe("Instant Rewards Contract test", () => { const start = currentBlock.timestamp + 1000; const end = start + 1000; const name = "Instant Rewards"; - const tx = instantRewardsFactory.connect(owner).createInstantRewards(signer.address, start, end, name); + const tx = instantRewardsFactory + .connect(owner) + .createInstantRewards(signer.address, start, end, name, "http://img.com", "http://avatar.com", "Description"); await expect(tx).to.emit(instantRewardsFactory, "InstantRewardsCreated"); const events = await instantRewardsFactory.queryFilter("InstantRewardsCreated"); @@ -47,7 +48,15 @@ describe("Instant Rewards Contract test", () => { const start = currentBlock.timestamp + 1000; const end = start + 1000; const name = "Instant Rewards"; - const tx = instantRewardsFactory.createInstantRewards(signer.address, start, end, name); + const tx = instantRewardsFactory.createInstantRewards( + signer.address, + start, + end, + name, + "http://img.com", + "http://avatar.com", + "Description" + ); await expect(tx).to.revertedWith("AccessDenied"); }); @@ -58,7 +67,15 @@ describe("Instant Rewards Contract test", () => { const start = currentBlock.timestamp + 1000; const end = start + 1000; const name = "Instant Rewards"; - const tx = instantRewardsFactory.createInstantRewards(signer.address, start, end, name); + const tx = instantRewardsFactory.createInstantRewards( + signer.address, + start, + end, + name, + "http://img.com", + "http://avatar.com", + "Description" + ); await expect(tx).to.emit(instantRewardsFactory, "InstantRewardsCreated"); }); }); From ded93e75d6ab2faee591ff6497b47f51ee9b7eeb Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Mon, 16 Dec 2024 11:57:02 -0300 Subject: [PATCH 2/4] deploy to mainnet --- .../instant-rewards/InstantRewards.sol | 4 +- .../instant-rewards/InstantRewardsFactory.sol | 3 +- .../zevm-app-contracts/data/addresses.json | 5 +- .../scripts/explorer.helpers.ts | 18 +++-- .../scripts/instant-rewards/deploy-v2.ts | 65 ++++++++++++++++--- 5 files changed, 76 insertions(+), 19 deletions(-) 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) => { From 75dbf0fff3037459ab84c9c8ffda096425a2ae80 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Mon, 16 Dec 2024 12:11:02 -0300 Subject: [PATCH 3/4] redeploy mainnet --- packages/zevm-app-contracts/data/addresses.json | 2 +- .../scripts/instant-rewards/deploy-v2.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/zevm-app-contracts/data/addresses.json b/packages/zevm-app-contracts/data/addresses.json index 876e59c..b3da2be 100644 --- a/packages/zevm-app-contracts/data/addresses.json +++ b/packages/zevm-app-contracts/data/addresses.json @@ -25,7 +25,7 @@ "ZetaXP": "0x9A4e8bB5FFD8088ecF1DdE823e97Be8080BD38cb", "InstantRewards": "0xfD5dcBf68c81274B48593Cb4b0322e965741392b", "ProofOfLiveness": "0x327c9837B183e69C522a30E6f91A42c86e057432", - "InstantRewardsFactory": "0x03Cdd980eFe1EBfc0eC814C823e2f52c3704c8D9" + "InstantRewardsFactory": "0xAf5693bBC958e442462F411F46421e389c7A8602" } } } \ No newline at end of file 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 74cf021..1010a45 100644 --- a/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts +++ b/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts @@ -10,7 +10,7 @@ const networkName = network.name; const OWNERS = { zeta_mainnet: "0xD7E8bD37db625a4856E056D2617C9d140dB99182", - zeta_testnet: "0xD7E8bD37db625a4856E056D2617C9d140dB99182", + zeta_testnet: "0x1d24d94520B94B26351f6573de5ef9731c48531A", }; //@ts-ignore @@ -48,7 +48,11 @@ const deployInstantRewardsSample = async (instantRewards: InstantRewardsFactory) if (!instantRewardsAddress) throw new Error("InstantRewards address not found"); console.log("InstantRewards deployed to:", instantRewardsAddress); - await verifyContract(instantRewardsAddress, [owner, ...params]); + await verifyContract( + instantRewardsAddress, + [owner, ...params], + "contracts/instant-rewards/InstantRewardsV2.sol:InstantRewardsV2" + ); }; const deployInstantRewards = async () => { @@ -65,11 +69,7 @@ const deployInstantRewards = async () => { saveAddress("InstantRewardsFactory", instantRewards.address, networkName); - await verifyContract( - instantRewards.address, - [owner], - "contracts/instant-rewards/InstantRewardsV2.sol:InstantRewardsV2" - ); + await verifyContract(instantRewards.address, [owner]); return instantRewards; }; From de743def68d53c933d08fe76d072dc93cf5ace12 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Mon, 16 Dec 2024 15:24:23 -0300 Subject: [PATCH 4/4] redeploy testnet --- packages/zevm-app-contracts/data/addresses.json | 2 +- .../scripts/instant-rewards/deploy-v2.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/zevm-app-contracts/data/addresses.json b/packages/zevm-app-contracts/data/addresses.json index b3da2be..44b5424 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": "0xe79fA3b72278AdaE6d4B43cfFDACd6446F41d03f" + "InstantRewardsFactory": "0x3A557fe83FD734f21DD35E98f546B9706d486F55" }, "zeta_mainnet": { "disperse": "0x23ce409Ea60c3d75827d04D9db3d52F3af62e44d", 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 1010a45..37ff9af 100644 --- a/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts +++ b/packages/zevm-app-contracts/scripts/instant-rewards/deploy-v2.ts @@ -15,8 +15,14 @@ const OWNERS = { //@ts-ignore const owner = OWNERS[networkName]; +console.log("Owner:", owner); + +const deployInstantRewardsSample = async (instantRewardsFactoryAddress: string) => { + const [deployer] = await ethers.getSigners(); + + const InstantRewardsFactory = new InstantRewardsFactory__factory(deployer); + const instantRewards = InstantRewardsFactory.attach(instantRewardsFactoryAddress); -const deployInstantRewardsSample = async (instantRewards: InstantRewardsFactory) => { // get current timestamp from ethers const block = await ethers.provider.getBlock("latest"); const timestamp = block.timestamp; @@ -38,7 +44,7 @@ const deployInstantRewardsSample = async (instantRewards: InstantRewardsFactory) }); const rec = await tx.wait(); - console.log(rec); + // query event InstantRewardsCreated to get the address const event = rec.events?.find((event) => event.event === "InstantRewardsCreated"); @@ -70,6 +76,7 @@ const deployInstantRewards = async () => { saveAddress("InstantRewardsFactory", instantRewards.address, networkName); await verifyContract(instantRewards.address, [owner]); + // await verifyContract("0xAf5693bBC958e442462F411F46421e389c7A8602", [owner]); return instantRewards; }; @@ -77,7 +84,8 @@ const deployInstantRewards = async () => { const main = async () => { if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); const instantRewards = await deployInstantRewards(); - await deployInstantRewardsSample(instantRewards); + await deployInstantRewardsSample(instantRewards.address); + // await deployInstantRewardsSample("0x3A557fe83FD734f21DD35E98f546B9706d486F55"); }; main().catch((error) => {