Skip to content

Commit

Permalink
refactor: run golintci
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <troian.ap@gmail.com>
  • Loading branch information
troian committed Sep 9, 2024
1 parent 13f27c6 commit a9ab9d7
Show file tree
Hide file tree
Showing 50 changed files with 214 additions and 299 deletions.
8 changes: 7 additions & 1 deletion go/cli/auth_query.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"encoding/hex"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -341,8 +342,13 @@ $ %s query tx --%s=%s <sig1_base64>,<sig2_base64...>
return fmt.Errorf("argument should be a tx hash")
}

hash, err := hex.DecodeString(args[0])
if err != nil {
return err
}

// If hash is given, then query the tx by hash.
output, err := nutils.QueryTx(ctx, cctx, args[0])
output, err := nutils.QueryTx(ctx, cctx, hash)
if err != nil {
return err
}
Expand Down
12 changes: 5 additions & 7 deletions go/cli/auth_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ func (s *AuthCLITestSuite) TestCLIQueryTxCmdByHash() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetQueryAuthTxCmd()
cmd.SetArgs(tc.args)
Expand Down Expand Up @@ -328,7 +327,6 @@ func (s *AuthCLITestSuite) TestCLIQueryTxCmdByEvents() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetQueryAuthTxCmd()
cmd.SetArgs(tc.args)
Expand Down Expand Up @@ -363,7 +361,6 @@ func (s *AuthCLITestSuite) TestCLIQueryTxsCmdByEvents() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetQueryAuthTxsByEventsCmd()

Expand Down Expand Up @@ -1133,7 +1130,6 @@ func (s *AuthCLITestSuite) TestQueryParamsCmd() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetQueryAuthParamsCmd()
cctx := s.cctx
Expand Down Expand Up @@ -1335,7 +1331,6 @@ func (s *AuthCLITestSuite) TestAuxSigner() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetTxGovSubmitLegacyProposalCmd()
_, err := clitestutil.ExecTestCLICmd(
Expand Down Expand Up @@ -1541,7 +1536,6 @@ func (s *AuthCLITestSuite) TestAuxToFeeWithTips() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetTxGovSubmitLegacyProposalCmd()
res, err := clitestutil.ExecTestCLICmd(
Expand Down Expand Up @@ -1603,7 +1597,11 @@ func (s *AuthCLITestSuite) TestAuxToFeeWithTips() {
}

func (s *AuthCLITestSuite) getBalances(cctx client.Context, addr sdk.AccAddress, denom string) math.Int {
resp, err := clitestutil.QueryBalancesExec(context.Background(), cctx, addr)
resp, err := clitestutil.QueryBalancesExec(
context.Background(),
cctx,
cli.TestFlags().
With(addr.String())...)
s.Require().NoError(err)

var balRes banktypes.QueryAllBalancesResponse
Expand Down
4 changes: 0 additions & 4 deletions go/cli/authz_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ func (s *AuthzCLITestSuite) TestQueryAuthorizations() {
},
}
for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryAuthzGrantsCmd()
resp, err := clitestutil.ExecTestCLICmd(context.Background(), s.cctx, cmd, tc.args...)
Expand Down Expand Up @@ -158,8 +156,6 @@ func (s *AuthzCLITestSuite) TestQueryAuthorization() {
},
}
for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryAuthzGrantsCmd()
_, err := clitestutil.ExecTestCLICmd(context.Background(), s.cctx, cmd, tc.args...)
Expand Down
3 changes: 0 additions & 3 deletions go/cli/authz_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ func (s *AuthzCLITestSuite) TestCmdRevokeAuthorizations() {
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetTxAuthzRevokeAuthorizationCmd()

Expand Down Expand Up @@ -607,7 +606,6 @@ func (s *AuthzCLITestSuite) TestNewExecGenericAuthorized() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetTxAuthzExecAuthorizationCmd()

Expand Down Expand Up @@ -701,7 +699,6 @@ func (s *AuthzCLITestSuite) TestNewExecGrantAuthorized() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetTxAuthzExecAuthorizationCmd()
cctx := s.cctx
Expand Down
2 changes: 1 addition & 1 deletion go/cli/bank_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ To query for the total supply of a specific coin denomination use:
),
),
PersistentPreRunE: QueryPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
cl := MustQueryClientFromContext(ctx)

