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

Extend Lock & Swap Lock #38

Closed
wants to merge 6 commits into from
Closed

Extend Lock & Swap Lock #38

wants to merge 6 commits into from

Conversation

HouseOfHufflepuff
Copy link
Contributor

@HouseOfHufflepuff HouseOfHufflepuff commented May 12, 2023

  • 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.

javiersoto15
javiersoto15 previously approved these changes May 15, 2023
@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

https://github.com/dapperlabs/studio-platform-smart-contracts/pull/38/files#diff-787282924cd2e33a1f8859a16e87a50889699486d711b3fae0720d52b147b7f7R143

pickerflicker
pickerflicker previously approved these changes May 17, 2023
Copy link

@pickerflicker pickerflicker left a 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"

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants