-
Notifications
You must be signed in to change notification settings - Fork 4
/
LockUpPeriodValidator.sol
117 lines (103 loc) · 2.9 KB
/
LockUpPeriodValidator.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
108
109
110
111
112
113
114
115
116
117
pragma solidity 0.4.24;
import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "../interfaces/IModuleContract.sol";
import "../inheritables/TransferValidator.sol";
/**
* @title LockUpPeriodValidator
* TransferValidator where Owner sets the time when a LockUp period ends. All transfers fail until that time is reached.
*/
contract LockUpPeriodValidator is TransferValidator, IModuleContract, Pausable {
/*----------- Constants -----------*/
bytes32 public constant moduleName = "LockUpPeriodValidator";
/*----------- Globals -----------*/
uint256 public openingTime_;
/*----------- Events -----------*/
event LogSetOpeningTime(address indexed sender, uint newOpeningTime);
/**
* @dev Constructor for contract
* @param _openingTime blocktime at which trading can start
*/
constructor(
uint _openingTime
) public {
setOpeningTime_(_openingTime);
}
/*----------- Validator Methods -----------*/
/**
* @dev Validate whether a trade will occur before the specified openingTime
* @param _token address token we are checking
* @param _to address The address which you want to transfer to
* @param _from address The Address which you want to transfer from
* @param _amount uint256 The Amount of tokens being transferred
* @return bool
*/
function canSend(
address _token,
address _from,
address _to,
uint256 _amount
)
external
returns(bool)
{
return (openingTime_ <= block.timestamp);
}
/*----------- Internal Methods -----------*/
function setOpeningTime_(uint _openingTime)
internal
{
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
openingTime_ = _openingTime;
}
/*----------- Setter Methods -----------*/
/**
* @dev Sets OpeningTime,
* @param _openingTime desired opening time
* @return uint newOpeningTime
*/
function setOpeningTime(uint _openingTime)
external
onlyOwner
whenNotPaused
returns (uint newOpeningTime)
{
setOpeningTime_(_openingTime);
emit LogSetOpeningTime(msg.sender, openingTime_);
return openingTime_;
}
/*----------- Getter Methods -----------*/
/**
* @dev Returns the name of the validator
* @return bytes32
*/
function getName()
external
view
returns(bytes32)
{
return moduleName;
}
/**
* @dev Returns the type of the validator
* @return uint8
*/
function getType()
external
view
returns(uint8)
{
return moduleType;
}
/**
* @dev Returns the investorMin of the validator
* @return uint
*/
function openingTime()
external
view
returns(uint)
{
return openingTime_;
}
}