Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Minor docs errors #82

Merged
merged 8 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions contracts/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Factory is Deployer, Converter {

address payable private feeManager;
address private tokenTemplate;
uint256 private tokenCount = 0;
uint256 private currentTokenCount = 1;
// cap has max uint256 (2^256 -1)
uint256 constant private cap =
115792089237316195423570985008687907853269984665640564039457584007913129639935;
Expand Down Expand Up @@ -80,8 +80,8 @@ contract Factory is Deployer, Converter {
'Factory: Failed to perform minimal deploy of a new token'
);

string memory name = uintToString(tokenCount);
string memory symbol = uintToString(tokenCount);
string memory name = uintToString(currentTokenCount);
string memory symbol = uintToString(currentTokenCount);

IERC20Template tokenInstance = IERC20Template(token);
tokenInstance.initialize(
Expand Down Expand Up @@ -114,6 +114,6 @@ contract Factory is Deployer, Converter {
blob
);

tokenCount += 1;
currentTokenCount += 1;
}
}
22 changes: 21 additions & 1 deletion contracts/fee/FeeCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ pragma solidity ^0.5.7;

import 'openzeppelin-solidity/contracts/math/SafeMath.sol';

/**
* @title Fee Calculator Contract
* @author Ocean Protocol Team
*
* @dev Implementation of Fee Calculator
* Fee calculator provides some helper functions
*/
contract FeeCalculator {

using SafeMath for uint256;
uint256 constant private BASE_TX_COST = 44000;
uint256 constant private BASE = 10;

/**
* @dev calculateRange
* For a given number, calculates number of zeros.
* @param number input number value.
* @return number of zeros.
*/
function calculateRange(
uint256 number
)
Expand All @@ -27,7 +40,14 @@ contract FeeCalculator {
return zeros;
}


/**
* @dev calculateFee
* calculates the fee based on the number of minted tokens compared to
* the capital
* @param tokens the amount of minted tokens.
* @param cap the capital
* @return fee.
*/
function calculateFee(
uint256 tokens,
uint256 cap
Expand Down
12 changes: 12 additions & 0 deletions contracts/fee/FeeCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ pragma solidity ^0.5.7;
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0

/**
* @title Fee Collector Contract
* @author Ocean Protocol Team
*
* @dev Implementation of Fee Collector
* Receives only Ether
*/
contract FeeCollector {

/**
* @dev
* payable function which receives only Etehreum
*/
function() external payable{
}
}
14 changes: 14 additions & 0 deletions contracts/fee/FeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import './FeeCalculator.sol';
import './FeeCollector.sol';
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';

/**
* @title Fee Manager Contract
* @author Ocean Protocol Team
*
* @dev Implementation of Fee Manager
* manages the life cycle of the ocean service fee
* It inherits the fee collector and fee calcualtor
* in which allows charging fee, accumlating fee, and
* withdraw accumalted fee (only by contract owner)
*/
contract FeeManager is FeeCalculator, FeeCollector, Ownable {

constructor()
Expand All @@ -15,6 +25,10 @@ contract FeeManager is FeeCalculator, FeeCollector, Ownable {
{
}

/**
* @dev withdraw
* allows contract owner to withdraw accumlated service fee.
*/
function withdraw()
public
onlyOwner
Expand Down
92 changes: 47 additions & 45 deletions contracts/templates/DataTokenTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import '../interfaces/IERC20Template.sol';
/**
* @title DataTokenTemplate
*
* @dev DataTokenTemplate is a DataToken ERC20 compliant template
* Used by the factory contract as a bytecode reference to deploy new DataTokens.
* @dev DataTokenTemplate is an ERC20 compliant token template
* Used by the factory contract as a bytecode reference to
* deploy new DataTokens.
*/
contract DataTokenTemplate is IERC20Template, ERC20Pausable {
using SafeMath for uint256;
Expand Down Expand Up @@ -43,11 +44,11 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev constructor
* Called on contract deployment. Could not be called with zero address parameters.
* @param name refers to a template DataToken name.
* @param symbol refers to a template DataToken symbol.
* @param minter refers to an address that has minter rights.
* @param feeManager refers to an address of a FeeManager contract.
* Called prior contract deployment
* @param name refers to a template DataToken name
* @param symbol refers to a template DataToken symbol
* @param minter refers to an address that has minter role
* @param feeManager refers to an address of a FeeManager contract address
*/
constructor(
string memory name,
Expand All @@ -72,12 +73,12 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev initialize
* Called on contract initialization. Used on new DataToken instance setup.
Calls private _initialize function. Only if contract is not initialized.
* @param name refers to a new DataToken name.
* @param symbol refers to a nea DataToken symbol.
* @param minter refers to an address that has minter rights.
* @param feeManager refers to an address of a FeeManager contract.
* Called prior contract initialization (e.g creating new DataToken instance)
* Calls private _initialize function. Only if contract is not initialized.
* @param name refers to a new DataToken name
* @param symbol refers to a nea DataToken symbol
* @param minter refers to an address that has minter rights
* @param feeManager refers to an address of a FeeManager contract address
*/
function initialize(
string memory name,
Expand All @@ -104,11 +105,10 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
/**
* @dev _initialize
* Private function called on contract initialization.
No of the parameters can be a zero address.
* @param name refers to a new DataToken name.
* @param symbol refers to a nea DataToken symbol.
* @param minter refers to an address that has minter rights.
* @param feeManager refers to an address of a FeeManager contract.
* @param name refers to a new DataToken name
* @param symbol refers to a nea DataToken symbol
* @param minter refers to an address that has minter rights
* @param feeManager refers to an address of a FeeManager contract address
*/
function _initialize(
string memory name,
Expand All @@ -133,7 +133,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

require(
_minter == address(0),
'DataTokenTemplate: Invalid minter, access denied'
'DataTokenTemplate: Invalid minter, zero address'
);

require(
Expand All @@ -154,11 +154,12 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev mint
* Function that takes the fee as msg.value and mints new DataTokens.
Can be called only if the contract is not paused.
Can be called only by the minter address.
Msg.value should be higher than zero.
* @param account refers to a an address that token is going to be minted to.
* It takes the fee as msg.value and mints new DataTokens
* the minting fee is calculated using ServiceFeeManager
* it could be called only if the contract is not paused.
* Only the minter address can call it.
* msg.value should be higher than zero and gt or eq minting fee
* @param account refers to an address that token is going to be minted to.
* @param value refers to amount of tokens that is going to be minted.
*/
function mint(
Expand All @@ -184,38 +185,38 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev pause
* Function that pauses the contract.
Can be called only if the contract is not already paused.
Can be called only by the minter address.
* It pauses the contract functionalities (transfer, mint, etc)
* Only could be called if the contract is not already paused.
* Only called by the minter address.
*/
function pause() public onlyNotPaused onlyMinter {
paused = true;
}

/**
* @dev unpause
* Function that unpauses the contract.
Can be called only if the contract is paused.
Can be called only by the minter address.
* It unpauses the contract.
* Only called if the contract is paused.
* Only minter can call it.
*/
function unpause() public onlyPaused onlyMinter {
paused = false;
}

/**
* @dev setMinter
* Function that sents a new minter address.
Can be called only if the contract is not paused.
Can be called only by the minter address.
* @param minter refers to a new minter address.
* It sets a new token minter address.
* Only called be called if the contract is not paused.
* Only the current minter can call it.
* @param minter refers to a new token minter address.
*/
function setMinter(address minter) public onlyNotPaused onlyMinter {
_minter = minter;
}

/**
* @dev name
* Function that reads private variable name.
* It returns the token name.
* @return DataToken name.
*/
function name() public view returns(string memory) {
Expand All @@ -224,7 +225,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev symbol
* Function that reads private variable symbol.
* It returns the token symbol.
* @return DataToken symbol.
*/
function symbol() public view returns(string memory) {
Expand All @@ -233,7 +234,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev blob
* Function that reads private variable blob.
* It returns the blob (e.g https://123.com).
* @return DataToken blob.
*/
function blob() public view returns(string memory) {
Expand All @@ -242,7 +243,8 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev decimals
* Function that reads private variable decimals.
* It returns the token decimals.
* how many supported decimal points
* @return DataToken decimals.
*/
function decimals() public view returns(uint256) {
Expand All @@ -251,7 +253,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev cap
* Function that reads private variable cap.
* it returns the capital.
* @return DataToken cap.
*/
function cap() public view returns (uint256) {
Expand All @@ -260,18 +262,18 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {

/**
* @dev isMinter
* Function takes the address and checks if it is a minter address.
* @param account refers to the address that will be checked if it is a minter address.
* @return DataToken cap.
* It takes the address and checks whether it has a minter role.
* @param account refers to the address.
* @return true if account has a minter role.
*/
function isMinter(address account) public view returns(bool) {
return (_minter == account);
}

/**
* @dev isInitialized
* Function checks if the contract is initialized.
* @return true if the contract is initialized, false if it is not.
* It checks whether the contract is initialized.
* @return true if the contract is initialized.
*/
function isInitialized() public view returns(bool) {
return initialized;
Expand All @@ -280,7 +282,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
/**
* @dev isPaused
* Function checks if the contract is paused.
* @return true if the contract is paused, false if it is not.
* @return true if the contract is paused.
*/
function isPaused() public view returns(bool) {
return paused;
Expand Down
18 changes: 17 additions & 1 deletion contracts/utils/Converter.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
pragma solidity ^0.5.7;
// Copyright BigchainDB GmbH and Ocean Protocol contributors
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0


/**
* @title Converter Contract
* @author Ocean Protocol Team
*
* @dev Simple types converter
* This contract provides sompe helper functions
* such as converting integers to strings
*/
contract Converter {

/**
* @dev uintToString
* converts an integer value to a string value
* @param value refers to integer value
* @return converted string value
*/
function uintToString
(
uint256 value
Expand Down
18 changes: 18 additions & 0 deletions contracts/utils/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ pragma solidity ^0.5.7;
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0

/**
* @title Deployer Contract
* @author Ocean Protocol Team
*
* @dev Contract Deployer
* This contract allowes factory contract
* to deploy new contract instances using
* the same library pattern in solidity.
* the logic it self is deployed only once, but
* executed in the context of the new storage
* contract (new contract instance)
*/
contract Deployer {
event InstanceDeployed(address instance);

/**
* @dev deploy
* deploy new contract instance
* @param _logic the logic contract address
* @return address of the new instance
*/
function deploy(
address _logic
)
Expand Down
Loading