MCPcopy Create free account
hub / github.com/DNAProject/DNA / stringify

Function stringify

vm/crossvm_codec/notify_codec.go:42–65  ·  view source on GitHub ↗
(notify interface{})

Source from the content-addressed store, hash-verified

40}
41
42func stringify(notify interface{}) interface{} {
43 switch val := notify.(type) {
44 case []byte:
45 return hex.EncodeToString(val)
46 case common.Address:
47 return val.ToBase58()
48 case bool, string:
49 return val
50 case common.Uint256:
51 return val.ToHexString()
52 case *big.Int:
53 return fmt.Sprintf("%d", val)
54 case []interface{}:
55 list := make([]interface{}, 0, len(val))
56 for _, v := range val {
57 list = append(list, stringify(v))
58 }
59 return list
60 default:
61 log.Warn("notify codec: unsupported type:", reflect.TypeOf(val).String())
62
63 return val
64 }
65}
66
67// input byte array should be the following format
68// evt\0(4byte) + type(1byte) + usize( bytearray or list) (4 bytes) + data...

Callers 1

DeserializeNotifyFunction · 0.85

Calls 4

WarnFunction · 0.92
ToBase58Method · 0.80
ToHexStringMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected