Merge PR #4346: report card minor fixes
* report card minor fixes * fix
This commit is contained in:
parent
4b7d295eca
commit
5b7690e5e9
|
@ -692,6 +692,7 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) (ctx sdk.Con
|
||||||
}
|
}
|
||||||
|
|
||||||
// runMsgs iterates through all the messages and executes them.
|
// 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) {
|
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
|
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
|
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
|
// anteHandler. The provided txBytes may be nil in some cases, eg. in tests. For
|
||||||
// further details on transaction execution, reference the BaseApp SDK
|
// further details on transaction execution, reference the BaseApp SDK
|
||||||
// documentation.
|
// 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
|
// only run the tx if there is block gas remaining
|
||||||
if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() {
|
if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() {
|
||||||
result = sdk.ErrOutOfGas("no block gas left to run tx").Result()
|
return sdk.ErrOutOfGas("no block gas left to run tx").Result()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var startingGas uint64
|
var startingGas uint64
|
||||||
|
@ -883,7 +883,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
|
||||||
}
|
}
|
||||||
|
|
||||||
if mode == runTxModeCheck {
|
if mode == runTxModeCheck {
|
||||||
return
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new context based off of the existing context with a cache wrapped
|
// 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
|
result.GasWanted = gasWanted
|
||||||
|
|
||||||
if mode == runTxModeSimulate {
|
if mode == runTxModeSimulate {
|
||||||
return
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// only update state if all messages pass
|
// 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()
|
msCache.Write()
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndBlock implements the ABCI interface.
|
// EndBlock implements the ABCI interface.
|
||||||
|
|
|
@ -465,6 +465,7 @@ func TestGaiaCLIQueryRewards(t *testing.T) {
|
||||||
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
|
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
|
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
|
||||||
|
require.NoError(t, err)
|
||||||
require.NoError(t, genDoc.SaveAs(genFile))
|
require.NoError(t, genDoc.SaveAs(genFile))
|
||||||
|
|
||||||
// start gaiad server
|
// start gaiad server
|
||||||
|
@ -860,7 +861,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
|
||||||
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
||||||
|
|
||||||
// Test broadcast
|
// Test broadcast
|
||||||
success, stdout, _ = f.TxBroadcast(signedTxFile.Name())
|
success, _, _ = f.TxBroadcast(signedTxFile.Name())
|
||||||
require.True(t, success)
|
require.True(t, success)
|
||||||
tests.WaitForNextNBlocksTM(1, f.Port)
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool)
|
||||||
require.Nil(t, err, "%+v", err)
|
require.Nil(t, err, "%+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint
|
// nolint: vet
|
||||||
func ExamplePrintRegisteredTypes() {
|
func ExamplePrintRegisteredTypes() {
|
||||||
cdc.PrintTypes(os.Stdout)
|
cdc.PrintTypes(os.Stdout)
|
||||||
// Output: | Type | Name | Prefix | Length | Notes |
|
// Output: | Type | Name | Prefix | Length | Notes |
|
||||||
|
|
|
@ -17,7 +17,7 @@ func mnemonicToSeed(mnemonic string) []byte {
|
||||||
return bip39.NewSeed(mnemonic, defaultBIP39Passphrase)
|
return bip39.NewSeed(mnemonic, defaultBIP39Passphrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint
|
// nolint: vet
|
||||||
func ExampleStringifyPathParams() {
|
func ExampleStringifyPathParams() {
|
||||||
path := NewParams(44, 0, 0, false, 0)
|
path := NewParams(44, 0, 0, false, 0)
|
||||||
fmt.Println(path.String())
|
fmt.Println(path.String())
|
||||||
|
@ -96,7 +96,7 @@ func TestParamsFromPath(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint
|
// nolint: vet
|
||||||
func ExampleSomeBIP32TestVecs() {
|
func ExampleSomeBIP32TestVecs() {
|
||||||
|
|
||||||
seed := mnemonicToSeed("barrel original fuel morning among eternal " +
|
seed := mnemonicToSeed("barrel original fuel morning among eternal " +
|
||||||
|
|
|
@ -7,12 +7,12 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
amino "github.com/tendermint/go-amino"
|
|
||||||
"github.com/tendermint/tendermint/crypto/multisig"
|
"github.com/tendermint/tendermint/crypto/multisig"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
|
@ -28,7 +28,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSignCommand returns the transaction sign command.
|
// GetSignCommand returns the transaction sign command.
|
||||||
func GetSignCommand(codec *amino.Codec) *cobra.Command {
|
func GetSignCommand(codec *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "sign [file]",
|
Use: "sign [file]",
|
||||||
Short: "Sign transactions generated offline",
|
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 {
|
func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error {
|
||||||
return func(cmd *cobra.Command, args []string) (err error) {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
stdTx, err := utils.ReadStdTxFromFile(cdc, args[0])
|
stdTx, err := utils.ReadStdTxFromFile(cdc, args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
offline := viper.GetBool(flagOffline)
|
offline := viper.GetBool(flagOffline)
|
||||||
|
@ -137,35 +137,14 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var json []byte
|
json, err := getSignatureJSON(cdc, newTx, cliCtx.Indent, generateSignatureOnly)
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetString(flagOutfile) == "" {
|
if viper.GetString(flagOutfile) == "" {
|
||||||
fmt.Printf("%s\n", json)
|
fmt.Printf("%s\n", json)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fp, err := os.OpenFile(
|
fp, err := os.OpenFile(
|
||||||
|
@ -178,7 +157,28 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
|
||||||
defer fp.Close()
|
defer fp.Close()
|
||||||
fmt.Fprintf(fp, "%s\n", json)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue