Skip to content

Commit

Permalink
remove fee from contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
0x3bfc committed Jun 9, 2020
1 parent 5343f87 commit 90441b0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 174 deletions.
11 changes: 3 additions & 8 deletions contracts/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import './interfaces/IERC20Template.sol';
*/
contract Factory is Deployer, Converter {

address payable private feeManager;
address private tokenTemplate;
uint256 private currentTokenCount = 1;
// cap has max uint256 (2^256 -1)
Expand Down Expand Up @@ -46,20 +45,17 @@ contract Factory is Deployer, Converter {
* @dev constructor
* Called on contract deployment. Could not be called with zero address parameters.
* @param _template refers to the address of a deployed DataToken contract.
* @param _feeManager refers to the address of a fee manager .
*/
constructor(
address _template,
address payable _feeManager
address _template
)
public
{
require(
_template != address(0) && _feeManager != address(0),
_template != address(0),
'Factory: Invalid TokenFactory initialization'
);
tokenTemplate = _template;
feeManager = _feeManager;
}

/**
Expand Down Expand Up @@ -93,8 +89,7 @@ contract Factory is Deployer, Converter {
symbol,
msg.sender,
cap,
blob,
feeManager
blob
);

require(
Expand Down
70 changes: 0 additions & 70 deletions contracts/fee/FeeCalculator.sol

This file was deleted.

21 changes: 0 additions & 21 deletions contracts/fee/FeeCollector.sol

This file was deleted.

42 changes: 0 additions & 42 deletions contracts/fee/FeeManager.sol

This file was deleted.

3 changes: 1 addition & 2 deletions contracts/interfaces/IERC20Template.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ interface IERC20Template {
string calldata symbol,
address minter,
uint256 cap,
string calldata blob,
address payable feeManager
string calldata blob
) external returns(bool);
function mint(address account, uint256 value)
external payable;
Expand Down
36 changes: 5 additions & 31 deletions contracts/templates/DataTokenTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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

import '../fee/FeeManager.sol';
import './token/ERC20Pausable.sol';
import '../interfaces/IERC20Template.sol';
/**
Expand All @@ -23,8 +22,6 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
uint256 private _cap;
uint256 private _decimals;
address private _minter;

FeeManager serviceFeeManager;

modifier onlyNotInitialized() {
require(
Expand All @@ -48,16 +45,13 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
* @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,
string memory symbol,
address minter,
uint256 cap,
string memory blob,
address payable feeManager

string memory blob
)
public
{
Expand All @@ -66,8 +60,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
symbol,
minter,
cap,
blob,
feeManager
blob
);
}

Expand All @@ -78,15 +71,13 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
* @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,
string memory symbol,
address minter,
uint256 cap,
string memory blob,
address payable feeManager
string memory blob
)
public
onlyNotInitialized
Expand All @@ -97,8 +88,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
symbol,
minter,
cap,
blob,
feeManager
blob
);
}

Expand All @@ -108,15 +98,13 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
* @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,
string memory symbol,
address minter,
uint256 cap,
string memory blob,
address payable feeManager
string memory blob
)
private
returns(bool)
Expand All @@ -125,11 +113,6 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
minter != address(0),
'DataTokenTemplate: Invalid minter, zero address'
);

require(
feeManager != address(0),
'DataTokenTemplate: Invalid feeManager, zero address'
);

require(
_minter == address(0),
Expand All @@ -147,16 +130,12 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
_blob = blob;
_symbol = symbol;
_minter = minter;
serviceFeeManager = FeeManager(feeManager);
initialized = true;
return initialized;
}

/**
* @dev mint
* 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.
Expand All @@ -175,12 +154,7 @@ contract DataTokenTemplate is IERC20Template, ERC20Pausable {
totalSupply().add(value) <= _cap,
'DataTokenTemplate: cap exceeded'
);
require(
msg.value >= serviceFeeManager.calculateFee(value, _cap),
'DataTokenTemplate: invalid data token minting fee'
);
_mint(account, value);
address(serviceFeeManager).transfer(msg.value);
}

/**
Expand Down

0 comments on commit 90441b0

Please sign in to comment.