-
Notifications
You must be signed in to change notification settings - Fork 180
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
cw721-expiration
contract with invalid NFT
utility
#140
Conversation
Kudos to timpi for requesting this kind of NFTs, allowing NFT holders running nodes for a limited period. |
Some side notes to be addressed in other tasks. Mainly most of the code was simply copy-pasted from
Imo, by doing so, building custom, extended cw721 contracts get much faster done and better, with less/no copy paste code. |
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.
LGTM
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.
@taitruong LGTM! Mind fixing the one linting error?
Done. Also fixes #141 |
README.md:
CW721 Expiration
One typical use cases for an
cw721-expiration
contract is providing services for a limited period, like access cards, SLAs, cloud services, etc. Also check kudos below.This contract enables the creation of NFTs that expire after a predetermined number of days. The
expiration_days
is set during instantiation of contract.Expiration timestamp is: mint timestamp + expiration days.
Custom
cw721-base
ContractQuery Messages
This contract extends cw721-base by adding a new
invalid NFT
utility. The followingcw721-base
query messages have been extended with an optionalinclude_invalid
property:OwnerOf
: Queries owner of NFT, by default it throws an invalid NFT error.Approval
: Queries whether spender has approval for a NFT, by default it throws an invalid NFT error.Approvals
: Queries all approvals for a NFT, by default it throws an invalid NFT error.NftInfo
: Queries NFT Info data, by default it throws an invalid NFT error.AllNftInfo
: Queries NFT Info data, owner, and approvals, by default it throws an invalid NFT error.Tokens
: Queries all token IDs owned by given address, by default it filters invalid NFTs.AllTokens
: Queries all token IDs, by default it filters invalid NFTs.In case NFT is invalid (due to expiration) an error is thrown or filtered out. Above queries for including invalid NFTs must explicitly pass
include_invalid: Some(true)
(in all other cases (None
,Some(false)
) invalid NFTs are excluded).Execute Messages
Execute messages are kept unchanged, but during execution an error is thrown for invalid NFTs for these operations:
TransferNft
: Transfers a NFT to another account without triggering an action.SendNft
: Sends a NFT to another account and triggering an action.Approve
: Allows operator/spender to transfer, send, and burn an NFT.Revoke
: Revokes above approval.Burn
: Burns an NFT.Instantiation
To instantiate a new instance of this contract you must specify
expiration_days
- along with cw721-based properties:owner
(aka minter),name
, andsymbol
.