Skip to content

Commit

Permalink
Add initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Jul 21, 2022
1 parent 91c03a5 commit 4d770b6
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 4 deletions.
2 changes: 2 additions & 0 deletions contracts/SoundEdition/ISoundEditionV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ interface ISoundEditionV1 is IERC721AUpgradeable {
string memory _name,
string memory _symbol
) external;

function mint(address _to, uint256 _quantity) external payable;
}
40 changes: 40 additions & 0 deletions contracts/SoundEdition/ISoundNftV1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.15;

import "chiru-labs/ERC721A-Upgradeable/IERC721AUpgradeable.sol";
import "openzeppelin-upgradeable/access/OwnableUpgradeable.sol";

/*
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒███████████████████████████████████████████████████████████
▒███████████████████████████████████████████████████████████
▒▓▓▓▓▓▓▓▓▓▓▓▓▓████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████▓▒▒▒▒▒▒▒▒▒▒▒▒▒
█████████████████████████████▓ ████████████████████████████████████████████
█████████████████████████████▓ ████████████████████████████████████████████
█████████████████████████████▓ ▒▒▒▒▒▒▒▒▒▒▒▒▒██████████████████████████████
█████████████████████████████▓ ▒█████████████████████████████
█████████████████████████████▓ ▒████████████████████████████
█████████████████████████████████████████████████████████▓
███████████████████████████████████████████████████████████
███████████████████████████████████████████████████████████▒
███████████████████████████████████████████████████████████▒
▓██████████████████████████████████████████████████████████▒
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████████████████████▒
█████████████████████████████ ▒█████████████████████████████▒
██████████████████████████████ ▒█████████████████████████████▒
██████████████████████████████▓▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒█████████████████████████████▒
████████████████████████████████████████████▒ ▒█████████████████████████████▒
████████████████████████████████████████████▒ ▒█████████████████████████████▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▓██████████████████████████████████████████████████████████▒
▓██████████████████████████████████████████████████████████
*/

/// @title ISoundNftV1
/// @author Sound.xyz
interface ISoundNftV1 is IERC721AUpgradeable {
function initialize(string memory _name, string memory _symbol) external;

function mint(address to, uint256 quantity) external payable;
}
25 changes: 21 additions & 4 deletions contracts/SoundEdition/SoundEditionV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "chiru-labs/ERC721A-Upgradeable/ERC721AUpgradeable.sol";
import "openzeppelin-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "openzeppelin-upgradeable/access/OwnableUpgradeable.sol";
import "openzeppelin-upgradeable/interfaces/IERC2981Upgradeable.sol";
import "openzeppelin-upgradeable/access/AccessControlUpgradeable.sol";

/*
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
Expand Down Expand Up @@ -35,7 +36,9 @@ import "openzeppelin-upgradeable/interfaces/IERC2981Upgradeable.sol";

/// @title SoundEditionV1
/// @author Sound.xyz
contract SoundEditionV1 is ERC721AUpgradeable, IERC2981Upgradeable, OwnableUpgradeable {
contract SoundEditionV1 is ERC721AUpgradeable, IERC2981Upgradeable, OwnableUpgradeable, AccessControlUpgradeable {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

/// @notice Initializes the contract
/// @param _owner Owner of contract (artist)
/// @param _name Name of the token
Expand All @@ -47,9 +50,13 @@ contract SoundEditionV1 is ERC721AUpgradeable, IERC2981Upgradeable, OwnableUpgra
) public initializerERC721A initializer {
__ERC721A_init(_name, _symbol);
__Ownable_init();

__AccessControl_init();

// Set ownership to owner
transferOwnership(_owner);

// Give owner the DEFAULT_ADMIN_ROLE
_grantRole(DEFAULT_ADMIN_ROLE, _owner);
}

/// @notice Informs other contracts which interfaces this contract supports
Expand All @@ -58,10 +65,12 @@ contract SoundEditionV1 is ERC721AUpgradeable, IERC2981Upgradeable, OwnableUpgra
function supportsInterface(bytes4 _interfaceId)
public
view
override(ERC721AUpgradeable, IERC165Upgradeable)
override(ERC721AUpgradeable, AccessControlUpgradeable, IERC165Upgradeable)
returns (bool)
{
// todo
return
ERC721AUpgradeable.supportsInterface(_interfaceId) ||
AccessControlUpgradeable.supportsInterface(_interfaceId);
}

/// @notice Get royalty information for token
Expand All @@ -75,4 +84,12 @@ contract SoundEditionV1 is ERC721AUpgradeable, IERC2981Upgradeable, OwnableUpgra
{
// todo
}

/// @notice Mints `_quantity` tokens to addrress `_to`
/// Each token will be assigned a token ID that is consecutively increasing
/// @param _to Address to mint to
/// @param _quantity Number of tokens to mint
function mint(address _to, uint256 _quantity) public payable onlyRole(MINTER_ROLE) {
_mint(_to, _quantity);
}
}
65 changes: 65 additions & 0 deletions contracts/SoundEdition/SoundNftV1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.15;

import "chiru-labs/ERC721A-Upgradeable/ERC721AUpgradeable.sol";
import "openzeppelin-upgradeable/access/OwnableUpgradeable.sol";
import "openzeppelin-upgradeable/access/AccessControlUpgradeable.sol";

/*
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒███████████████████████████████████████████████████████████
▒███████████████████████████████████████████████████████████
▒▓▓▓▓▓▓▓▓▓▓▓▓▓████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████▓▒▒▒▒▒▒▒▒▒▒▒▒▒
█████████████████████████████▓ ████████████████████████████████████████████
█████████████████████████████▓ ████████████████████████████████████████████
█████████████████████████████▓ ▒▒▒▒▒▒▒▒▒▒▒▒▒██████████████████████████████
█████████████████████████████▓ ▒█████████████████████████████
█████████████████████████████▓ ▒████████████████████████████
█████████████████████████████████████████████████████████▓
███████████████████████████████████████████████████████████
███████████████████████████████████████████████████████████▒
███████████████████████████████████████████████████████████▒
▓██████████████████████████████████████████████████████████▒
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████████████████████▒
█████████████████████████████ ▒█████████████████████████████▒
██████████████████████████████ ▒█████████████████████████████▒
██████████████████████████████▓▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒█████████████████████████████▒
████████████████████████████████████████████▒ ▒█████████████████████████████▒
████████████████████████████████████████████▒ ▒█████████████████████████████▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▓██████████████████████████████████████████████████████████▒
▓██████████████████████████████████████████████████████████
*/

