Skip to content

Commit ca84691

Browse files
author
Alex | Interchain Labs
authored
Merge branch 'main' into chore/changlog
2 parents a1e624a + b6d3d72 commit ca84691

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

codec/depinject.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ func ProvideInterfaceRegistry(
5151
return interfaceRegistry, interfaceRegistry, nil
5252
}
5353

54-
func ProvideLegacyAmino() registry.AminoRegistrar {
55-
return NewLegacyAmino()
54+
func ProvideLegacyAmino() (registry.AminoRegistrar, *LegacyAmino) {
55+
amino := NewLegacyAmino()
56+
return amino, amino
5657
}
5758

5859
func ProvideProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec {

x/tx/signing/aminojson/json_marshal.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type EncoderOptions struct {
3838
// It is useful when using the Amino JSON encoder for non Amino purposes,
3939
// such as JSON RPC.
4040
AminoNameAsTypeURL bool
41+
// MarshalMappings when set will use the Amino JSON encoder to marshal maps.
42+
MarshalMappings bool
4143
// TypeResolver is used to resolve protobuf message types by TypeURL when marshaling any packed messages.
4244
TypeResolver signing.TypeResolver
4345
// FileResolver is used to resolve protobuf file descriptors TypeURL when TypeResolver fails.
@@ -57,6 +59,7 @@ type Encoder struct {
5759
indent string
5860
enumsAsString bool
5961
aminoNameAsTypeURL bool
62+
marshalMappings bool
6063
}
6164

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

239243
case protoreflect.Map:
244+
if enc.marshalMappings {
245+
return jsonMarshal(writer, value)
246+
}
240247
return errors.New("maps are not supported")
241248

242249
case protoreflect.List:

0 commit comments

Comments
 (0)