From 2bac44e6b26c7395880ce567a95392352f542fa4 Mon Sep 17 00:00:00 2001 From: vzotova Date: Sat, 14 Mar 2020 20:06:21 +0300 Subject: [PATCH] Apply suggestions from code review #1764 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: David Núñez --- nucypher/blockchain/eth/deployers.py | 8 ++++---- .../blockchain/eth/sol/source/contracts/StakingEscrow.sol | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nucypher/blockchain/eth/deployers.py b/nucypher/blockchain/eth/deployers.py index 67745372b..c8720b2f0 100644 --- a/nucypher/blockchain/eth/deployers.py +++ b/nucypher/blockchain/eth/deployers.py @@ -693,8 +693,8 @@ class StakingEscrowDeployer(BaseContractDeployer, UpgradeableContractMixin, Owna # TODO: Consider looking for absence of Initialized event - see #1193 # This mimics initialization pre-condition in Issuer (StakingEscrow's base contract) - current_supply_1 = deployed_contract.functions.currentSupply1().call() - return current_supply_1 == 0 + current_minting_period = deployed_contract.functions.currentMintingPeriod().call() + return current_minting_period == 0 @property def is_active(self) -> bool: @@ -705,8 +705,8 @@ class StakingEscrowDeployer(BaseContractDeployer, UpgradeableContractMixin, Owna # TODO: Consider looking for Initialized event - see #1193 # This mimics isInitialized() modifier in Issuer (StakingEscrow's base contract) - current_supply_1 = deployed_contract.functions.currentSupply1().call() - return current_supply_1 != 0 + current_minting_period = deployed_contract.functions.currentMintingPeriod().call() + return current_minting_period != 0 class PolicyManagerDeployer(BaseContractDeployer, UpgradeableContractMixin, OwnableContractMixin): diff --git a/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol b/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol index 6f98e01ad..b3f531b9e 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol @@ -545,6 +545,7 @@ contract StakingEscrow is Issuer { /** * @notice Batch deposit. Allowed only initial deposit for each staker * @param _stakers Stakers + * @param _numberOfSubStakes Number of sub-stakes which belong to staker in _values and _periods arrays * @param _values Amount of tokens to deposit for each staker * @param _periods Amount of periods during which tokens will be locked for each staker */ @@ -569,15 +570,14 @@ contract StakingEscrow is Issuer { for (uint256 i = 0; i < _stakers.length; i++) { address staker = _stakers[i]; uint256 numberOfSubStakes = _numberOfSubStakes[i]; - require(numberOfSubStakes > 0 && subStakesLength >= i + numberOfSubStakes); + uint256 endIndex = j + numberOfSubStakes; + require(numberOfSubStakes > 0 && subStakesLength >= endIndex); StakerInfo storage info = stakerInfo[staker]; require(info.subStakes.length == 0); - require(workerToStaker[staker] == address(0) || workerToStaker[staker] == info.worker, - "A staker can't be a worker for another staker"); + require(workerToStaker[staker] == address(0), "A staker can't be a worker for another staker"); stakers.push(staker); policyManager.register(staker, previousPeriod); - uint256 endIndex = j + numberOfSubStakes; for (; j < endIndex; j++) { uint256 value = _values[j]; uint16 periods = _periods[j];