-
Notifications
You must be signed in to change notification settings - Fork 15
/
PresaleFactory.sol
74 lines (59 loc) · 2.3 KB
/
PresaleFactory.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
// SPDX-License-Identifier: UNLICENSED
// @Credits Unicrypt Network 2021
// This contract logs all presales on the platform
pragma solidity 0.6.12;
import "./Ownable.sol";
import "./EnumerableSet.sol";
contract PresaleFactory is Ownable {
using EnumerableSet for EnumerableSet.AddressSet;
EnumerableSet.AddressSet private presales;
EnumerableSet.AddressSet private presaleGenerators;
mapping(address => EnumerableSet.AddressSet) private presaleOwners;
event presaleRegistered(address presaleContract);
function adminAllowPresaleGenerator (address _address, bool _allow) public onlyOwner {
if (_allow) {
presaleGenerators.add(_address);
} else {
presaleGenerators.remove(_address);
}
}
/**
* @notice called by a registered PresaleGenerator upon Presale creation
*/
function registerPresale (address _presaleAddress) public {
require(presaleGenerators.contains(msg.sender), 'FORBIDDEN');
presales.add(_presaleAddress);
emit presaleRegistered(_presaleAddress);
}
/**
* @notice Number of allowed PresaleGenerators
*/
function presaleGeneratorsLength() external view returns (uint256) {
return presaleGenerators.length();
}
/**
* @notice Gets the address of a registered PresaleGenerator at specified index
*/
function presaleGeneratorAtIndex(uint256 _index) external view returns (address) {
return presaleGenerators.at(_index);
}
/**
* @notice returns true if the presale address was generated by the Octofi presale platform
*/
function presaleIsRegistered(address _presaleAddress) external view returns (bool) {
return presales.contains(_presaleAddress);
}
/**
* @notice The length of all presales on the platform
*/
function presalesLength() external view returns (uint256) {
return presales.length();
}
/**
* @notice gets a presale at a specific index. Although using Enumerable Set, since presales are only added and not removed, indexes will never change
* @return the address of the Presale contract at index
*/
function presaleAtIndex(uint256 _index) external view returns (address) {
return presales.at(_index);
}
}