From 61f849287a050918f2a286e137a42240fbe27b49 Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 3 Jul 2024 19:38:11 +0900 Subject: [PATCH 1/9] refactor: `CustomGetSigners` for `MsgSwapOrder` --- app/app.go | 2 ++ x/coinswap/types/msgs.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/app.go b/app/app.go index ce44812f..30eaf681 100644 --- a/app/app.go +++ b/app/app.go @@ -121,6 +121,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v8/testing" ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" + coinswapv1 "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" erc20v1 "github.com/Canto-Network/Canto/v7/api/canto/erc20/v1" evmv1 "github.com/evmos/ethermint/api/ethermint/evm/v1" ethante "github.com/evmos/ethermint/app/ante" @@ -314,6 +315,7 @@ func NewCanto( // evm/MsgEthereumTx, erc20/MsgConvertERC20 signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2) interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, diff --git a/x/coinswap/types/msgs.go b/x/coinswap/types/msgs.go index e064bb1c..560437b1 100644 --- a/x/coinswap/types/msgs.go +++ b/x/coinswap/types/msgs.go @@ -2,7 +2,9 @@ package types import ( sdkmath "cosmossdk.io/math" + coinswapv1 "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" sdk "github.com/cosmos/cosmos-sdk/types" + protov2 "google.golang.org/protobuf/proto" ) var ( @@ -72,3 +74,15 @@ func NewMsgRemoveLiquidity( Sender: sender, } } + +func GetSignersFromMsgSwapOrderV2(msg protov2.Message) ([][]byte, error) { + msgv2, ok := msg.(*coinswapv1.MsgSwapOrder) + if !ok { + return nil, nil + } + + signers := [][]byte{} + signers = append(signers, []byte(msgv2.Input.Address)) + + return signers, nil +} From 3508ec6a2f3b25827b4778fbf51bf753c1310880 Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 3 Jul 2024 19:51:19 +0900 Subject: [PATCH 2/9] refactor: `CustomGetSigners` for `MsgSwapOrder` --- app/signer_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/signer_test.go diff --git a/app/signer_test.go b/app/signer_test.go new file mode 100644 index 00000000..2378c43f --- /dev/null +++ b/app/signer_test.go @@ -0,0 +1,39 @@ +package app + +import ( + "testing" + + "cosmossdk.io/x/tx/signing" + coinswapapi "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" + coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" + "github.com/cosmos/cosmos-sdk/codec/address" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + protov2 "google.golang.org/protobuf/proto" +) + +func TestMsgSwapOrderSigners(t *testing.T) { + sw := coinswapapi.MsgSwapOrder{ + Input: &coinswapapi.Input{Address: "signer"}, + } + + signingOptions := signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + } + signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapapi.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2) + + ctx, err := signing.NewContext(signingOptions) + + require.NoError(t, err) + signers, err := ctx.GetSigners(&sw) + + require.NoError(t, err) + assert.Equal(t, 1, len(signers)) + assert.Equal(t, []byte("signer"), signers[0]) +} From 06bc4c5ae8c2390c094362d71efa0206083618da Mon Sep 17 00:00:00 2001 From: poorphd Date: Thu, 4 Jul 2024 18:08:31 +0900 Subject: [PATCH 3/9] refactor: CustomGetSigners for MsgSwapOrder --- app/app.go | 2 +- x/coinswap/types/msgs.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 30eaf681..ed262faf 100644 --- a/app/app.go +++ b/app/app.go @@ -312,7 +312,7 @@ func NewCanto( }, } - // evm/MsgEthereumTx, erc20/MsgConvertERC20 + // evm/MsgEthereumTx, erc20/MsgConvertERC20, coinswap/MsgSwapOrder signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2) diff --git a/x/coinswap/types/msgs.go b/x/coinswap/types/msgs.go index 560437b1..31bac5f1 100644 --- a/x/coinswap/types/msgs.go +++ b/x/coinswap/types/msgs.go @@ -1,6 +1,8 @@ package types import ( + "fmt" + sdkmath "cosmossdk.io/math" coinswapv1 "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" sdk "github.com/cosmos/cosmos-sdk/types" @@ -78,7 +80,7 @@ func NewMsgRemoveLiquidity( func GetSignersFromMsgSwapOrderV2(msg protov2.Message) ([][]byte, error) { msgv2, ok := msg.(*coinswapv1.MsgSwapOrder) if !ok { - return nil, nil + return nil, fmt.Errorf("invalid x/coinswap/MsgSwapOrder msg v2: %v", msg) } signers := [][]byte{} From e2bc3bca82c51a7bff64367654580aab33f56769 Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 10 Jul 2024 17:17:17 +0900 Subject: [PATCH 4/9] refactor: change the custom GetSigner to use `StringToBytes` instead of ``[]byte` --- app/app.go | 13 +++++++++---- x/coinswap/types/msgs.go | 11 +++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/app.go b/app/app.go index ed262faf..9efca37f 100644 --- a/app/app.go +++ b/app/app.go @@ -312,10 +312,7 @@ func NewCanto( }, } - // evm/MsgEthereumTx, erc20/MsgConvertERC20, coinswap/MsgSwapOrder - signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) - signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) - signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2) + DefineCustomGetSigners(options * signing.Options) interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, @@ -1000,6 +997,14 @@ func NewCanto( return app } +func DefineCustomGetSigners(options *signing.Options) { + // evm/MsgEthereumTx, erc20/MsgConvertERC20, coinswap/MsgSwapOrder + options.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) + options.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) + options.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2(options)) + +} + // use Canto's custom AnteHandler func (app *Canto) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64, cdc codec.BinaryCodec, simulation bool) { anteHandler, err := ante.NewAnteHandler( diff --git a/x/coinswap/types/msgs.go b/x/coinswap/types/msgs.go index 31bac5f1..297a3b1c 100644 --- a/x/coinswap/types/msgs.go +++ b/x/coinswap/types/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" sdkmath "cosmossdk.io/math" + "cosmossdk.io/x/tx/signing" coinswapv1 "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" sdk "github.com/cosmos/cosmos-sdk/types" protov2 "google.golang.org/protobuf/proto" @@ -77,14 +78,16 @@ func NewMsgRemoveLiquidity( } } -func GetSignersFromMsgSwapOrderV2(msg protov2.Message) ([][]byte, error) { +func GetSignersFromMsgSwapOrderV2(options *signing.Options, msg protov2.Message) ([][]byte, error) { msgv2, ok := msg.(*coinswapv1.MsgSwapOrder) if !ok { return nil, fmt.Errorf("invalid x/coinswap/MsgSwapOrder msg v2: %v", msg) } - signers := [][]byte{} - signers = append(signers, []byte(msgv2.Input.Address)) + addr, err := options.AddressCodec.StringToBytes(msgv2.Input.Address) + if err != nil { + return nil, err + } - return signers, nil + return [][]byte{addr}, nil } From 5e3c64d119040d055f5fc0967b75081445c24e30 Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 10 Jul 2024 17:27:23 +0900 Subject: [PATCH 5/9] refactor: change the custom GetSigner to use `StringToBytes` instead of ``[]byte` --- app/app.go | 7 +++++-- x/coinswap/types/msgs.go | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index 9efca37f..039bb2c8 100644 --- a/app/app.go +++ b/app/app.go @@ -312,7 +312,7 @@ func NewCanto( }, } - DefineCustomGetSigners(options * signing.Options) + DefineCustomGetSigners(&signingOptions) interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, @@ -1001,7 +1001,10 @@ func DefineCustomGetSigners(options *signing.Options) { // evm/MsgEthereumTx, erc20/MsgConvertERC20, coinswap/MsgSwapOrder options.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) options.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) - options.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2(options)) + options.DefineCustomGetSigners( + protov2.MessageName(&coinswapv1.MsgSwapOrder{}), + coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(options), + ) } diff --git a/x/coinswap/types/msgs.go b/x/coinswap/types/msgs.go index 297a3b1c..cddda09c 100644 --- a/x/coinswap/types/msgs.go +++ b/x/coinswap/types/msgs.go @@ -78,16 +78,18 @@ func NewMsgRemoveLiquidity( } } -func GetSignersFromMsgSwapOrderV2(options *signing.Options, msg protov2.Message) ([][]byte, error) { - msgv2, ok := msg.(*coinswapv1.MsgSwapOrder) - if !ok { - return nil, fmt.Errorf("invalid x/coinswap/MsgSwapOrder msg v2: %v", msg) - } +func CreateGetSignersFromMsgSwapOrderV2(options *signing.Options) func(msg protov2.Message) ([][]byte, error) { + return func(msg protov2.Message) ([][]byte, error) { + msgv2, ok := msg.(*coinswapv1.MsgSwapOrder) + if !ok { + return nil, fmt.Errorf("invalid x/coinswap/MsgSwapOrder msg v2: %v", msg) + } - addr, err := options.AddressCodec.StringToBytes(msgv2.Input.Address) - if err != nil { - return nil, err - } + addr, err := options.AddressCodec.StringToBytes(msgv2.Input.Address) + if err != nil { + return nil, err + } - return [][]byte{addr}, nil + return [][]byte{addr}, nil + } } From 5ad9d8897b5e991dde47988d1f1af8d78d8c2e03 Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 10 Jul 2024 19:30:38 +0900 Subject: [PATCH 6/9] refactor: test function modified --- app/app.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index 039bb2c8..f82e74ea 100644 --- a/app/app.go +++ b/app/app.go @@ -312,7 +312,13 @@ func NewCanto( }, } - DefineCustomGetSigners(&signingOptions) + // evm/MsgEthereumTx, erc20/MsgConvertERC20, coinswap/MsgSwapOrder + signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) + signingOptions.DefineCustomGetSigners( + protov2.MessageName(&coinswapv1.MsgSwapOrder{}), + coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions), + ) interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, @@ -997,17 +1003,6 @@ func NewCanto( return app } -func DefineCustomGetSigners(options *signing.Options) { - // evm/MsgEthereumTx, erc20/MsgConvertERC20, coinswap/MsgSwapOrder - options.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) - options.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) - options.DefineCustomGetSigners( - protov2.MessageName(&coinswapv1.MsgSwapOrder{}), - coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(options), - ) - -} - // use Canto's custom AnteHandler func (app *Canto) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64, cdc codec.BinaryCodec, simulation bool) { anteHandler, err := ante.NewAnteHandler( From 211687dcedd14567b454e77348120d0ee25e46a8 Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 10 Jul 2024 19:30:44 +0900 Subject: [PATCH 7/9] refactor: test function modified --- app/signer_test.go | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/app/signer_test.go b/app/signer_test.go index 2378c43f..99d8c7df 100644 --- a/app/signer_test.go +++ b/app/signer_test.go @@ -5,18 +5,20 @@ import ( "cosmossdk.io/x/tx/signing" coinswapapi "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" + erc20v1 "github.com/Canto-Network/Canto/v7/api/canto/erc20/v1" coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" + erc20types "github.com/Canto-Network/Canto/v7/x/erc20/types" "github.com/cosmos/cosmos-sdk/codec/address" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + evmv1 "github.com/evmos/ethermint/api/ethermint/evm/v1" + evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" protov2 "google.golang.org/protobuf/proto" ) func TestMsgSwapOrderSigners(t *testing.T) { - sw := coinswapapi.MsgSwapOrder{ - Input: &coinswapapi.Input{Address: "signer"}, - } + + addr := "canto13e9t6s6ra8caz5zzmy5w9v23dm2dr5nrr9sz03" signingOptions := signing.Options{ AddressCodec: address.Bech32Codec{ @@ -26,14 +28,36 @@ func TestMsgSwapOrderSigners(t *testing.T) { Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), }, } - signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapapi.MsgSwapOrder{}), coinswaptypes.GetSignersFromMsgSwapOrderV2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapapi.MsgSwapOrder{}), coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions)) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) ctx, err := signing.NewContext(signingOptions) - require.NoError(t, err) - signers, err := ctx.GetSigners(&sw) - require.NoError(t, err) - assert.Equal(t, 1, len(signers)) - assert.Equal(t, []byte("signer"), signers[0]) + tests := []struct { + name string + msg protov2.Message + want [][]byte + wantErr bool + }{ + { + name: "MsgSwapOrder", + msg: &coinswapapi.MsgSwapOrder{ + Input: &coinswapapi.Input{Address: addr}, + }, + want: [][]byte{[]byte(sdk.AccAddress(addr))}, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + signers, err := ctx.GetSigners(test.msg) + if test.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + require.Equal(t, test.want, signers) + }) + } } From c68de59c2d721c34a1b0539ea9a17d9e770706cd Mon Sep 17 00:00:00 2001 From: poorphd Date: Wed, 10 Jul 2024 23:31:01 +0900 Subject: [PATCH 8/9] fix: test function modified --- app/signer_test.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/signer_test.go b/app/signer_test.go index 99d8c7df..5011d7b6 100644 --- a/app/signer_test.go +++ b/app/signer_test.go @@ -5,13 +5,9 @@ import ( "cosmossdk.io/x/tx/signing" coinswapapi "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" - erc20v1 "github.com/Canto-Network/Canto/v7/api/canto/erc20/v1" coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" - erc20types "github.com/Canto-Network/Canto/v7/x/erc20/types" "github.com/cosmos/cosmos-sdk/codec/address" sdk "github.com/cosmos/cosmos-sdk/types" - evmv1 "github.com/evmos/ethermint/api/ethermint/evm/v1" - evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" protov2 "google.golang.org/protobuf/proto" ) @@ -19,6 +15,8 @@ import ( func TestMsgSwapOrderSigners(t *testing.T) { addr := "canto13e9t6s6ra8caz5zzmy5w9v23dm2dr5nrr9sz03" + accAddr, err := sdk.AccAddressFromBech32(addr) + require.NoError(t, err) signingOptions := signing.Options{ AddressCodec: address.Bech32Codec{ @@ -29,8 +27,6 @@ func TestMsgSwapOrderSigners(t *testing.T) { }, } signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapapi.MsgSwapOrder{}), coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions)) - signingOptions.DefineCustomGetSigners(protov2.MessageName(&evmv1.MsgEthereumTx{}), evmtypes.GetSignersFromMsgEthereumTxV2) - signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) ctx, err := signing.NewContext(signingOptions) require.NoError(t, err) @@ -46,7 +42,7 @@ func TestMsgSwapOrderSigners(t *testing.T) { msg: &coinswapapi.MsgSwapOrder{ Input: &coinswapapi.Input{Address: addr}, }, - want: [][]byte{[]byte(sdk.AccAddress(addr))}, + want: [][]byte{accAddr}, }, } for _, test := range tests { From 200a4efd484ea2ab17cbe98a7f4d400fd5c0f4f7 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Thu, 11 Jul 2024 02:28:27 +0900 Subject: [PATCH 9/9] test: Add erc20/MsgConvertERC20 test --- app/signer_test.go | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/signer_test.go b/app/signer_test.go index 5011d7b6..c488d113 100644 --- a/app/signer_test.go +++ b/app/signer_test.go @@ -3,17 +3,21 @@ package app import ( "testing" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" + protov2 "google.golang.org/protobuf/proto" + "cosmossdk.io/x/tx/signing" - coinswapapi "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" - coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" "github.com/cosmos/cosmos-sdk/codec/address" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - protov2 "google.golang.org/protobuf/proto" -) -func TestMsgSwapOrderSigners(t *testing.T) { + coinswapv1 "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" + erc20v1 "github.com/Canto-Network/Canto/v7/api/canto/erc20/v1" + coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" + erc20types "github.com/Canto-Network/Canto/v7/x/erc20/types" +) +func TestDefineCustomGetSigners(t *testing.T) { addr := "canto13e9t6s6ra8caz5zzmy5w9v23dm2dr5nrr9sz03" accAddr, err := sdk.AccAddressFromBech32(addr) require.NoError(t, err) @@ -26,7 +30,8 @@ func TestMsgSwapOrderSigners(t *testing.T) { Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), }, } - signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapapi.MsgSwapOrder{}), coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions)) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions)) ctx, err := signing.NewContext(signingOptions) require.NoError(t, err) @@ -37,12 +42,19 @@ func TestMsgSwapOrderSigners(t *testing.T) { want [][]byte wantErr bool }{ + { + name: "MsgConvertERC20", + msg: &erc20v1.MsgConvertERC20{ + Sender: common.BytesToAddress(accAddr.Bytes()).String(), + }, + want: [][]byte{accAddr.Bytes()}, + }, { name: "MsgSwapOrder", - msg: &coinswapapi.MsgSwapOrder{ - Input: &coinswapapi.Input{Address: addr}, + msg: &coinswapv1.MsgSwapOrder{ + Input: &coinswapv1.Input{Address: addr}, }, - want: [][]byte{accAddr}, + want: [][]byte{accAddr.Bytes()}, }, } for _, test := range tests {