Skip to content

Commit

Permalink
updated natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Oct 26, 2023
1 parent 38f04f0 commit 979b3dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import {ZoraCreator1155PremintExecutorImplLib} from "./ZoraCreator1155PremintExe
import {PremintEncoding, ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig, PremintConfigV2, TokenCreationConfig, TokenCreationConfigV2} from "./ZoraCreator1155Attribution.sol";
import {IZoraCreator1155PremintExecutor, ILegacyZoraCreator1155PremintExecutor} from "../interfaces/IZoraCreator1155PremintExecutor.sol";

interface IZoraCreator1155PremintV1Signatures {
function delegateSetupNewToken(PremintConfig calldata premintConfig, bytes calldata signature, address sender) external returns (uint256 newTokenId);
}

/// @title Enables creation of and minting tokens on Zora1155 contracts transactions using eip-712 signatures.
/// Signature must provided by the contract creator, or an account that's permitted to create new tokens on the contract.
/// Mints the first x tokens to the executor of the transaction.
Expand All @@ -43,16 +39,17 @@ contract ZoraCreator1155PremintExecutorImpl is
__UUPSUpgradeable_init();
}

/// Creates a new token on the given erc1155 contract on behalf of a creator, and mints x tokens to the executor of this transaction.
/// @notice Creates a new token on the given erc1155 contract on behalf of a creator, and mints x tokens to the executor of this transaction.
/// If the erc1155 contract hasn't been created yet, it will be created with the given config within this same transaction.
/// The creator must sign the intent to create the token, and must have mint new token permission on the erc1155 contract,
/// or match the contract admin on the contract creation config if the contract hasn't been created yet.
/// Contract address of the created contract is deterministically generated from the contract config and this contract's address.
/// @dev For use with v2 of premint config, PremintConfigV2, which supports setting `createReferral`.
/// @param contractConfig Parameters for creating a new contract, if one doesn't exist yet. Used to resolve the deterministic contract address.
/// @param premintConfig Parameters for creating the token, and minting the initial x tokens to the executor.
/// @param signature Signature of the creator of the token, which must match the signer of the premint config, or have permission to create new tokens on the erc1155 contract if it's already been created
/// @param quantityToMint How many tokens to mint to the executor of this transaction once the token is created
/// @param mintArguments Abi encoded additional mint arguments: including mintComment and mintReferral
/// @param quantityToMint How many tokens to mint to the mintRecipient
/// @param mintArguments mint arguments specifying the token mint recipient, mint comment, and mint referral
function premintV2(
ContractCreationConfig calldata contractConfig,
PremintConfigV2 calldata premintConfig,
Expand Down Expand Up @@ -95,11 +92,12 @@ contract ZoraCreator1155PremintExecutorImpl is
/// The creator must sign the intent to create the token, and must have mint new token permission on the erc1155 contract,
/// or match the contract admin on the contract creation config if the contract hasn't been created yet.
/// Contract address of the created contract is deterministically generated from the contract config and this contract's address.
/// @dev For use with v1 of premint config, PremintConfigV2, which supports setting `createReferral`.
/// @param contractConfig Parameters for creating a new contract, if one doesn't exist yet. Used to resolve the deterministic contract address.
/// @param premintConfig Parameters for creating the token, and minting the initial x tokens to the executor.
/// @param signature Signature of the creator of the token, which must match the signer of the premint config, or have permission to create new tokens on the erc1155 contract if it's already been created
/// @param quantityToMint How many tokens to mint to the executor of this transaction once the token is created
/// @param mintArguments Abi encoded additional mint arguments: including mintComment and mintReferral
/// @param quantityToMint How many tokens to mint to the mintRecipient
/// @param mintArguments mint arguments specifying the token mint recipient, mint comment, and mint referral
function premintV1(
ContractCreationConfig calldata contractConfig,
PremintConfig calldata premintConfig,
Expand Down Expand Up @@ -130,7 +128,7 @@ contract ZoraCreator1155PremintExecutorImpl is
});
}

