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

Update docs to explain state migration side-effects on accessing stored values #3206

Open
nvdtf opened this issue Mar 28, 2024 · 4 comments
Open
Labels
Documentation Improvements or additions to documentation Feedback

Comments

@nvdtf
Copy link
Member

nvdtf commented Mar 28, 2024

Issue to be solved

Ref onflow/flow-nft#126 (comment)

In the above discussion we observed there will be some side effects with accessing stored values after migration.

For example, an NFT collection that can be accessed with:

account.capabilities.borrow<&{NonFungibleToken.Collection}>

Should now be written as:

account.capabilities.borrow<&{
        NonFungibleToken.CollectionPublic,
        ExampleNFT.ExampleNFTCollectionPublic,
        ViewResolver.ResolverCollection
    }>

This issue is not asking for the above to be solved, but to explain it in a special paragraph/section in the docs as we think it might raise some questions during the migration process for developers.

Suggested Solution

Add a special section or paragraph in the migration docs about how to solve common issues with accessing migrated values.

@nvdtf nvdtf added Feature Feedback Documentation Improvements or additions to documentation and removed Feature labels Mar 28, 2024
@SupunS
Copy link
Member

SupunS commented Apr 5, 2024

@nvdtf Can you please check if this still the case? I tried with the CLI v1.15.0-cadence-v1.0.0-preview.13 (there are even newer versions, so maybe try with the latest), and I could borrow the old value with account.capabilities.borrow<&{NonFungibleToken.Collection}>, just like the old way, even after the migration.

@SupunS
Copy link
Member

SupunS commented Apr 5, 2024

@onflow/cadence Being able to borrow with &{NonFungibleToken.Collection} was a bit of a surprise, because the old value was linked as:

self.account.link<&ExampleNFT.Collection{NonFungibleToken.CollectionPublic, ExampleNFT.ExampleNFTCollectionPublic, MetadataViews.ResolverCollection}>(
    self.CollectionPublicPath,
    target: self.CollectionStoragePath
)

But thinking about it more, It seems correct, because with the entitlement migration &ExampleNFT.Collection{NonFungibleToken.CollectionPublic, ExampleNFT.ExampleNFTCollectionPublic, MetadataViews.ResolverCollection} becomes just &ExampleNFT.Collection, and should be able to borrow with any interface it implements (i.e: with any subtype of ExampleNFT.Collection)?

@turbolent
Copy link
Member

@SupunS Thanks for looking into this!

Being able to borrow with &{NonFungibleToken.Collection} makes sense and seems correct (though a little bit surprising at first, but then not at all), and I guess that applies to both values migrated from pre-1.0 and values created in 1.0?

@SupunS
Copy link
Member

SupunS commented Apr 5, 2024

I guess that applies to both values migrated from pre-1.0 and values created in 1.0?

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Feedback
Projects
None yet
Development

No branches or pull requests

3 participants