ApprovalMintModule

Git Source

Inherits: IMintModule4Note, ModuleBase

This is a simple MintModule implementation, inheriting from the IMintModule4Note interface. This module works by allowing limited minting for a post, and only for those who are approved.

State Variables

_approvedInfo

mapping(uint256 => mapping(uint256 => mapping(address => ApprovedInfo))) internal _approvedInfo;

Functions

constructor

constructor(address web3Entry_) ModuleBase(web3Entry_);

initializeMintModule

Initialize the MintModule for a specific note.

The data should an abi encoded bytes, containing (in order): an address array and an uint256

function initializeMintModule(uint256 characterId, uint256 noteId, bytes calldata data)
    external
    override
    onlyWeb3Entry
    returns (bytes memory);

Parameters

NameTypeDescription
characterIduint256The character ID of the note to initialize.
noteIduint256The note ID to initialize.
databytesThe data passed from the user to be decoded.

Returns

NameTypeDescription
<none>bytesbytes The returned data of calling initializeMintModule.

setApprovedAmount

Set the approved addresses for minting and the approvedAmount allowed to be minted.
The approvedAmount is 0 by default, and you can also revoke the approval for addresses by setting the approvedAmount to 0.

function setApprovedAmount(uint256 characterId, uint256 noteId, address[] calldata addresses, uint256 approvedAmount)
    external;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note.
addressesaddress[]The Addresses to set.
approvedAmountuint256The amount of NFTs allowed to be minted.

processMint

Process minting and check if the caller is eligible.

function processMint(address to, uint256 characterId, uint256 noteId, bytes calldata) external override onlyWeb3Entry;

Parameters

NameTypeDescription
toaddressThe receive address of the NFT.
characterIduint256The character ID of the note owner.
noteIduint256The note ID.
<none>bytes

getApprovedInfo

Returns the approved info indicates the approved amount and minted amount of an address.

function getApprovedInfo(uint256 characterId, uint256 noteId, address account)
    external
    view
    returns (uint256 approvedAmount, uint256 mintedAmount);

Parameters

NameTypeDescription
characterIduint256ID of the character to query.
noteIduint256ID of the note to query.
accountaddressThe address to query.

Returns

NameTypeDescription
approvedAmountuint256The approved amount that the address can mint.
mintedAmountuint256The amount that the address has already minted.

_setApprovedAmount

function _setApprovedAmount(uint256 characterId, uint256 noteId, address[] memory addresses, uint256 approvedAmount)
    internal;

Structs

ApprovedInfo

struct ApprovedInfo {
    uint256 approvedAmount;
    uint256 mintedAmount;
}