github.com/MetalBlockchain/metalgo@v1.11.9/vms/types/blob_data.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package types
     5  
     6  import (
     7  	"encoding/json"
     8  
     9  	"github.com/MetalBlockchain/metalgo/utils/formatting"
    10  )
    11  
    12  // JSONByteSlice represents [[]byte] that is json marshalled to hex
    13  type JSONByteSlice []byte
    14  
    15  func (b JSONByteSlice) MarshalJSON() ([]byte, error) {
    16  	hexData, err := formatting.Encode(formatting.HexNC, b)
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  	return json.Marshal(hexData)
    21  }