Skip to content

Commit

Permalink
Merge pull request #3467 from onflow/bastian/update-atree-inlining-ca…
Browse files Browse the repository at this point in the history
…dence-v1.0-12
  • Loading branch information
turbolent authored Jul 12, 2024
2 parents d358573 + 15cb429 commit 0761227
Show file tree
Hide file tree
Showing 27 changed files with 3,429 additions and 449 deletions.
5 changes: 0 additions & 5 deletions migrations/capcons/capabilitymigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ func (m *CapabilityValueMigration) Migrate(
panic(errors.NewUnexpectedError("unexpected non-reference borrow type: %T", oldBorrowType))
}

// Convert the old AuthAccount type to the new fully-entitled Account type
if newBorrowType.ReferencedType == interpreter.PrimitiveStaticTypeAuthAccount { //nolint:staticcheck
newBorrowType = fullyEntitledAccountReferenceStaticType
}

newCapability := interpreter.NewUnmeteredCapabilityValue(
capabilityID,
oldCapability.Address,
Expand Down
28 changes: 15 additions & 13 deletions migrations/capcons/linkmigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ type LinkMigrationReporter interface {

// LinkValueMigration migrates all links to capability controllers.
type LinkValueMigration struct {
CapabilityMapping *CapabilityMapping
AccountIDGenerator stdlib.AccountIDGenerator
Reporter LinkMigrationReporter
CapabilityMapping *CapabilityMapping
IssueHandler stdlib.CapabilityControllerIssueHandler
Handler stdlib.CapabilityControllerHandler
Reporter LinkMigrationReporter
}

var _ migrations.ValueMigration = &LinkValueMigration{}
Expand Down Expand Up @@ -98,7 +99,7 @@ func (m *LinkValueMigration) Migrate(
}

reporter := m.Reporter
accountIDGenerator := m.AccountIDGenerator
issueHandler := m.IssueHandler

locationRange := interpreter.EmptyLocationRange

Expand Down Expand Up @@ -180,7 +181,7 @@ func (m *LinkValueMigration) Migrate(
capabilityID, _ = stdlib.IssueStorageCapabilityController(
inter,
locationRange,
accountIDGenerator,
issueHandler,
accountAddress,
borrowType,
targetPath,
Expand All @@ -190,7 +191,7 @@ func (m *LinkValueMigration) Migrate(
capabilityID, _ = stdlib.IssueAccountCapabilityController(
inter,
locationRange,
accountIDGenerator,
issueHandler,
accountAddress,
borrowType,
)
Expand Down Expand Up @@ -237,10 +238,10 @@ func storageKeyToPathValue(
return interpreter.NewUnmeteredPathValue(domain, identifier), true
}

var authAccountReferenceStaticType = interpreter.NewReferenceStaticType(
var unauthorizedAccountReferenceStaticType = interpreter.NewReferenceStaticType(
nil,
interpreter.UnauthorizedAccess,
interpreter.PrimitiveStaticTypeAuthAccount, //nolint:staticcheck
interpreter.PrimitiveStaticTypeAccount,
)

func (m *LinkValueMigration) getPathCapabilityFinalTarget(
Expand All @@ -253,6 +254,7 @@ func (m *LinkValueMigration) getPathCapabilityFinalTarget(
authorization interpreter.Authorization,
err error,
) {
handler := m.Handler

locationRange := interpreter.EmptyLocationRange

Expand Down Expand Up @@ -309,10 +311,9 @@ func (m *LinkValueMigration) getPathCapabilityFinalTarget(
pathValue = targetPath

case interpreter.AccountLinkValue: //nolint:staticcheck
if !inter.IsSubTypeOfSemaType(
authAccountReferenceStaticType,
wantedBorrowType,
) {
allowedType := unauthorizedAccountReferenceStaticType

if !inter.IsSubTypeOfSemaType(allowedType, wantedBorrowType) {
return nil, interpreter.UnauthorizedAccess, nil
}

Expand Down Expand Up @@ -343,11 +344,12 @@ func (m *LinkValueMigration) getPathCapabilityFinalTarget(
// just get target address/path
reference := stdlib.GetCheckedCapabilityControllerReference(
inter,
locationRange,
value.Address,
value.ID,
wantedBorrowType,
capabilityBorrowType,
locationRange,
handler,
)
if reference == nil {
return nil, interpreter.UnauthorizedAccess, nil
Expand Down
Loading

0 comments on commit 0761227

Please sign in to comment.