Skip to content

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

Merged
merged 4 commits into from
Jun 14, 2022
Merged

Sadie/AllDay Secure Cadence upgrade #10

merged 4 commits into from
Jun 14, 2022

Conversation

sadief
Copy link
Contributor

@sadief sadief commented May 19, 2022

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

@@ -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)
Copy link
Contributor Author

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? {
Copy link
Contributor Author

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?)!
Copy link
Contributor Author

@sadief sadief May 25, 2022

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

Copy link
Contributor Author

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!)

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

@sadief sadief changed the title Sadie/secure cadence [WIP] Sadie/AllDay Secure Cadence upgrade May 25, 2022
Copy link

@joshuahannan joshuahannan left a 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?)!

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

@sadief sadief requested a review from satyamakgec May 26, 2022 17:19
Copy link
Contributor

@judezhu judezhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@joshuahannan
Copy link

Is this ready to be merged?

@sadief
Copy link
Contributor Author

sadief commented Jun 14, 2022

@joshuahannan yes - merging now - the contract is upgraded now on testnet

@sadief sadief merged commit 28eea34 into main Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants