diff --git a/contracts/dividend.sol b/contracts/dividend.sol index bd9b60d..4f89f35 100644 --- a/contracts/dividend.sol +++ b/contracts/dividend.sol @@ -77,21 +77,21 @@ contract DividendContract is Initializable, UUPSUpgradeable, ReentrancyGuardUpgr event NewCycle(uint256 cycleIndex, uint256 startBlock); event Withdraw(address indexed user, address token, uint256 amount); - function initialize(address _stakingToken, uint256 _cycleMaxLength, address[] memory tokenList) public initializer { + function initialize(address _stakingToken, uint256 _cycleMaxLength, address[] memory _tokenList) public initializer { __UUPSUpgradeable_init(); __ReentrancyGuard_init(); __Ownable_init(msg.sender); - __DividendContractUpgradable_init(_stakingToken, _cycleMaxLength, tokenList); + __DividendContractUpgradable_init(_stakingToken, _cycleMaxLength, _tokenList); } - function __DividendContractUpgradable_init(address _stakingToken, uint256 _cycleMaxLength, address[] memory tokenList) public onlyInitializing { + function __DividendContractUpgradable_init(address _stakingToken, uint256 _cycleMaxLength, address[] memory _tokenList) public onlyInitializing { stakingToken = _stakingToken; cycleMaxLength = _cycleMaxLength; cycleStartBlock = block.number; - for (uint i = 0; i < tokenList.length; i++) { - tokenWhiteList[tokenList[i]] = true; - tokenWhiteListArray.push(tokenList[i]); + for (uint i = 0; i < _tokenList.length; i++) { + tokenWhiteList[_tokenList[i]] = true; + tokenWhiteListArray.push(_tokenList[i]); } } diff --git a/test/test_dividend2.ts b/test/test_dividend2.ts index 3d6efa4..292eca4 100644 --- a/test/test_dividend2.ts +++ b/test/test_dividend2.ts @@ -29,17 +29,13 @@ describe("Devidend", function () { //dividend = await (await ethers.deployContract("Dividend2", [await dmc.getAddress(), 1000])).waitForDeployment() // add init token address as white list, address(0) and gwt token address - //await (await dividend.addTokenAddress(await gwt.getAddress())).wait(); - //await (await dividend.addTokenAddress("0x" const tokenWhiteList = [await gwt.getAddress(), "0x0000000000000000000000000000000000000000"]; - dividend = await ( - await ethers.deployContract("DividendContract", [ - await dmc.getAddress(), - 1000, - tokenWhiteList, - ]) - ).waitForDeployment(); + dividend = await (await upgrades.deployProxy(await ethers.getContractFactory("DividendContract"), [ + await dmc.getAddress(), + 1000, + tokenWhiteList + ])).waitForDeployment() as unknown as DividendContract; // 给signers[0] 1000个GWT await (await gwt.enableMinter([signers[0].address])).wait();