-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPartyFactory.sol
54 lines (47 loc) · 1.55 KB
/
PartyFactory.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
// SPDX-License-Identifier: Beta Software
pragma solidity ^0.8;
import "../globals/IGlobals.sol";
import "../globals/LibGlobals.sol";
import "../tokens/IERC721.sol";
import "../utils/Proxy.sol";
import "./Party.sol";
import "./IPartyFactory.sol";
/// @notice Factory used to deploys new proxified `Party` instances.
contract PartyFactory is IPartyFactory {
error InvalidAuthorityError(address authority);
/// @inheritdoc IPartyFactory
IGlobals public immutable GLOBALS;
// Set the `Globals` contract.
constructor(IGlobals globals) {
GLOBALS = globals;
}
/// @inheritdoc IPartyFactory
function createParty(
address authority,
Party.PartyOptions memory opts,
IERC721[] memory preciousTokens,
uint256[] memory preciousTokenIds
)
external
returns (Party party)
{
// Ensure a valid authority is set to mint governance NFTs.
if (authority == address(0)) {
revert InvalidAuthorityError(authority);
}
// Deploy a new proxified `Party` instance.
Party.PartyInitData memory initData = Party.PartyInitData({
options: opts,
preciousTokens: preciousTokens,
preciousTokenIds: preciousTokenIds,
mintAuthority: authority
});
party = Party(payable(
new Proxy(
GLOBALS.getImplementation(LibGlobals.GLOBAL_PARTY_IMPL),
abi.encodeCall(Party.initialize, (initData))
)
));
emit PartyCreated(party, msg.sender);
}
}