-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* branches coverage reached to 85 % * increase coverage of transferManagers * improve the coverage of token * introduced withdrawERC20() in the changelog * fix * minor fixes
- Loading branch information
1 parent
468b047
commit df996a1
Showing
33 changed files
with
1,309 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./MockRedemptionManager.sol"; | ||
import "../modules/Burn/TrackedRedemptionFactory.sol"; | ||
|
||
/** | ||
* @title Mock Contract Not fit for production environment | ||
*/ | ||
|
||
contract MockBurnFactory is TrackedRedemptionFactory { | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public | ||
TrackedRedemptionFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
{ | ||
} | ||
|
||
/** | ||
* @notice used to launch the Module with the help of factory | ||
* @return address Contract address of the Module | ||
*/ | ||
function deploy(bytes /*_data*/) external returns(address) { | ||
if(setupCost > 0) | ||
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost"); | ||
//Check valid bytes - can only call module init function | ||
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken)); | ||
emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, setupCost, now); | ||
return address(mockRedemptionManager); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,42 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../modules/STO/DummySTO.sol"; | ||
import "../modules/ModuleFactory.sol"; | ||
import "../libraries/Util.sol"; | ||
import "../modules/STO/DummySTOFactory.sol"; | ||
|
||
contract MockFactory is ModuleFactory { | ||
/** | ||
* @title Mock Contract Not fit for production environment | ||
*/ | ||
|
||
contract MockFactory is DummySTOFactory { | ||
|
||
bool public switchTypes = false; | ||
/** | ||
* @notice Constructor | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public | ||
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
{ | ||
version = "1.0.0"; | ||
name = "Mock"; | ||
title = "Mock Manager"; | ||
description = "MockManager"; | ||
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
} | ||
|
||
/** | ||
* @notice used to launch the Module with the help of factory | ||
* @param _data Data used for the intialization of the module factory variables | ||
* @return address Contract address of the Module | ||
*/ | ||
function deploy(bytes _data) external returns(address) { | ||
if(setupCost > 0) | ||
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost"); | ||
//Check valid bytes - can only call module init function | ||
DummySTO dummySTO = new DummySTO(msg.sender, address(polyToken)); | ||
//Checks that _data is valid (not calling anything it shouldn't) | ||
require(Util.getSig(_data) == dummySTO.getInitFunction(), "Invalid initialisation"); | ||
require(address(dummySTO).call(_data), "Unsuccessfull initialisation"); | ||
return address(dummySTO); | ||
} | ||
|
||
/** | ||
* @notice Type of the Module factory | ||
*/ | ||
function getTypes() external view returns(uint8[]) { | ||
uint8[] memory res = new uint8[](0); | ||
return res; | ||
} | ||
|
||
/** | ||
* @notice Get the name of the Module | ||
*/ | ||
function getName() public view returns(bytes32) { | ||
return name; | ||
} | ||
|
||
/** | ||
* @notice Get the description of the Module | ||
*/ | ||
function getDescription() external view returns(string) { | ||
return description; | ||
} | ||
|
||
/** | ||
* @notice Get the title of the Module | ||
*/ | ||
function getTitle() external view returns(string) { | ||
return title; | ||
} | ||
|
||
/** | ||
* @notice Get the version of the Module | ||
*/ | ||
function getVersion() external view returns(string) { | ||
return version; | ||
} | ||
|
||
/** | ||
* @notice Get the setup cost of the module | ||
*/ | ||
function getSetupCost() external view returns (uint256) { | ||
return setupCost; | ||
} | ||
|
||
/** | ||
* @notice Returns the instructions associated with the module | ||
*/ | ||
function getInstructions() external view returns(string) { | ||
return "Mock Manager - This is mock in nature"; | ||
} | ||
|
||
/** | ||
* @notice Get the tags related to the module factory | ||
*/ | ||
function getTags() external view returns(bytes32[]) { | ||
bytes32[] memory availableTags = new bytes32[](4); | ||
availableTags[0] = "Mock"; | ||
return availableTags; | ||
if (!switchTypes) { | ||
uint8[] memory types = new uint8[](0); | ||
return types; | ||
} else { | ||
uint8[] memory res = new uint8[](2); | ||
res[0] = 1; | ||
res[1] = 1; | ||
return res; | ||
} | ||
|
||
} | ||
|
||
function changeTypes() external onlyOwner { | ||
switchTypes = !switchTypes; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../modules/Burn/TrackedRedemption.sol"; | ||
|
||
/** | ||
* @title Burn module for burning tokens and keeping track of burnt amounts | ||
*/ | ||
contract MockRedemptionManager is TrackedRedemption { | ||
|
||
mapping (address => uint256) tokenToRedeem; | ||
|
||
event RedeemedTokenByOwner(address _investor, address _byWhoom, uint256 _value, uint256 _timestamp); | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _securityToken Address of the security token | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _securityToken, address _polyAddress) public | ||
TrackedRedemption(_securityToken, _polyAddress) | ||
{ | ||
} | ||
|
||
/** | ||
* @notice Transfer tokens to Module to burn | ||
* @param _value The number of tokens to redeem | ||
*/ | ||
function transferToRedeem(uint256 _value) public { | ||
require(ISecurityToken(securityToken).transferFrom(msg.sender, address(this), _value), "Insufficient funds"); | ||
tokenToRedeem[msg.sender] = _value; | ||
} | ||
|
||
/** | ||
* @notice use to redeem tokens by the module | ||
* @param _value The number of tokens to redeem | ||
*/ | ||
function redeemTokenByOwner(uint256 _value) public { | ||
require(tokenToRedeem[msg.sender] >= _value); | ||
tokenToRedeem[msg.sender] = tokenToRedeem[msg.sender].sub(_value); | ||
redeemedTokens[msg.sender] = redeemedTokens[msg.sender].add(_value); | ||
ISecurityToken(securityToken).burnWithData(_value, ""); | ||
emit RedeemedTokenByOwner(msg.sender, address(this), _value, now); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./MockBurnFactory.sol"; | ||
import "../modules/ModuleFactory.sol"; | ||
import "../libraries/Util.sol"; | ||
|
||
/** | ||
* @title Mock Contract Not fit for production environment | ||
*/ | ||
|
||
contract MockWrongTypeFactory is MockBurnFactory { | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public | ||
MockBurnFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
{ | ||
} | ||
|
||
/** | ||
* @notice Type of the Module factory | ||
*/ | ||
function getTypes() external view returns(uint8[]) { | ||
uint8[] memory types = new uint8[](1); | ||
types[0] = 4; | ||
return types; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.