Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
.env
pnpm-lock.yaml
coverage
coverage.json
typechain
Expand Down
13 changes: 11 additions & 2 deletions contracts/RMRK/Diamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ pragma solidity ^0.8.0;
import {LibDiamond} from "./library/LibDiamond.sol";
import {IDiamondCut} from "./interfaces/IDiamondCut.sol";

/**
* @title Diamond
* @author Lightm
* @notice Entry for external call, all method must be call by Diamond contract
* @dev You should deploy diamond cut facet first before deploy Diamond
* @dev function in diamondCut will automatically register in constructor
*/
contract Diamond {
constructor(address _contractOwner, address _diamondCutFacet) payable {
LibDiamond.setContractOwner(_contractOwner);
Expand All @@ -27,8 +34,10 @@ contract Diamond {
LibDiamond.diamondCut(cut, address(0), "");
}

// Find facet for function that is called and execute the
// function if a facet is found and return any value.
/**
* @dev Find facet for function that is called and execute the
* @dev function if a facet is found and return any value.
*/
fallback() external payable {
LibDiamond.DiamondStorage storage ds;
bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
Expand Down
18 changes: 10 additions & 8 deletions contracts/RMRK/LightmInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import {ILightmEquippable} from "./interfaces/ILightmEquippable.sol";
import {IRMRKCollectionMetadata} from "./interfaces/IRMRKCollectionMetadata.sol";
import {ERC721Storage, MultiAssetStorage, EquippableStorage, CollectionMetadataStorage, LightmImplStorage} 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.

/**
* @dev 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 {
struct InitStruct {
string name;
Expand All @@ -23,8 +24,10 @@ contract LightmInit {
string collectionMetadataURI;
}

// You can add parameters to this function in order to pass in
// data to set your own state variables
/**
* @dev You can add parameters to this function in order to pass in
* You can add parameters to this function in order to pass in
*/
function init(InitStruct calldata _initStruct, address _owner) external {
// adding ERC165 data
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
Expand Down Expand Up @@ -55,8 +58,7 @@ contract LightmInit {
s._name = _initStruct.name;
s._symbol = _initStruct.symbol;

MultiAssetStorage.State storage mrs = MultiAssetStorage
.getState();
MultiAssetStorage.State storage mrs = MultiAssetStorage.getState();
mrs._fallbackURI = _initStruct.fallbackURI;

CollectionMetadataStorage.State storage cms = CollectionMetadataStorage
Expand Down
21 changes: 16 additions & 5 deletions contracts/RMRK/LightmUniversalFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import {LightmImpl} from "../implementations/LightmImplementer.sol";

import "./interfaces/ILightmUniversalFactory.sol";

import "hardhat/console.sol";

/**
* @title LightmUniversalFactory
* @author Lightm
* @notice Factory on-chain that indexed all facet contract address
* and can be used for deploying RMRK NFT collection
*/
contract LightmUniversalFactory is ILightmUniversalFactory {
string private constant VERSION = "0.1.0-alpha";

Expand Down Expand Up @@ -98,9 +102,16 @@ contract LightmUniversalFactory is ILightmUniversalFactory {
return _implContractAddress;
}

function deployCollection(LightmInit.InitStruct calldata initStruct)
external
{
/**
* @notice Used to deploy new collection.
* @dev It will deploy diamond contract only.
* @dev It will loads all facet cuts by `diamondCut` method after deployed.
* @dev Diamond contract can use all DiamondCut methods because it has loaded when Diamond contract init.
* @param initStruct metadata of NFT like name,symbol
*/
function deployCollection(
LightmInit.InitStruct calldata initStruct
) external {
Diamond instance = new Diamond(address(this), _diamondCutFacetAddress);

address instanceAddress = address(instance);
Expand Down
Loading