-
Notifications
You must be signed in to change notification settings - Fork 2
Sadie/AllDay Secure Cadence upgrade #10
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
Conversation
@@ -244,7 +244,9 @@ func metadataDict(dict map[string]string) cadence.Dictionary { | |||
pairs := []cadence.KeyValuePair{} | |||
|
|||
for key, value := range dict { | |||
pairs = append(pairs, cadence.KeyValuePair{Key: cadence.NewString(key), Value: cadence.NewString(value)}) | |||
k, _ := cadence.NewString(key) |
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.
These changes aren't related to the secure Cadence work but rather an older version of the SDK that we hadn't updated in a while
self.id = series.id | ||
self.name = series.name | ||
self.active = series.active | ||
if let series = &AllDay.seriesByID[id] as &AllDay.Series? { |
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.
Talked to Bastian about best practise syntax for this. Slack thread here for context: https://axiomzen.slack.com/archives/CTGAW0TM2/p1653430599342029
self.ownedNFTs[id] != nil: "Cannot borrow NFT, no such id" | ||
} | ||
|
||
return (&self.ownedNFTs[id] as &NonFungibleToken.NFT?)! |
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.
Used the force unwrap here because we have already nil checked in the precondition and I figured it would be easier than changing the function signature to limit what we need to change on our transactions
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.
(Open to other suggestions here though!)
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.
yeah, I think in an ideal world, we would return an optional, but that would require changing the standard, which would be a breaking change unfortunately
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.
Looks good!
self.ownedNFTs[id] != nil: "Cannot borrow NFT, no such id" | ||
} | ||
|
||
return (&self.ownedNFTs[id] as &NonFungibleToken.NFT?)! |
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.
yeah, I think in an ideal world, we would return an optional, but that would require changing the standard, which would be a breaking change unfortunately
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.
nice!
Is this ready to be merged? |
@joshuahannan yes - merging now - the contract is upgraded now on testnet |
Updating the AllDay.cdc contract to be compatible with the Secure Cadence upgrade. Details on upgrade here: https://forum.onflow.org/t/breaking-changes-coming-with-secure-cadence-release/3052/14
Main things updated in this contract were for the following breaking changes:
Taking a reference to an optional value now produces an optionally-typed reference