-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollectionFactory.sol
104 lines (80 loc) · 3.66 KB
/
CollectionFactory.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
/*
███╗ ███╗███████╗████████╗ █████╗ ██╗ █████╗ ██████╗ ███████╗██╗
████╗ ████║██╔════╝╚══██╔══╝██╔══██╗██║ ██╔══██╗██╔══██╗██╔════╝██║
██╔████╔██║█████╗ ██║ ███████║██║ ███████║██████╔╝█████╗ ██║
██║╚██╔╝██║██╔══╝ ██║ ██╔══██║██║ ██╔══██║██╔══██╗██╔══╝ ██║
██║ ╚═╝ ██║███████╗ ██║ ██║ ██║███████╗██║ ██║██████╔╝███████╗███████╗
╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝╚══════╝
Deployed by Metalabel with 💖 as a permanent application on the Ethereum blockchain.
Metalabel is a growing universe of tools, knowledge, and resources for
metalabels and cultural collectives.
Our purpose is to establish the metalabel as key infrastructure for creative
collectives and to inspire a new culture of creative collaboration and mutual
support.
OUR SQUAD
Anna Bulbrook (Curator)
Austin Robey (Community)
Brandon Valosek (Engineer)
Ilya Yudanov (Designer)
Lauren Dorman (Engineer)
Rob Kalin (Board)
Yancey Strickler (Director)
https://metalabel.xyz
*/
import {ClonesWithImmutableArgs} from "clones-with-immutable-args/ClonesWithImmutableArgs.sol";
import {INodeRegistry} from "./interfaces/INodeRegistry.sol";
import {Collection} from "./Collection.sol";
/// @notice A factory that deploys record collections.
contract CollectionFactory {
using ClonesWithImmutableArgs for address;
// ---
// Errors
// ---
/// @notice An unauthorized address attempted to create a collection.
error NotAuthorized();
// ---
// Events
// ---
/// @notice A new collection was deployed
event CollectionCreated(
address indexed collection,
string name,
string symbol
);
// ---
// Storage
// ---
/// @notice Reference to the collection implementation that will be cloned.
Collection public immutable implementation;
/// @notice Reference to the node registry of the protocol.
INodeRegistry public immutable nodeRegistry;
// ---
// Constructor
// ---
constructor(INodeRegistry _nodeRegistry, Collection _implementation) {
implementation = _implementation;
nodeRegistry = _nodeRegistry;
}
// ---
// Public funcionality
// ---
/// @notice Deploy a new collection.
function createCollection(
string calldata name,
string calldata symbol,
uint64 controlNode,
address owner,
string calldata collectionURI
) external returns (Collection collection) {
// msg.sender must be authorized to manage the control node
if (!nodeRegistry.isAuthorizedAddressForNode(controlNode, msg.sender)) {
revert NotAuthorized();
}
bytes memory data = abi.encodePacked(nodeRegistry, controlNode);
collection = Collection(address(implementation).clone(data));
collection.init(name, symbol, owner, collectionURI);
emit CollectionCreated(address(collection), name, symbol);
}
}