Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Don't break SignModeHandler API #14087

Merged
merged 10 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (signing) [#14087](https://github.com/cosmos/cosmos-sdk/pull/14087) Add SignModeHandlerWithContext interface with a new `GetSignBytesWithContext` to get the sign bytes using `context.Context` as an argument to access state.
* (server) [#14062](https://github.com/cosmos/cosmos-sdk/pull/14062) Remove rosetta from server start.
* [13882] (https://github.com/cosmos/cosmos-sdk/pull/13882) Add tx `encode` and `decode` endpoints to amino tx service.
> Note: These endpoints encodes and decodes only amino txs.
Expand Down Expand Up @@ -179,7 +180,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#13794](https://github.com/cosmos/cosmos-sdk/pull/13794) Most methods on `types/module.AppModule` have been moved to
extension interfaces. `module.Manager.Modules` is now of type `map[string]interface{}` to support in parallel the new
`cosmossdk.io/core/appmodule.AppModule` API.
* (signing) [#13701](https://github.com/cosmos/cosmos-sdk/pull/) Add `context.Context` as an argument to SignModeHandler's `GetSignBytes` method and `x/auth/signing.VerifySignature`. You can pass `nil` for now, it will only be used once SIGN_MODE_TEXTUAL is live.
* (signing) [#13701](https://github.com/cosmos/cosmos-sdk/pull/) Add `context.Context` as an argument `x/auth/signing.VerifySignature`.
* (x/group) [#13876](https://github.com/cosmos/cosmos-sdk/pull/13876) Add `GetMinExecutionPeriod` method on DecisionPolicy interface.
* (x/auth)[#13780](https://github.com/cosmos/cosmos-sdk/pull/13780) Querying with `id` (type of int64) in `AccountAddressByID` grpc query now throws error, use account-id(type of uint64) instead.
* (snapshots) [14048](https://github.com/cosmos/cosmos-sdk/pull/14048) Move the Snapshot package to the store package. This is done in an effort group all storage related logic under one package.
Expand Down
4 changes: 2 additions & 2 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func SignWithPrivKey(
var sigV2 signing.SignatureV2

// Generate the bytes to be signed.
signBytes, err := txConfig.SignModeHandler().GetSignBytes(ctx, signMode, signerData, txBuilder.GetTx())
signBytes, err := authsigning.GetSignBytesWithContext(txConfig.SignModeHandler(), ctx, signMode, signerData, txBuilder.GetTx())
if err != nil {
return sigV2, err
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func Sign(ctx context.Context, txf Factory, name string, txBuilder client.TxBuil
}

// Generate the bytes to be signed.
bytesToSign, err := txf.txConfig.SignModeHandler().GetSignBytes(ctx, signMode, signerData, txBuilder.GetTx())
bytesToSign, err := authsigning.GetSignBytesWithContext(txf.txConfig.SignModeHandler(), ctx, signMode, signerData, txBuilder.GetTx())
if err != nil {
return err
}
Expand Down
3 changes: 0 additions & 3 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ require (
)

replace (
// Temporary until we tag a new version
cosmossdk.io/tools/rosetta => ../tools/rosetta

github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// Update to rosetta-sdk-go temporarly to have `check:spec` passing. See https://github.com/coinbase/rosetta-sdk-go/issues/449
github.com/coinbase/rosetta-sdk-go => github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a
Expand Down
2 changes: 2 additions & 0 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
cosmossdk.io/math v1.0.0-beta.4 h1:JtKedVLGzA0vv84xjYmZ75RKG35Kf2WwcFu8IjRkIIw=
cosmossdk.io/math v1.0.0-beta.4/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM=
cosmossdk.io/tools/rosetta v0.1.0 h1:rJ0sp9bTuGzava+C2b0MFaci/zhINdxSOiJE1FC/UJw=
cosmossdk.io/tools/rosetta v0.1.0/go.mod h1:9wDBVqKC7BDJjk+RWvoE4VXs3Ub/i5rLBrieKpoH+Zw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
Expand Down
6 changes: 3 additions & 3 deletions testutil/sims/tx_helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sims

import (
"context"
"math/rand"
"testing"
"time"
Expand Down Expand Up @@ -62,8 +61,9 @@ func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, fee
Sequence: accSeqs[i],
PubKey: p.PubKey(),
}
// When Textual is wired up, the context argument should be retrieved from the client context.
signBytes, err := txConfig.SignModeHandler().GetSignBytes(context.TODO(), signMode, signerData, tx.GetTx())
// When Textual is wired up, use GetSignBytesWithContext
// ref: https://github.com/cosmos/cosmos-sdk/issues/13747
signBytes, err := txConfig.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions tools/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rosetta

import (
"bytes"
"context"
"encoding/json"
"fmt"
"reflect"
Expand Down Expand Up @@ -115,7 +114,7 @@ func NewConverter(cdc *codec.ProtoCodec, ir codectypes.InterfaceRegistry, cfg sd
txDecode: cfg.TxDecoder(),
txEncode: cfg.TxEncoder(),
bytesToSign: func(tx authsigning.Tx, signerData authsigning.SignerData) (b []byte, err error) {
bytesToSign, err := cfg.SignModeHandler().GetSignBytes(context.TODO(), signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx)
bytesToSign, err := cfg.SignModeHandler().GetSignBytes(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func genTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins,
AccountNumber: accNums[i],
Sequence: accSeqs[i],
}
signBytes, err := gen.SignModeHandler().GetSignBytes(nil, signMode, signerData, tx.GetTx())
signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions x/auth/migrations/legacytx/amino_signing.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package legacytx

import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -33,7 +32,7 @@ func (stdTxSignModeHandler) Modes() []signingtypes.SignMode {
}

// DefaultMode implements SignModeHandler.GetSignBytes
func (stdTxSignModeHandler) GetSignBytes(_ context.Context, mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx) ([]byte, error) {
func (stdTxSignModeHandler) GetSignBytes(mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx) ([]byte, error) {
if mode != signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON {
return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, mode)
}
Expand Down
4 changes: 2 additions & 2 deletions x/auth/migrations/legacytx/amino_signing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {
Sequence: seqNum,
PubKey: priv1.PubKey(),
}
signBz, err := handler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.NoError(t, err)

expectedSignBz := StdSignBytes(chainId, accNum, seqNum, timeoutHeight, fee, msgs, memo, nil)

require.Equal(t, expectedSignBz, signBz)

// expect error with wrong sign mode
_, err = handler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, tx)
_, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, tx)
require.Error(t, err)
}

Expand Down
23 changes: 20 additions & 3 deletions x/auth/signing/handler_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,28 @@ func (h SignModeHandlerMap) Modes() []signing.SignMode {
return h.modes
}

// DefaultMode implements SignModeHandler.GetSignBytes
func (h SignModeHandlerMap) GetSignBytes(ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) {
// GetSignBytes implements SignModeHandler.GetSignBytes
func (h SignModeHandlerMap) GetSignBytes(mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) {
handler, found := h.signModeHandlers[mode]
if !found {
return nil, fmt.Errorf("can't verify sign mode %s", mode.String())
}
return handler.GetSignBytes(ctx, mode, data, tx)
return handler.GetSignBytes(mode, data, tx)
}

// GetSignBytesWithContext implements SignModeHandler.GetSignBytesWithContext
func (h SignModeHandlerMap) GetSignBytesWithContext(ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) {
handler, found := h.signModeHandlers[mode]
if !found {
return nil, fmt.Errorf("can't verify sign mode %s", mode.String())
}

handlerWithContext, ok := handler.(SignModeHandlerWithContext)
if ok {
return handlerWithContext.GetSignBytesWithContext(ctx, mode, data, tx)
}

// Default to stateless GetSignBytes if the underlying handler does not
// implement WithContext.
return handler.GetSignBytes(mode, data, tx)
}
6 changes: 3 additions & 3 deletions x/auth/signing/handler_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ func TestHandlerMap_GetSignBytes(t *testing.T) {
Sequence: seqNum,
PubKey: priv1.PubKey(),
}
signBz, err := handler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.NoError(t, err)

expectedSignBz, err := aminoJSONHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
expectedSignBz, err := aminoJSONHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.NoError(t, err)

require.Equal(t, expectedSignBz, signBz)

// expect error with wrong sign mode
_, err = aminoJSONHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, tx)
_, err = aminoJSONHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, tx)
require.Error(t, err)
}

Expand Down
16 changes: 15 additions & 1 deletion x/auth/signing/sign_mode_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ type SignModeHandler interface {

// GetSignBytes returns the sign bytes for the provided SignMode, SignerData and Tx,
// or an error
GetSignBytes(ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)
GetSignBytes(mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)
}

// SignModeHandlerWithContext is like SignModeHandler, with a new GetSignBytes
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
// method which takes an additional context.Context argument, to be used to
// access state. Consumers should preferably type-cast to this interface and
// pass in the context.Context arg, and default to SignModeHandler otherwise.
// This interface is created for backwards compatibility, and will be
// deleted once SDK versions <v0.47 are not supported anymore.
type SignModeHandlerWithContext interface {
SignModeHandler

// GetSignBytes returns the sign bytes for the provided SignMode, SignerData and Tx,
// or an error
GetSignBytesWithContext(ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error)
}

// SignerData is the specific information needed to sign a transaction that generally
Expand Down
22 changes: 20 additions & 2 deletions x/auth/signing/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData SignerData, sigData signing.SignatureData, handler SignModeHandler, tx sdk.Tx) error {
switch data := sigData.(type) {
case *signing.SingleSignatureData:
signBytes, err := handler.GetSignBytes(ctx, data.SignMode, signerData, tx)
signBytes, err := GetSignBytesWithContext(handler, ctx, data.SignMode, signerData, tx)
if err != nil {
return err
}
Expand All @@ -30,7 +30,12 @@ func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData
return fmt.Errorf("expected %T, got %T", (multisig.PubKey)(nil), pubKey)
}
err := multiPK.VerifyMultisignature(func(mode signing.SignMode) ([]byte, error) {
return handler.GetSignBytes(ctx, mode, signerData, tx)
handlerWithContext, ok := handler.(SignModeHandlerWithContext)
if ok {
return handlerWithContext.GetSignBytesWithContext(ctx, mode, signerData, tx)
} else {
return handler.GetSignBytes(mode, signerData, tx)
}
}, data)
if err != nil {
return err
Expand All @@ -40,3 +45,16 @@ func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData
return fmt.Errorf("unexpected SignatureData %T", sigData)
}
}

// GetSignBytesWithContext gets the sign bytes from the sign mode handler. It
// checks if the sign mode handler supports SignModeHandlerWithContext, in
// which case it passes the context.Context argument. Otherwise, it fallbacks
// to GetSignBytes.
func GetSignBytesWithContext(h SignModeHandler, ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) {
hWithCtx, ok := h.(SignModeHandlerWithContext)
if ok {
return hWithCtx.GetSignBytesWithContext(ctx, mode, data, tx)
} else {
return h.GetSignBytes(mode, data, tx)
}
}
2 changes: 1 addition & 1 deletion x/auth/tx/aux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestBuilderWithAux(t *testing.T) {
Sequence: 15,
})
signBz, err = txConfig.SignModeHandler().GetSignBytes(
nil, signing.SignMode_SIGN_MODE_DIRECT,
signing.SignMode_SIGN_MODE_DIRECT,
authsigning.SignerData{
Address: feepayerAddr.String(),
ChainID: chainID,
Expand Down
3 changes: 1 addition & 2 deletions x/auth/tx/direct.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tx

import (
"context"
"fmt"

signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
Expand All @@ -27,7 +26,7 @@ func (signModeDirectHandler) Modes() []signingtypes.SignMode {
}

// GetSignBytes implements SignModeHandler.GetSignBytes
func (signModeDirectHandler) GetSignBytes(_ context.Context, mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx) ([]byte, error) {
func (signModeDirectHandler) GetSignBytes(mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx) ([]byte, error) {
if mode != signingtypes.SignMode_SIGN_MODE_DIRECT {
return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_DIRECT, mode)
}
Expand Down
3 changes: 1 addition & 2 deletions x/auth/tx/direct_aux.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tx

import (
"context"
"fmt"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -29,7 +28,7 @@ func (signModeDirectAuxHandler) Modes() []signingtypes.SignMode {

// GetSignBytes implements SignModeHandler.GetSignBytes
func (signModeDirectAuxHandler) GetSignBytes(
_ context.Context, mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx,
mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx,
) ([]byte, error) {
if mode != signingtypes.SignMode_SIGN_MODE_DIRECT_AUX {
return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, mode)
Expand Down
10 changes: 5 additions & 5 deletions x/auth/tx/direct_aux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ func TestDirectAuxHandler(t *testing.T) {
modeHandler := signModeDirectAuxHandler{}

t.Log("verify fee payer cannot use SIGN_MODE_DIRECT_AUX")
_, err = modeHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, feePayerSigningData, txBuilder.GetTx())
_, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, feePayerSigningData, txBuilder.GetTx())
require.EqualError(t, err, fmt.Sprintf("fee payer %s cannot sign with %s: unauthorized", feePayerAddr.String(), signingtypes.SignMode_SIGN_MODE_DIRECT_AUX))

t.Log("verify GetSignBytes with generating sign bytes by marshaling signDocDirectAux")
signBytes, err := modeHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx())
signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx())
require.NoError(t, err)
require.NotNil(t, signBytes)

Expand Down Expand Up @@ -121,7 +121,7 @@ func TestDirectAuxHandler(t *testing.T) {
require.NoError(t, err)
err = txBuilder.SetSignatures(sig)
require.NoError(t, err)
signBytes, err = modeHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx())
signBytes, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx())
require.NoError(t, err)
require.Equal(t, expectedSignBytes, signBytes)

Expand All @@ -148,7 +148,7 @@ func TestDirectAuxModeHandler_nonDIRECT_MODE(t *testing.T) {
t.Run(invalidMode.String(), func(t *testing.T) {
var dh signModeDirectAuxHandler
var signingData signing.SignerData
_, err := dh.GetSignBytes(nil, invalidMode, signingData, nil)
_, err := dh.GetSignBytes(invalidMode, signingData, nil)
require.Error(t, err)
wantErr := fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, invalidMode)
require.Equal(t, err, wantErr)
Expand All @@ -160,7 +160,7 @@ func TestDirectAuxModeHandler_nonProtoTx(t *testing.T) {
var dh signModeDirectAuxHandler
var signingData signing.SignerData
tx := new(nonProtoTx)
_, err := dh.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, tx)
_, err := dh.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, tx)
require.Error(t, err)
wantErr := fmt.Errorf("can only handle a protobuf Tx, got %T", tx)
require.Equal(t, err, wantErr)
Expand Down
8 changes: 4 additions & 4 deletions x/auth/tx/direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestDirectModeHandler(t *testing.T) {
PubKey: pubkey,
}

signBytes, err := modeHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx())
signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx())

require.NoError(t, err)
require.NotNil(t, signBytes)
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestDirectModeHandler(t *testing.T) {
require.NoError(t, err)
err = txBuilder.SetSignatures(sig)
require.NoError(t, err)
signBytes, err = modeHandler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx())
signBytes, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx())
require.NoError(t, err)
require.Equal(t, expectedSignBytes, signBytes)

Expand All @@ -141,7 +141,7 @@ func TestDirectModeHandler_nonDIRECT_MODE(t *testing.T) {
t.Run(invalidMode.String(), func(t *testing.T) {
var dh signModeDirectHandler
var signingData signing.SignerData
_, err := dh.GetSignBytes(nil, invalidMode, signingData, nil)
_, err := dh.GetSignBytes(invalidMode, signingData, nil)
require.Error(t, err)
wantErr := fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_DIRECT, invalidMode)
require.Equal(t, err, wantErr)
Expand All @@ -160,7 +160,7 @@ func TestDirectModeHandler_nonProtoTx(t *testing.T) {
var dh signModeDirectHandler
var signingData signing.SignerData
tx := new(nonProtoTx)
_, err := dh.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, tx)
_, err := dh.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, tx)
require.Error(t, err)
wantErr := fmt.Errorf("can only handle a protobuf Tx, got %T", tx)
require.Equal(t, err, wantErr)
Expand Down
2 changes: 1 addition & 1 deletion x/auth/tx/encode_decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestUnknownFields(t *testing.T) {
decoder := DefaultTxDecoder(codec.NewProtoCodec(codectypes.NewInterfaceRegistry()))
theTx, err := decoder(txBz)
require.NoError(t, err)
_, err = handler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signing.SignerData{}, theTx)
_, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signing.SignerData{}, theTx)
require.EqualError(t, err, tt.shouldAminoErr)
}
})
Expand Down
3 changes: 1 addition & 2 deletions x/auth/tx/legacy_amino_json.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tx

import (
"context"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -27,7 +26,7 @@ func (s signModeLegacyAminoJSONHandler) Modes() []signingtypes.SignMode {
return []signingtypes.SignMode{signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON}
}

func (s signModeLegacyAminoJSONHandler) GetSignBytes(_ context.Context, mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx) ([]byte, error) {
func (s signModeLegacyAminoJSONHandler) GetSignBytes(mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx) ([]byte, error) {
if mode != signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON {
return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, mode)
}
Expand Down
Loading