-
Notifications
You must be signed in to change notification settings - Fork 2
/
VRFNFTRandomDrawFactory.sol
60 lines (54 loc) · 2.22 KB
/
VRFNFTRandomDrawFactory.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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
import {IERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol";
import {ClonesUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {OwnableUpgradeable} from "./ownable/OwnableUpgradeable.sol";
import {IVRFNFTRandomDrawFactory} from "./interfaces/IVRFNFTRandomDrawFactory.sol";
import {IVRFNFTRandomDraw} from "./interfaces/IVRFNFTRandomDraw.sol";
import {Version} from "./utils/Version.sol";
/// @notice VRFNFTRandom Draw with NFT Tickets Factory Implementation
/// @author @isiain
contract VRFNFTRandomDrawFactory is
IVRFNFTRandomDrawFactory,
OwnableUpgradeable,
UUPSUpgradeable,
Version(1)
{
/// @notice Implementation to clone of the raffle code
address public immutable implementation;
/// @notice Constructor to set the implementation
constructor(address _implementation) initializer {
if (_implementation == address(0)) {
revert IMPL_ZERO_ADDRESS_NOT_ALLOWED();
}
implementation = _implementation;
}
function initialize(address _initialOwner) initializer external {
__Ownable_init(_initialOwner);
emit SetupFactory();
}
/// @notice Function to make a new drawing
/// @param settings settings for the new drawing
function makeNewDraw(IVRFNFTRandomDraw.Settings memory settings)
external
returns (address)
{
address admin = msg.sender;
// Clone the contract
address newDrawing = ClonesUpgradeable.clone(implementation);
// Setup the new drawing
IVRFNFTRandomDraw(newDrawing).initialize(admin, settings);
// Emit event for indexing
emit SetupNewDrawing(admin, newDrawing);
// Return address for integration or testing
return newDrawing;
}
/// @notice Allows only the owner to upgrade the contract
/// @param newImplementation proposed new upgrade implementation
function _authorizeUpgrade(address newImplementation)
internal
override
onlyOwner
{}
}