-
Notifications
You must be signed in to change notification settings - Fork 14
/
CloneRegistry.sol
68 lines (56 loc) · 2.02 KB
/
CloneRegistry.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
// SPDX-License-Identifier: GPL-3.0
// Docgen-SOLC: 0.8.15
pragma solidity ^0.8.15;
import { Owned } from "../utils/Owned.sol";
/**
* @title CloneRegistry
* @author RedVeil
* @notice Registers clones created by `CloneFactory`.
*
* Clones get saved on creation via `DeploymentController`.
* Is used by `VaultController` to check if a target is a registerd clone.
*/
contract CloneRegistry is Owned {
/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/
/// @param _owner `AdminProxy`
constructor(address _owner) Owned(_owner) {}
/*//////////////////////////////////////////////////////////////
ADD CLONE LOGIC
//////////////////////////////////////////////////////////////*/
mapping(address => bool) public cloneExists;
// TemplateCategory => TemplateId => Clones
mapping(bytes32 => mapping(bytes32 => address[])) public clones;
address[] public allClones;
event CloneAdded(address clone);
/**
* @notice Add a clone to the registry. Caller must be owner. (`DeploymentController`)
* @param templateCategory Category of the template to use.
* @param templateId Unique Id of the template to use.
* @param clone Address of the clone to add.
*/
function addClone(
bytes32 templateCategory,
bytes32 templateId,
address clone
) external onlyOwner {
cloneExists[clone] = true;
clones[templateCategory][templateId].push(clone);
allClones.push(clone);
emit CloneAdded(clone);
}
/*//////////////////////////////////////////////////////////////
VIEWS
//////////////////////////////////////////////////////////////*/
function getClonesByCategoryAndId(bytes32 templateCategory, bytes32 templateId)
external
view
returns (address[] memory)
{
return clones[templateCategory][templateId];
}
function getAllClones() external view returns (address[] memory) {
return allClones;
}
}