6 "github.com/vapor/blockchain/query"
9 func isValidJSON(b []byte) bool {
11 err := json.Unmarshal(b, &v)
15 //Annotated annotate the asset
16 func Annotated(a *Asset) (*query.AnnotatedAsset, error) {
17 jsonDefinition := json.RawMessage(`{}`)
19 // a.RawDefinitionByte is the asset definition as it appears on the
20 // blockchain, so it's untrusted and may not be valid json.
21 if isValidJSON(a.RawDefinitionByte) {
22 jsonDefinition = json.RawMessage(a.RawDefinitionByte)
25 annotatedAsset := &query.AnnotatedAsset{
28 VMVersion: a.VMVersion,
29 RawDefinitionByte: a.RawDefinitionByte,
30 Definition: &jsonDefinition,
33 return annotatedAsset, nil