forked from Perfect-Abstractions/Compose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleDiamond.sol
More file actions
59 lines (52 loc) · 2.07 KB
/
ExampleDiamond.sol
File metadata and controls
59 lines (52 loc) · 2.07 KB
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
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.30;
/* Compose
* https://compose.diamonds
*/
import "../DiamondMod.sol" as DiamondMod;
import "../../access/Owner/OwnerMod.sol" as OwnerMod;
import "../../token/ERC721/Metadata/ERC721MetadataMod.sol" as ERC721MetadataMod;
import "../../interfaceDetection/ERC165/ERC165Mod.sol" as ERC165Mod;
import {IERC721} from "../../interfaces/IERC721.sol";
import {IERC721Metadata} from "../../interfaces/IERC721Metadata.sol";
contract ExampleDiamond {
/**
* @notice Struct to hold facet address and its function selectors.
* struct FacetFunctions {
* address facet;
* bytes4[] selectors;
* }
*/
/**
* @notice Initializes the diamond contract with facets, owner and other data.
* @dev Adds all provided facets to the diamond's function selector mapping and sets the contract owner.
* Each facet in the array will have its function selectors registered to enable delegatecall routing.
* @param _facets Array of facet addresses and their corresponding function selectors to add to the diamond.
* @param _diamondOwner Address that will be set as the owner of the diamond contract.
*/
constructor(DiamondMod.FacetFunctions[] memory _facets, address _diamondOwner) {
DiamondMod.addFacets(_facets);
/*************************************
* Initialize storage variables
************************************/
/**
* Setting the contract owner
*/
OwnerMod.setContractOwner(_diamondOwner);
/**
* Setting ERC721 token details
*/
ERC721MetadataMod.setMetadata({
_name: "ExampleDiamondNFT", _symbol: "EDN", _baseURI: "https://example.com/metadata/"
});
/**
* Registering ERC165 interfaces
*/
ERC165Mod.registerInterface(type(IERC721).interfaceId);
ERC165Mod.registerInterface(type(IERC721Metadata).interfaceId);
}
fallback() external payable {
DiamondMod.diamondFallback();
}
receive() external payable {}
}