Skip to content

Commit

Permalink
improve reporting of cyclic link migration errors
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Jul 29, 2024
1 parent 18c8533 commit 35ee1da
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion cmd/util/ledger/migrations/cadence_values_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ func (t *cadenceValueMigrationReporter) MigratedLink(
}

func (t *cadenceValueMigrationReporter) CyclicLink(err capcons.CyclicLinkError) {
t.reportWriter.Write(err)
t.reportWriter.Write(linkCyclicEntry{
Address: err.Address,
Paths: err.Paths,
})
}

func (t *cadenceValueMigrationReporter) MissingTarget(accountAddressPath interpreter.AddressPath) {
Expand Down Expand Up @@ -734,6 +737,39 @@ func (e linkMissingTargetEntry) MarshalJSON() ([]byte, error) {
})
}

// linkCyclicEntry

type linkCyclicEntry struct {
Address common.Address
Paths []interpreter.PathValue
}

var _ valueMigrationReportEntry = linkCyclicEntry{}

func (e linkCyclicEntry) accountAddress() common.Address {
return e.Address
}

var _ json.Marshaler = linkCyclicEntry{}

func (e linkCyclicEntry) MarshalJSON() ([]byte, error) {

pathStrings := make([]string, 0, len(e.Paths))
for _, path := range e.Paths {
pathStrings = append(pathStrings, path.String())
}

return json.Marshal(struct {
Kind string `json:"kind"`
AccountAddress string `json:"account_address"`
Paths []string `json:"paths"`
}{
Kind: "link-cyclic",
AccountAddress: e.Address.HexWithPrefix(),
Paths: pathStrings,
})
}

// dictionaryKeyConflictEntry

type dictionaryKeyConflictEntry struct {
Expand Down

0 comments on commit 35ee1da

Please sign in to comment.