Expand Down
10 changes: 0 additions & 10 deletions go/cli/bank_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ func (s *BankCLITestSuite) TestGetBalancesCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryBankBalancesCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), tc.ctxGen(), cmd, tc.args...)
Expand Down Expand Up @@ -160,8 +158,6 @@ func (s *BankCLITestSuite) TestGetSpendableBalancesCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryBankSpendableBalancesCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), tc.ctxGen(), cmd, tc.args...)
Expand Down Expand Up @@ -232,8 +228,6 @@ func (s *BankCLITestSuite) TestGetCmdDenomsMetadata() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryBankDenomsMetadataCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), tc.ctxGen(), cmd, tc.args...)
Expand Down Expand Up @@ -306,8 +300,6 @@ func (s *BankCLITestSuite) TestGetCmdQueryTotalSupply() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryBankTotalSupplyCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), tc.ctxGen(), cmd, tc.args...)
Expand Down Expand Up @@ -368,8 +360,6 @@ func (s *BankCLITestSuite) TestGetCmdQuerySendEnabled() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryBankSendEnabledCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), tc.ctxGen(), cmd, tc.args...)
Expand Down
2 changes: 0 additions & 2 deletions go/cli/bank_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (s *BankCLITestSuite) TestSendTxCmd() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cctx := tc.ctxGen()

Expand Down Expand Up @@ -171,7 +170,6 @@ func (s *BankCLITestSuite) TestMultiSendTxCmd() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cctx := tc.ctxGen()

Expand Down
2 changes: 1 addition & 1 deletion go/cli/cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func ReadPersistentCommandFlags(cctx sdkclient.Context, flagSet *pflag.FlagSet)
})))
}