/// @title SoundNftV1
/// @author Sound.xyz
contract SoundNftV1 is ERC721AUpgradeable, OwnableUpgradeable, AccessControlUpgradeable {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

function initialize(string memory _name, string memory _symbol)
public
initializerERC721A
initializer
{
__ERC721A_init(_name, _symbol);
__Ownable_init();
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

function mint(address to, uint256 quantity) public payable onlyRole(MINTER_ROLE) {
_mint(to, quantity);
}

function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721AUpgradeable, AccessControlUpgradeable)
returns (bool)
{
return
ERC721AUpgradeable.supportsInterface(interfaceId) ||
AccessControlUpgradeable.supportsInterface(interfaceId);
}
}
54 changes: 54 additions & 0 deletions contracts/modules/Minting/EditionMintControllers.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.15;

contract EditionMintControllers {

event EditionMintControllerUpdated(address indexed edition, address indexed newController);

mapping(address => address) private _controllers;

modifier onlyEditionMintController(address edition) virtual {
require(msg.sender == _controllers[edition], "Unauthorized.");
_;
}

function _initEditionMintController(address edition) internal {
_initEditionMintController(edition, msg.sender);
}

function _initEditionMintController(address edition, address editionMintController) internal {
require(editionMintController != address(0), "Edition mint controller cannot be the zero address.");
require(_controllers[edition] == address(0), "Edition mint controller already exists.");

_controllers[edition] = editionMintController;

emit EditionMintControllerUpdated(edition, editionMintController);
}

function _deleteEditionMintController(address edition) internal {
require(_controllers[edition] != address(0), "Edition mint controller does not exist.");

delete _controllers[edition];

emit EditionMintControllerUpdated(edition, address(0));
}

function _deleteEditionMintController() internal {
_deleteEditionMintController(msg.sender);
}

function _editionMintController(address edition) internal view returns (address) {
return _controllers[edition];
}

function setEditionMintController(
address edition,
address newController
) public virtual onlyEditionMintController(edition) {
require(newController != address(0), "");

_controllers[edition] = newController;
emit EditionMintControllerUpdated(edition, newController);
}
}
49 changes: 49 additions & 0 deletions contracts/modules/Minting/FixedPricePermissionedSaleMinter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.15;

import "./EditionMintControllers.sol";
import "../../SoundEdition/ISoundEditionV1.sol";

contract FixedPricePermissionedMinter is EditionMintControllers {

struct EditionMintData {
// The price at which each token will be sold, in ETH.
uint256 price;
// Whitelist signer address.
address signer;
// The maximum number of tokens that can can be minted for this sale.
uint32 maxMinted;
// The total number of tokens minted so far for this sale.
uint32 totalMinted;
}

mapping(address => EditionMintData) public editionMintData;

function createEditionMint(
address edition,
uint256 price,
address signer,
uint32 maxMinted
) public {
_initEditionMintController(edition);
EditionMintData storage data = editionMintData[edition];
data.price = price;
data.signer = signer;
data.maxMinted = maxMinted;
}

function deleteMintee(address edition) public onlyEditionMintController(edition) {
_deleteEditionMintController();
delete editionMintData[edition];
}

function mint(address edition, uint256 quantity) public payable {
// EditionMintData storage data = editionMintData[edition];
// require(data.startTime <= block.timestamp, "Mint not started.");
// require(data.endTime > block.timestamp, "Mint has ended.");
// require(data.price * quantity == msg.value, "Wrong ether value.");
// require((data.totalMinted += quantity) <= data.maxMinted, "No more mints.");
ISoundEditionV1(edition).mint{value: msg.value}(edition, quantity);
}
}
Loading

0 comments on commit 4d770b6

Please sign in to comment.