Skip to content

Commit

Permalink
doc: updated natspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Adjimann committed Dec 9, 2024
1 parent a268b9b commit 5c44710
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ abstract contract ERC721BurnMemoryUpgradeable is ERC721Upgradeable {

/**
* @notice enables burning of tokens
* @custom:event TokenBurningEnabled
*/
function _enableBurning() internal {
ERC721BurnMemoryUpgradeableStorage storage $ = _getERC721BurnMemoryUpgradableStorage();
Expand All @@ -85,7 +84,6 @@ abstract contract ERC721BurnMemoryUpgradeable is ERC721Upgradeable {

/**
* @notice disables burning of tokens
* @custom:event TokenBurningDisabled
*/
function _disableBurning() internal {
ERC721BurnMemoryUpgradeableStorage storage $ = _getERC721BurnMemoryUpgradableStorage();
Expand All @@ -98,7 +96,6 @@ abstract contract ERC721BurnMemoryUpgradeable is ERC721Upgradeable {

/**
* @notice Burns `tokenId`. The caller must own `tokenId` or be an approved operator.
* @custom:event TokenBurned
* @param tokenId the token id to be burned
*/
function _burnWithCheck(uint256 tokenId) internal virtual {
Expand Down
39 changes: 5 additions & 34 deletions packages/avatar/contracts/nft-collection/NFTCollection.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ There are two ways of minting tokens:
2. The backend gives a signed message to the user. Using this authorization a user can mint certain amount of tokens to
his wallet paying a price in Sand or any other configured ERC20 token.

Minting is done in waves set the price of the tokens and some limits on the amount of tokens that can be minted and are
configured by the owner of the contract. After setting an initial wave the owner can set a new wave at any time, the
previous wave is cancelled each time a new wave is set.
Minting is done in waves, a wave set the price of the tokens and some limits on the amount of tokens that can be minted.
Waves are configured by the owner of the contract. After setting an initial wave the owner can set a new wave at any
time. Usually the previous wave is cancelled each time a new wave is set, but, the owner can choose to leave a wave open
so two waves can run in parallel (to use this new functionality the user must claim using `waveMint` method).

### Minting Limits

Expand Down Expand Up @@ -160,8 +161,6 @@ function setupWave(
function to setup a new wave. A wave is defined as a combination of allowed number tokens to be minted in total, per
wallet and minting price

event: {WaveSetup}

Parameters:

| Name | Type | Description |
Expand All @@ -184,7 +183,7 @@ function mint(
token minting function on the last wave. Price is set by wave and is paid in tokens denoted by the allowedToExecuteMint
contract

this method is backward compatible with the previous contract, so, it uses last configured wave event: {Transfer}
this method is backward compatible with the previous contract, so, it uses last configured wave

Parameters:

Expand All @@ -210,8 +209,6 @@ function waveMint(
token minting function on a certain wave. Price is set by wave and is paid in tokens denoted by the allowedToExecuteMint
contract

event: {Transfer}

Parameters:

| Name | Type | Description |
Expand All @@ -231,8 +228,6 @@ function cancelWave(uint256 waveIndex) external onlyOwner
function to setup wave parameters. A wave is defined as a combination of allowed number tokens to be minted in total,
per wallet and minting price

event: {WaveSetup}

Parameters:

| Name | Type | Description |
Expand All @@ -252,8 +247,6 @@ batch minting function, used by owner to airdrop directly to users.

this methods takes a list of destination wallets and can only be used by the owner of the contract

event: {Transfer}

Parameters:

| Name | Type | Description |
Expand All @@ -277,8 +270,6 @@ reveal.

will revert if owner of token is not caller or if signature is not valid

event: {MetadataUpdate}

Parameters:

| Name | Type | Description |
Expand All @@ -302,8 +293,6 @@ personalize token traits according to the provided personalization bit-mask

after checks, it is reduced to personalizationTraits[_tokenId] = _personalizationMask

event: {MetadataUpdate}

Parameters:

| Name | Type | Description |
Expand All @@ -327,8 +316,6 @@ on an in-game action

reverts if token does not exist or if not authorized

event: {MetadataUpdate}

Parameters:

| Name | Type | Description |
Expand All @@ -346,8 +333,6 @@ Burns `tokenId`. The caller must own `tokenId` or be an approved operator.

See {ERC721BurnMemoryEnumerableUpgradeable.burn}.

event: TokenBurned

Parameters:

| Name | Type | Description |
Expand All @@ -364,8 +349,6 @@ enables burning of tokens

reverts if burning already enabled.

event: TokenBurningEnabled

### disableBurning (0x98603cca)

```solidity
Expand All @@ -376,8 +359,6 @@ disables burning of tokens

reverts if burning already disabled.

event: TokenBurningDisabled

### pause (0x8456cb59)

```solidity
Expand Down Expand Up @@ -406,8 +387,6 @@ function setTreasury(address treasury) external onlyOwner

update the treasury address

event: {TreasurySet}

Parameters:

| Name | Type | Description |
Expand All @@ -422,8 +401,6 @@ function setSignAddress(address _signAddress) external onlyOwner

updates the sign address.

event: {SignAddressSet}

Parameters:

| Name | Type | Description |
Expand All @@ -438,8 +415,6 @@ function setMaxSupply(uint256 _maxSupply) external onlyOwner

updates the sign address.

event: {MaxSupplySet}

Parameters:

| Name | Type | Description |
Expand All @@ -456,8 +431,6 @@ updates which address is allowed to execute the mint function.

also resets default mint price

event: {DefaultMintingValuesSet}

Parameters:

| Name | Type | Description |
Expand All @@ -472,8 +445,6 @@ function setBaseURI(string calldata baseURI) external onlyOwner

updates the base token URI for the contract

event: {BaseURISet}

Parameters:

| Name | Type | Description |
Expand Down
29 changes: 1 addition & 28 deletions packages/avatar/contracts/nft-collection/NFTCollection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ INFTCollection
revert InvalidSymbol(_symbol);
}
__ReentrancyGuard_init();
// @dev we don't want to set the owner to _msgSender, so, we don't call __Ownable_init
// We don't want to set the owner to _msgSender, so, we call _transferOwnership instead of __Ownable_init
_transferOwnership(_collectionOwner);
__ERC2981_init();
_setTrustedForwarder(_initialTrustedForwarder);
Expand All @@ -228,7 +228,6 @@ INFTCollection
/**
* @notice function to setup a new wave. A wave is defined as a combination of allowed number tokens to be
* minted in total, per wallet and minting price
* @custom:event {WaveSetup}
* @param _waveMaxTokensOverall the allowed number of tokens to be minted in this wave (cumulative by all minting wallets)
* @param _waveMaxTokensPerWallet max tokens to buy, per wallet in a given wave
* @param _waveSingleTokenPrice the price to mint a token in a given wave, in wei
Expand Down Expand Up @@ -258,7 +257,6 @@ INFTCollection
/**
* @notice token minting function on the last wave. Price is set by wave and is paid in tokens denoted
* by the allowedToExecuteMint contract
* @custom:event {Transfer}
* @param wallet minting wallet
* @param amount number of token to mint
* @param signatureId signing signature ID
Expand Down Expand Up @@ -287,7 +285,6 @@ INFTCollection
/**
* @notice token minting function on a certain wave. Price is set by wave and is paid in tokens denoted
* by the allowedToExecuteMint contract
* @custom:event {Transfer}
* @param wallet minting wallet
* @param amount number of token to mint
* @param waveIndex the index of the wave used to mint
Expand Down Expand Up @@ -316,7 +313,6 @@ INFTCollection
/**
* @notice function to setup wave parameters. A wave is defined as a combination of allowed number tokens to be
* minted in total, per wallet and minting price
* @custom:event {WaveSetup}
* @param waveIndex the index of the wave to be canceled
*/
function cancelWave(uint256 waveIndex) external onlyOwner {
Expand All @@ -331,7 +327,6 @@ INFTCollection
/**
* @notice batch minting function, used by owner to airdrop directly to users.
* @dev this methods takes a list of destination wallets and can only be used by the owner of the contract
* @custom:event {Transfer}
* @param waveIndex the index of the wave used to mint
* @param wallets list of destination wallets and amounts
*/
Expand Down Expand Up @@ -368,7 +363,6 @@ INFTCollection
* refresh metadata, for the provided token ID. Off-chain, gaming mechanics are done and this
* function is ultimately called to signal the end of a reveal.
* @dev will revert if owner of token is not caller or if signature is not valid
* @custom:event {MetadataUpdate}
* @param tokenId the ID belonging to the NFT token for which to emit the event
* @param signatureId validation signature ID
* @param signature validation signature
Expand All @@ -390,8 +384,6 @@ INFTCollection
/**
* @notice personalize token traits according to the provided personalization bit-mask
* @dev after checks, it is reduced to personalizationTraits[_tokenId] = _personalizationMask
* @custom:event {Personalized}
* @custom:event {MetadataUpdate}
* @param tokenId what token to personalize
* @param personalizationMask a mask where each bit has a custom meaning in-game
* @param signatureId the ID of the provided signature
Expand All @@ -416,8 +408,6 @@ INFTCollection
* @notice personalize token traits but can be called by owner or special roles address
* Used to change the traits of a token based on an in-game action
* @dev reverts if token does not exist or if not authorized
* @custom:event {Personalized}
* @custom:event {MetadataUpdate}
* @param tokenId what token to personalize
* @param personalizationMask a mask where each bit has a custom meaning in-game
*/
Expand All @@ -433,7 +423,6 @@ INFTCollection
/**
* @notice Burns `tokenId`. The caller must own `tokenId` or be an approved operator.
* @dev See {ERC721BurnMemoryEnumerableUpgradeable.burn}.
* @custom:event TokenBurned
* @param tokenId the token id to be burned
*/
function burn(uint256 tokenId) external whenNotPaused {
Expand All @@ -443,7 +432,6 @@ INFTCollection
/**
* @notice enables burning of tokens
* @dev reverts if burning already enabled.
* @custom:event TokenBurningEnabled
*/
function enableBurning() external onlyOwner {
_enableBurning();
Expand All @@ -452,7 +440,6 @@ INFTCollection
/**
* @notice disables burning of tokens
* @dev reverts if burning already disabled.
* @custom:event TokenBurningDisabled
*/
function disableBurning() external onlyOwner {
_disableBurning();
Expand All @@ -478,7 +465,6 @@ INFTCollection

/**
* @notice update the treasury address
* @custom:event {TreasurySet}
* @param treasury new treasury address to be saved
*/
function setTreasury(address treasury) external onlyOwner {
Expand All @@ -487,7 +473,6 @@ INFTCollection

/**
* @notice updates the sign address.
* @custom:event {SignAddressSet}
* @param _signAddress new signer address to be set
*/
function setSignAddress(address _signAddress) external onlyOwner {
Expand All @@ -496,7 +481,6 @@ INFTCollection

/**
* @notice updates the sign address.
* @custom:event {MaxSupplySet}
* @param _maxSupply maximum amount of tokens that can be minted
*/
function setMaxSupply(uint256 _maxSupply) external onlyOwner {
Expand All @@ -506,8 +490,6 @@ INFTCollection
/**
* @notice updates which address is allowed to execute the mint function.
* @dev also resets default mint price
* @custom:event {AllowedExecuteMintSet}
* @custom:event {DefaultMintingValuesSet}
* @param minterToken the address that will be allowed to execute the mint function
*/
function setAllowedExecuteMint(IERC20Metadata minterToken) external onlyOwner {
Expand All @@ -516,7 +498,6 @@ INFTCollection

/**
* @notice updates the base token URI for the contract
* @custom:event {BaseURISet}
* @param baseURI an URI that will be used as the base for token URI
*/
function setBaseURI(string calldata baseURI) external onlyOwner {
Expand Down Expand Up @@ -851,7 +832,6 @@ INFTCollection

/**
* @notice complete the minting called from waveMint and mint
* @custom:event {Transfer}
* @param waveData the data of the wave used to mint
* @param wallet minting wallet
* @param amount number of token to mint
Expand Down Expand Up @@ -945,8 +925,6 @@ INFTCollection
/**
* @notice actually updates the variables that store the personalization traits per token.
* @dev no checks are done on input validations. Calling functions are expected to do them
* @custom:event {Personalized}
* @custom:event {MetadataUpdate}
* @param tokenId the ID for the token to personalize
* @param personalizationMask the personalization mask that will be applied
*/
Expand All @@ -971,7 +949,6 @@ INFTCollection

/**
* @notice updates the base token URI for the contract
* @custom:event {BaseURISet}
* @param baseURI an URI that will be used as the base for token URI
*/
function _setBaseURI(string calldata baseURI) internal {
Expand All @@ -985,7 +962,6 @@ INFTCollection

/**
* @notice update the treasury address
* @custom:event {TreasurySet}
* @param _treasury new treasury address to be saved
*/
function _setTreasury(address _treasury) internal {
Expand All @@ -1000,8 +976,6 @@ INFTCollection
/**
* @notice updates which address is allowed to execute the mint function.
* @dev also resets default mint price
* @custom:event {AllowedExecuteMintSet}
* @custom:event {DefaultMintingValuesSet}
* @param _minterToken the address that will be allowed to execute the mint function
*/
function _setAllowedExecuteMint(IERC20Metadata _minterToken) internal {
Expand All @@ -1015,7 +989,6 @@ INFTCollection

/**
* @notice updates maximum supply
* @custom:event {MaxSupplySet}
* @param _maxSupply maximum amount of tokens that can be minted
*/
function _setMaxSupply(uint256 _maxSupply) internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {ECDSA} from "@openzeppelin/contracts-5.0.2/utils/cryptography/ECDSA.sol"
* @custom:security-contact [email protected]
* @notice Signatures accepted by the NFTCollection
* @dev We have a set of different signatures to be backward compatible with previous collections
* @dev We must be sure that all the signatures are different and cannot be reused so we added a string to reveal.
* @dev We must be sure that all the signatures are different and cannot be reused by different methods, so,
* @dev we added an extra constant string to reveal to distinguish it from the mint signature.
* @dev mint: ['address', 'uint256', 'address', 'uint256']
* @dev reveal: ['address', 'uint256', 'address', 'uint256', 'string']
* @dev personalize: ['address', 'uint256', 'address', 'uint256', 'uint256', 'uint256']
Expand Down Expand Up @@ -91,7 +92,6 @@ abstract contract NFTCollectionSignature {

/**
* @notice updates the sign address.
* @custom:event {SignAddressSet}
* @param _signAddress new signer address to be set
*/
function _setSignAddress(address _signAddress) internal {
Expand Down

1 comment on commit 5c44710

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

90.36%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/avatar/contracts/avatar
   AvatarCollection.sol74.25%56.56%73.81%90.37%285, 329–337, 339–340, 345, 403–407, 425, 442, 459, 483–487, 491–492, 495, 526, 537, 545, 545–546, 565, 599, 621, 631, 712, 732, 745, 745, 745, 763, 763, 765, 774, 774, 776, 786, 786–787, 797, 797–798, 809, 809–810, 823, 832, 861–862, 992–993, 996, 999
   CollectionAccessControl.sol60.87%53.33%63.64%67.86%120, 130–131, 140, 150–151, 161–162, 162, 162, 164–165, 167, 173, 173–174, 185, 192, 192–194, 98–99
   ERC721BurnMemoryEnumerableUpgradeable.sol93.33%75%100%100%62, 75
packages/avatar/contracts/common
   IERC4906.sol100%100%100%100%
   IERC5313.sol100%100%100%100%
packages/avatar/contracts/common/BaseWithStorage/ERC2771
   ERC2771HandlerUpgradeable.sol44.44%25%60%44.44%22, 26, 29, 38, 38, 38–39, 41
packages/avatar/contracts/common/OperatorFilterer
   IOperatorFilterRegistry.sol100%100%100%100%
   UpdatableOperatorFiltererUpgradeable.sol11.11%10%25%9.52%18, 23–24, 24, 24–25, 27, 27, 27–28, 30, 38, 38, 38, 42, 42, 42–44, 46, 46, 46–47, 50, 55, 55, 55–56, 56, 56–57, 60, 68, 68, 68–69, 71
packages/avatar/contracts/nft-collection
   ERC2771HandlerUpgradeable.sol100%100%100%100%
   ERC721BurnMemoryUpgradeable.sol100%100%100%100%
   INFTCollection.sol100%100%100%100%
   NFTCollection.sol99.76%99.28%100%100%300
   NFTCollectionSignature.sol100%100%100%100%
   UpdatableOperatorFiltererUpgradeable.sol100%100%100%100%
packages/avatar/contracts/proxy
   CollectionFactory.sol86.59%89.06%75%87.50%149, 230, 293, 362–366, 368, 385, 402, 410, 410–411, 423, 423–424
   CollectionProxy.sol88.24%50%100%100%55, 70
packages/avatar/contracts/raffle
   DanceFight.sol75%50%100%100%20
   FistOfTheNorthStar.sol75%50%100%100%20
   GenericRaffle.sol67.92%52.22%62.07%84.95%178, 189–195, 225–229, 252–259, 266–267, 270, 288, 288–289, 289, 289–290, 308, 381, 390, 409, 409–410, 419, 419, 421, 430, 430, 432, 442, 442–443, 453, 453–454, 465, 465–466, 566, 575, 626–627, 630, 633
   HellsKitchen.sol75%50%100%100%20
   MadBalls.sol75%50%100%100%20
   ParisHilton.sol75%50%100%100%20
   Rabbids.sol75%50%100%100%20

Please sign in to comment.