Bohao | Flow (2024-05-11)
C1.0 - Will this code be handled during migration? Because this interface has been moved from MetadataViews to ViewResolver.
cap
is a member of some resource.28 Replies
I've created a thread for your message. Please continue any relevant discussion in this thread.
You can rename this thread using
/title <new title>
If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadenceI directly use
--skip-validation
for stagingUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Another question is, Is removing inherited interface valid in the migration process?
Just like
From
pub resource Vault: FungibleToken.Provider, FungibleToken.Receiver, FungibleToken.Balance, MetadataViews.Resolver
to access(all) resource Vault: FungibleToken.Vault
I'm not sure if this is specific treatment for Vault
, NFT
, Collection
, or if it's the same for all Resources.
cc @Bastian | CadenceUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Yes, all FT and NFT changes are handled. There are special rules in the migration and contract update checker
Please see the migration guide on how to update FT and NFT contracts
Actually, what I want to ask is whether other non-FT/NFT can also do this?
That is, using the inherited Interface instead of the original lengthy interfaces(will replace some interfaces).
If it's only for FT/NFT special rules, does that mean other Resources cannot?
And the first question:
after resource member
Capability<&{MetadataViews.ResolverCollection}>
modified to Capability<&{ViewResolver.ResolverCollection}>
, an error occurred when staging.
Is this a bug of flow-cli
? or something wrong on my side?It’s only for code using the FT and NFT standard. We’ve added special rules so that the new V2 standards could be made even better
Typo? The types before and after are the same, no?
Except for the change in Type, everything else is the same.
Since
MetadataViews.ResolverCollection
no longer exists, it must be changed to ViewResolver.ResolverCollection
.
This is a resource memberyeah. this needs to be documented better in https://cadence-lang.org/docs/cadence-migration-guide/nft-guide, @joshua | Flow
@Bohao | Flow can you please open an issue in https://github.com/onflow/cadence-lang.org/issues/new/choose ?
actually the resource is not a NFT related... just using MetadataViews...
Sure
Sad.... I also want to simplify some other resources...
It seems that I can only treat it as legacy code...
Wait, a document issue
I thought it might be a migration bug... 😂
If it is not possible to modify the Capability resource member's type in this way, does it mean that many of the resource members that existed as PrivateCap may have problems during Migration? Because their Type has been modified (from restricted
Capability<&Resource{PrivateInterface}>
to Capability<auth(Entitlement) &Resource>
.
Oh, maybe it's a little different. They are still the same type...
Maybe only MetadataView has this problem.
Capability<&{MetadataViews.ResolverCollection}>
needs to be modified to Capability<&{ViewResolver.ResolverCollection}>
,
cc @joshua | Flow
Daily asking...
Is there an answer to the problem of migrating from Capability<&{MetadataViews.ResolverCollection}>
to Capability<&{ViewResolver.ResolverCollection}>
?
@Bastian | Cadence @joshua | FlowThere is no issue. You just need to change it in your code to be the correct type (ViewResolver.ResolverCollection) and the migrations will update it properly
It is the correct type (ViewResolver.ResolverCollection)
I'm not sure if it will really be updated properly because it hasn't happened yet.
But there was an error when staging with flow-cli.
MetadataViews
and ViewResolver
are both at "testnet": "631e88ae7f1d7c20"
, that should be the correct contract address.
but staging verification failed
Probably, is it just a problem with flow-cli
?
cc @Chase | Flow 4D @Jordan R | Flow 4Dwe have a test case for this rewrite rule in the migration: https://github.com/onflow/flow-go/blob/63080cc17b1f633b0447166e47895bdd09c8549e/cmd/util/ledger/migrations/cadence_values_migration_test.go#L1406
Are you using the latest CLI prerelease?
v1.18.0-cadence-v1.0.0-preview.23
I think it is.
The test case is running:
migrate
method https://github.com/onflow/flow-go/blob/63080cc17b1f633b0447166e47895bdd09c8549e/cmd/util/ledger/migrations/cadence_values_migration_test.go#L972
But is the validator running checkTypeUpgradability
method?
I found this: https://github.com/onflow/cadence/blob/master/runtime/stdlib/cadence_v0.42_to_v1_contract_upgrade_validator.go#L402
I cannot find any specific case on MetadataViews
then throw newTypeMismatchErrorGitHub
cadence/runtime/stdlib/cadence_v0.42_to_v1_contract_upgrade_validat...
Cadence, the resource-oriented smart contract programming language 🏃♂️ - onflow/cadence
GitHub
flow-go/cmd/util/ledger/migrations/cadence_values_migration_test.go...
A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps, and the digital assets that power them. - onflow/flow-go
The rules for the NFT/FT types changes are in flow-go. Still the migration in flow-go should use the rules both for the state migration, and the update checker.
Then there's also the CLI, which runs the update checker too to give some preliminary results, maybe that one isn't using the rules properly?
@joshua | Flow do you happen to know if this is a general problem, i.e. are there other reports where
ResolverCollection
is causing problems? if there are alreafy updates staged that change ResolverCollection
successfuly, it might be a problem on your end @Bohao | FlowI haven't heard of this problem before, but I don't think many people ever created capabilities of the type
{ResolverCollection}
, so there might not be any other examples.Do we have a similar problem for
Resolver
?
we're setting up rules for both Resolver
and ResolverCollection
, from MetadataViews
to ViewResolver
(https://github.com/onflow/flow-go/blob/v0.34.0-crescendo-preview.18/cmd/util/ledger/migrations/cadence.go#L182-L183), here: https://github.com/onflow/flow-go/blob/v0.34.0-crescendo-preview.18/cmd/util/ledger/migrations/cadence.go#L22-L27
and we're using those rules in the update checker (https://github.com/onflow/flow-go/blob/v0.34.0-crescendo-preview.18/cmd/util/ledger/migrations/staged_contracts_migration.go#L642) which runs as part of the migration
the CLI uses the same: https://github.com/onflow/flow-cli/blob/v1.18.0-cadence-v1.0.0-preview.23/internal/migrate/staging_validator.go#L170
@Bohao | Flow could you maybe provide a reproducer? ideally as small as possibleSure, here is a reproducer:
Old Contract
After
flow.json, dependences:
I found that
checkUserDefinedType
only applied in case ast.NominalType
, during the checkFields
in the checkDeclarationUpdatability
method.
The MetadataViews => ViewResolver
is protected by checkUserDefinedType
func. so checkConformance
should be working.
The only possible error is an error occurring during checkFields.Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
@Supun | Cadence could you maybe have a look here, given you have a bit more knowledge and experience with the migration's update checker?
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
@Jordan R | Flow 4D thanks for debugging and finding the issue 🙏
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View