Skip to content

Commit

Permalink
check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Aug 30, 2023
1 parent 8943b32 commit 6494216
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ issues:
- text: 'Use of weak random number generator'
linters:
- gosec
- text: 'ST1003'
linters:
- stylecheck

max-issues-per-linter: 10000
max-same-issues: 10000
Expand Down
5 changes: 2 additions & 3 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -180,7 +179,7 @@ $ %s cfg i`, appName, defaultHome, appName)),
// An error is only returned if the directory cannot be read at all.
func addChainsFromDirectory(ctx context.Context, stderr io.Writer, a *appState, dir string) error {
dir = path.Clean(dir)
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return err
}
Expand Down Expand Up @@ -232,7 +231,7 @@ func addChainsFromDirectory(ctx context.Context, stderr io.Writer, a *appState,
// which means a's paths may include a subset of the path files in dir.
func addPathsFromDirectory(ctx context.Context, stderr io.Writer, a *appState, dir string) error {
dir = path.Clean(dir)
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ $ %s q conns ibc-1`,
// pagereq, err := client.ReadPageRequest(cmd.Flags())
// if err != nil {
// return err
//}
// }

res, err := chain.ChainProvider.QueryConnections(cmd.Context())
if err != nil {
Expand Down Expand Up @@ -624,7 +624,7 @@ $ %s query connection-channels ibc-2 ibcconnection2 --offset 2 --limit 30`,
// pagereq, err := client.ReadPageRequest(cmd.Flags())
// if err != nil {
// return err
//}
// }

chans, err := chain.ChainProvider.QueryConnectionChannels(cmd.Context(), 0, args[1])
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions relayer/chains/cosmos/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand All @@ -39,17 +40,17 @@ func (cc *CosmosProvider) Invoke(ctx context.Context, method string, req, reply

// In both cases, we don't allow empty request req (it will panic unexpectedly).
if reflect.ValueOf(req).IsNil() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "request cannot be nil")
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "request cannot be nil")
}

// Case 1. Broadcasting a Tx.
if reqProto, ok := req.(*tx.BroadcastTxRequest); ok {
if !ok {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected %T, got %T", (*tx.BroadcastTxRequest)(nil), req)
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "expected %T, got %T", (*tx.BroadcastTxRequest)(nil), req)
}
resProto, ok := reply.(*tx.BroadcastTxResponse)
if !ok {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected %T, got %T", (*tx.BroadcastTxResponse)(nil), req)
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "expected %T, got %T", (*tx.BroadcastTxResponse)(nil), req)
}

broadcastRes, err := cc.TxServiceBroadcast(ctx, reqProto)
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/cosmos/keys/sr25519/privkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool {
return m.PrivKey.Equals(sk2.PrivKey)
}

func (m *PrivKey) ProtoMessage() {}
func (*PrivKey) ProtoMessage() {}

func (m *PrivKey) Reset() {
m.PrivKey = tmsr25519.PrivKey{}
Expand Down
7 changes: 4 additions & 3 deletions relayer/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ func (e RelayerEvent) MarshalLogObject(enc zapcore.ObjectEncoder) error {
// MarshalLogArray satisfies the zapcore.ArrayMarshaler interface.
func (es loggableEvents) MarshalLogArray(enc zapcore.ArrayEncoder) error {
for _, e := range es {
enc.AppendObject(e)
err := enc.AppendObject(e)
return err
}
return nil
}
Expand All @@ -210,8 +211,8 @@ func (r RelayerTxResponse) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddString("codespace", r.Codespace)
enc.AddUint32("code", r.Code)
enc.AddString("data", r.Data)
enc.AddArray("events", loggableEvents(r.Events))
return nil
err := enc.AddArray("events", loggableEvents(r.Events))
return err
}

type KeyProvider interface {
Expand Down

0 comments on commit 6494216

Please sign in to comment.