Skip to content

Commit

Permalink
Merge pull request #6388 from onflow/bastian/recover-nft
Browse files Browse the repository at this point in the history
[FVM] Recover NFT contract
  • Loading branch information
turbolent authored Aug 23, 2024
2 parents 4df1bf3 + ab9e300 commit 400bcd0
Show file tree
Hide file tree
Showing 8 changed files with 451 additions and 85 deletions.
16 changes: 3 additions & 13 deletions cmd/util/ledger/migrations/account_storage_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,15 @@ func NewAccountStorageMigration(
log.Err(err).Msg("storage health check failed")
}

// Finalize the transaction
result, err := migrationRuntime.TransactionState.FinalizeMainTransaction()
if err != nil {
return fmt.Errorf("failed to finalize main transaction: %w", err)
}
// Commit/finalize the transaction

// Merge the changes into the registers
expectedAddresses := map[flow.Address]struct{}{
flow.Address(address): {},
}

err = registers.ApplyChanges(
registersByAccount,
result.WriteSet,
expectedAddresses,
log,
)
err = migrationRuntime.Commit(expectedAddresses, log)
if err != nil {
return fmt.Errorf("failed to apply register changes: %w", err)
return fmt.Errorf("failed to commit: %w", err)
}

return nil
Expand Down
16 changes: 3 additions & 13 deletions cmd/util/ledger/migrations/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,25 +392,15 @@ func (m *IssueStorageCapConMigration) MigrateAccount(
return fmt.Errorf("failed to commit changes: %w", err)
}

// finalize the transaction
result, err := migrationRuntime.TransactionState.FinalizeMainTransaction()
if err != nil {
return fmt.Errorf("failed to finalize main transaction: %w", err)
}
// Commit/finalize the transaction

// Merge the changes into the registers
expectedAddresses := map[flow.Address]struct{}{
flow.Address(address): {},
}

err = registers.ApplyChanges(
accountRegisters,
result.WriteSet,
expectedAddresses,
m.log,
)
err = migrationRuntime.Commit(expectedAddresses, m.log)
if err != nil {
return fmt.Errorf("failed to apply changes: %w", err)
return fmt.Errorf("failed to commit: %w", err)
}

return nil
Expand Down
16 changes: 3 additions & 13 deletions cmd/util/ledger/migrations/cadence_values_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,15 @@ func (m *CadenceBaseMigration) MigrateAccount(
}
}

// finalize the transaction
result, err := migrationRuntime.TransactionState.FinalizeMainTransaction()
if err != nil {
return fmt.Errorf("failed to finalize main transaction: %w", err)
}
// Commit/finalize the transaction

// Merge the changes into the registers
expectedAddresses := map[flow.Address]struct{}{
flow.Address(address): {},
}

err = registers.ApplyChanges(
accountRegisters,
result.WriteSet,
expectedAddresses,
m.log,
)
err = migrationRuntime.Commit(expectedAddresses, m.log)
if err != nil {
return fmt.Errorf("failed to apply changes: %w", err)
return fmt.Errorf("failed to commit: %w", err)
}

if m.diffReporter != nil {
Expand Down
Loading

0 comments on commit 400bcd0

Please sign in to comment.