-
Notifications
You must be signed in to change notification settings - Fork 15
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
Turn registration into NFT #76
Conversation
test/conference_ticket.js
Outdated
let tokenId = 123 | ||
await ct.tokenURI(tokenId).should.be.rejected | ||
await ct.mint(accounts[1], tokenId).should.be.fulfilled | ||
await ct.tokenURI(tokenId).should.eventually.eq(tokenId.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be {baseUri}/{registrantID}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the baseTokenURI
has not been set it should just return the tokenId
.
contracts/test/conference_ticket.js
Lines 101 to 104 in 1bf8b61
let tokenId = 123 | |
await ct.setBaseTokenURI('https://kickback.events/test/') | |
await ct.mint(accounts[1], tokenId).should.be.fulfilled | |
await ct.tokenURI(tokenId).should.eventually.eq('https://kickback.events/test/123') |
yarn deploy:polygon
|
contracts/AbstractConference.sol
Outdated
*/ | ||
constructor ( | ||
string memory _name, | ||
uint256 _deposit, | ||
uint256 _limitOfParticipants, | ||
uint256 _coolingPeriod, | ||
address payable _owner, | ||
uint256 _clearFee | ||
uint256 _clearFee, | ||
string memory _baseTokenUri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than passing _baseTokenUri at the constructor, can you save the deployer address and reference the baseTokenUri via Deployer.
For example, define deployer variable
Deployer public deployer;
Then set at the constructor
deployer = msg.sender
then tokenURI
becomes like this.
function tokenURI(uint256 tokenId) public view returns (string memory) {
return string(abi.encodePacked(deployer.baseTokenURI(), Utils.addr2str(address(this)), '/', _tokenURI(tokenId)));
}
Most variables(deposit, cooling period, etc) has to be set at the constructor to make the variable unique to the event.
However, the only time we change baseTokenURI is when we change the metadata server to some other domain so it should be referred to the latest baseTokenURI, rather than passed by the constructor and fixed.
This also has the benefit of reducing changes on frontend/backend code as we are only adding ERC721 related functions, not changing existing interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting deployer = msg.sender
at the constructor will not work because the sender in this case is either EthDeployer
or ERC20Deployer
and not Deployer
. Thus we can't call deployer.baseTokenURI()
as suggested.
What about passing the address of Deployer
instead of _baseTokenUri
at the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good point. Let's do that
contracts/AbstractConference.sol
Outdated
|
||
Participant memory participant = participants[from]; | ||
participantsIndex[participant.index] = to; | ||
participants[from] = Participant(0, address(0), participant.paid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be participants[from] = Participant(0, address(0), false);
if you are nullifying everything
contracts/AbstractConference.sol
Outdated
|
||
function safeTransferFrom(address from, address to, uint256 tokenId) public { | ||
safeTransferFrom(from, to, tokenId, ''); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be overridden? Seems exactly the same as the parent class implementation
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_tokenURIs[tokenId] = Utils.uint2str(tokenId); | ||
} | ||
|
||
function transferFrom(address from, address to, uint256 tokenId) public onlyActive { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you rename transferFrom
to _beforeTokenTransfer
you don't need to override safeTransferFrom(address from, address to, uint256 tokenId)
nor safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2.5 does not have _beforeTokenTransfer
according to https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/token/ERC721/ERC721.sol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, is it because we still use the old version of the solidity? Ok, then let's leave it as is.
|
||
function transferFrom(address from, address to, uint256 tokenId) public onlyActive { | ||
require(!isRegistered(to), 'already registered'); | ||
super.transferFrom(from, to, tokenId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use the _beforeTokenTransfer
hook, you don't need to call super.transferFrom
as it gets called after _beforeTokenTransfer
is called.
Issue number
Issue #73
Description
Turn Kickback registration into NFT (aka ticket as NFT)
List of features added/changed
Conference
) has its own NFT contractConference
constructorDeployer
and can be changed bygroupAdmin
. (Refer to changeClearFee for the similar implementation).How Has This Been Tested?
All of the changes have been tested with unit tests.
ownerOf(tokenId)
returns the registrant address.isRegistered/isAttended/isPaid
returns the info about the recipient (if this ended up causing too much attack vector, we may make the token not transferrable ).withdraw
andclearAndSend
to receive the payoutScreenshots (if appropriate):
Checklist: