From 309c06f431aa141991dbb8273b837176c119c6fb Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 2 Aug 2024 13:05:53 +0200 Subject: [PATCH] lint --- x/tx/signing/aminojson/encoder.go | 6 +++--- x/tx/signing/aminojson/encoder_test.go | 4 ++-- x/tx/signing/context.go | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/x/tx/signing/aminojson/encoder.go b/x/tx/signing/aminojson/encoder.go index 9fe589c0e544..c1e37ec0723c 100644 --- a/x/tx/signing/aminojson/encoder.go +++ b/x/tx/signing/aminojson/encoder.go @@ -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") } @@ -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") diff --git a/x/tx/signing/aminojson/encoder_test.go b/x/tx/signing/aminojson/encoder_test.go index 29e08a39177f..42f47638d1df 100644 --- a/x/tx/signing/aminojson/encoder_test.go +++ b/x/tx/signing/aminojson/encoder_test.go @@ -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 @@ -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)) }) diff --git a/x/tx/signing/context.go b/x/tx/signing/context.go index f44be0118cca..e3a9855cdd25 100644 --- a/x/tx/signing/context.go +++ b/x/tx/signing/context.go @@ -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: @@ -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())