Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Aug 9, 2024
1 parent a0193b1 commit 97ddc31
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
10 changes: 0 additions & 10 deletions migrations/capcons/capabilitymigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ type CapabilityMigrationReporter interface {
accountAddress common.Address,
addressPath interpreter.AddressPath,
)
MissingBorrowType(
accountAddress common.Address,
addressPath interpreter.AddressPath,
)
IssuedStorageCapability(
accountAddress common.Address,
addressPath interpreter.AddressPath,
borrowType *interpreter.ReferenceStaticType,
capabilityID interpreter.UInt64Value,
)
}

// CapabilityValueMigration migrates all path capabilities to ID capabilities,
Expand Down
3 changes: 2 additions & 1 deletion migrations/capcons/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type testMigrationReporter struct {
var _ migrations.Reporter = &testMigrationReporter{}
var _ LinkMigrationReporter = &testMigrationReporter{}
var _ CapabilityMigrationReporter = &testMigrationReporter{}
var _ StorageCapabilityMigrationReporter = &testMigrationReporter{}

func (t *testMigrationReporter) Migrated(
storageKey interpreter.StorageKey,
Expand Down Expand Up @@ -194,7 +195,7 @@ func (t *testMigrationReporter) MissingBorrowType(
)
}

func (t *testMigrationReporter) IssuedStorageCapability(
func (t *testMigrationReporter) IssuedStorageCapabilityController(
accountAddress common.Address,
addressPath interpreter.AddressPath,
borrowType *interpreter.ReferenceStaticType,
Expand Down
17 changes: 15 additions & 2 deletions migrations/capcons/storagecapmigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ import (
"github.com/onflow/cadence/runtime/stdlib"
)

type StorageCapabilityMigrationReporter interface {
MissingBorrowType(
accountAddress common.Address,
addressPath interpreter.AddressPath,
)
IssuedStorageCapabilityController(
accountAddress common.Address,
addressPath interpreter.AddressPath,
borrowType *interpreter.ReferenceStaticType,
capabilityID interpreter.UInt64Value,
)
}

// StorageCapMigration records path capabilities with storage domain target.
// It does not actually migrate any values.
type StorageCapMigration struct {
Expand Down Expand Up @@ -73,7 +86,7 @@ func (m *StorageCapMigration) CanSkip(valueType interpreter.StaticType) bool {

func IssueAccountCapabilities(
inter *interpreter.Interpreter,
reporter CapabilityMigrationReporter,
reporter StorageCapabilityMigrationReporter,
address common.Address,
capabilities *AccountCapabilities,
handler stdlib.CapabilityControllerIssueHandler,
Expand Down Expand Up @@ -105,7 +118,7 @@ func IssueAccountCapabilities(

mapping.Record(addressPath, capabilityID, borrowType)

reporter.IssuedStorageCapability(
reporter.IssuedStorageCapabilityController(
address,
addressPath,
borrowStaticType.(*interpreter.ReferenceStaticType),
Expand Down

0 comments on commit 97ddc31

Please sign in to comment.