refactor event display
@@ -130,29 +130,7 @@ func eventString(writer io.Writer, event flow.Event) {
}
func printField(writer io.Writer, field cadence.Field, value cadence.Value) {
- v := value.ToGoValue()
- typeInfo := "Unknown"
-
- if field.Type != nil {
- typeInfo = field.Type.ID()
- } else if _, isAddress := v.([8]byte); isAddress {
- typeInfo = "Address"
- }
-
fmt.Fprintf(writer, "\t\t-")
- fmt.Fprintf(writer, " %s (%s):\t", field.Identifier, typeInfo)
- // Try the two most obvious cases
- if address, ok := v.([8]byte); ok {
- fmt.Fprintf(writer, "%x", address)
- } else if util.IsByteSlice(v) || field.Identifier == "publicKey" {
- // make exception for public key, since it get's interpreted as []*big.Int
- for _, b := range v.([]interface{}) {
- fmt.Fprintf(writer, "%x", b)
- }
- } else if uintVal, ok := v.(uint64); typeInfo == "UFix64" && ok {
- fmt.Fprintf(writer, "%v", cadence.UFix64(uintVal))
- } else {
- fmt.Fprintf(writer, "%v", v)
- }
+ fmt.Fprintf(writer, " %s (%s): %s", field.Identifier, field.Type.ID(), value.String())
fmt.Fprintf(writer, "\n")
}
