Skip to main content

ERC1155

An IERC1155Receiver contract manages the collection tokens that are ub the ERC1155 standard, so it can represent any number of fungible and non-fungible token types in the DAO extension.

In other words, the DAO becomes capable of managing and curating a collection of multi tokens in ERC1155 standard, and it allows for each token ID to represent a new configurable token type, which may have its own metadata, supply and other attributes.

Access Flags#

  • WITHDRAW_NFT: Allows the caller to remove the NFT from the GUILD collection and return it to a new owner.
  • INTERNAL_TRANSFER: Allows the caller to update the internal ownership of the NFT within the GUILD collection.

Storage#

public initialized#

Internally tracks deployment under eip-1167 proxy pattern.

public dao#

Keeps track of each DAO instance the current contract belongs to.

private _nfts#

Tracks all the Token IDs that belong to an NFT address stored in the GUILD collection.

private _nftTracker#

Tracks the address of the Owner to the NFT address, the NFT's corresponding Token ID and the Amount of that particular Token Id held by Owner.

private _ownership#

Tracks the internal owner of record of an NFT that has been transferred to the extension.

private _nftAddresses#

Tracks all the NFTs addresses collected and stored in the GUILD collection.

Dependencies#

DaoRegistry#

Functions#

collect#

/**  * @notice Collects the NFT from the owner and moves it to the NFT extension.  * @notice It must be have been allowed to move this token by either {approve} or {setApprovalForAll}.  * @dev Reverts if the NFT is not in ERC1155 standard.  * @param owner The actual owner of the NFT that will get collected.  * @param nftAddr The NFT contract address.  * @param nftTokenId The NFT token id.  * @param amount The amount of NFT with nftTokenId to be collected.  */function collect(    address owner,    address nftAddr,    uint256 nftTokenId,    uint256 amount) external hasExtensionAccess(this, AclFlag.COLLECT_NFT)

withdrawNFT#

/**  * @notice Transfers the NFT token from the extension address to the new owner.  * @notice It also updates the internal state to keep track of the all the NFTs collected by the extension.  * @notice The caller must have the ACL Flag: WITHDRAW_NFT  * @notice This function needs to be called from a new adapter (RagequitNFT) that will manage the Bank balances, and will return the NFT to the owner.  * @dev Reverts if the NFT is not in ERC1155 standard.  * @param newOwner The address of the new owner that will receive the NFT.  * @param nftAddr The NFT address that must be in ERC1155 standard.  * @param nftTokenId The NFT token id.  * @param amount The NFT token id amount to withdraw.  */function withdrawNFT(    address newOwner,    address nftAddr,    uint256 nftTokenId,    uint256 amount) external hasExtensionAccess(this, AclFlag.WITHDRAW_NFT)

internalTransfer#

/**  * @notice Updates internally the ownership of the NFT.  * @notice The caller must have the ACL Flag: INTERNAL_TRANSFER  * @dev Reverts if the NFT is not already internally owned in the extension.  * @param fromOwner The address of the current owner.  * @param toOwner The address of the new owner.  * @param nftAddr The NFT address.  * @param nftTokenId The NFT token id.  * @param amount the number of a particular NFT token id.  */function internalTransfer(    address fromOwner,    address toOwner,    address nftAddr,    uint256 nftTokenId,    uint256 amount) external hasExtensionAccess(this, AclFlag.INTERNAL_TRANSFER)

getNFTId#

/**  * @notice Gets ID generated from an NFT address and token id (used internally to map ownership).  * @param nftAddress The NFT address.  * @param tokenId The NFT token id.  */function getNFTId(address nftAddress, uint256 tokenId)    public    pure    returns (bytes32)

getNFTIdAmount#

/**  * @notice gets owner's amount of a TokenId for an NFT address.  * @param owner eth address  * @param tokenAddr the NFT address.  * @param tokenId The NFT token id.  */function getNFTIdAmount(    address owner,    address tokenAddr,    uint256 tokenId) public view returns (uint256)

nbNFTs#

/**  * @notice Returns the total amount of token ids collected for an NFT address.  * @param tokenAddr The NFT address.  */function nbNFTs(address tokenAddr) public view returns (uint256)

getNFT#

/**  * @notice Returns token id associated with an NFT address stored in the GUILD collection at the specified index.  * @param tokenAddr The NFT address.  * @param index The index to get the token id if it exists.  */function getNFT(address tokenAddr, uint256 index)    public    view    returns (uint256)

nbNFTAddresses#

/**  * @notice Returns the total amount of NFT addresses collected.  */function nbNFTAddresses() external view returns (uint256)

getNFTAddress#

/**  * @notice Returns NFT address stored in the GUILD collection at the specified index.  * @param index The index to get the NFT address if it exists.  */function getNFTAddress(uint256 index) external view returns (address)

getNFTOwner#

/**  * @notice Returns owner of NFT that has been transferred to the extension.  * @param nftAddress The NFT address.  * @param tokenId The NFT token id.  */function getNFTOwner(    address nftAddress,    uint256 tokenId,    uint256 index) public view returns (address)

nbNFTOwners#

/**  * @notice Returns the total number of owners of an NFT addresses and token id collected.  */function nbNFTOwners(address nftAddress, uint256 tokenId)    external    view    returns (uint256)

_saveNFT#

/**  * @notice Helper function to update the extension states for an NFT collected by the extension.  * @param nftAddr The NFT address.  * @param nftTokenId The token id.  * @param owner The address of the owner.  * @param amount of the tokenID  */function _saveNft(    address nftAddr,    uint256 nftTokenId,    address owner,    uint256 amount) private

onERC1155Received#

/**  *  @notice required function from IERC1155 standard to be able to to receive tokens  */function onERC1155Received(    address,    address,    uint256,    uint256,    bytes calldata) external pure override returns (bytes4)

onERC1155BatchReceived#

/**  *  @notice required function from IERC1155 standard to be able to to batch receive tokens  *  @dev this function is currently not supported in this extension and will revert  */function onERC1155BatchReceived(    address,    address,    uint256[] calldata,    uint256[] calldata,    bytes calldata) external pure override returns (bytes4)

supportsInterface#

/**  * @notice Supports ERC-165 & ERC-1155 interfaces only.  * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md  */function supportsInterface(bytes4 interfaceID)    external    pure    override    returns (bool)

_updateTokenAmount#

/**  *  @notice internal function to update the amount of a tokenID for an NFT an owner has  */function _updateTokenAmount(    address owner,    address nft,    uint256 tokenId,    uint256 amount) internal

_getTokenAmount#

/**  *  @notice internal function to get the amount of a tokenID for an NFT an owner has  */function _getTokenAmount(    address owner,    address nft,    uint256 tokenId) internal view returns (uint256)

Events#

CollectedNFT#

When a NFT is collected/stored into the NFT collection.

  • event CollectedNFT(address nftAddr, uint256 nftTokenId, uint256 amount);

WithdrawnNFT#

When a NFT is transferred from the extension to another owner.

  • event WithdrawnNFT(address nftAddr, uint256 nftTokenId, ,uint amount,address toAddress);

TransferredNFT#

When a NFT is transferred from the escrow adapter to the NFT collection in the extension.

  • event TransferredNFT(address oldOwner, address newOwner, address nftAddr, uint256 nftTokenId, uint256 amount );