Documentation ¶
Index ¶
- func MarshalAny(m BinaryMarshaler, x interface{}) ([]byte, error)
- func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error)
- func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte
- func ProtoMarshalJSON(msg proto.Message) ([]byte, error)
- func RegisterEvidences(cdc *LegacyAmino)
- func UnmarshalAny(m BinaryMarshaler, iface interface{}, bz []byte) error
- type AminoCodec
- func (ac *AminoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
- func (ac *AminoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
- func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error)
- func (ac *AminoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte
- func (ac *AminoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
- func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte
- func (ac *AminoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
- func (ac *AminoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
- func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
- func (ac *AminoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
- func (ac *AminoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
- func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
- type AminoMarshaler
- type BinaryMarshaler
- type JSONMarshaler
- type LegacyAmino
- func (cdc *LegacyAmino) MarshalBinaryBare(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalBinaryLengthPrefixed(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
- func (cdc *LegacyAmino) MustMarshalBinaryBare(o interface{}) []byte
- func (cdc *LegacyAmino) MustMarshalBinaryLengthPrefixed(o interface{}) []byte
- func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
- func (cdc *LegacyAmino) MustUnmarshalBinaryBare(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
- func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)
- func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)
- func (cdc *LegacyAmino) Seal()
- func (cdc *LegacyAmino) UnmarshalBinaryBare(bz []byte, ptr interface{}) error
- func (cdc *LegacyAmino) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error
- func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
- func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error
- type Marshaler
- type ProtoCodec
- func (pc *ProtoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
- func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
- func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error)
- func (pc *ProtoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte
- func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
- func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte
- func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
- func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
- func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
- func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
- func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
- func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
- func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error
- type ProtoMarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalAny ¶
func MarshalAny(m BinaryMarshaler, x interface{}) ([]byte, error)
MarshalAny is a convenience function for packing the provided value in an Any and then proto marshaling it to bytes
func MarshalJSONIndent ¶
func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error)
MarshalJSONIndent provides a utility for indented JSON encoding of an object via an Amino codec. It returns an error if it cannot serialize or indent as JSON.
func MustMarshalJSONIndent ¶
func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte
MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure.
func ProtoMarshalJSON ¶
ProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded bytes of a message.
func RegisterEvidences ¶
func RegisterEvidences(cdc *LegacyAmino)
RegisterEvidences registers Tendermint evidence types with the provided Amino codec.
func UnmarshalAny ¶
func UnmarshalAny(m BinaryMarshaler, iface interface{}, bz []byte) error
UnmarshalAny is a convenience function for proto unmarshaling an Any from bz and then unpacking it to the interface pointer passed in as iface using the provided AnyUnpacker or returning an error
Ex:
var x MyInterface err := UnmarshalAny(unpacker, &x, bz)
Types ¶
type AminoCodec ¶
type AminoCodec struct {
*LegacyAmino
}
AminoCodec defines a codec that utilizes Codec for both binary and JSON encoding.
func NewAminoCodec ¶
func NewAminoCodec(codec *LegacyAmino) *AminoCodec
NewAminoCodec returns a reference to a new AminoCodec
func (*AminoCodec) MarshalBinaryBare ¶
func (ac *AminoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
MarshalBinaryBare implements BinaryMarshaler.MarshalBinaryBare method.
func (*AminoCodec) MarshalBinaryLengthPrefixed ¶
func (ac *AminoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
MarshalBinaryLengthPrefixed implements BinaryMarshaler.MarshalBinaryLengthPrefixed method.
func (*AminoCodec) MarshalJSON ¶
func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error)
MarshalJSON implements JSONMarshaler.MarshalJSON method, it marshals to JSON using legacy amino codec.
func (*AminoCodec) MustMarshalBinaryBare ¶
func (ac *AminoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte
MustMarshalBinaryBare implements BinaryMarshaler.MustMarshalBinaryBare method.
func (*AminoCodec) MustMarshalBinaryLengthPrefixed ¶
func (ac *AminoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
MustMarshalBinaryLengthPrefixed implements BinaryMarshaler.MustMarshalBinaryLengthPrefixed method.
func (*AminoCodec) MustMarshalJSON ¶
func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte
MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.
func (*AminoCodec) MustUnmarshalBinaryBare ¶
func (ac *AminoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
MustUnmarshalBinaryBare implements BinaryMarshaler.MustUnmarshalBinaryBare method.
func (*AminoCodec) MustUnmarshalBinaryLengthPrefixed ¶
func (ac *AminoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
MustUnmarshalBinaryLengthPrefixed implements BinaryMarshaler.MustUnmarshalBinaryLengthPrefixed method.
func (*AminoCodec) MustUnmarshalJSON ¶
func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.
func (*AminoCodec) UnmarshalBinaryBare ¶
func (ac *AminoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
UnmarshalBinaryBare implements BinaryMarshaler.UnmarshalBinaryBare method.
func (*AminoCodec) UnmarshalBinaryLengthPrefixed ¶
func (ac *AminoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
UnmarshalBinaryLengthPrefixed implements BinaryMarshaler.UnmarshalBinaryLengthPrefixed method.
func (*AminoCodec) UnmarshalJSON ¶
func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, it unmarshals from JSON using legacy amino codec.
type AminoMarshaler ¶
type AminoMarshaler interface { MarshalAmino() ([]byte, error) UnmarshalAmino([]byte) error MarshalAminoJSON() ([]byte, error) UnmarshalAminoJSON([]byte) error }
AminoMarshaler defines an interface where Amino marshalling can be overridden by custom marshalling.
type BinaryMarshaler ¶
type BinaryMarshaler interface { MarshalBinaryBare(o ProtoMarshaler) ([]byte, error) MustMarshalBinaryBare(o ProtoMarshaler) []byte MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) types.AnyUnpacker }
type JSONMarshaler ¶
type LegacyAmino ¶
deprecated: LegacyAmino defines a wrapper for an Amino codec that properly handles protobuf types with Any's
func NewLegacyAmino ¶
func NewLegacyAmino() *LegacyAmino
func (*LegacyAmino) MarshalBinaryBare ¶
func (cdc *LegacyAmino) MarshalBinaryBare(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) MarshalBinaryLengthPrefixed(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalJSON ¶
func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalJSONIndent ¶
func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
func (*LegacyAmino) MustMarshalBinaryBare ¶
func (cdc *LegacyAmino) MustMarshalBinaryBare(o interface{}) []byte
func (*LegacyAmino) MustMarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) MustMarshalBinaryLengthPrefixed(o interface{}) []byte
func (*LegacyAmino) MustMarshalJSON ¶
func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
func (*LegacyAmino) MustUnmarshalBinaryBare ¶
func (cdc *LegacyAmino) MustUnmarshalBinaryBare(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalJSON ¶
func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
func (*LegacyAmino) PrintTypes ¶
func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
func (*LegacyAmino) RegisterConcrete ¶
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)
func (*LegacyAmino) RegisterInterface ¶
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)
func (*LegacyAmino) Seal ¶
func (cdc *LegacyAmino) Seal()
func (*LegacyAmino) UnmarshalBinaryBare ¶
func (cdc *LegacyAmino) UnmarshalBinaryBare(bz []byte, ptr interface{}) error
func (*LegacyAmino) UnmarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error
func (*LegacyAmino) UnmarshalJSON ¶
func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
type Marshaler ¶
type Marshaler interface { BinaryMarshaler JSONMarshaler }
Marshaler defines the interface module codecs must implement in order to support backwards compatibility with Amino while allowing custom Protobuf-based serialization. Note, Amino can still be used without any dependency on Protobuf. There are two typical implementations that fulfill this contract:
1. AminoCodec: Provides full Amino serialization compatibility. 2. ProtoCodec: Provides full Protobuf serialization compatibility.
type ProtoCodec ¶
type ProtoCodec struct {
// contains filtered or unexported fields
}
ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON encoding.
func NewProtoCodec ¶
func NewProtoCodec(anyUnpacker types.AnyUnpacker) *ProtoCodec
NewProtoCodec returns a reference to a new ProtoCodec
func (*ProtoCodec) MarshalBinaryBare ¶
func (pc *ProtoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
MarshalBinaryBare implements BinaryMarshaler.MarshalBinaryBare method.
func (*ProtoCodec) MarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
MarshalBinaryLengthPrefixed implements BinaryMarshaler.MarshalBinaryLengthPrefixed method.
func (*ProtoCodec) MarshalJSON ¶
func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error)
MarshalJSON implements JSONMarshaler.MarshalJSON method, it marshals to JSON using proto codec.
func (*ProtoCodec) MustMarshalBinaryBare ¶
func (pc *ProtoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte
MustMarshalBinaryBare implements BinaryMarshaler.MustMarshalBinaryBare method.
func (*ProtoCodec) MustMarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
MustMarshalBinaryLengthPrefixed implements BinaryMarshaler.MustMarshalBinaryLengthPrefixed method.
func (*ProtoCodec) MustMarshalJSON ¶
func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte
MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.
func (*ProtoCodec) MustUnmarshalBinaryBare ¶
func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
MustUnmarshalBinaryBare implements BinaryMarshaler.MustUnmarshalBinaryBare method.
func (*ProtoCodec) MustUnmarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
MustUnmarshalBinaryLengthPrefixed implements BinaryMarshaler.MustUnmarshalBinaryLengthPrefixed method.
func (*ProtoCodec) MustUnmarshalJSON ¶
func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)
MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.
func (*ProtoCodec) UnmarshalBinaryBare ¶
func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
UnmarshalBinaryBare implements BinaryMarshaler.UnmarshalBinaryBare method.
func (*ProtoCodec) UnmarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
UnmarshalBinaryLengthPrefixed implements BinaryMarshaler.UnmarshalBinaryLengthPrefixed method.
func (*ProtoCodec) UnmarshalJSON ¶
func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error
UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, it unmarshals from JSON using proto codec.
type ProtoMarshaler ¶
type ProtoMarshaler interface { proto.Message // for JSON serialization Marshal() ([]byte, error) MarshalTo(data []byte) (n int, err error) MarshalToSizedBuffer(dAtA []byte) (int, error) Size() int Unmarshal(data []byte) error }
ProtoMarshaler defines an interface a type must implement as protocol buffer defined message.
Directories ¶
Path | Synopsis |
---|---|
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK.
|
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK. |
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection
|
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection |
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor b) Mismatched wire types for a field -- this is indicative of mismatched services Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { // Handle the error.
|
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor b) Mismatched wire types for a field -- this is indicative of mismatched services Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { // Handle the error. |