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 1 commit
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
Next Next commit
refactor: Make SignModeHandler update not API breaking
  • Loading branch information
amaury1093 committed Nov 30, 2022
commit 38329a61a07e323b1c8b986472e3b5903efdfb51
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) [#TODO](https://github.com/cosmos/cosmos-sdk/pull/) Add a new SignModeHandlerWithContext interface with a new GetSignBytesWithContext to get the sign bytes using `context.Context` as an argument to access state.
* [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.
* (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration.
Expand Down Expand Up @@ -177,7 +178,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
19 changes: 17 additions & 2 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,16 @@ func SignWithPrivKey(
var sigV2 signing.SignatureV2

// Generate the bytes to be signed.
signBytes, err := txConfig.SignModeHandler().GetSignBytes(ctx, signMode, signerData, txBuilder.GetTx())
var (
signBytes []byte
err error
)
h, ok := txConfig.SignModeHandler().(authsigning.SignModeHandlerWithContext)
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
if ok {
signBytes, err = h.GetSignBytesWithContext(ctx, signMode, signerData, txBuilder.GetTx())
} else {
signBytes, err = txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx())
}
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return sigV2, err
}
Expand Down Expand Up @@ -300,7 +309,13 @@ 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())
var bytesToSign []byte
h, ok := txf.txConfig.SignModeHandler().(authsigning.SignModeHandlerWithContext)
if ok {
bytesToSign, err = h.GetSignBytesWithContext(ctx, signMode, signerData, txBuilder.GetTx())
} else {
bytesToSign, err = txf.txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx())
}
if err != nil {
return err
}
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
10 changes: 9 additions & 1 deletion tools/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ 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)
var bytesToSign []byte
h, ok := cfg.SignModeHandler().(authsigning.SignModeHandlerWithContext)
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
if ok {
// Replace context.TODO() with a client side context
// https://github.com/cosmos/cosmos-sdk/issues/13747
bytesToSign, err = h.GetSignBytesWithContext(context.TODO(), signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx)
} else {
bytesToSign, err = cfg.SignModeHandler().GetSignBytes(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx)
}
if err != nil {
return nil, err
}
Expand Down
9 changes: 7 additions & 2 deletions tools/rosetta/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,10 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

// Update to rosetta-sdk-go temporarly to have `check:spec` passing. See https://github.com/coinbase/rosetta-sdk-go/issues/449
replace github.com/coinbase/rosetta-sdk-go => github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a
replace (
// temporary until we tag a new sdk version
github.com/cosmos/cosmos-sdk => ../..

// 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
)
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 handlerWithContext.GetSignBytes(mode, data, tx)
}
14 changes: 13 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,19 @@ 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.
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
19 changes: 17 additions & 2 deletions x/auth/signing/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ 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)
var (
signBytes []byte
err error
)
handlerWithContext, ok := handler.(SignModeHandlerWithContext)
if ok {
signBytes, err = handlerWithContext.GetSignBytesWithContext(ctx, data.SignMode, signerData, tx)
} else {
signBytes, err = handler.GetSignBytes(data.SignMode, signerData, tx)
}

if err != nil {
return err
}
Expand All @@ -30,7 +40,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 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
8 changes: 4 additions & 4 deletions x/auth/tx/legacy_amino_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {
AccountNumber: accNum,
Sequence: seqNum,
}
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)

require.Equal(t, tc.expectedSignBz, signBz)
Expand All @@ -116,7 +116,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {
}

// 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)

// expect error with extension options
Expand All @@ -126,15 +126,15 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {
require.NoError(t, err)
bldr.tx.Body.ExtensionOptions = []*cdctypes.Any{any}
tx = bldr.GetTx()
_, err = handler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
_, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.Error(t, err)

// expect error with non-critical extension options
bldr = newBuilder(nil)
buildTx(t, bldr)
bldr.tx.Body.NonCriticalExtensionOptions = []*cdctypes.Any{any}
tx = bldr.GetTx()
_, err = handler.GetSignBytes(nil, signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
_, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx)
require.Error(t, err)
}

Expand Down
Loading