diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 8bd81f6eb..d18408564 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -692,6 +692,7 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) (ctx sdk.Con } // runMsgs iterates through all the messages and executes them. +// nolint: gocyclo func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (result sdk.Result) { idxLogs := make([]sdk.ABCIMessageLog, 0, len(msgs)) // a list of JSON-encoded logs with msg index @@ -782,7 +783,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) ( return ctx.WithMultiStore(msCache), msCache } -// runTx processes a transaction. The transactions is proccessed via an +// runTx processes a transaction. The transactions is processed via an // anteHandler. The provided txBytes may be nil in some cases, eg. in tests. For // further details on transaction execution, reference the BaseApp SDK // documentation. @@ -797,8 +798,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk // only run the tx if there is block gas remaining if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() { - result = sdk.ErrOutOfGas("no block gas left to run tx").Result() - return + return sdk.ErrOutOfGas("no block gas left to run tx").Result() } var startingGas uint64 @@ -883,7 +883,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk } if mode == runTxModeCheck { - return + return result } // Create a new context based off of the existing context with a cache wrapped @@ -893,7 +893,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk result.GasWanted = gasWanted if mode == runTxModeSimulate { - return + return result } // only update state if all messages pass @@ -901,7 +901,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk msCache.Write() } - return + return result } // EndBlock implements the ABCI interface. diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 0aafbbe61..8ba0573cf 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -465,6 +465,7 @@ func TestGaiaCLIQueryRewards(t *testing.T) { genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) + require.NoError(t, err) require.NoError(t, genDoc.SaveAs(genFile)) // start gaiad server @@ -860,7 +861,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) // Test broadcast - success, stdout, _ = f.TxBroadcast(signedTxFile.Name()) + success, _, _ = f.TxBroadcast(signedTxFile.Name()) require.True(t, success) tests.WaitForNextNBlocksTM(1, f.Port) diff --git a/crypto/encode_test.go b/crypto/encode_test.go index aef8d8e32..06d6dadc1 100644 --- a/crypto/encode_test.go +++ b/crypto/encode_test.go @@ -47,7 +47,7 @@ func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool) require.Nil(t, err, "%+v", err) } -//nolint +// nolint: vet func ExamplePrintRegisteredTypes() { cdc.PrintTypes(os.Stdout) // Output: | Type | Name | Prefix | Length | Notes | diff --git a/crypto/keys/hd/hdpath_test.go b/crypto/keys/hd/hdpath_test.go index 509cdb6c2..b0089603e 100644 --- a/crypto/keys/hd/hdpath_test.go +++ b/crypto/keys/hd/hdpath_test.go @@ -17,7 +17,7 @@ func mnemonicToSeed(mnemonic string) []byte { return bip39.NewSeed(mnemonic, defaultBIP39Passphrase) } -//nolint +// nolint: vet func ExampleStringifyPathParams() { path := NewParams(44, 0, 0, false, 0) fmt.Println(path.String()) @@ -96,7 +96,7 @@ func TestParamsFromPath(t *testing.T) { } -//nolint +// nolint: vet func ExampleSomeBIP32TestVecs() { seed := mnemonicToSeed("barrel original fuel morning among eternal " + diff --git a/x/auth/client/cli/sign.go b/x/auth/client/cli/sign.go index 2de22d447..6fbe51eae 100644 --- a/x/auth/client/cli/sign.go +++ b/x/auth/client/cli/sign.go @@ -7,12 +7,12 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - amino "github.com/tendermint/go-amino" "github.com/tendermint/tendermint/crypto/multisig" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/utils" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" @@ -28,7 +28,7 @@ const ( ) // GetSignCommand returns the transaction sign command. -func GetSignCommand(codec *amino.Codec) *cobra.Command { +func GetSignCommand(codec *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "sign [file]", Short: "Sign transactions generated offline", @@ -92,11 +92,11 @@ func preSignCmd(cmd *cobra.Command, _ []string) { } } -func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error { - return func(cmd *cobra.Command, args []string) (err error) { +func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error { + return func(cmd *cobra.Command, args []string) error { stdTx, err := utils.ReadStdTxFromFile(cdc, args[0]) if err != nil { - return + return err } offline := viper.GetBool(flagOffline) @@ -137,35 +137,14 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error return err } - var json []byte - - switch generateSignatureOnly { - case true: - switch cliCtx.Indent { - case true: - json, err = cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ") - - default: - json, err = cdc.MarshalJSON(newTx.Signatures[0]) - } - - default: - switch cliCtx.Indent { - case true: - json, err = cdc.MarshalJSONIndent(newTx, "", " ") - - default: - json, err = cdc.MarshalJSON(newTx) - } - } - + json, err := getSignatureJSON(cdc, newTx, cliCtx.Indent, generateSignatureOnly) if err != nil { return err } if viper.GetString(flagOutfile) == "" { fmt.Printf("%s\n", json) - return + return nil } fp, err := os.OpenFile( @@ -178,7 +157,28 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error defer fp.Close() fmt.Fprintf(fp, "%s\n", json) - return + return nil + } +} + +func getSignatureJSON(cdc *codec.Codec, newTx auth.StdTx, indent, generateSignatureOnly bool) ([]byte, error) { + switch generateSignatureOnly { + case true: + switch indent { + case true: + return cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ") + + default: + return cdc.MarshalJSON(newTx.Signatures[0]) + } + default: + switch indent { + case true: + return cdc.MarshalJSONIndent(newTx, "", " ") + + default: + return cdc.MarshalJSON(newTx) + } } }