ApprovalMintModule
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
Name | Type | Description |
---|---|---|
characterId | uint256 | The character ID of the note to initialize. |
noteId | uint256 | The note ID to initialize. |
data | bytes | The data passed from the user to be decoded. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | bytes 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
Name | Type | Description |
---|---|---|
characterId | uint256 | The character ID of the note owner. |
noteId | uint256 | The ID of the note. |
addresses | address[] | The Addresses to set. |
approvedAmount | uint256 | The 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
Name | Type | Description |
---|---|---|
to | address | The receive address of the NFT. |
characterId | uint256 | The character ID of the note owner. |
noteId | uint256 | The 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
Name | Type | Description |
---|---|---|
characterId | uint256 | ID of the character to query. |
noteId | uint256 | ID of the note to query. |
account | address | The address to query. |
Returns
Name | Type | Description |
---|---|---|
approvedAmount | uint256 | The approved amount that the address can mint. |
mintedAmount | uint256 | The 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;
}