-
Notifications
You must be signed in to change notification settings - Fork 4
/
ProxyTokenFactory.sol
69 lines (58 loc) · 1.92 KB
/
ProxyTokenFactory.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
pragma solidity 0.4.24;
import {OwnedUpgradeabilityProxy as ProxyToken} from "../proxy/OwnedUpgradeabilityProxy.sol";
import "openzeppelin-solidity/contracts/lifecycle/TokenDestructible.sol";
import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "../interfaces/IAssetTokenInitializer.sol";
/**
* @title ProxyToken contract factory
*
* @dev Implementation of the ProxyToken contract factory.
* Launches Owned and Upgradeable Proxy Contracts,
* points them to the passed in implementation
*/
contract ProxyTokenFactory is TokenDestructible, Pausable {
event ProxyTokenCreated(
address indexed owner,
address indexed implementationAddress,
address indexed proxyTokenAddress,
uint256 _initialSupply,
string _name,
uint8 _decimalUnits,
string _symbol
);
function createProxyToken(
IAssetTokenInitializer _implementation,
uint256 _initialSupply,
string _name,
uint8 _decimalUnits,
string _symbol
)
external
whenNotPaused
returns (address)
{
require(_implementation != address(0), "Implementation must not be address 0");
require(_implementation != address(this), "Implementation must not be this address");
ProxyToken proxyToken = new ProxyToken();
proxyToken.upgradeTo(_implementation);
IAssetTokenInitializer proxyTokenInitializer = IAssetTokenInitializer(address(proxyToken));
proxyTokenInitializer.initialize(
msg.sender,
_initialSupply,
_name,
_decimalUnits,
_symbol
);
proxyToken.transferProxyOwnership(msg.sender);
emit ProxyTokenCreated(
msg.sender,
_implementation,
proxyToken,
_initialSupply,
_name,
_decimalUnits,
_symbol
);
return proxyToken;
}
}