fix: created interface for factory to avoid circular dependences (#151)

This commit is contained in:
Richard Ramos 2019-04-01 14:59:21 -04:00 committed by GitHub
parent 1687d7add8
commit 55d109ffd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 8 deletions

View File

@ -30,7 +30,7 @@ import "../common/Controlled.sol";
import "./TokenController.sol";
import "./ApproveAndCallFallBack.sol";
import "./MiniMeTokenInterface.sol";
import "./MiniMeTokenFactory.sol";
import "./TokenFactory.sol";
/**
* @dev The actual token contract, the default controller is the msg.sender
@ -84,7 +84,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
bool public transfersEnabled;
// The factory used to create new clone tokens
MiniMeTokenFactory public tokenFactory;
TokenFactory public tokenFactory;
////////////////
// Constructor
@ -116,7 +116,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
)
public
{
tokenFactory = MiniMeTokenFactory(_tokenFactory);
tokenFactory = TokenFactory(_tokenFactory);
name = _tokenName; // Set the name
decimals = _decimalUnits; // Set the decimals
symbol = _tokenSymbol; // Set the symbol
@ -425,14 +425,14 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
if (snapshotBlock == 0) {
snapshotBlock = block.number;
}
MiniMeToken cloneToken = tokenFactory.createCloneToken(
MiniMeToken cloneToken = MiniMeToken(tokenFactory.createCloneToken(
address(this),
snapshotBlock,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
));
cloneToken.changeController(msg.sender);

View File

@ -1,5 +1,6 @@
pragma solidity ^0.5.0;
import "./TokenFactory.sol";
import "./MiniMeToken.sol";
////////////////
@ -11,7 +12,7 @@ import "./MiniMeToken.sol";
* In solidity this is the way to create a contract from a contract of the
* same class
*/
contract MiniMeTokenFactory {
contract MiniMeTokenFactory is TokenFactory {
/**
* @notice Update the DApp by creating a new token with new functionalities
@ -32,7 +33,7 @@ contract MiniMeTokenFactory {
uint8 _decimalUnits,
string memory _tokenSymbol,
bool _transfersEnabled
) public returns (MiniMeToken) {
) public returns (address payable) {
MiniMeToken newToken = new MiniMeToken(
address(this),
_parentToken,
@ -44,6 +45,6 @@ contract MiniMeTokenFactory {
);
newToken.changeController(msg.sender);
return newToken;
return address(newToken);
}
}

View File

@ -0,0 +1,12 @@
pragma solidity ^0.5.0;
contract TokenFactory {
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string memory _tokenName,
uint8 _decimalUnits,
string memory _tokenSymbol,
bool _transfersEnabled
) public returns (address payable);
}