Update events.go
handle panic from array type in events
@@ -23,6 +23,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "log"
"github.com/onflow/flow-cli/pkg/flowkit/util"
@@ -126,12 +127,23 @@ func eventString(writer io.Writer, event flow.Event) {
}
func printField(writer io.Writer, field cadence.Field, value cadence.Value) {
+ v := value.String()
var typeId string
+
+ defer func() {
+ if err := recover(); err != nil {
+ v = fmt.Sprintf("%s\n\t\thex: %x", v, v)
+ _, _ = fmt.Fprintf(writer, "\t\t- %s (%s): %s \n", field.Identifier, typeId, v)
+ log.Println("panic occurred:", err)
+ }
+ }()
+
if field.Type != nil {
+ //TODO: onflow/cadence issue #1672
+ //currently getting ID for cadence array will cause panic
typeId = field.Type.ID()
}
- v := value.String()
if typeId == "" { // exception for not known typeId workaround for cadence arrays
v = fmt.Sprintf("%s\n\t\thex: %x", v, v)
}
