diff --git a/.pending/breaking/sdk/4507-New-Signature-g b/.pending/breaking/sdk/4507-New-Signature-g deleted file mode 100644 index 80e1b83d12ad..000000000000 --- a/.pending/breaking/sdk/4507-New-Signature-g +++ /dev/null @@ -1,3 +0,0 @@ -#4507 New `Signature` generic interface available in the top level types package. -`auth.StdSignature` implements such interface. User defined auth module can now -define their own custom signature types. diff --git a/client/keys/import.go b/client/keys/import.go index 944267fdcf80..433c703a60f9 100644 --- a/client/keys/import.go +++ b/client/keys/import.go @@ -3,9 +3,8 @@ package keys import ( "io/ioutil" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client/input" + "github.com/spf13/cobra" ) func importKeyCommand() *cobra.Command { diff --git a/client/keys/list.go b/client/keys/list.go index 7edec854152e..1600d345b05b 100644 --- a/client/keys/list.go +++ b/client/keys/list.go @@ -1,9 +1,8 @@ package keys import ( - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" ) func listKeysCmd() *cobra.Command { diff --git a/client/keys/mnemonic_test.go b/client/keys/mnemonic_test.go index 62abef02cfe2..617a2ecc7574 100644 --- a/client/keys/mnemonic_test.go +++ b/client/keys/mnemonic_test.go @@ -5,10 +5,9 @@ import ( "strings" "testing" + "github.com/cosmos/cosmos-sdk/client/input" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client/input" ) func Test_RunMnemonicCmdNormal(t *testing.T) { diff --git a/client/keys/update.go b/client/keys/update.go index 39131a3b4980..3e1160fe8ebe 100644 --- a/client/keys/update.go +++ b/client/keys/update.go @@ -3,9 +3,8 @@ package keys import ( "fmt" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client/input" + "github.com/spf13/cobra" ) func updateKeyCommand() *cobra.Command { diff --git a/client/utils/utils_test.go b/client/utils/utils_test.go index dd023510da96..94df3e797d0d 100644 --- a/client/utils/utils_test.go +++ b/client/utils/utils_test.go @@ -100,7 +100,7 @@ func TestReadStdTxFromFile(t *testing.T) { // Build a test transaction fee := authtypes.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) - stdTx := authtypes.NewStdTx([]sdk.Msg{}, fee, nil, "foomemo") + stdTx := authtypes.NewStdTx([]sdk.Msg{}, fee, []authtypes.StdSignature{}, "foomemo") // Write it to the file encodedTx, _ := cdc.MarshalJSON(stdTx) @@ -143,8 +143,8 @@ func TestValidateCmd(t *testing.T) { }{ {"misspelled command", []string{"comission"}, true}, {"no command provided", []string{}, false}, - {"help flag", []string{"commission", "--help"}, false}, - {"shorthand help flag", []string{"commission", "-h"}, false}, + {"help flag", []string{"comission", "--help"}, false}, + {"shorthand help flag", []string{"comission", "-h"}, false}, } for _, tt := range tests { @@ -158,7 +158,7 @@ func TestValidateCmd(t *testing.T) { func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) { msgs := []sdk.Msg{sdk.NewTestMsg(addr)} - tx := authtypes.NewStdTx(msgs, authtypes.StdFee{}, []sdk.Signature{}, "") + tx := authtypes.NewStdTx(msgs, authtypes.StdFee{}, []authtypes.StdSignature{}, "") defaultEncoderBytes, err := expected(tx) require.NoError(t, err) diff --git a/contrib/runsim/main.go b/contrib/runsim/main.go index b54be8ba75a6..ba96c5cae006 100644 --- a/contrib/runsim/main.go +++ b/contrib/runsim/main.go @@ -26,7 +26,7 @@ var ( 989182, 89182391, 11, 22, 44, 77, 99, 2020, 3232, 123123, 124124, 582582, 18931893, 29892989, 30123012, 47284728, 7601778, 8090485, - 977367484, 491163361, 424254581, 673398983, + 977367484, 491163361, 424254581, 673398983, } // goroutine-safe process map diff --git a/docs/spec/auth/03_types.md b/docs/spec/auth/03_types.md index 41ade660cac2..4d37c55c8e61 100644 --- a/docs/spec/auth/03_types.md +++ b/docs/spec/auth/03_types.md @@ -20,9 +20,9 @@ type StdFee struct { ## StdSignature -`StdSignature` implements the `sdk.Signature` interface and consists of a combination of an -optional public key and a cryptographic signature as a byte slice. The SDK is agnostic to -particular key or signature formats and supports any supported by the `PubKey` interface. +A `StdSignature` is the combination of an optional public key and a cryptographic signature +as a byte array. The SDK is agnostic to particular key or signature formats and supports any +supported by the `PubKey` interface. ```golang type StdSignature struct { diff --git a/simapp/test_util.go b/simapp/test_util.go index 8337a1cc4c55..8b79e757a9b5 100644 --- a/simapp/test_util.go +++ b/simapp/test_util.go @@ -5,11 +5,10 @@ import ( "github.com/tendermint/tendermint/libs/log" - dbm "github.com/tendermint/tendermint/libs/db" - bam "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking" + dbm "github.com/tendermint/tendermint/libs/db" ) // NewSimAppUNSAFE is used for debugging purposes only. diff --git a/types/codec.go b/types/codec.go index 8606ef0ad3f5..3d789afe9f0a 100644 --- a/types/codec.go +++ b/types/codec.go @@ -6,5 +6,4 @@ import "github.com/cosmos/cosmos-sdk/codec" func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*Msg)(nil), nil) cdc.RegisterInterface((*Tx)(nil), nil) - cdc.RegisterInterface((*Signature)(nil), nil) } diff --git a/types/coin_test.go b/types/coin_test.go index 7643b221c42b..9d6177afeb78 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -4,10 +4,9 @@ import ( "strings" "testing" + "github.com/cosmos/cosmos-sdk/codec" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/codec" ) var ( diff --git a/types/tx_msg.go b/types/tx_msg.go index 15a9ea587e35..bc4c2540d911 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -2,8 +2,6 @@ package types import ( "encoding/json" - - "github.com/tendermint/tendermint/crypto" ) // Transactions messages must fulfill the Msg @@ -44,12 +42,6 @@ type Tx interface { //__________________________________________________________ -// Signature defines the properties of the signature payload. -type Signature interface { - GetPubKey() crypto.PubKey - GetSignature() []byte -} - // TxDecoder unmarshals transaction bytes type TxDecoder func(txBytes []byte) (Tx, Error) diff --git a/x/auth/alias.go b/x/auth/alias.go index 5b0308752c58..3c1fe15fde10 100644 --- a/x/auth/alias.go +++ b/x/auth/alias.go @@ -46,7 +46,6 @@ var ( NewStdTx = types.NewStdTx CountSubKeys = types.CountSubKeys NewStdFee = types.NewStdFee - NewStdSignature = types.NewStdSignature StdSignBytes = types.StdSignBytes DefaultTxDecoder = types.DefaultTxDecoder DefaultTxEncoder = types.DefaultTxEncoder diff --git a/x/auth/ante.go b/x/auth/ante.go index 04a9f0b994a8..28a16821e9ac 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -136,8 +136,7 @@ func NewAnteHandler(ak AccountKeeper, fck FeeCollectionKeeper, sigGasConsumer Si // check signature, return account with incremented nonce signBytes := GetSignBytes(newCtx.ChainID(), stdTx, signerAccs[i], isGenesis) - signerAccs[i], res = processSig(newCtx, signerAccs[i], stdSigs[i], signBytes, - simulate, params, sigGasConsumer) + signerAccs[i], res = processSig(newCtx, signerAccs[i], stdSigs[i], signBytes, simulate, params, sigGasConsumer) if !res.IsOK() { return newCtx, res, true } @@ -166,7 +165,7 @@ func ValidateSigCount(stdTx StdTx, params Params) sdk.Result { sigCount := 0 for i := 0; i < len(stdSigs); i++ { - sigCount += CountSubKeys(stdSigs[i].GetPubKey()) + sigCount += CountSubKeys(stdSigs[i].PubKey) if uint64(sigCount) > params.TxSigLimit { return sdk.ErrTooManySignatures( fmt.Sprintf("signatures: %d, limit: %d", sigCount, params.TxSigLimit), @@ -195,7 +194,7 @@ func ValidateMemo(stdTx StdTx, params Params) sdk.Result { // verify the signature and increment the sequence. If the account doesn't have // a pubkey, set it. func processSig( - ctx sdk.Context, acc Account, sig sdk.Signature, signBytes []byte, simulate bool, params Params, + ctx sdk.Context, acc Account, sig StdSignature, signBytes []byte, simulate bool, params Params, sigGasConsumer SignatureVerificationGasConsumer, ) (updatedAcc Account, res sdk.Result) { @@ -217,11 +216,11 @@ func processSig( consumeSimSigGas(ctx.GasMeter(), pubKey, sig, params) } - if res := sigGasConsumer(ctx.GasMeter(), sig.GetSignature(), pubKey, params); !res.IsOK() { + if res := sigGasConsumer(ctx.GasMeter(), sig.Signature, pubKey, params); !res.IsOK() { return nil, res } - if !simulate && !pubKey.VerifyBytes(signBytes, sig.GetSignature()) { + if !simulate && !pubKey.VerifyBytes(signBytes, sig.Signature) { return nil, sdk.ErrUnauthorized("signature verification failed; verify correct account sequence and chain-id").Result() } @@ -232,9 +231,9 @@ func processSig( return acc, res } -func consumeSimSigGas(gasmeter sdk.GasMeter, pubkey crypto.PubKey, sig sdk.Signature, params Params) { - simSig := NewStdSignature(pubkey, nil) - if len(sig.GetSignature()) == 0 { +func consumeSimSigGas(gasmeter sdk.GasMeter, pubkey crypto.PubKey, sig StdSignature, params Params) { + simSig := StdSignature{PubKey: pubkey} + if len(sig.Signature) == 0 { simSig.Signature = simSecp256k1Sig[:] } @@ -253,7 +252,7 @@ func consumeSimSigGas(gasmeter sdk.GasMeter, pubkey crypto.PubKey, sig sdk.Signa // ProcessPubKey verifies that the given account address matches that of the // StdSignature. In addition, it will set the public key of the account if it // has not been set. -func ProcessPubKey(acc Account, sig sdk.Signature, simulate bool) (crypto.PubKey, sdk.Result) { +func ProcessPubKey(acc Account, sig StdSignature, simulate bool) (crypto.PubKey, sdk.Result) { // If pubkey is not known for account, set it from the StdSignature. pubKey := acc.GetPubKey() if simulate { @@ -269,7 +268,7 @@ func ProcessPubKey(acc Account, sig sdk.Signature, simulate bool) (crypto.PubKey } if pubKey == nil { - pubKey = sig.GetPubKey() + pubKey = sig.PubKey if pubKey == nil { return nil, sdk.ErrInvalidPubKey("PubKey not found").Result() } diff --git a/x/auth/ante_test.go b/x/auth/ante_test.go index 3fe0d4f06cb5..f0c3125144ff 100644 --- a/x/auth/ante_test.go +++ b/x/auth/ante_test.go @@ -515,8 +515,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) { msgs = []sdk.Msg{msg} tx = NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) sigs := tx.(types.StdTx).GetSignatures() - sig := sigs[0].(StdSignature) - sig.PubKey = nil + sigs[0].PubKey = nil checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey) acc2 = input.ak.GetAccount(ctx, addr2) @@ -552,11 +551,11 @@ func TestProcessPubKey(t *testing.T) { args args wantErr bool }{ - {"no sigs, simulate off", args{acc1, NewStdSignature(nil, nil), false}, true}, - {"no sigs, simulate on", args{acc1, NewStdSignature(nil, nil), true}, false}, - {"no sigs, account with pub, simulate on", args{acc2, NewStdSignature(nil, nil), true}, false}, - {"pubkey doesn't match addr, simulate off", args{acc1, NewStdSignature(priv2.PubKey(), nil), false}, true}, - {"pubkey doesn't match addr, simulate on", args{acc1, NewStdSignature(priv2.PubKey(), nil), true}, false}, + {"no sigs, simulate off", args{acc1, StdSignature{}, false}, true}, + {"no sigs, simulate on", args{acc1, StdSignature{}, true}, false}, + {"no sigs, account with pub, simulate on", args{acc2, StdSignature{}, true}, false}, + {"pubkey doesn't match addr, simulate off", args{acc1, StdSignature{PubKey: priv2.PubKey()}, false}, true}, + {"pubkey doesn't match addr, simulate on", args{acc1, StdSignature{PubKey: priv2.PubKey()}, true}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index 6505811d5278..c1a88a6a0b03 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -18,7 +18,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/codec" crkeys "github.com/cosmos/cosmos-sdk/crypto/keys" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -120,8 +119,7 @@ func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) } newStdSig := types.StdSignature{Signature: cdc.MustMarshalBinaryBare(multisigSig), PubKey: multisigPub} - newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []sdk.Signature{newStdSig}, - stdTx.GetMemo()) + newTx := types.NewStdTx(stdTx.GetMsgs(), stdTx.Fee, []types.StdSignature{newStdSig}, stdTx.GetMemo()) sigOnly := viper.GetBool(flagSigOnly) var json []byte diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index f3c701e49600..f7be335010e4 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -206,7 +206,7 @@ func printAndValidateSigs( } for i, sig := range sigs { - sigAddr := sdk.AccAddress(sig.GetPubKey().Address()) + sigAddr := sdk.AccAddress(sig.Address()) sigSanity := "OK" var ( @@ -233,16 +233,16 @@ func printAndValidateSigs( stdTx.Fee, stdTx.GetMsgs(), stdTx.GetMemo(), ) - if ok := sig.GetPubKey().VerifyBytes(sigBytes, sig.GetSignature()); !ok { + if ok := sig.VerifyBytes(sigBytes, sig.Signature); !ok { sigSanity = "ERROR: signature invalid" success = false } } - multiPK, ok := sig.GetPubKey().(multisig.PubKeyMultisigThreshold) + multiPK, ok := sig.PubKey.(multisig.PubKeyMultisigThreshold) if ok { var multiSig multisig.Multisignature - cliCtx.Codec.MustUnmarshalBinaryBare(sig.GetSignature(), &multiSig) + cliCtx.Codec.MustUnmarshalBinaryBare(sig.Signature, &multiSig) var b strings.Builder b.WriteString("\n MultiSig Signatures:\n") diff --git a/x/auth/genaccounts/genesis_state_test.go b/x/auth/genaccounts/genesis_state_test.go index bca4fbcc3800..4977fab37cfe 100644 --- a/x/auth/genaccounts/genesis_state_test.go +++ b/x/auth/genaccounts/genesis_state_test.go @@ -3,11 +3,10 @@ package genaccounts import ( "testing" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" ) func TestSanitize(t *testing.T) { diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index de917de6e99b..296c2b148356 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -13,7 +13,6 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(&ContinuousVestingAccount{}, "auth/ContinuousVestingAccount", nil) cdc.RegisterConcrete(&DelayedVestingAccount{}, "auth/DelayedVestingAccount", nil) cdc.RegisterConcrete(StdTx{}, "auth/StdTx", nil) - cdc.RegisterConcrete(StdSignature{}, "auth/StdSignature", nil) } // RegisterBaseAccount most users shouldn't use this, but this comes in handy for tests. diff --git a/x/auth/types/stdtx.go b/x/auth/types/stdtx.go index b577522202a9..18cdfaf0a0f2 100644 --- a/x/auth/types/stdtx.go +++ b/x/auth/types/stdtx.go @@ -12,8 +12,7 @@ import ( ) var ( - _ sdk.Tx = (*StdTx)(nil) - _ sdk.Signature = (*StdSignature)(nil) + _ sdk.Tx = (*StdTx)(nil) maxGasWanted = uint64((1 << 63) - 1) ) @@ -21,13 +20,13 @@ var ( // StdTx is a standard way to wrap a Msg with Fee and Signatures. // NOTE: the first signature is the fee payer (Signatures must not be nil). type StdTx struct { - Msgs []sdk.Msg `json:"msg"` - Fee StdFee `json:"fee"` - Signatures []sdk.Signature `json:"signatures"` - Memo string `json:"memo"` + Msgs []sdk.Msg `json:"msg"` + Fee StdFee `json:"fee"` + Signatures []StdSignature `json:"signatures"` + Memo string `json:"memo"` } -func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []sdk.Signature, memo string) StdTx { +func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { return StdTx{ Msgs: msgs, Fee: fee, @@ -105,7 +104,7 @@ func (tx StdTx) GetMemo() string { return tx.Memo } // CONTRACT: If the signature is missing (ie the Msg is // invalid), then the corresponding signature is // .Empty(). -func (tx StdTx) GetSignatures() []sdk.Signature { return tx.Signatures } +func (tx StdTx) GetSignatures() []StdSignature { return tx.Signatures } //__________________________________________________________ @@ -192,17 +191,6 @@ type StdSignature struct { Signature []byte `json:"signature"` } -// NewStdSignature constructs a new StdSignature instance. -func NewStdSignature(pubKey crypto.PubKey, signature []byte) StdSignature { - return StdSignature{PubKey: pubKey, Signature: signature} -} - -// GetPubKey returns the embedded crypto.PubKey type. -func (sig StdSignature) GetPubKey() crypto.PubKey { return sig.PubKey } - -// GetSignature returns the embedded byte signature. -func (sig StdSignature) GetSignature() []byte { return sig.Signature } - // DefaultTxDecoder logic for standard transaction decoding func DefaultTxDecoder(cdc *codec.Codec) sdk.TxDecoder { return func(txBytes []byte) (sdk.Tx, sdk.Error) { diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index 270788215995..d6315d5fb9f7 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -1,12 +1,10 @@ package types import ( - "bytes" "fmt" "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" @@ -24,7 +22,7 @@ var ( func TestStdTx(t *testing.T) { msgs := []sdk.Msg{sdk.NewTestMsg(addr)} fee := NewTestStdFee() - sigs := []sdk.Signature{} + sigs := []StdSignature{} tx := NewStdTx(msgs, fee, sigs, "") require.Equal(t, msgs, tx.GetMsgs()) @@ -123,7 +121,7 @@ func TestDefaultTxEncoder(t *testing.T) { msgs := []sdk.Msg{sdk.NewTestMsg(addr)} fee := NewTestStdFee() - sigs := []sdk.Signature{} + sigs := []StdSignature{} tx := NewStdTx(msgs, fee, sigs, "") @@ -135,11 +133,3 @@ func TestDefaultTxEncoder(t *testing.T) { require.NoError(t, err) require.Equal(t, cdcBytes, encoderBytes) } - -func TestNewStdSignature(t *testing.T) { - pub := ed25519.GenPrivKey().PubKey() - sigBytes := []byte("data") - got := NewStdSignature(pub, sigBytes) - require.True(t, bytes.Equal(got.GetSignature(), sigBytes)) - require.True(t, got.GetPubKey().Equals(pub)) -} diff --git a/x/auth/types/test_common.go b/x/auth/types/test_common.go index 8b12d3055071..c6f4d26b1d62 100644 --- a/x/auth/types/test_common.go +++ b/x/auth/types/test_common.go @@ -70,7 +70,7 @@ func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { } func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee) sdk.Tx { - sigs := make([]sdk.Signature, len(privs)) + sigs := make([]StdSignature, len(privs)) for i, priv := range privs { signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "") @@ -79,7 +79,7 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums panic(err) } - sigs[i] = NewStdSignature(priv.PubKey(), sig) + sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } tx := NewStdTx(msgs, fee, sigs, "") @@ -87,7 +87,7 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums } func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, memo string) sdk.Tx { - sigs := make([]sdk.Signature, len(privs)) + sigs := make([]StdSignature, len(privs)) for i, priv := range privs { signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, memo) @@ -96,7 +96,7 @@ func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, panic(err) } - sigs[i] = NewStdSignature(priv.PubKey(), sig) + sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } tx := NewStdTx(msgs, fee, sigs, memo) @@ -104,14 +104,14 @@ func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, } func NewTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, signBytes []byte, memo string) sdk.Tx { - sigs := make([]sdk.Signature, len(privs)) + sigs := make([]StdSignature, len(privs)) for i, priv := range privs { sig, err := priv.Sign(signBytes) if err != nil { panic(err) } - sigs[i] = NewStdSignature(priv.PubKey(), sig) + sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } tx := NewStdTx(msgs, fee, sigs, memo) diff --git a/x/auth/types/txbuilder.go b/x/auth/types/txbuilder.go index c9375c4318ab..b29d977fd468 100644 --- a/x/auth/types/txbuilder.go +++ b/x/auth/types/txbuilder.go @@ -214,7 +214,7 @@ func (bldr TxBuilder) Sign(name, passphrase string, msg StdSignMsg) ([]byte, err return nil, err } - return bldr.txEncoder(NewStdTx(msg.Msgs, msg.Fee, []sdk.Signature{sig}, msg.Memo)) + return bldr.txEncoder(NewStdTx(msg.Msgs, msg.Fee, []StdSignature{sig}, msg.Memo)) } // BuildAndSign builds a single message to be signed, and signs a transaction @@ -237,7 +237,7 @@ func (bldr TxBuilder) BuildTxForSim(msgs []sdk.Msg) ([]byte, error) { } // the ante handler will populate with a sentinel pubkey - sigs := []sdk.Signature{NewStdSignature(nil, nil)} + sigs := []StdSignature{{}} return bldr.txEncoder(NewStdTx(signMsg.Msgs, signMsg.Fee, sigs, signMsg.Memo)) } @@ -262,7 +262,7 @@ func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig sigs := stdTx.GetSignatures() if len(sigs) == 0 || !appendSig { - sigs = []sdk.Signature{stdSignature} + sigs = []StdSignature{stdSignature} } else { sigs = append(sigs, stdSignature) } @@ -271,8 +271,8 @@ func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig } // MakeSignature builds a StdSignature given keybase, key name, passphrase, and a StdSignMsg. -func MakeSignature(keybase crkeys.Keybase, name, - passphrase string, msg StdSignMsg) (sig sdk.Signature, err error) { +func MakeSignature(keybase crkeys.Keybase, name, passphrase string, + msg StdSignMsg) (sig StdSignature, err error) { if keybase == nil { keybase, err = keys.NewKeyBaseFromHomeFlag() if err != nil { @@ -284,6 +284,8 @@ func MakeSignature(keybase crkeys.Keybase, name, if err != nil { return } - - return NewStdSignature(pubkey, sigBytes), nil + return StdSignature{ + PubKey: pubkey, + Signature: sigBytes, + }, nil } diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 9551e2bc94bd..8d26753dcde1 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -5,10 +5,9 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/stretchr/testify/require" ) var ( diff --git a/x/genutil/genesis_state_test.go b/x/genutil/genesis_state_test.go index 78175f214c76..c835de44c0f2 100644 --- a/x/genutil/genesis_state_test.go +++ b/x/genutil/genesis_state_test.go @@ -3,12 +3,11 @@ package genutil import ( "testing" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" ) var ( diff --git a/x/gov/types/keys_test.go b/x/gov/types/keys_test.go index 80d77c66043a..93434d457de3 100644 --- a/x/gov/types/keys_test.go +++ b/x/gov/types/keys_test.go @@ -4,10 +4,9 @@ import ( "testing" "time" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" - - sdk "github.com/cosmos/cosmos-sdk/types" ) var addr = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) diff --git a/x/mock/app.go b/x/mock/app.go index 3f36c3f2a9f8..75deed6a5caf 100644 --- a/x/mock/app.go +++ b/x/mock/app.go @@ -217,7 +217,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe Gas: 100000, } - sigs := make([]sdk.Signature, len(priv)) + sigs := make([]auth.StdSignature, len(priv)) memo := "testmemotestmemo" for i, p := range priv { @@ -226,7 +226,10 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe panic(err) } - sigs[i] = auth.NewStdSignature(p.PubKey(), sig) + sigs[i] = auth.StdSignature{ + PubKey: p.PubKey(), + Signature: sig, + } } return auth.NewStdTx(msgs, fee, sigs, memo) diff --git a/x/mock/app_test.go b/x/mock/app_test.go index 91d9e3406051..7a2b6adfd41e 100644 --- a/x/mock/app_test.go +++ b/x/mock/app_test.go @@ -24,13 +24,13 @@ type testMsg struct { positiveNum int64 } -func (tx testMsg) Route() string { return msgRoute } -func (tx testMsg) Type() string { return "test" } -func (tx testMsg) GetMsg() sdk.Msg { return tx } -func (tx testMsg) GetMemo() string { return "" } -func (tx testMsg) GetSignBytes() []byte { return nil } -func (tx testMsg) GetSigners() []sdk.AccAddress { return tx.signers } -func (tx testMsg) GetSignatures() []sdk.Signature { return nil } +func (tx testMsg) Route() string { return msgRoute } +func (tx testMsg) Type() string { return "test" } +func (tx testMsg) GetMsg() sdk.Msg { return tx } +func (tx testMsg) GetMemo() string { return "" } +func (tx testMsg) GetSignBytes() []byte { return nil } +func (tx testMsg) GetSigners() []sdk.AccAddress { return tx.signers } +func (tx testMsg) GetSignatures() []auth.StdSignature { return nil } func (tx testMsg) ValidateBasic() sdk.Error { if tx.positiveNum >= 0 { return nil diff --git a/x/staking/exported/exported.go b/x/staking/exported/exported.go index 121bf20a0895..496fda5a5618 100644 --- a/x/staking/exported/exported.go +++ b/x/staking/exported/exported.go @@ -1,9 +1,8 @@ package exported import ( - "github.com/tendermint/tendermint/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto" ) // DelegationI delegation bond for a delegated proof of stake system