Skip to content

Commit

Permalink
update open zeppelin
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Dec 8, 2020
1 parent dbd6d36 commit 23dfe20
Show file tree
Hide file tree
Showing 26 changed files with 563 additions and 75 deletions.
2 changes: 0 additions & 2 deletions contracts/Common.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pragma solidity 0.6.12;


import 'zos-lib/contracts/Initializable.sol';

/**
* @title Common functions
* @author Keyko & Ocean Protocol
Expand Down
13 changes: 7 additions & 6 deletions contracts/Dispenser.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
pragma solidity 0.6.12;


import 'openzeppelin-eth/contracts/math/SafeMath.sol';
import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
import '@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import './NeverminedToken.sol';

/**
* @title Ocean Protocol Dispenser Contract
* @author Keyko & Ocean Protocol
*/
contract Dispenser is Ownable {
contract Dispenser is OwnableUpgradeable {

using SafeMath for uint256;
using SafeMath for uint;
using SafeMathUpgradeable for uint256;
using SafeMathUpgradeable for uint;

// limit period for request of tokens
// mapping from address to last time of request
Expand Down Expand Up @@ -65,7 +65,8 @@ contract Dispenser is Ownable {
initializer
isValidAddress(_tokenAddress)
{
Ownable.initialize(_owner);
OwnableUpgradeable.__Ownable_init();
transferOwnership(_owner);
// init total mint amount
totalMintAmount = 0;
// instantiate Token contract
Expand Down
7 changes: 4 additions & 3 deletions contracts/HashLists.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.6.12;

import './interfaces/IList.sol';
import './libraries/HashListLibrary.sol';
import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

/**
* @title HashLists contract
Expand All @@ -17,7 +17,7 @@ import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
* same condition.
*/

contract HashLists is Ownable, IList {
contract HashLists is OwnableUpgradeable, IList {

using HashListLibrary for HashListLibrary.List;
mapping(bytes32 => HashListLibrary.List) lists;
Expand All @@ -32,7 +32,8 @@ contract HashLists is Ownable, IList {
)
public
{
Ownable.initialize(_owner);
OwnableUpgradeable.__Ownable_init();
transferOwnership(_owner);
}

/**
Expand Down
20 changes: 11 additions & 9 deletions contracts/NeverminedToken.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pragma solidity 0.6.12;


import 'openzeppelin-eth/contracts/token/ERC20/ERC20Capped.sol';
import 'openzeppelin-eth/contracts/token/ERC20/ERC20Detailed.sol';
import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20CappedUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';

/**
* @title Test Token Contract
Expand All @@ -12,9 +13,9 @@ import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
* @dev Implementation of a Test Token.
* Test Token is an ERC20 token only for testing purposes
*/
contract NeverminedToken is Ownable, ERC20Detailed, ERC20Capped {
contract NeverminedToken is OwnableUpgradeable, AccessControlUpgradeable, ERC20Upgradeable, ERC20CappedUpgradeable {

using SafeMath for uint256;
using SafeMathUpgradeable for uint256;

/**
* @dev NeverminedToken Initializer
Expand All @@ -32,11 +33,12 @@ contract NeverminedToken is Ownable, ERC20Detailed, ERC20Capped {
uint256 CAP = 1500000000;
uint256 TOTALSUPPLY = CAP.mul(10 ** 18);

ERC20Detailed.initialize('NeverminedToken', 'NVM', 18);
ERC20Capped.initialize(TOTALSUPPLY, _owner);
Ownable.initialize(_owner);
ERC20Upgradeable.__ERC20_init('NeverminedToken', 'NVM');
ERC20CappedUpgradeable.__ERC20Capped_init(TOTALSUPPLY);
OwnableUpgradeable.__Ownable_init();
transferOwnership(_owner);

// set initial minter, this has to be renounced after the setup!
_addMinter(_initialMinter);
AccessControlUpgradeable.grantRole("minter", _initialMinter);
}
}
8 changes: 5 additions & 3 deletions contracts/agreements/AgreementStoreManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../conditions/ConditionStoreManager.sol';
import '../registry/DIDRegistry.sol';
import '../templates/TemplateStoreManager.sol';

import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

/**
* @title Agreement Store Manager
Expand All @@ -23,7 +23,7 @@ import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
* Agreement templates must to be approved in the Template Store
* Each agreement is linked to the DID of an asset.
*/
contract AgreementStoreManager is Ownable {
contract AgreementStoreManager is OwnableUpgradeable {

/**
* @dev The Agreement Store Library takes care of the basic storage functions
Expand Down Expand Up @@ -63,7 +63,9 @@ contract AgreementStoreManager is Ownable {
_didRegistryAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.__Ownable_init();
transferOwnership(_owner);

conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
Expand Down
4 changes: 2 additions & 2 deletions contracts/conditions/AccessSecretStoreCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ ISecretStore, ISecretStorePermission {
)
external
initializer()
{
Ownable.initialize(_owner);
{
OwnableUpgradeable.initialize(_owner);

conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
Expand Down
5 changes: 3 additions & 2 deletions contracts/conditions/ComputeExecutionCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ contract ComputeExecutionCondition is Condition {
)
external
initializer()
{
Ownable.initialize(_owner);
{
OwnableUpgradeable.__Ownable_init();
transferOwnership(_owner);

conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
Expand Down
4 changes: 2 additions & 2 deletions contracts/conditions/Condition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity 0.6.12;


import './ConditionStoreManager.sol';
import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
/**
* @title Condition
* @author Keyko & Ocean Protocol
Expand All @@ -23,7 +23,7 @@ import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
* https://github.com/oceanprotocol/OEPs/issues/133
* TODO: update the OEP link
*/
contract Condition is Ownable {
contract Condition is OwnableUpgradeable {

ConditionStoreManager internal conditionStoreManager;

Expand Down
6 changes: 3 additions & 3 deletions contracts/conditions/ConditionStoreManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../Common.sol';
import '../libraries/EpochLibrary.sol';
import './ConditionStoreLibrary.sol';

import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

/**
* @title Condition Store Manager
Expand All @@ -28,7 +28,7 @@ import 'openzeppelin-eth/contracts/ownership/Ownable.sol';
* https://github.com/oceanprotocol/OEPs/issues/119
* TODO: update the OEP link
*/
contract ConditionStoreManager is Ownable, Common {
contract ConditionStoreManager is OwnableUpgradeable, Common {

using ConditionStoreLibrary for ConditionStoreLibrary.ConditionList;
using EpochLibrary for EpochLibrary.EpochList;
Expand Down Expand Up @@ -101,7 +101,7 @@ contract ConditionStoreManager is Ownable, Common {
createRole == address(0),
'Role already assigned'
);
Ownable.initialize(_owner);
OwnableUpgradeable.initialize(_owner);
createRole = _owner;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/conditions/HashLockCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract HashLockCondition is Condition {
_conditionStoreManagerAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.initialize(_owner);
conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
Expand Down
8 changes: 4 additions & 4 deletions contracts/conditions/LockRewardCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity 0.6.12;


import './Condition.sol';
import 'openzeppelin-eth/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';

/**
* @title Lock Reward Condition
Expand All @@ -20,7 +20,7 @@ import 'openzeppelin-eth/contracts/token/ERC20/ERC20.sol';
*/
contract LockRewardCondition is Condition {

IERC20 private token;
IERC20Upgradeable private token;

event Fulfilled(
bytes32 indexed _agreementId,
Expand Down Expand Up @@ -51,11 +51,11 @@ contract LockRewardCondition is Condition {
_conditionStoreManagerAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.initialize(_owner);
conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
token = ERC20(_tokenAddress);
token = ERC20Upgradeable(_tokenAddress);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions contracts/conditions/SignCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pragma solidity 0.6.12;

import './Condition.sol';
import './ConditionStoreLibrary.sol';
import 'openzeppelin-eth/contracts/cryptography/ECDSA.sol';
import '@openzeppelin/contracts-upgradeable/cryptography/ECDSAUpgradeable.sol';
/**
* @title Sign Condition
* @author Keyko & Ocean Protocol
Expand Down Expand Up @@ -39,7 +39,8 @@ contract SignCondition is Condition {
_conditionStoreManagerAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.__Ownable_init();
transferOwnership(_owner);
conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
Expand Down Expand Up @@ -78,7 +79,7 @@ contract SignCondition is Condition {
returns (ConditionStoreLibrary.ConditionState)
{
require(
ECDSA.recover(_message, _signature) == _publicKey,
ECDSAUpgradeable.recover(_message, _signature) == _publicKey,
'Could not recover signature'
);
return super.fulfill(
Expand Down
2 changes: 1 addition & 1 deletion contracts/conditions/ThresholdCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract ThresholdCondition is Condition {
_conditionStoreManagerAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.initialize(_owner);
conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
Expand Down
4 changes: 2 additions & 2 deletions contracts/conditions/WhitelistingCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../Common.sol';
import './Condition.sol';
import './ConditionStoreLibrary.sol';
import '../interfaces/IList.sol';
import 'openzeppelin-eth/contracts/cryptography/ECDSA.sol';
import '@openzeppelin/contracts-upgradeable/cryptography/ECDSAUpgradeable.sol';
/**
* @title Whitelisting Condition
* @author Keyko & Ocean Protocol
Expand Down Expand Up @@ -38,7 +38,7 @@ contract WhitelistingCondition is Condition, Common {
_conditionStoreManagerAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.initialize(_owner);
conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
Expand Down
4 changes: 2 additions & 2 deletions contracts/conditions/rewards/EscrowReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ contract EscrowReward is Reward {
_conditionStoreManagerAddress != address(0),
'Invalid address'
);
Ownable.initialize(_owner);
OwnableUpgradeable.initialize(_owner);
conditionStoreManager = ConditionStoreManager(
_conditionStoreManagerAddress
);
token = ERC20(_tokenAddress);
token = ERC20Upgradeable(_tokenAddress);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/conditions/rewards/Reward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.6.12;

import '../Condition.sol';
import '../ConditionStoreManager.sol';
import 'openzeppelin-eth/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';

/**
* @title Reward
Expand All @@ -17,7 +17,7 @@ import 'openzeppelin-eth/contracts/token/ERC20/ERC20.sol';
* TODO: update the OEP link
*/
contract Reward is Condition {
IERC20 internal token;
IERC20Upgradeable internal token;
}


Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/EpochLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity 0.6.12;
// Code is Apache-2.0 and docs are CC-BY-4.0


import 'openzeppelin-eth/contracts/math/SafeMath.sol';
import '@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol';

/**
* @title Epoch Library
Expand All @@ -21,7 +21,7 @@ import 'openzeppelin-eth/contracts/math/SafeMath.sol';
*/
library EpochLibrary {

using SafeMath for uint256;
using SafeMathUpgradeable for uint256;

struct Epoch {
uint256 timeLock;
Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/HashListLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity 0.6.12;
// Code is Apache-2.0 and docs are CC-BY-4.0


import 'openzeppelin-eth/contracts/math/SafeMath.sol';
import '@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol';

/**
* @title Hash List library
Expand All @@ -18,7 +18,7 @@ import 'openzeppelin-eth/contracts/math/SafeMath.sol';

library HashListLibrary {

using SafeMath for uint256;
using SafeMathUpgradeable for uint256;

struct List {
address _owner;
Expand Down

0 comments on commit 23dfe20

Please sign in to comment.