-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathMintPassFactory.sol
67 lines (53 loc) · 1.89 KB
/
MintPassFactory.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import './hyperverse/CloneFactory.sol';
import './hyperverse/IHyperverseModule.sol';
import './MintPass.sol';
/**
* @dev Clone Factory Implementation for ERC20 Token
*/
contract MintPassFactory is CloneFactory {
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ S T A T E @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
struct Tenant {
MintPass mintpass;
address owner;
}
mapping(address => Tenant) public tenants;
address public immutable masterContract;
address private hyperverseAdmin = 0xD847C7408c48b6b6720CCa75eB30a93acbF5163D;
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ M O D I F I E R S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
modifier isOwner(address _tenant) {
require(
tenants[_tenant].owner == msg.sender,
'The calling address is not an owner of a tenant'
);
_;
}
modifier isAllowedToCreateInstance(address _tenant) {
require(
msg.sender == _tenant || msg.sender == hyperverseAdmin,
'Please use a valid address to create an instance'
);
_;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ E V E N T S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ C O N S T R U C T O R @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
constructor(address _masterContract) {
masterContract = _masterContract;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ F U N C T I O N S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
function createInstance(string memory name, string memory symbol) external {
address tenant = msg.sender;
MintPass mintpass = MintPass(createClone(masterContract));
//initializing tenant state of clone
mintpass.init(name, symbol, tenant);
//set Tenant data
Tenant storage newTenant = tenants[tenant];
newTenant.mintpass = mintpass;
newTenant.owner = tenant;
}
function getProxy(address _tenant) public view returns (MintPass) {
return tenants[_tenant].mintpass;
}
}