Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Aug 2, 2024
1 parent 960a37a commit 309c06f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions x/tx/signing/aminojson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func nullSliceAsEmptyEncoder(enc *Encoder, v protoreflect.Value, w io.Writer) er
func cosmosInlineJSON(_ *Encoder, v protoreflect.Value, w io.Writer) error {
switch bz := v.Interface().(type) {
case []byte:
json, err := sortedJsonStringify(bz)
json, err := sortedJSONStringify(bz)
if err != nil {
return errors.Wrap(err, "could not normalize JSON")
}
Expand Down Expand Up @@ -217,8 +217,8 @@ func sortedObject(obj interface{}) interface{} {
}
}

// sortedJsonStringify returns a JSON with objects sorted by key.
func sortedJsonStringify(jsonBytes []byte) ([]byte, error) {
// sortedJSONStringify returns a JSON with objects sorted by key.
func sortedJSONStringify(jsonBytes []byte) ([]byte, error) {
var obj interface{}
if err := json.Unmarshal(jsonBytes, &obj); err != nil {
return nil, errors.New("invalid JSON bytes")
Expand Down
4 changes: 2 additions & 2 deletions x/tx/signing/aminojson/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestCosmosInlineJSON(t *testing.T) {
}
}

func TestSortedJsonStringify(t *testing.T) {
func TestSortedJSONStringify(t *testing.T) {
tests := map[string]struct {
input []byte
wantOutput string
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestSortedJsonStringify(t *testing.T) {

for name, tc := range tests {
t.Run(name, func(t *testing.T) {
got, err := sortedJsonStringify(tc.input)
got, err := sortedJSONStringify(tc.input)
require.NoError(t, err)
assert.Equal(t, tc.wantOutput, string(got))
})
Expand Down
18 changes: 9 additions & 9 deletions x/tx/signing/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ func (c *Context) makeGetSignersFunc(descriptor protoreflect.MessageDescriptor)
arr = append(arr, res...)
}
return arr, nil
} else {
return fieldGetter(msg.Get(childField).Message(), depth+1)
}

return fieldGetter(msg.Get(childField).Message(), depth+1)
case childField.IsMap() || childField.HasOptionalKeyword():
return nil, fmt.Errorf("cosmos.msg.v1.signer field %s in message %s must not be a map or optional", signerFieldName, desc.FullName())
case childField.Kind() == protoreflect.StringKind:
Expand All @@ -268,14 +268,14 @@ func (c *Context) makeGetSignersFunc(descriptor protoreflect.MessageDescriptor)
res = append(res, addrBz)
}
return res, nil
} else {
addrStr := msg.Get(childField).String()
addrBz, err := addrCdc.StringToBytes(addrStr)
if err != nil {
return nil, err
}
return [][]byte{addrBz}, nil
}

addrStr := msg.Get(childField).String()
addrBz, err := addrCdc.StringToBytes(addrStr)
if err != nil {
return nil, err
}
return [][]byte{addrBz}, nil
}
return nil, fmt.Errorf("unexpected field type %s for field %s in message %s, only string and message type are supported",
childField.Kind(), signerFieldName, desc.FullName())
Expand Down

0 comments on commit 309c06f

Please sign in to comment.