mirror of https://github.com/nucypher/nucypher.git
Contracts: public -> external where possible
parent
546fc83b44
commit
16757e32a2
|
@ -10,7 +10,7 @@ import "zeppelin/math/Math.sol";
|
|||
|
||||
/**
|
||||
* @notice Supervises stakers' behavior and punishes when something's wrong.
|
||||
* @dev |v1.1.1|
|
||||
* @dev |v1.1.2|
|
||||
*/
|
||||
contract Adjudicator is Upgradeable {
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import "zeppelin/token/ERC20/SafeERC20.sol";
|
|||
|
||||
/**
|
||||
* @notice Contract for calculate issued tokens
|
||||
* @dev |v1.1.2|
|
||||
* @dev |v1.1.3|
|
||||
*/
|
||||
contract Issuer is Upgradeable {
|
||||
using SafeERC20 for NuCypherToken;
|
||||
|
@ -100,7 +100,7 @@ contract Issuer is Upgradeable {
|
|||
/**
|
||||
* @notice Initialize reserved tokens for reward
|
||||
*/
|
||||
function initialize(uint256 _reservedReward) public onlyOwner {
|
||||
function initialize(uint256 _reservedReward) external onlyOwner {
|
||||
require(currentSupply1 == 0);
|
||||
token.safeTransferFrom(msg.sender, address(this), _reservedReward);
|
||||
currentMintingPeriod = getCurrentPeriod();
|
||||
|
@ -176,7 +176,7 @@ contract Issuer is Upgradeable {
|
|||
* @notice Burn sender's tokens. Amount of tokens will be returned for future minting
|
||||
* @param _value Amount to burn
|
||||
*/
|
||||
function burn(uint256 _value) public {
|
||||
function burn(uint256 _value) external {
|
||||
token.safeTransferFrom(msg.sender, address(this), _value);
|
||||
unMint(_value);
|
||||
emit Burnt(msg.sender, _value);
|
||||
|
|
|
@ -113,7 +113,7 @@ contract MultiSig {
|
|||
* @param _owner Address of new owner
|
||||
*/
|
||||
function addOwner(address _owner)
|
||||
public
|
||||
external
|
||||
onlyThisContract
|
||||
{
|
||||
require(owners.length < MAX_OWNER_COUNT &&
|
||||
|
@ -130,7 +130,7 @@ contract MultiSig {
|
|||
* @param _owner Address of owner
|
||||
*/
|
||||
function removeOwner(address _owner)
|
||||
public
|
||||
external
|
||||
onlyThisContract
|
||||
{
|
||||
require(owners.length > required && isOwner[_owner]);
|
||||
|
@ -151,7 +151,7 @@ contract MultiSig {
|
|||
* @param _required Number of required signatures
|
||||
*/
|
||||
function changeRequirement(uint8 _required)
|
||||
public
|
||||
external
|
||||
onlyThisContract
|
||||
{
|
||||
require(_required <= owners.length && _required > 0);
|
||||
|
|
|
@ -26,8 +26,8 @@ contract NuCypherToken is ERC20, ERC20Detailed('NuCypher', 'NU', 18) {
|
|||
* @dev call the receiveApproval function on the contract you want to be notified.
|
||||
* receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
|
||||
*/
|
||||
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
|
||||
public returns (bool success)
|
||||
function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData)
|
||||
external returns (bool success)
|
||||
{
|
||||
approve(_spender, _value);
|
||||
TokenRecipient(_spender).receiveApproval(msg.sender, _value, address(this), _extraData);
|
||||
|
|
|
@ -148,7 +148,7 @@ contract PolicyManager is Upgradeable {
|
|||
/**
|
||||
* @notice Set the minimum reward that the node will take
|
||||
*/
|
||||
function setMinRewardRate(uint256 _minRewardRate) public {
|
||||
function setMinRewardRate(uint256 _minRewardRate) external {
|
||||
NodeInfo storage node = nodes[msg.sender];
|
||||
node.minRewardRate = _minRewardRate;
|
||||
}
|
||||
|
@ -165,9 +165,9 @@ contract PolicyManager is Upgradeable {
|
|||
bytes16 _policyId,
|
||||
address _policyOwner,
|
||||
uint64 _endTimestamp,
|
||||
address[] memory _nodes
|
||||
address[] calldata _nodes
|
||||
)
|
||||
public payable
|
||||
external payable
|
||||
{
|
||||
Policy storage policy = policies[_policyId];
|
||||
require(
|
||||
|
@ -287,7 +287,7 @@ contract PolicyManager is Upgradeable {
|
|||
/**
|
||||
* @notice Withdraw reward by node
|
||||
*/
|
||||
function withdraw() public returns (uint256) {
|
||||
function withdraw() external returns (uint256) {
|
||||
return withdraw(msg.sender);
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ contract PolicyManager is Upgradeable {
|
|||
* @notice Revoke policy by the sponsor
|
||||
* @param _policyId Policy id
|
||||
*/
|
||||
function revokePolicy(bytes16 _policyId) public returns (uint256 refundValue) {
|
||||
function revokePolicy(bytes16 _policyId) external returns (uint256 refundValue) {
|
||||
require(getPolicyOwner(_policyId) == msg.sender);
|
||||
return refundInternal(_policyId, RESERVED_NODE, true);
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ contract PolicyManager is Upgradeable {
|
|||
* @param _node Node that will be excluded
|
||||
*/
|
||||
function revokeArrangement(bytes16 _policyId, address _node)
|
||||
public returns (uint256 refundValue)
|
||||
external returns (uint256 refundValue)
|
||||
{
|
||||
require(_node != RESERVED_NODE);
|
||||
require(getPolicyOwner(_policyId) == msg.sender);
|
||||
|
@ -519,8 +519,8 @@ contract PolicyManager is Upgradeable {
|
|||
* @param _node Node that will be excluded, zero address if whole policy will be revoked
|
||||
* @param _signature Signature of owner, EIP191 version 0x45 ('E')
|
||||
*/
|
||||
function revoke(bytes16 _policyId, address _node, bytes memory _signature)
|
||||
public returns (uint256 refundValue)
|
||||
function revoke(bytes16 _policyId, address _node, bytes calldata _signature)
|
||||
external returns (uint256 refundValue)
|
||||
{
|
||||
checkOwnerSignature(_policyId, _node, _signature);
|
||||
return refundInternal(_policyId, _node, true);
|
||||
|
@ -530,7 +530,7 @@ contract PolicyManager is Upgradeable {
|
|||
* @notice Refund part of fee by the sponsor
|
||||
* @param _policyId Policy id
|
||||
*/
|
||||
function refund(bytes16 _policyId) public {
|
||||
function refund(bytes16 _policyId) external {
|
||||
Policy storage policy = policies[_policyId];
|
||||
require(policy.owner == msg.sender || policy.sponsor == msg.sender);
|
||||
refundInternal(_policyId, RESERVED_NODE, false);
|
||||
|
@ -542,7 +542,7 @@ contract PolicyManager is Upgradeable {
|
|||
* @param _node Node address
|
||||
*/
|
||||
function refund(bytes16 _policyId, address _node)
|
||||
public returns (uint256 refundValue)
|
||||
external returns (uint256 refundValue)
|
||||
{
|
||||
require(_node != RESERVED_NODE);
|
||||
Policy storage policy = policies[_policyId];
|
||||
|
@ -577,7 +577,7 @@ contract PolicyManager is Upgradeable {
|
|||
* @param _policyId Policy id
|
||||
*/
|
||||
function getArrangementsLength(bytes16 _policyId)
|
||||
public view returns (uint256)
|
||||
external returns (uint256)
|
||||
{
|
||||
return policies[_policyId].arrangements.length;
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ contract PolicyManager is Upgradeable {
|
|||
* @param _period Period to get reward delta
|
||||
*/
|
||||
function getNodeRewardDelta(address _node, uint16 _period)
|
||||
public view returns (int256)
|
||||
external view returns (int256)
|
||||
{
|
||||
return nodes[_node].rewardDelta[_period];
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ contract PolicyManager is Upgradeable {
|
|||
function getArrangementInfo(bytes16 _policyId, uint256 _index)
|
||||
// TODO change to structure when ABIEncoderV2 is released (#1501)
|
||||
// public view returns (ArrangementInfo)
|
||||
public view returns (address node, uint256 indexOfDowntimePeriods, uint16 lastRefundedPeriod)
|
||||
external view returns (address node, uint256 indexOfDowntimePeriods, uint16 lastRefundedPeriod)
|
||||
{
|
||||
ArrangementInfo storage info = policies[_policyId].arrangements[_index];
|
||||
node = info.node;
|
||||
|
|
|
@ -30,7 +30,7 @@ contract Seeder is Ownable {
|
|||
* @notice Returns the length of the seed nodes array
|
||||
*/
|
||||
function getSeedArrayLength()
|
||||
public view returns (uint256)
|
||||
external view returns (uint256)
|
||||
{
|
||||
return seedArray.length;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ contract Seeder is Ownable {
|
|||
* @param _ip IPv4 address of the seed node
|
||||
* @param _port TCP port of the seed node
|
||||
*/
|
||||
function enroll(address _seed, string memory _ip, uint16 _port) public onlyOwner {
|
||||
function enroll(address _seed, string calldata _ip, uint16 _port) external onlyOwner {
|
||||
seeds[_seed] = SeedInfo(_ip, _port);
|
||||
|
||||
uint256 i = 0;
|
||||
|
@ -62,7 +62,7 @@ contract Seeder is Ownable {
|
|||
* @param _ip Updated IPv4 address of the existing seed node
|
||||
* @param _port Updated TCP port of the existing seed node
|
||||
*/
|
||||
function refresh(string memory _ip, uint16 _port) public {
|
||||
function refresh(string calldata _ip, uint16 _port) external {
|
||||
SeedInfo storage seed = seeds[msg.sender];
|
||||
require(seed.port != 0);
|
||||
seed.ip = _ip;
|
||||
|
|
|
@ -10,7 +10,7 @@ import "contracts/Issuer.sol";
|
|||
contract PolicyManagerInterface {
|
||||
function register(address _node, uint16 _period) external;
|
||||
function updateReward(address _node, uint16 _period) external;
|
||||
function escrow() public view returns (address);
|
||||
function escrow() external view returns (address);
|
||||
function setDefaultRewardDelta(address _node, uint16 _period) external;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ contract PolicyManagerInterface {
|
|||
* @notice Adjudicator interface
|
||||
*/
|
||||
contract AdjudicatorInterface {
|
||||
function escrow() public view returns (address);
|
||||
function escrow() external view returns (address);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ contract AdjudicatorInterface {
|
|||
* @notice WorkLock interface
|
||||
*/
|
||||
contract WorkLockInterface {
|
||||
function escrow() public view returns (address);
|
||||
function escrow() external view returns (address);
|
||||
}
|
||||
|
||||
|
||||
|
@ -389,7 +389,7 @@ contract StakingEscrow is Issuer {
|
|||
/**
|
||||
* @notice Get worker using staker's address
|
||||
*/
|
||||
function getWorkerFromStaker(address _staker) public view returns (address) {
|
||||
function getWorkerFromStaker(address _staker) external view returns (address) {
|
||||
StakerInfo storage info = stakerInfo[_staker];
|
||||
// specified address is not a staker
|
||||
if (stakerInfo[_staker].subStakes.length == 0) {
|
||||
|
@ -408,7 +408,7 @@ contract StakingEscrow is Issuer {
|
|||
/**
|
||||
* @notice Get work that completed by the staker
|
||||
*/
|
||||
function getCompletedWork(address _staker) public view returns (uint256) {
|
||||
function getCompletedWork(address _staker) external view returns (uint256) {
|
||||
return stakerInfo[_staker].completedWork;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ contract StakingEscrow is Issuer {
|
|||
* @param _measureWork Value for `measureWork` parameter
|
||||
* @return Work that was previously done
|
||||
*/
|
||||
function setWorkMeasurement(address _staker, bool _measureWork) public returns (uint256) {
|
||||
function setWorkMeasurement(address _staker, bool _measureWork) external returns (uint256) {
|
||||
require(msg.sender == address(workLock));
|
||||
StakerInfo storage info = stakerInfo[_staker];
|
||||
info.measureWork = _measureWork;
|
||||
|
@ -445,7 +445,7 @@ contract StakingEscrow is Issuer {
|
|||
/** @notice Set worker
|
||||
* @param _worker Worker address. Must be a real address, not a contract
|
||||
*/
|
||||
function setWorker(address _worker) public onlyStaker {
|
||||
function setWorker(address _worker) external onlyStaker {
|
||||
StakerInfo storage info = stakerInfo[msg.sender];
|
||||
require(_worker != info.worker, "Specified worker is already set for this staker");
|
||||
uint16 currentPeriod = getCurrentPeriod();
|
||||
|
@ -476,7 +476,7 @@ contract StakingEscrow is Issuer {
|
|||
* Only if this parameter is not locked
|
||||
* @param _reStake Value for parameter
|
||||
*/
|
||||
function setReStake(bool _reStake) public isInitialized {
|
||||
function setReStake(bool _reStake) external isInitialized {
|
||||
require(!isReStakeLocked(msg.sender));
|
||||
StakerInfo storage info = stakerInfo[msg.sender];
|
||||
if (info.reStakeDisabled == !_reStake) {
|
||||
|
@ -490,7 +490,7 @@ contract StakingEscrow is Issuer {
|
|||
* @notice Lock `reStake` parameter. Only if this parameter is not locked
|
||||
* @param _lockReStakeUntilPeriod Can't change `reStake` value until this period
|
||||
*/
|
||||
function lockReStake(uint16 _lockReStakeUntilPeriod) public isInitialized {
|
||||
function lockReStake(uint16 _lockReStakeUntilPeriod) external isInitialized {
|
||||
require(!isReStakeLocked(msg.sender) &&
|
||||
_lockReStakeUntilPeriod > getCurrentPeriod());
|
||||
stakerInfo[msg.sender].lockReStakeUntilPeriod = _lockReStakeUntilPeriod;
|
||||
|
@ -502,7 +502,7 @@ contract StakingEscrow is Issuer {
|
|||
* If true then stakes duration will be decreasing in each period with `confirmActivity()`
|
||||
* @param _windDown Value for parameter
|
||||
*/
|
||||
function setWindDown(bool _windDown) public onlyStaker {
|
||||
function setWindDown(bool _windDown) external onlyStaker {
|
||||
StakerInfo storage info = stakerInfo[msg.sender];
|
||||
if (info.windDown == _windDown) {
|
||||
return;
|
||||
|
|
|
@ -131,7 +131,7 @@ contract WorkLock {
|
|||
/**
|
||||
* @notice Get remaining work to full refund
|
||||
*/
|
||||
function getRemainingWork(address _depositor) public view returns (uint256) {
|
||||
function getRemainingWork(address _depositor) external view returns (uint256) {
|
||||
WorkInfo storage info = workInfo[_depositor];
|
||||
uint256 completedWork = escrow.getCompletedWork(_depositor).sub(info.completedWork);
|
||||
uint256 remainingWork = ethToWork(info.depositedETH);
|
||||
|
@ -192,7 +192,7 @@ contract WorkLock {
|
|||
/**
|
||||
* @notice Refund ETH for the completed work
|
||||
*/
|
||||
function refund() public returns (uint256 refundETH) {
|
||||
function refund() external returns (uint256 refundETH) {
|
||||
WorkInfo storage info = workInfo[msg.sender];
|
||||
require(info.depositedETH > 0, "Nothing deposited");
|
||||
uint256 currentWork = escrow.getCompletedWork(msg.sender);
|
||||
|
@ -218,7 +218,7 @@ contract WorkLock {
|
|||
/**
|
||||
* @notice Burn unclaimed tokens
|
||||
*/
|
||||
function burnUnclaimed() public {
|
||||
function burnUnclaimed() external {
|
||||
require(block.timestamp >= endBidDate, "Burning tokens allowed when bidding is over");
|
||||
require(unclaimedTokens > 0, "There are no tokens that can be burned");
|
||||
token.approve(address(escrow), unclaimedTokens);
|
||||
|
|
|
@ -30,7 +30,7 @@ contract StakingInterfaceRouter is Ownable {
|
|||
* @param _secret Secret for proof of contract owning
|
||||
* @param _newSecretHash New secret hash (keccak256)
|
||||
*/
|
||||
function upgrade(address _target, bytes memory _secret, bytes32 _newSecretHash) public onlyOwner {
|
||||
function upgrade(address _target, bytes calldata _secret, bytes32 _newSecretHash) external onlyOwner {
|
||||
require(_target.isContract());
|
||||
require(keccak256(_secret) == secretHash && _newSecretHash != secretHash);
|
||||
target = _target;
|
||||
|
|
|
@ -12,8 +12,8 @@ import "contracts/staking_contracts/AbstractStakingContract.sol";
|
|||
* @notice StakingEscrow interface
|
||||
*/
|
||||
contract StakingEscrowInterface {
|
||||
function getAllTokens(address _staker) public view returns (uint256);
|
||||
function secondsPerPeriod() public view returns (uint32);
|
||||
function getAllTokens(address _staker) external view returns (uint256);
|
||||
function secondsPerPeriod() external view returns (uint32);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ contract PreallocationEscrow is AbstractStakingContract, Ownable {
|
|||
* @param _value Amount of token to deposit
|
||||
* @param _duration Duration of tokens locking
|
||||
*/
|
||||
function initialDeposit(uint256 _value, uint256 _duration) public {
|
||||
function initialDeposit(uint256 _value, uint256 _duration) external {
|
||||
initialDeposit(msg.sender, _value, _duration);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ contract PreallocationEscrow is AbstractStakingContract, Ownable {
|
|||
* @notice Withdraw available amount of tokens to owner
|
||||
* @param _value Amount of token to withdraw
|
||||
*/
|
||||
function withdrawTokens(uint256 _value) public onlyOwner {
|
||||
function withdrawTokens(uint256 _value) external onlyOwner {
|
||||
uint256 balance = token.balanceOf(address(this));
|
||||
require(balance >= _value);
|
||||
// Withdrawal invariant for PreallocationEscrow:
|
||||
|
@ -142,7 +142,7 @@ contract PreallocationEscrow is AbstractStakingContract, Ownable {
|
|||
/**
|
||||
* @notice Withdraw available ETH to the owner
|
||||
*/
|
||||
function withdrawETH() public onlyOwner {
|
||||
function withdrawETH() external onlyOwner {
|
||||
uint256 balance = address(this).balance;
|
||||
require(balance != 0);
|
||||
msg.sender.sendValue(balance);
|
||||
|
|
|
@ -198,7 +198,7 @@ def test_inflation_rate(testerchain, token, deploy_contract):
|
|||
testerchain.wait_for_receipt(tx)
|
||||
tx = token.functions.approve(issuer.address, amount_to_burn).transact({'from': ursula})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
tx = issuer.functions.testBurn(amount_to_burn).transact({'from': ursula})
|
||||
tx = issuer.functions.burn(amount_to_burn).transact({'from': ursula})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
assert reward + amount_to_burn == issuer.functions.getReservedReward().call()
|
||||
|
||||
|
|
|
@ -45,10 +45,6 @@ contract IssuerMock is Issuer {
|
|||
token.transfer(msg.sender, amount);
|
||||
}
|
||||
|
||||
function testBurn(uint256 _value) public {
|
||||
burn(_value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue