forked from PolymathNetwork/polymath-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PreSaleSTOFactory.sol
84 lines (72 loc) · 2.6 KB
/
PreSaleSTOFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
pragma solidity ^0.4.24;
import "./PreSaleSTO.sol";
import "../../interfaces/IModuleFactory.sol";
import "../../interfaces/IModule.sol";
/**
* @title Factory for deploying PreSaleSTO module
*/
contract PreSaleSTOFactory is IModuleFactory {
/**
* @notice Constructor
* @param _polyAddress Address of the polytoken
*/
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public
IModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost)
{
}
/**
* @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), "Failed transferFrom because of sufficent Allowance is not provided");
}
//Check valid bytes - can only call module init function
PreSaleSTO preSaleSTO = new PreSaleSTO(msg.sender, address(polyToken));
//Checks that _data is valid (not calling anything it shouldn't)
require(getSig(_data) == preSaleSTO.getInitFunction(), "Provided data is not valid");
require(address(preSaleSTO).call(_data), "Un-successfull call");
emit LogGenerateModuleFromFactory(address(preSaleSTO), getName(), address(this), msg.sender, now);
return address(preSaleSTO);
}
/**
* @notice Type of the Module factory
*/
function getType() public view returns(uint8) {
return 3;
}
/**
* @notice Get the name of the Module
*/
function getName() public view returns(bytes32) {
return "PreSaleSTO";
}
/**
* @notice Get the description of the Module
*/
function getDescription() public view returns(string) {
return "Allows Issuer to configure pre-sale token allocations";
}
/**
* @notice Get the title of the Module
*/
function getTitle() public view returns(string) {
return "PreSale STO";
}
/**
* @notice Get the Instructions that helped to used the module
*/
function getInstructions() public view returns(string) {
return "Configure and track pre-sale token allocations";
}
/**
* @notice Get the tags related to the module factory
*/
function getTags() public view returns(bytes32[]) {
bytes32[] memory availableTags = new bytes32[](1);
availableTags[0] = "Presale";
return availableTags;
}
}