/// Gets the deterministic contract address for the given contract creation config.
/// @notice Gets the deterministic contract address for the given contract creation config.
/// Contract address is generated deterministically from a hash based on the contract uri, contract name,
/// contract admin, and the msg.sender, which is this contract's address.
function getContractAddress(ContractCreationConfig calldata contractConfig) public view returns (address) {
Expand All @@ -146,7 +144,7 @@ contract ZoraCreator1155PremintExecutorImpl is
return (true, ERC1155DelegationStorageV1(contractAddress).delegatedTokenId(uid));
}

/// deprecated - use isValidSignatureV1
// @custom:deprecated use isValidSignatureV1 instead
function isValidSignature(
ContractCreationConfig calldata contractConfig,
PremintConfig calldata premintConfig,
Expand All @@ -157,33 +155,49 @@ contract ZoraCreator1155PremintExecutorImpl is
(isValid, recoveredSigner) = isValidSignatureV1(contractConfig.contractAdmin, contractAddress, premintConfig, signature);
}

/// @notice Recovers the signer of a premint, and checks if the signer is authorized to sign the premint.
/// @dev for use with v1 of premint config, PremintConfig
/// @param premintContractConfigContractAdmin If this contract was created via premint, the original contractConfig.contractAdmin. Otherwise, set to address(0)
/// @param contractAddress The determinstic 1155 contract address the premint is for
/// @param premintConfig The premint config
/// @param signature The signature of the premint
/// @return isValid Whether the signature is valid
/// @return recoveredSigner The signer of the premint
function isValidSignatureV1(
address originalContractAdmin,
address premintContractConfigContractAdmin,
address contractAddress,
PremintConfig calldata premintConfig,
bytes calldata signature
) public view returns (bool isValid, address recoveredSigner) {
bytes32 hashedPremint = ZoraCreator1155Attribution.hashPremint(premintConfig);

(isValid, recoveredSigner) = ZoraCreator1155Attribution.isValidSignature(
originalContractAdmin,
premintContractConfigContractAdmin,
contractAddress,
hashedPremint,
ZoraCreator1155Attribution.HASHED_VERSION_1,
signature
);
}

/// @notice Recovers the signer of a premint, and checks if the signer is authorized to sign the premint.
/// @dev for use with v2 of premint config, PremintConfig
/// @param premintContractConfigContractAdmin If this contract was created via premint, the original contractConfig.contractAdmin. Otherwise, set to address(0)
/// @param contractAddress The determinstic 1155 contract address the premint is for
/// @param premintConfig The premint config
/// @param signature The signature of the premint
/// @return isValid Whether the signature is valid
/// @return recoveredSigner The signer of the premint
function isValidSignatureV2(
address originalContractAdmin,
address premintContractConfigContractAdmin,
address contractAddress,
PremintConfigV2 calldata premintConfig,
bytes calldata signature
) public view returns (bool isValid, address recoveredSigner) {
bytes32 hashedPremint = ZoraCreator1155Attribution.hashPremint(premintConfig);

(isValid, recoveredSigner) = ZoraCreator1155Attribution.isValidSignature(
originalContractAdmin,
premintContractConfigContractAdmin,
contractAddress,
hashedPremint,
ZoraCreator1155Attribution.HASHED_VERSION_2,
Expand Down Expand Up @@ -216,7 +230,7 @@ contract ZoraCreator1155PremintExecutorImpl is

// Deprecated functions:

/// @notice Deprecated
/// @custom:deprecated use premintV1 instead
function premint(
ContractCreationConfig calldata contractConfig,
PremintConfig calldata premintConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ library ZoraCreator1155PremintExecutorImplLib {
) internal returns (IZoraCreator1155PremintExecutor.PremintResult memory) {
// get or create the contract with the given params
// contract address is deterministic.
(IZoraCreator1155 tokenContract, bool isNewContract) = ZoraCreator1155PremintExecutorImplLib.getOrCreateContract(zora1155Factory, contractConfig);
(IZoraCreator1155 tokenContract, bool isNewContract) = getOrCreateContract(zora1155Factory, contractConfig);

// pass the signature and the premint config to the token contract to create the token.
// The token contract will verify the signature and that the signer has permission to create a new token.
Expand Down

0 comments on commit 979b3dc

Please sign in to comment.