-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: break out lazy sovereign into own factory
- Loading branch information
1 parent
3584da8
commit aca7f4b
Showing
6 changed files
with
130 additions
and
48 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
scripts/token/sovereign/LazySovereignNFTFactoryDeploy.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
import "../../../src/token/ERC721/sovereign/lazy/LazySovereignNFTContractFactory.sol"; | ||
|
||
contract LazySovereignNFTContractFactoryDeploy is Script { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// Deploy Logic Contracts | ||
new LazySovereignNFTContractFactory(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/token/ERC721/sovereign/lazy/LazySovereignNFTContractFactory.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// contracts/token/ERC721/sovereign/SovereignNFTContractFactory.sol | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.15; | ||
|
||
import "openzeppelin-contracts/access/Ownable.sol"; | ||
import "openzeppelin-contracts/proxy/Clones.sol"; | ||
import "./LazySovereignNFT.sol"; | ||
import "./extensions/LazySovereignNFTRoyaltyGuard.sol"; | ||
import "./extensions/LazySovereignNFTRoyaltyGuardDeadmanTrigger.sol"; | ||
|
||
contract LazySovereignNFTContractFactory is Ownable { | ||
|
||
bytes32 public constant LAZY_SOVEREIGN_NFT = keccak256("LAZY_SOVEREIGN_NFT"); | ||
bytes32 public constant LAZY_ROYALTY_GUARD = keccak256("LAZY_ROYALTY_GUARD"); | ||
bytes32 public constant LAZY_ROYALTY_GUARD_DEADMAN = keccak256("LAZY_ROYALTY_GUARD_DEADMAN"); | ||
|
||
address public lazySovereignNFT; | ||
address public lazySovereignNFTRoyaltyGuard; | ||
address public lazySovereignNFTRoyaltyGuardDeadmanTrigger; | ||
|
||
event SovereignNFTContractCreated( | ||
address indexed contractAddress, | ||
address indexed owner | ||
); | ||
|
||
event SovereignNFTContractCreated( | ||
address indexed contractAddress, | ||
address indexed owner, | ||
bytes32 indexed contractType | ||
); | ||
|
||
constructor() { | ||
LazySovereignNFT lsovNFT = new LazySovereignNFT(); | ||
lazySovereignNFT = address(lsovNFT); | ||
|
||
LazySovereignNFTRoyaltyGuard lsovNFTRG = new LazySovereignNFTRoyaltyGuard(); | ||
lazySovereignNFTRoyaltyGuard = address(lsovNFTRG); | ||
|
||
LazySovereignNFTRoyaltyGuardDeadmanTrigger lsovNFTRGDT = new LazySovereignNFTRoyaltyGuardDeadmanTrigger(); | ||
lazySovereignNFTRoyaltyGuardDeadmanTrigger = address(lsovNFTRGDT); | ||
} | ||
|
||
function setSovereignNFT(address _sovereignNFT, bytes32 _contractType) | ||
external | ||
onlyOwner | ||
{ | ||
require(_sovereignNFT != address(0)); | ||
if (_contractType == LAZY_SOVEREIGN_NFT) { | ||
lazySovereignNFT = _sovereignNFT; | ||
return; | ||
} | ||
if (_contractType == LAZY_ROYALTY_GUARD) { | ||
lazySovereignNFTRoyaltyGuard = _sovereignNFT; | ||
return; | ||
} | ||
if (_contractType == LAZY_ROYALTY_GUARD_DEADMAN) { | ||
lazySovereignNFTRoyaltyGuardDeadmanTrigger = _sovereignNFT; | ||
return; | ||
} | ||
require(false, "setSovereignNFT::Unsupported _contractType."); | ||
} | ||
|
||
|
||
function createSovereignNFTContract( | ||
string memory _name, | ||
string memory _symbol, | ||
uint256 _maxTokens, | ||
bytes32 _contractType | ||
) public returns (address) { | ||
require( | ||
_maxTokens != 0, | ||
"createSovereignNFTContract::_maxTokens cant be zero" | ||
); | ||
|
||
address sovAddr; | ||
if (_contractType == LAZY_SOVEREIGN_NFT) { | ||
sovAddr = Clones.clone(lazySovereignNFT); | ||
LazySovereignNFT(sovAddr).init(_name, _symbol, msg.sender, _maxTokens); | ||
} | ||
if (_contractType == LAZY_ROYALTY_GUARD) { | ||
sovAddr = Clones.clone(lazySovereignNFTRoyaltyGuard); | ||
LazySovereignNFTRoyaltyGuard(sovAddr).init( | ||
_name, | ||
_symbol, | ||
msg.sender, | ||
_maxTokens | ||
); | ||
} | ||
if (_contractType == LAZY_ROYALTY_GUARD_DEADMAN) { | ||
sovAddr = Clones.clone(lazySovereignNFTRoyaltyGuardDeadmanTrigger); | ||
LazySovereignNFTRoyaltyGuardDeadmanTrigger(sovAddr).init( | ||
_name, | ||
_symbol, | ||
msg.sender, | ||
_maxTokens | ||
); | ||
} | ||
require( | ||
sovAddr != address(0), | ||
"createSovereignNFTContract::_contractType unsupported contract type." | ||
); | ||
emit SovereignNFTContractCreated(sovAddr, msg.sender); | ||
emit SovereignNFTContractCreated(sovAddr, msg.sender, _contractType); | ||
|
||
return address(sovAddr); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.