Skip to content

Commit

Permalink
better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Aug 11, 2023
1 parent 53d5d33 commit 6998c66
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions src/premint/ZoraCreator1155Preminter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,22 @@ contract ZoraCreator1155Preminter {
string calldata mintComment
) public payable returns (uint256 newTokenId) {
// 1. Validate the signature.
// 2. Create an erc1155 contract with the given name and uri and the creator as the admin/owner
// 3. Allow this contract to create new new tokens on the contract
// 4. Mint a new token, and get the new token id
// 5. Setup fixed price minting rules for the new token
// 6. Make the creator an admin of that token (and remove this contracts admin rights)
// 7. Mint x tokens, as configured, to the executor of this transaction.
// 2. get or create an erc1155 contract with the same determinsitic address as that from the contract config
// 3. Have the erc1155 contract create a new token. the signer must have permission to do mint new tokens
// (that role enforcement is expected to be in the tokenContract).
// 4. The erc1155 will sedtup the token with the signign address as the creator, and follow the creator rewards standard.
// 5. Mint x tokens, as configured, to the executor of this transaction.
// 6. Future: First minter gets rewards

// get or create the contract with the given params
(IZoraCreator1155 tokenContract, bool isNewContract) = _getOrCreateContract(premintConfig.contractConfig);
address contractAddress = address(tokenContract);

newTokenId = tokenContract.delegateSetupNewToken(premintConfig, signature);

// mint the initial x tokens for this new token id to the executor.
address tokenRecipient = msg.sender;
tokenContract.mint{value: msg.value}(
IMinter1155(premintConfig.tokenConfig.fixedPriceMinter),
newTokenId,
quantityToMint,
abi.encode(tokenRecipient, mintComment)
);
// have the address setup the new token. The signer must have permission to do this.
// (that role enforcement is expected to be in the tokenContract).
// the token contract will:

// emit event early to have a cleaner log
emit Preminted(
contractAddress,
newTokenId,
Expand All @@ -85,6 +79,23 @@ contract ZoraCreator1155Preminter {
msg.sender,
quantityToMint
);

// * setup the token with the signer as the creator, and follow the creator rewards standard.
// * will revert if the token in the contract with the same uid already exists.
// * will make sure creator has admin rights to the token.
// * setup the token with the given token config.
// * return the new token id.
newTokenId = tokenContract.delegateSetupNewToken(premintConfig, signature);

// mint the initial x tokens for this new token id to the executor.
address tokenRecipient = msg.sender;

tokenContract.mint{value: msg.value}(
IMinter1155(premintConfig.tokenConfig.fixedPriceMinter),
newTokenId,
quantityToMint,
abi.encode(tokenRecipient, mintComment)
);
}

function _getOrCreateContract(ContractCreationConfig calldata contractConfig) private returns (IZoraCreator1155 tokenContract, bool isNewContract) {
Expand Down

0 comments on commit 6998c66

Please sign in to comment.