Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions x/tx/signing/aminojson/json_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type EncoderOptions struct {
// It is useful when using the Amino JSON encoder for non Amino purposes,
// such as JSON RPC.
AminoNameAsTypeURL bool
// MarshalMappings when set will use the Amino JSON encoder to marshal maps.
MarshalMappings 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.
Expand All @@ -57,6 +59,7 @@ type Encoder struct {
indent string
enumsAsString bool
aminoNameAsTypeURL bool
marshalMappings bool
}

// NewEncoder returns a new Encoder capable of serializing protobuf messages to JSON using the Amino JSON encoding
Expand Down Expand Up @@ -93,6 +96,7 @@ func NewEncoder(options EncoderOptions) Encoder {
indent: options.Indent,
enumsAsString: options.EnumAsString,
aminoNameAsTypeURL: options.AminoNameAsTypeURL,
marshalMappings: options.MarshalMappings,
}
return enc
}
Expand Down Expand Up @@ -237,6 +241,9 @@ func (enc Encoder) marshal(value protoreflect.Value, fd protoreflect.FieldDescri
return err

case protoreflect.Map:
if enc.marshalMappings {
return jsonMarshal(writer, value)
}
return errors.New("maps are not supported")

case protoreflect.List:
Expand Down
Loading