Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Implemented singular _mint function in Soulbounds and added POAP contract. #37

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions core/contracts/Admin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,19 @@ contract Admin {
function deployERC721ExtensionSignature(
string memory _name,
string memory _symbol,
address _comissioner,
uint256 _maxSupply,
uint256 _commissions,
uint256 _cappedSupply,
address _devWallet
uint256 _redemptionTariff
)
public
returns(address)
{
/// @dev Get selector.
bytes4 _selector = bytes4(
abi.encodeWithSignature(
"deployERC721ExtensionSignature(string,string,uint256,address)"
"deployERC721ExtensionSignature(string,string,address,uint256,uint256,uint256,uint256)"
)
);
/// @dev Require that the selector for the function exists.
Expand All @@ -119,10 +122,13 @@ contract Admin {
(bool sent, bytes memory data) = _delegate.delegatecall(
abi.encodeWithSelector(
_selector,
_name,
_name,
_symbol,
_comissioner,
_maxSupply,
_commissions,
_cappedSupply,
_devWallet
_redemptionTariff
)
);
/// @dev Require the call was sent.
Expand Down Expand Up @@ -297,7 +303,7 @@ contract Admin {
/// @dev Get selector.
bytes4 _selector = bytes4(
abi.encodeWithSignature(
"deploySoulboundRedeemable(string,string,address,uint256)"
"deploySoulboundWithSignature(string,string,address,uint256)"
)
);
/// @dev Require that the selector for the function exists.
Expand Down
10 changes: 8 additions & 2 deletions core/contracts/facets/DeployerERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ contract DeployerERC721 is Pausable {
function deployERC721ExtensionSignature(
string memory _name,
string memory _symbol,
address _comissioner,
uint256 _maxSupply,
uint256 _commissions,
uint256 _cappedSupply,
address _devWallet
uint256 _redemptionTariff
)
external
nonReentrant
Expand All @@ -78,8 +81,11 @@ contract DeployerERC721 is Pausable {
ERC721ExtensionSignature _erc721ExtensionSignature = new ERC721ExtensionSignature(
_name,
_symbol,
_comissioner,
_maxSupply,
_commissions,
_cappedSupply,
_devWallet
_redemptionTariff
);
/// @dev Return address.
contractAddress = address(_erc721ExtensionSignature);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.8;

import "../interfaces/IAllowlist.sol";
import "./IAllowlist.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
Expand Down
67 changes: 67 additions & 0 deletions packages/nft/contracts/POAP.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: GPL-3.0

/// _____ ______ ______ ______ ______ ______ _____
/// /\ __-. /\ __ \ /\ ___\ /\ ___\ /\ == \ /\ ___\ /\ __-.
/// \ \ \/\ \ \ \ __ \ \ \ \____ \ \ \____ \ \ __< \ \ __\ \ \ \/\ \
/// \ \____- \ \_\ \_\ \ \_____\ \ \_____\ \ \_\ \_\ \ \_____\ \ \____-
/// \/____/ \/_/\/_/ \/_____/ \/_____/ \/_/ /_/ \/_____/ \/____/

pragma solidity ^0.8.8;

import {IPOAP} from "./interfaces/IPOAP.sol";
import {ERC721A} from "./ERC721A.sol";

/**
* @title POAP [Proof Of Attendance Protocol] Interface.
* @author Daccred.
* @dev
* POAPs are a type of NFTs minted to addresses, showing that they attended a particular event or activity.
* These NFTs are minted on a POAP minting smart contract, then transferred free to the attenders of the events.
* [Ref: https://www.fool.com/investing/stock-market/market-sectors/financials/non-fungible-tokens/poap-nfts/].
* This unique type of NFT is a free digital gift from the organizers of an event to the attendees.
* Sample Metadata: https://poap.xyz/events/jsons/28.json.
*/
abstract contract POAP is IPOAP, ERC721A {
/// @dev Constructor.
constructor(string memory _name, string memory _symbol)
ERC721A(_name, _symbol) {}

/**
* @dev Mints token `_tokenQuantity` for a particular event to `_eventId`.
* Emits the {EventToken} event.
* On calling this function, all tokens are minted to the caller.
* Then it can be transferred to attendees via transferToken.
*
* @param
* _eventId => The event for which the token was minted.
* _tokenQuantity => Token to be minted.
*/
function mint(address _eventId, uint256 _tokenQuantity) public {
_safeMint(_eventId, _tokenQuantity);
emit EventToken(_eventId, _tokenQuantity);
}

/**
* @dev Transfers the POAP token `_tokenQuantity` to `_receiver`.
*
* @param
* _eventId => The event for which the token was minted.
* _receiver => Address receiving the token.
* _tokenQuantity => Token to be minted.
*/
function transferToken(
address _eventId,
address _receiver,
uint256 _tokenId
) public
{

require(_eventId == address(this), "Invalid event");

safeTransferFrom(
msg.sender,
_receiver,
_tokenId
);
}
}
14 changes: 7 additions & 7 deletions packages/nft/contracts/interfaces/IPOAP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ interface IPOAP is IERC721A {
// ========== E V E N T S ==========

/// @dev Emitted when a token is minted for an event.
event EventToken(uint256 eventId, uint256 tokenId);
event EventToken(address eventId, uint256 tokenQuantity);

// ========== E V E N T S ==========

/**
* @dev Mints token `_tokenId` for a particular event `_eventId`.
* @dev Mints token `_tokenQuantity` for a particular event to `_eventId`.
* Emits the {EventToken} event.
* On calling this function, all tokens are minted to the caller.
* Then it can be transferred to attendees via transferToken.
*
* @param
* _eventId => The event for which the token was minted.
* _tokenId => Token to be minted.
* _tokenQuantity => Token to be minted.
*/
function mintToken(uint256 _eventId, uint256 _tokenId) external;
function mint(address _eventId, uint256 _tokenQuantity) external;

/**
* @dev Mints the POAP token `_tokenId` to `_receiver`.
* @dev Transfers the POAP token `_tokenQuantity` to `_receiver`.
*
* @param
* _eventId => The event for which the token was minted.
* _receiver => Address receiving the token.
* _tokenId => Token to be minted.
* _tokenQuantity => Token to be minted.
*/
function transferToken(
uint256 _eventId,
address _eventId,
address _receiver,
uint256 _tokenId
) external;
Expand Down
45 changes: 24 additions & 21 deletions packages/soulbound/contracts/Soulbound.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,14 @@ contract Soulbound is ERC4973 {
* @param _to Address to which token `_tokenId` is minted.
* @param _tokenId Token to mint.
* @param tokenURI Auto generated or user passed URI for minted token.
*
* @return bool true or false.
*/
function issue(
function mint(
address _to,
uint256 _tokenId,
string memory tokenURI
) internal returns (bool) {
) internal {
/// @dev Mint Soulbound token to `_to` using ERC4973 _mint().
mintSoulboundToken(_to, _tokenId, tokenURI);
/// @dev Return true.
return true;
_mint(_to, _tokenId, tokenURI);
}

/**
Expand All @@ -79,18 +75,14 @@ contract Soulbound is ERC4973 {
*
* @param _from Address which owns token `_tokenId`.
* @param _tokenId Token to revoke.
*
* @return bool true or false.
*/
function revoke(address _from, uint256 _tokenId) internal returns (bool) {
function burn(address _from, uint256 _tokenId) internal {
/// @dev Require token exists.
require(_exists(_tokenId), "Non-existent token.");
/// @dev Require _tokenId is owned by _from.
require(ownerOf(_tokenId) == _from, "Token not owned by address");
/// @dev Burn the token.
burnSoulboundToken(_tokenId);
/// @dev Return true.
return true;
_burn(_tokenId);
}

/**
Expand Down Expand Up @@ -150,21 +142,28 @@ contract Soulbound is ERC4973 {
* @param tokenId Amount to be minted, GT 0.
* @param tokenURI URI of token minted.
*/
function mintSoulboundToken(
function _mint(
address to,
uint256 tokenId,
string memory tokenURI
) private {
)
internal
virtual
override
returns (uint256)
{
/// @dev Require the address receiving is not a zero address.
require(to != address(0), "Mint to zero address.");
/// @dev ERC-4973 doesn't include checks for empty tokenURIs
/// but they should be necessary.
require(bytes(tokenURI).length != 0, "Empty tokenURI.");
/// @dev Mint to the `to` address.
/// ERC4973 runs check for existent token.
_mint(to, tokenId, tokenURI);
/// @dev Set record of owner to true;
mints[to][tokenId] = true;
/// @dev Mint to the `to` address.
/// ERC4973 runs check for existent token.
super._mint(to, tokenId, tokenURI);
/// @dev Return tokenID.
return tokenId;
}

/**
Expand All @@ -173,15 +172,19 @@ contract Soulbound is ERC4973 {
*
* @param tokenId Token to be burnt.
*/
function burnSoulboundToken(uint256 tokenId) private {
function _burn(uint256 tokenId)
internal
virtual
override
{
/// @dev Checks that the token actually exists.
require(_exists(tokenId), "Burn of inexistent token");
/// @dev Get owner of token tokenId.
address _tokenOwner = ownerOf(tokenId);
/// @dev Burn the token.
_burn(tokenId);
/// @dev Set record of owner to false.
mints[_tokenOwner][tokenId] = false;
/// @dev Burn the token.
super._burn(tokenId);
}

/**
Expand Down
20 changes: 10 additions & 10 deletions packages/soulbound/contracts/SoulboundCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
pragma solidity ^0.8.8;

import "./Soulbound.sol";
import "./Ownable.sol";
import "./Allowlist.sol";
import "../../common/Allowlist.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
* @title Soulbound Core Contract.
Expand Down Expand Up @@ -78,7 +78,7 @@ contract SoulboundCore is Ownable, Soulbound, Allowlist {
bytes memory sig,
uint256 tokenId,
string memory tokenURI
) public {
) public virtual {
/// @dev Require that the address is not a zero address.
require(addr != address(0), "Mint to zero address.");
/// @dev Require that the hash is actually 32 [64 characters]
Expand All @@ -89,11 +89,11 @@ contract SoulboundCore is Ownable, Soulbound, Allowlist {
/// @dev Verifies that the address was actually signed by the
/// allowlistOwner.
require(verifySignature(hash, sig), "Hash not signed by owner.");
/// @dev Mint the tokens to address.
/// [Ref Soulbound.sol].
issue(addr, tokenId, tokenURI);
/// @dev Emit the IssueWithSignature event.
emit IssueWithSignature(addr, tokenId);
/// @dev Mint the tokens to address.
/// [Ref Soulbound.sol].
super._mint(addr, tokenId, tokenURI);
}

/**
Expand All @@ -112,7 +112,7 @@ contract SoulboundCore is Ownable, Soulbound, Allowlist {
bytes32 hash,
bytes memory sig,
uint256 tokenId
) public {
) public virtual {
/// @dev Require that the token exists.
require(_exists(tokenId), "Revoke of inexistent token.");
/// @dev Require that the hash is actually 32 [64 characters]
Expand All @@ -123,11 +123,11 @@ contract SoulboundCore is Ownable, Soulbound, Allowlist {
/// @dev Verifies that the address was actually signed by the
/// allowlistOwner.
require(verifySignature(hash, sig), "Hash not signed by owner.");
/// @dev Mint the tokens to address.
/// [Ref Soulbound.sol].
revoke(ownerOf(tokenId), tokenId);
/// @dev Emit the RevokeWithSignature event.
emit RevokeWithSignature(tokenId);
/// @dev Burn the tokens from address.
/// [Ref Soulbound.sol].
burn(ownerOf(tokenId), tokenId);
}

/**
Expand Down
Loading