grpcClient, err := grpc.Dial(grpcURI, dialOpts...)
grpcClient, err := grpc.NewClient(grpcURI, dialOpts...)
if err != nil {
return sdkclient.Context{}, err
}
Expand Down
52 changes: 26 additions & 26 deletions go/cli/deployment_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func GetTxDeploymentCmds() *cobra.Command {

func GetTxDeploymentCreateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create [sdl-file]",
Short: "Create deployment",
Args: cobra.ExactArgs(1),
Use: "create [sdl-file]",
Short: "Create deployment",
Args: cobra.ExactArgs(1),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -149,9 +149,9 @@ func GetTxDeploymentCreateCmd() *cobra.Command {

func GetTxDeploymentDepositCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "deposit <amount>",
Short: "Deposit funds to deployment",
Args: cobra.ExactArgs(1),
Use: "deposit <amount>",
Short: "Deposit funds to deployment",
Args: cobra.ExactArgs(1),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -197,9 +197,9 @@ func GetTxDeploymentDepositCmd() *cobra.Command {

func GetTxDeploymentCloseCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "close",
Short: "Close deployment",
Args: cobra.ExactArgs(0),
Use: "close",
Short: "Close deployment",
Args: cobra.ExactArgs(0),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -229,9 +229,9 @@ func GetTxDeploymentCloseCmd() *cobra.Command {

func GetTxDeploymentUpdateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update [sdl-file]",
Short: "update deployment",
Args: cobra.ExactArgs(1),
Use: "update [sdl-file]",
Short: "update deployment",
Args: cobra.ExactArgs(1),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -317,10 +317,10 @@ func GetTxDeploymentGroupCmds() *cobra.Command {

func GetTxDeploymentGroupCloseCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "close",
Short: "close a Deployment's specific Group",
Example: "akash tx deployment group-close --owner=[Account Address] --dseq=[uint64] --gseq=[uint32]",
Args: cobra.ExactArgs(0),
Use: "close",
Short: "close a Deployment's specific Group",
Example: "akash tx deployment group-close --owner=[Account Address] --dseq=[uint64] --gseq=[uint32]",
Args: cobra.ExactArgs(0),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -357,10 +357,10 @@ func GetTxDeploymentGroupCloseCmd() *cobra.Command {

func GetDeploymentGroupPauseCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "pause",
Short: "pause a Deployment's specific Group",
Example: "akash tx deployment group pause --owner=[Account Address] --dseq=[uint64] --gseq=[uint32]",
Args: cobra.ExactArgs(0),
Use: "pause",
Short: "pause a Deployment's specific Group",
Example: "akash tx deployment group pause --owner=[Account Address] --dseq=[uint64] --gseq=[uint32]",
Args: cobra.ExactArgs(0),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -397,10 +397,10 @@ func GetDeploymentGroupPauseCmd() *cobra.Command {

func GetDeploymentGroupStartCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "start",
Short: "start a Deployment's specific Group",
Example: "akash tx deployment group pause --owner=[Account Address] --dseq=[uint64] --gseq=[uint32]",
Args: cobra.ExactArgs(0),
Use: "start",
Short: "start a Deployment's specific Group",
Example: "akash tx deployment group pause --owner=[Account Address] --dseq=[uint64] --gseq=[uint32]",
Args: cobra.ExactArgs(0),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -462,7 +462,7 @@ Examples:
$ akash tx %s authz grant akash1skjw.. 50akt --from=akash1skl.. --expiration=1661020200
`, dv1.ModuleName, dv1.ModuleName),
),
Args: cobra.ExactArgs(2),
Args: cobra.ExactArgs(2),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
Expand Down Expand Up @@ -522,7 +522,7 @@ Example:
$ akash tx %s authz revoke akash1skj.. --from=akash1skj..
`, dv1.ModuleName),
),
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
PersistentPreRunE: TxPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
Expand Down
2 changes: 1 addition & 1 deletion go/cli/distribution_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ $ %s query distribution community-pool
),
),
PersistentPreRunE: QueryPersistentPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()

cl := MustQueryClientFromContext(ctx)
Expand Down
11 changes: 8 additions & 3 deletions go/cli/distribution_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ func getTxDistributionCmd() *cobra.Command {
type distrGenerateOrBroadcastFunc func(context.Context, []sdk.Msg, ...cclient.BroadcastOption) (interface{}, error)

func newSplitAndApply(
genOrBroadcastFn distrGenerateOrBroadcastFunc, ctx context.Context, msgs []sdk.Msg, chunkSize int, opts ...cclient.BroadcastOption) error {
ctx context.Context,
genOrBroadcastFn distrGenerateOrBroadcastFunc,
msgs []sdk.Msg,
chunkSize int,
opts ...cclient.BroadcastOption,
) error {
if chunkSize == 0 {
if _, err := genOrBroadcastFn(ctx, msgs, opts...); err != nil {
return err
Expand Down Expand Up @@ -176,7 +181,7 @@ $ %[1]s tx distribution withdraw-all-rewards --from mykey

chunkSize, _ := cmd.Flags().GetInt(FlagMaxMessagesPerTx)

return newSplitAndApply(cl.Tx().BroadcastMsgs, ctx, msgs, chunkSize)
return newSplitAndApply(ctx, cl.Tx().BroadcastMsgs, msgs, chunkSize)
},
}

Expand Down Expand Up @@ -287,7 +292,7 @@ $ %s tx distribution withdraw-tokenize-share-rewards --from mykey
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
cl := MustClientFromContext(ctx)
cctx := cl.ClientContext()
Expand Down
1 change: 0 additions & 1 deletion go/cli/flags/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

// ClientOptionsFromFlags reads client options from cli flag set.
//
func ClientOptionsFromFlags(flagSet *pflag.FlagSet) ([]cltypes.ClientOption, error) {
opts := make([]cltypes.ClientOption, 0)

Expand Down
4 changes: 0 additions & 4 deletions go/cli/genesis_genaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import (
cflags "pkg.akt.dev/go/cli/flags"
)

const (

)

// GetGenesisAddAccountCmd returns add-genesis-account cobra Command.
// This command is provided as a default, applications are expected to provide their own command if custom genesis accounts are needed.
func GetGenesisAddAccountCmd(defaultNodeHome string) *cobra.Command {
Expand Down
1 change: 0 additions & 1 deletion go/cli/genesis_genaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestAddGenesisAccountCmd(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
home := t.TempDir()
logger := log.NewNopLogger()
Expand Down
2 changes: 0 additions & 2 deletions go/cli/genesis_gentx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func (s *GenesisCLITestSuite) TestGenTxCmd() {
}

for _, tc := range tests {
tc := tc

dir := s.T().TempDir()
genTxFile := filepath.Join(dir, "myTx")

Expand Down
Loading

0 comments on commit a9ab9d7

Please sign in to comment.