Documentation ¶
Index ¶
- Constants
- type Encoder
- func (enc Encoder) DefineFieldEncoding(name string, encoder FieldEncoder) Encoder
- func (enc Encoder) DefineMessageEncoding(name string, encoder MessageEncoder) Encoder
- func (enc Encoder) DefineScalarEncoding(name string, encoder FieldEncoder) Encoder
- func (enc Encoder) DefineTypeEncoding(typeURL string, encoder MessageEncoder) Encoder
- func (enc Encoder) Marshal(message proto.Message) ([]byte, error)
- type EncoderOptions
- type FieldEncoder
- type MessageEncoder
- type SignModeHandler
- type SignModeHandlerOptions
Constants ¶
const MaxDurationSeconds = int64(math.MaxInt64)/1e9 - 1
MaxDurationSeconds the maximum number of seconds (when expressed as nanoseconds) which can fit in an int64. gogoproto encodes google.protobuf.Duration as a time.Duration, which is 64-bit signed integer.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a JSON encoder that uses the Amino JSON encoding rules for protobuf messages.
func NewEncoder ¶ added in v0.6.3
func NewEncoder(options EncoderOptions) Encoder
NewEncoder returns a new Encoder capable of serializing protobuf messages to JSON using the Amino JSON encoding rules.
func (Encoder) DefineFieldEncoding ¶
func (enc Encoder) DefineFieldEncoding(name string, encoder FieldEncoder) Encoder
DefineFieldEncoding defines a custom encoding for a protobuf field. The `name` field must match a usage of an (amino.encoding) option in the protobuf message as in the following example. This encoding will be used instead of the default encoding for all usages of the tagged field.
message Balance { repeated cosmos.base.v1beta1.Coin coins = 2 [ (amino.encoding) = "legacy_coins", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; ... }
func (Encoder) DefineMessageEncoding ¶
func (enc Encoder) DefineMessageEncoding(name string, encoder MessageEncoder) Encoder
DefineMessageEncoding defines a custom encoding for a protobuf message. The `name` field must match a usage of an (amino.message_encoding) option in the protobuf message as in the following example. This encoding will be used instead of the default encoding for all usages of the tagged message.
message ModuleAccount { option (amino.name) = "cosmos-sdk/ModuleAccount"; option (amino.message_encoding) = "module_account"; ... }
func (Encoder) DefineScalarEncoding ¶ added in v0.10.0
func (enc Encoder) DefineScalarEncoding(name string, encoder FieldEncoder) Encoder
DefineScalarEncoding defines a custom encoding for a protobuf scalar field. The `name` field must match a usage of an (cosmos_proto.scalar) option in the protobuf message as in the following example. This encoding will be used instead of the default encoding for all usages of the tagged field.
message Balance { string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; ... }
func (Encoder) DefineTypeEncoding ¶ added in v0.10.0
func (enc Encoder) DefineTypeEncoding(typeURL string, encoder MessageEncoder) Encoder
type EncoderOptions ¶ added in v0.7.0
type EncoderOptions struct { // Indent can only be composed of space or tab characters. // It defines the indentation used for each level of indentation. Indent string // DoNotSortFields when set turns off sorting of field names. DoNotSortFields bool // EnumAsString when set will encode enums as strings instead of integers. // Caution: Enabling this option produce different sign bytes. EnumAsString bool // AminoNameAsTypeURL when set will use the amino name as the type URL in the JSON output. // It is useful when using the Amino JSON encoder for non Amino purposes, // such as JSON RPC. AminoNameAsTypeURL bool // TypeResolver is used to resolve protobuf message types by TypeURL when marshaling any packed messages. TypeResolver signing.TypeResolver // FileResolver is used to resolve protobuf file descriptors TypeURL when TypeResolver fails. FileResolver signing.ProtoFileResolver }
EncoderOptions are options for creating a new Encoder.
type FieldEncoder ¶
FieldEncoder is a function that can encode a protobuf protoreflect.Value to JSON.
type MessageEncoder ¶
MessageEncoder is a function that can encode a protobuf protoreflect.Message to JSON.
type SignModeHandler ¶ added in v0.5.1
type SignModeHandler struct {
// contains filtered or unexported fields
}
SignModeHandler implements the SIGN_MODE_LEGACY_AMINO_JSON signing mode.
func NewSignModeHandler ¶ added in v0.5.1
func NewSignModeHandler(options SignModeHandlerOptions) *SignModeHandler
NewSignModeHandler returns a new SignModeHandler.
func (SignModeHandler) GetSignBytes ¶ added in v0.5.1
func (h SignModeHandler) GetSignBytes(_ context.Context, signerData signing.SignerData, txData signing.TxData) ([]byte, error)
GetSignBytes implements the GetSignBytes method of the SignModeHandler interface.
func (SignModeHandler) Mode ¶ added in v0.5.1
func (h SignModeHandler) Mode() signingv1beta1.SignMode
Mode implements the Mode method of the SignModeHandler interface.
type SignModeHandlerOptions ¶ added in v0.5.1
type SignModeHandlerOptions struct { FileResolver signing.ProtoFileResolver TypeResolver signing.TypeResolver Encoder *Encoder }
SignModeHandlerOptions are the options for the SignModeHandler.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
aminojsonpb
Code generated by protoc-gen-go-pulsar.
|
Code generated by protoc-gen-go-pulsar. |
testpb
Code generated by protoc-gen-go-pulsar.
|
Code generated by protoc-gen-go-pulsar. |