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
Extend Lock & Swap Lock #38
Conversation
HouseOfHufflepuff
commented
May 12, 2023
•
edited
edited
- Added function to extend the lock of an NFT. This will be used when we mint sticker book tokens.
- Added tx and tests to swap a lock. This will be used to upgrade elements of the sticker book.
- Removed duration from data structure as it can be derived.
@@ -83,6 +94,14 @@ pub contract NFTLocker { | |||
return false | |||
} | |||
|
|||
pub fun nftIsLocked(id: UInt64, nftType: Type): Bool { | |||
if let lockedToken = (NFTLocker.lockedTokens[nftType]!)[id] { | |||
return true |
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.
Don't you need to check the lockedUntil
here?
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.
Glad you asked, because my intention was to delete the token from NFTLocker.lockedTokens, so that the key does not exist & would not have a lockedUntil. But I found a bug that I fixed here.
nftIsLocked will return false when the token does not exist for the type. Added tests to support.
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
NFTLocker.nftIsLocked( | ||
id: id, | ||
nftType: nftType | ||
) == true : "token is not locked" |
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.
I think there could be another validation for old lockedUntil + extendedDuration > now
otherwise the extension seems moot