From d32a789c38518506300e20ff6299eefddd2694c7 Mon Sep 17 00:00:00 2001 From: weiqiushi Date: Fri, 24 May 2024 15:19:09 +0800 Subject: [PATCH] Add view function for DividendContract, Add upgrade script --- contracts/dividend.sol | 12 ++++++++++++ scripts/deploy_dmc2.ts | 11 +++++++++-- scripts/update_dividend.ts | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 scripts/update_dividend.ts diff --git a/contracts/dividend.sol b/contracts/dividend.sol index 489456d..7d5dc2f 100644 --- a/contracts/dividend.sol +++ b/contracts/dividend.sol @@ -101,6 +101,18 @@ contract DividendContract is Initializable, UUPSUpgradeable, ReentrancyGuardUpgr return cycles[currentCycleIndex]; } + function getCycleInfos(uint256 startCycle, uint256 endCycle) public view returns (CycleInfo[] memory) { + require(startCycle <= endCycle, "Invalid cycle range"); + require(endCycle <= currentCycleIndex, "Invalid cycle range"); + + CycleInfo[] memory cycleInfos = new CycleInfo[](endCycle - startCycle + 1); + for (uint i = startCycle; i <= endCycle; i++) { + cycleInfos[i - startCycle] = cycles[i]; + } + + return cycleInfos; + } + function addTokenToWhitelist(address token) public onlyOwner { if (!tokenWhiteList[token]) { diff --git a/scripts/deploy_dmc2.ts b/scripts/deploy_dmc2.ts index 7f8ccb7..4176f79 100644 --- a/scripts/deploy_dmc2.ts +++ b/scripts/deploy_dmc2.ts @@ -1,8 +1,15 @@ import { ethers, upgrades } from "hardhat"; import { DividendContract, Exchange } from "../typechain-types"; +/* +DMC address: 0x05F2E406606f82Ec96DcE822B295278795c5053B +GWT address: 0x191Af8663fF88823d6b226621DC4700809D042fa +Dividend address: 0xD1AB647a6D3163bAD9D5C49C8A23Ee2811FC9e50 +exchange address: 0x785423901A501Bcef29Ab2a8cAFa25D5a8c027d3 +Layer1 DMC Address: 0x910e888698dA0C2eCC97A04A137Aa1CfC1Dfd209 +*/ + async function main() { - let signers = await ethers.getSigners(); let dmc = await (await ethers.deployContract("DMC", [ ethers.parseEther("1000000000"), // 总量10亿 ["0x000000000EefEA4e8A67d7434a02054b955Da62c", "0xDDDDDdDd91f172a0ceA030d20f68348E0370fE66", "0xCcCCCCCC5b74A876dB192d55ef8e4A60EfA1Eb5C", "0xad82A5fb394a525835A3a6DC34C1843e19160CFA"], @@ -11,7 +18,7 @@ async function main() { let dmcAddress = await dmc.getAddress(); console.log("DMC address:", dmcAddress); - let gwt = await (await ethers.deployContract("GWT", [[], []])).waitForDeployment(); + let gwt = await (await ethers.deployContract("GWT", [["0xad82A5fb394a525835A3a6DC34C1843e19160CFA"], [ethers.parseEther("5000000")]])).waitForDeployment(); let gwtAddress = await gwt.getAddress(); console.log("GWT address:", gwtAddress); diff --git a/scripts/update_dividend.ts b/scripts/update_dividend.ts new file mode 100644 index 0000000..bbf5fe8 --- /dev/null +++ b/scripts/update_dividend.ts @@ -0,0 +1,14 @@ +import { ethers, upgrades } from "hardhat"; +const DIVIDEND_ADDRESS = "0xD1AB647a6D3163bAD9D5C49C8A23Ee2811FC9e50" + +async function main() { + console.log("upgrading DividendContract..."); + (await upgrades.upgradeProxy(DIVIDEND_ADDRESS, await ethers.getContractFactory("DividendContract"), { + kind: "uups", + timeout: 0 + })).waitForDeployment(); +} + +main().then(() => { + process.exit(0); +}); \ No newline at end of file