Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-6672: Move to Last Call #6949

Merged
merged 35 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a93fa27
docs(eip): add Redeemable NFTs
ArchieR7 Feb 22, 2023
aee69fa
feat(specification): update Specification
ArchieR7 Mar 6, 2023
90d8c9d
Merge branch 'ethereum:master' into master
ArchieR7 Mar 8, 2023
a096660
Add detailed explanation
Randyanto Mar 10, 2023
611b5f3
Merge pull request #1 from redeemprotocol/add-explanation
ArchieR7 Mar 10, 2023
7fa034c
docs(draft): rename
ArchieR7 Mar 10, 2023
462ade8
fix(draft): fix error[markdown-re-erc-dash]
ArchieR7 Mar 10, 2023
581df4a
fix(draft): fix author and ref issues
ArchieR7 Mar 10, 2023
f3158e4
fix(draft): fix author and preamble-refs-description
ArchieR7 Mar 10, 2023
47dbc48
Change multiple-times to multiple-scenarios
Randyanto Mar 13, 2023
a5caf51
Merge pull request #2 from redeemprotocol/multiple-scenarios
Randyanto Mar 13, 2023
e9ab86b
Add link to discussion
Randyanto Mar 13, 2023
920a033
Small fixes based on Editor feedback for EIP6672
Randyanto Mar 22, 2023
cbd4f98
Move reference implementation to assets folder
Mar 22, 2023
f2f05e3
EIP6672 - fix error found by WIP Walidator
Mar 22, 2023
7984c49
EIP6672 - fix error found by WIP Walidator
Mar 22, 2023
0520556
EIP6672 - fix error found by WIP Walidator
Mar 22, 2023
c3be9bf
EIP6672 - fix error found by HTMLProofer
Mar 22, 2023
237b019
feat(erc6672): modify redemptions with EnumerableSet
ArchieR7 Mar 22, 2023
542612a
feat(erc6672): remove unnessary functions
ArchieR7 Mar 22, 2023
979a057
feat(erc6672): add supportsInterface()
ArchieR7 Mar 23, 2023
3094aee
feat(erc6672): update security considerations
Randyanto Mar 23, 2023
566e33c
feat(erc6672): fix error found by WIP Walidator
Randyanto Mar 23, 2023
ba651ff
feat(erc6672): add character I in the interface contract code for con…
Randyanto Mar 28, 2023
7ff9cd1
feat(erc6672): remove reference to stagnant EIP
Randyanto Apr 7, 2023
71c87f0
Merge branch 'ethereum:master' into master
ArchieR7 Apr 7, 2023
ec720d6
feat(erc6672): add ERC-165 identifier for ERC-6672
ArchieR7 Apr 7, 2023
fe1a776
feat(erc6672): change status to Review, remove existing-standards phr…
Randyanto Apr 13, 2023
11ca7f5
Merge pull request #3 from redeemprotocol/feature/move-to-review
Randyanto Apr 17, 2023
0edf7ff
Merge branch 'ethereum:master' into master
ArchieR7 Apr 17, 2023
57a00e0
refactor(assets): update ERC6672 and IERC6672 with events
ArchieR7 Apr 28, 2023
741a4d4
feat(erc6672): move to Last Call
Randyanto Apr 28, 2023
e64d762
feat(eips): add Boyu Chu as a author
ArchieR7 Apr 28, 2023
5d909b2
Merge branch 'master' into master
ArchieR7 Apr 28, 2023
2001896
feat(eips): add last-call-deadline
ArchieR7 Apr 28, 2023
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
5 changes: 3 additions & 2 deletions EIPS/eip-6672.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
eip: 6672
title: Multi-redeemable NFTs
description: An extension of ERC-721 which enables an NFT to be redeemed in multiple scenarios for either a physical or digital object
author: RE:DREAMER Lab <[email protected]>, Archie Chang (@ArchieR7) <[email protected]>, Kai Yu (@chihkaiyu) <[email protected]>, Yonathan Randyanto (@Randyanto) <[email protected]>
author: RE:DREAMER Lab <[email protected]>, Archie Chang (@ArchieR7) <[email protected]>, Kai Yu (@chihkaiyu) <[email protected]>, Yonathan Randyanto (@Randyanto) <[email protected]>, Boyu Chu (@chuboyu) <[email protected]>
discussions-to: https://ethereum-magicians.org/t/eip-6672-multi-redeemable-nfts/13276
status: Review
status: Last Call
last-call-deadline: 2023-05-16
type: Standards Track
category: ERC
created: 2023-02-21
Expand Down
86 changes: 73 additions & 13 deletions assets/eip-6672/contracts/ERC6672.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,109 @@ abstract contract ERC6672 is ERC721, IERC6672 {
bytes4 public constant IERC6672_ID = type(IERC6672).interfaceId;

mapping(address => mapping(uint256 => mapping(bytes32 => bool))) redemptionStatus;
mapping(address => mapping(uint256 => mapping(bytes32 => string))) public memos;
mapping(address => mapping(uint256 => mapping(bytes32 => string)))
public memos;
mapping(address => mapping(uint256 => EnumerableSet.Bytes32Set)) redemptions;

constructor() ERC721("Multiple RedeemableNFT", "mrNFT") {}

function isRedeemed(address _operator, bytes32 _redemptionId, uint256 _tokenId) external view returns (bool) {
function isRedeemed(
address _operator,
bytes32 _redemptionId,
uint256 _tokenId
) external view returns (bool) {
return _isRedeemed(_operator, _redemptionId, _tokenId);
}

function getRedemptionIds(address _operator, uint256 _tokenId) external view returns (bytes32[] memory) {
require(redemptions[_operator][_tokenId].length() > 0, "ERC6672: token doesn't have any redemptions.");
function getRedemptionIds(
address _operator,
uint256 _tokenId
) external view returns (bytes32[] memory) {
require(
redemptions[_operator][_tokenId].length() > 0,
"ERC6672: token doesn't have any redemptions."
);
return redemptions[_operator][_tokenId].values();
}

function redeem(bytes32 _redemptionId, uint256 _tokenId, string memory _memo) external {

function redeem(
bytes32 _redemptionId,
uint256 _tokenId,
string memory _memo
) external {
address _operator = msg.sender;
require(!_isRedeemed(_operator, _redemptionId, _tokenId), "ERC6672: token already redeemed.");
require(
!_isRedeemed(_operator, _redemptionId, _tokenId),
"ERC6672: token already redeemed."
);
_update(_operator, _redemptionId, _tokenId, _memo, true);
redemptions[_operator][_tokenId].add(_redemptionId);
emit Redeem(
_operator,
_tokenId,
ownerOf(_tokenId),
_redemptionId,
_memo
);
}

function cancel(bytes32 _redemptionId, uint256 _tokenId, string memory _memo) external {
function cancel(
bytes32 _redemptionId,
uint256 _tokenId,
string memory _memo
) external {
address _operator = msg.sender;
require(_isRedeemed(_operator, _redemptionId, _tokenId), "ERC6672: token doesn't redeemed.");
require(
_isRedeemed(_operator, _redemptionId, _tokenId),
"ERC6672: token doesn't redeemed."
);
_update(_operator, _redemptionId, _tokenId, _memo, false);
_removeRedemption(_operator, _redemptionId, _tokenId);
emit Cancel(_operator, _tokenId, _redemptionId, _memo);
}

function _isRedeemed(address _operator, bytes32 _redemptionId, uint256 _tokenId) internal view returns (bool) {
function _isRedeemed(
address _operator,
bytes32 _redemptionId,
uint256 _tokenId
) internal view returns (bool) {
require(_exists(_tokenId), "ERC6672: token doesn't exists.");
return redemptionStatus[_operator][_tokenId][_redemptionId];
}

function _update(address _operator, bytes32 _redemptionId, uint256 _tokenId, string memory _memo, bool isRedeemed_) internal {
function _update(
address _operator,
bytes32 _redemptionId,
uint256 _tokenId,
string memory _memo,
bool isRedeemed_
) internal {
redemptionStatus[_operator][_tokenId][_redemptionId] = isRedeemed_;
memos[_operator][_tokenId][_redemptionId] = _memo;
if (isRedeemed_) {
emit Redeem(
_operator,
_tokenId,
ownerOf(_tokenId),
_redemptionId,
_memo
);
} else {
emit Cancel(_operator, _tokenId, _redemptionId, _memo);
}
}

function _removeRedemption(address _operator, bytes32 _redemptionId, uint256 _tokenId) internal {
function _removeRedemption(
address _operator,
bytes32 _redemptionId,
uint256 _tokenId
) internal {
redemptions[_operator][_tokenId].remove(_redemptionId);
}

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) {
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC721, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC6672).interfaceId ||
Expand Down
41 changes: 37 additions & 4 deletions assets/eip-6672/contracts/interfaces/IERC6672.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@ pragma solidity 0.8.16;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IERC6672 is IERC721 {
function isRedeemed(address _operator, bytes32 _redemptionId, uint256 _tokenId) external view returns (bool);
function getRedemptionIds(address _operator, uint256 _tokenId) external view returns (bytes32[] memory);
function redeem(bytes32 _redemptionId, uint256 _tokenId, string memory _memo) external;
function cancel(bytes32 _redemptionId, uint256 _tokenId, string memory _memo) external;
event Redeem(
address indexed _operator,
uint256 indexed _tokenId,
address redeemer,
bytes32 _redemptionId,
string _memo
);

event Cancel(
address indexed _operator,
uint256 indexed _tokenId,
bytes32 _redemptionId,
string _memo
);

function isRedeemed(
address _operator,
bytes32 _redemptionId,
uint256 _tokenId
) external view returns (bool);

function getRedemptionIds(
address _operator,
uint256 _tokenId
) external view returns (bytes32[] memory);

function redeem(
bytes32 _redemptionId,
uint256 _tokenId,
string memory _memo
) external;

function cancel(
bytes32 _redemptionId,
uint256 _tokenId,
string memory _memo
) external;
}