Skip to content

Commit

Permalink
add missing interface type conversion rule, extend tests
Browse files Browse the repository at this point in the history
MetadataViews.ResolverCollection needs to get converted to ViewResolver.ResolverCollection
  • Loading branch information
turbolent committed Mar 12, 2024
1 parent a7c8cc3 commit 1f3d40e
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 94 deletions.
17 changes: 12 additions & 5 deletions cmd/util/ledger/migrations/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package migrations

import (
_ "embed"
"fmt"

"github.com/onflow/cadence/migrations/capcons"
"github.com/onflow/cadence/migrations/statictypes"
Expand All @@ -18,10 +19,15 @@ import (
func NewInterfaceTypeConversionRules(chainID flow.ChainID) StaticTypeMigrationRules {
systemContracts := systemcontracts.SystemContractsForChain(chainID)

oldFungibleTokenResolverType, newFungibleTokenResolverType := fungibleTokenResolverRule(systemContracts)
oldFungibleTokenResolverType, newFungibleTokenResolverType :=
newFungibleTokenMetadataViewsToViewResolverRule(systemContracts, "Resolver")

oldFungibleTokenResolverCollectionType, newFungibleTokenResolverCollectionType :=
newFungibleTokenMetadataViewsToViewResolverRule(systemContracts, "ResolverCollection")

return StaticTypeMigrationRules{
oldFungibleTokenResolverType.ID(): newFungibleTokenResolverType,
oldFungibleTokenResolverType.ID(): newFungibleTokenResolverType,
oldFungibleTokenResolverCollectionType.ID(): newFungibleTokenResolverCollectionType,
}
}

Expand Down Expand Up @@ -119,8 +125,9 @@ func fungibleTokenVaultRule(
return oldType, newType
}

func fungibleTokenResolverRule(
func newFungibleTokenMetadataViewsToViewResolverRule(
systemContracts *systemcontracts.SystemContracts,
typeName string,
) (
*interpreter.InterfaceStaticType,
*interpreter.InterfaceStaticType,
Expand All @@ -138,8 +145,8 @@ func fungibleTokenResolverRule(
Name: newContract.Name,
}

oldQualifiedIdentifier := oldContract.Name + ".Resolver"
newQualifiedIdentifier := newContract.Name + ".Resolver"
oldQualifiedIdentifier := fmt.Sprintf("%s.%s", oldContract.Name, typeName)
newQualifiedIdentifier := fmt.Sprintf("%s.%s", newContract.Name, typeName)

oldType := &interpreter.InterfaceStaticType{
Location: oldLocation,
Expand Down
Loading

0 comments on commit 1f3d40e

Please sign in to comment.