forked from PolymathNetwork/polymath-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DummySTO.sol
107 lines (90 loc) · 3.04 KB
/
DummySTO.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
pragma solidity ^0.4.24;
import "./ISTO.sol";
import "../../interfaces/IST20.sol";
/**
* @title STO module for sample implementation of a different crowdsale module
*/
contract DummySTO is ISTO {
bytes32 public constant ADMIN = "ADMIN";
uint256 public investorCount;
uint256 public cap;
string public someString;
event LogGenerateTokens(address _investor, uint256 _amount);
mapping (address => uint256) public investors;
/**
* @notice Constructor
* @param _securityToken Address of the security token
* @param _polyAddress Address of the polytoken
*/
constructor (address _securityToken, address _polyAddress) public
IModule(_securityToken, _polyAddress)
{
}
/**
* @notice Function used to intialize the differnet variables
* @param _startTime Unix timestamp at which offering get started
* @param _endTime Unix timestamp at which offering get ended
* @param _cap Maximum No. of tokens for sale
* @param _someString Any string that contails the details
*/
function configure(uint256 _startTime, uint256 _endTime, uint256 _cap, string _someString) public onlyFactory {
startTime = _startTime;
endTime = _endTime;
cap = _cap;
someString = _someString;
}
/**
* @notice This function returns the signature of configure function
*/
function getInitFunction() public pure returns (bytes4) {
return bytes4(keccak256("configure(uint256,uint256,uint256,string)"));
}
/**
* @notice Function used to generate the tokens
* @param _investor Address of the investor
* @param _amount Amount of ETH or Poly invested by the investor
*/
function generateTokens(address _investor, uint256 _amount) public withPerm(ADMIN) {
require(!paused);
require(_amount > 0, "Amount should be greater than 0");
IST20(securityToken).mint(_investor, _amount);
if (investors[_investor] == 0) {
investorCount = investorCount + 1;
}
//TODO: Add SafeMath maybe
investors[_investor] = investors[_investor] + _amount;
emit LogGenerateTokens (_investor, _amount);
}
/**
* @notice Return ETH raised by the STO
*/
function getRaisedEther() public view returns (uint256) {
return 0;
}
/**
* @notice Return POLY raised by the STO
*/
function getRaisedPOLY() public view returns (uint256) {
return 0;
}
/**
* @notice Return the total no. of investors
*/
function getNumberInvestors() public view returns (uint256) {
return investorCount;
}
/**
* @notice Return the total no. of investors
*/
function getTokensSold() public view returns (uint256) {
return 0;
}
/**
* @notice Return the permissions flag that are associated with STO
*/
function getPermissions() public view returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](1);
allPermissions[0] = ADMIN;
return allPermissions;
}
}