diff --git a/cmd/util/ledger/migrations/cadence_values_migration.go b/cmd/util/ledger/migrations/cadence_values_migration.go index 8a72172cf30..761f09ab125 100644 --- a/cmd/util/ledger/migrations/cadence_values_migration.go +++ b/cmd/util/ledger/migrations/cadence_values_migration.go @@ -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) { @@ -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 {