aminojson

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 24 Imported by: 17

Documentation

Index

Constants

View Source
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() 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) Marshal

func (enc Encoder) Marshal(message proto.Message) ([]byte, error)

Marshal serializes a protobuf message to JSON.

type FieldEncoder

type FieldEncoder func(*Encoder, protoreflect.Value, io.Writer) error

FieldEncoder is a function that can encode a protobuf protoreflect.Value to JSON.

type MessageEncoder

type MessageEncoder func(*Encoder, protoreflect.Message, io.Writer) error

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

Mode implements the Mode method of the SignModeHandler interface.

type SignModeHandlerOptions added in v0.5.1

type SignModeHandlerOptions struct {
	FileResolver protodesc.Resolver
	TypeResolver protoregistry.MessageTypeResolver
	Encoder      *Encoder
}

SignModeHandlerOptions are the options for the SignModeHandler.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL