Skip to content

Commit

Permalink
Add view function for DividendContract, Add upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiushi committed May 24, 2024
1 parent eb98f4b commit d32a789
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
12 changes: 12 additions & 0 deletions contracts/dividend.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
11 changes: 9 additions & 2 deletions scripts/deploy_dmc2.ts
Original file line number Diff line number Diff line change
@@ -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"],
Expand All @@ -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);

Expand Down
14 changes: 14 additions & 0 deletions scripts/update_dividend.ts
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit d32a789

Please sign in to comment.