|
1 | 1 | pragma solidity ^0.4.24; |
2 | 2 |
|
3 | | -import "../modules/STO/DummySTO.sol"; |
4 | | -import "../modules/ModuleFactory.sol"; |
5 | | -import "../libraries/Util.sol"; |
| 3 | +import "../modules/STO/DummySTOFactory.sol"; |
6 | 4 |
|
7 | | -contract MockFactory is ModuleFactory { |
| 5 | +/** |
| 6 | + * @title Mock Contract Not fit for production environment |
| 7 | + */ |
8 | 8 |
|
| 9 | +contract MockFactory is DummySTOFactory { |
| 10 | + |
| 11 | + bool public switchTypes = false; |
9 | 12 | /** |
10 | 13 | * @notice Constructor |
11 | 14 | * @param _polyAddress Address of the polytoken |
12 | 15 | */ |
13 | 16 | constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public |
14 | | - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) |
| 17 | + DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) |
15 | 18 | { |
16 | | - version = "1.0.0"; |
17 | | - name = "Mock"; |
18 | | - title = "Mock Manager"; |
19 | | - description = "MockManager"; |
20 | | - compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); |
21 | | - compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); |
22 | | - } |
23 | 19 |
|
24 | | - /** |
25 | | - * @notice used to launch the Module with the help of factory |
26 | | - * @param _data Data used for the intialization of the module factory variables |
27 | | - * @return address Contract address of the Module |
28 | | - */ |
29 | | - function deploy(bytes _data) external returns(address) { |
30 | | - if(setupCost > 0) |
31 | | - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost"); |
32 | | - //Check valid bytes - can only call module init function |
33 | | - DummySTO dummySTO = new DummySTO(msg.sender, address(polyToken)); |
34 | | - //Checks that _data is valid (not calling anything it shouldn't) |
35 | | - require(Util.getSig(_data) == dummySTO.getInitFunction(), "Invalid initialisation"); |
36 | | - require(address(dummySTO).call(_data), "Unsuccessfull initialisation"); |
37 | | - return address(dummySTO); |
38 | 20 | } |
39 | 21 |
|
40 | 22 | /** |
41 | 23 | * @notice Type of the Module factory |
42 | 24 | */ |
43 | 25 | function getTypes() external view returns(uint8[]) { |
44 | | - uint8[] memory res = new uint8[](0); |
45 | | - return res; |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * @notice Get the name of the Module |
50 | | - */ |
51 | | - function getName() public view returns(bytes32) { |
52 | | - return name; |
53 | | - } |
54 | | - |
55 | | - /** |
56 | | - * @notice Get the description of the Module |
57 | | - */ |
58 | | - function getDescription() external view returns(string) { |
59 | | - return description; |
60 | | - } |
61 | | - |
62 | | - /** |
63 | | - * @notice Get the title of the Module |
64 | | - */ |
65 | | - function getTitle() external view returns(string) { |
66 | | - return title; |
67 | | - } |
68 | | - |
69 | | - /** |
70 | | - * @notice Get the version of the Module |
71 | | - */ |
72 | | - function getVersion() external view returns(string) { |
73 | | - return version; |
74 | | - } |
75 | | - |
76 | | - /** |
77 | | - * @notice Get the setup cost of the module |
78 | | - */ |
79 | | - function getSetupCost() external view returns (uint256) { |
80 | | - return setupCost; |
81 | | - } |
82 | | - |
83 | | - /** |
84 | | - * @notice Returns the instructions associated with the module |
85 | | - */ |
86 | | - function getInstructions() external view returns(string) { |
87 | | - return "Mock Manager - This is mock in nature"; |
88 | | - } |
89 | | - |
90 | | - /** |
91 | | - * @notice Get the tags related to the module factory |
92 | | - */ |
93 | | - function getTags() external view returns(bytes32[]) { |
94 | | - bytes32[] memory availableTags = new bytes32[](4); |
95 | | - availableTags[0] = "Mock"; |
96 | | - return availableTags; |
| 26 | + if (!switchTypes) { |
| 27 | + uint8[] memory types = new uint8[](0); |
| 28 | + return types; |
| 29 | + } else { |
| 30 | + uint8[] memory res = new uint8[](2); |
| 31 | + res[0] = 1; |
| 32 | + res[1] = 1; |
| 33 | + return res; |
| 34 | + } |
| 35 | + |
| 36 | + } |
| 37 | + |
| 38 | + function changeTypes() external onlyOwner { |
| 39 | + switchTypes = !switchTypes; |
97 | 40 | } |
98 | 41 |
|
99 | 42 | } |
0 commit comments