forked from rmrk-team/evm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLightmInit.sol
More file actions
100 lines (88 loc) · 4.8 KB
/
LightmInit.sol
File metadata and controls
100 lines (88 loc) · 4.8 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
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {LibDiamond} from "./library/LibDiamond.sol";
import {IERC165, IERC721, IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./access/AccessControl.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
import {IDiamondCut} from "./interfaces/IDiamondCut.sol";
import {IRMRKNestable, ILightmNestableExtension} from "./interfaces/ILightmNestable.sol";
import {IRMRKMultiAsset, ILightmMultiAssetExtension, ILightmMultiAssetEventsAndStruct} from "./interfaces/ILightmMultiAsset.sol";
import {IERC6220WithoutIERC5773} from "./interfaces/IERC6220.sol";
import {ILightmEquippable} from "./interfaces/ILightmEquippable.sol";
import {IRMRKCollectionMetadata, IRMRKCollectionMetadataEventsAndStruct} from "./interfaces/IRMRKCollectionMetadata.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import {ERC2981Internal} from "./internalFunctionSet/ERC2981Internal.sol";
import {ILightmImplementer} from "./interfaces/ILightmImplementer.sol";
import {ILightmMintModule} from "./interfaces/ILightmMintModule.sol";
import {ERC721Storage, MultiAssetStorage, EquippableStorage, CollectionMetadataStorage, LightmImplStorage, LightmMintModuleStorage} from "./internalFunctionSet/Storage.sol";
// It is expected that this contract is customized if you want to deploy your diamond
// with data from a deployment script. Use the init function to initialize state variables
// of your diamond. Add parameters to the init funciton if you need to.
contract LightmInit is
IRMRKCollectionMetadataEventsAndStruct,
ILightmMultiAssetEventsAndStruct,
AccessControlInternal,
ERC2981Internal
{
struct InitStruct {
string name;
string symbol;
string fallbackURI;
string collectionMetadataURI;
uint96 royaltyNumerator;
ILightmMintModule.MintConfig mintConfig;
}
// You can add parameters to this function in order to pass in
// data to set your own state variables
function init(InitStruct calldata _initStruct, address _owner) external {
// adding ERC165 data
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
ds.supportedInterfaces[type(IERC165).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
ds.supportedInterfaces[type(IERC721).interfaceId] = true;
ds.supportedInterfaces[type(IERC721Metadata).interfaceId] = true;
ds.supportedInterfaces[type(IRMRKNestable).interfaceId] = true;
ds.supportedInterfaces[
type(ILightmNestableExtension).interfaceId
] = true;
ds.supportedInterfaces[type(IRMRKMultiAsset).interfaceId] = true;
ds.supportedInterfaces[
type(ILightmMultiAssetExtension).interfaceId
] = true;
ds.supportedInterfaces[
type(IERC6220WithoutIERC5773).interfaceId
] = true;
ds.supportedInterfaces[type(ILightmEquippable).interfaceId] = true;
ds.supportedInterfaces[
type(IRMRKCollectionMetadata).interfaceId
] = true;
ds.supportedInterfaces[type(IERC2981).interfaceId] = true;
ds.supportedInterfaces[type(IAccessControl).interfaceId] = true;
ds.supportedInterfaces[type(ILightmImplementer).interfaceId] = true;
ds.supportedInterfaces[type(ILightmMintModule).interfaceId] = true;
// add your own state variables
// EIP-2535 specifies that the `diamondCut` function takes two optional
// arguments: address _init and bytes calldata _calldata
// These arguments are used to execute an arbitrary function using delegatecall
// in order to set state variables in the diamond during deployment or an upgrade
// More info here: https://eips.ethereum.org/EIPS/eip-2535#diamond-interface
_grantRole(DEFAULT_ADMIN_ROLE, _owner);
_setDefaultRoyalty(_owner, _initStruct.royaltyNumerator);
LightmImplStorage.State storage lis = LightmImplStorage.getState();
lis._owner = _owner;
LightmMintModuleStorage.State storage mms = LightmMintModuleStorage
.getState();
mms.config = _initStruct.mintConfig;
ERC721Storage.State storage s = ERC721Storage.getState();
s._name = _initStruct.name;
s._symbol = _initStruct.symbol;
MultiAssetStorage.State storage mrs = MultiAssetStorage.getState();
mrs._fallbackURI = _initStruct.fallbackURI;
emit LightmMultiAssetFallbackURISet(_initStruct.fallbackURI);
CollectionMetadataStorage.State storage cms = CollectionMetadataStorage
.getState();
cms._collectionMetadata = _initStruct.collectionMetadataURI;
emit RMRKCollectionMetdataSet(_initStruct.collectionMetadataURI);
}
}