diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc6d79a479..edd12b8a5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,6 @@ jobs: run: | grep -vF \ -e 'github.com/provenance-io/provenance/cmd/provenanced/cmd' \ - -e 'github.com/provenance-io/provenance/internal/antewrapper' \ -e 'github.com/provenance-io/provenance/x/ibchooks' \ -e 'github.com/provenance-io/provenance/x/ibcratelimit/module' \ -e 'github.com/provenance-io/provenance/x/ibcratelimit/simulation' \ @@ -62,7 +61,6 @@ jobs: split -d -n l/3 pkgs.txt.tmp pkgs.txt.part. printf '%s\n' \ 'github.com/provenance-io/provenance/cmd/provenanced/cmd' \ - 'github.com/provenance-io/provenance/internal/antewrapper' \ 'github.com/provenance-io/provenance/x/ibchooks' \ 'github.com/provenance-io/provenance/x/ibcratelimit/module' \ 'github.com/provenance-io/provenance/x/ibcratelimit/simulation' \ diff --git a/internal/antewrapper/min_gas_prices_decorator_test.go b/internal/antewrapper/min_gas_prices_decorator_test.go index 495919d5e9..266cfdfbd4 100644 --- a/internal/antewrapper/min_gas_prices_decorator_test.go +++ b/internal/antewrapper/min_gas_prices_decorator_test.go @@ -6,14 +6,17 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" txtypes "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/provenance-io/provenance/app" "github.com/provenance-io/provenance/internal/antewrapper" ) @@ -48,42 +51,54 @@ func (t NonFeeTx) GetMsgsV2() ([]protov2.Message, error) { return nil, nil } -var _ sdk.Tx = &FeeTxWrapper{} +var _ sdk.Tx = (*FeeTxWrapper)(nil) +var _ sdk.FeeTx = (*FeeTxWrapper)(nil) // FeeTxWrapper is a wrapper on a txtypes.Tx that also has the GetMsgsV2 func so it satisfies the sdk.Tx interface. type FeeTxWrapper struct { txtypes.Tx + Codec codec.Codec } func (t FeeTxWrapper) GetMsgsV2() ([]protov2.Message, error) { - return nil, nil + msgs := t.Tx.GetMsgs() + rv := make([]protov2.Message, len(msgs)) + for i, msg := range msgs { + rv[i] = protoadapt.MessageV2Of(msg) + } + return rv, nil } -func NewFeeTxWrapper(tx txtypes.Tx) *FeeTxWrapper { - return &FeeTxWrapper{Tx: tx} +func (t FeeTxWrapper) FeePayer() []byte { + return t.Tx.FeePayer(t.Codec) } -func NewFeeTx(gasLimit uint64, fee sdk.Coins) sdk.Tx { - return NewFeeTxWrapper(txtypes.Tx{ - AuthInfo: &txtypes.AuthInfo{ - Fee: &txtypes.Fee{ - Amount: fee, - GasLimit: gasLimit, - }, - }, - }) +func (t FeeTxWrapper) FeeGranter() []byte { + return t.Tx.FeeGranter(t.Codec) +} + +func NewFeeTxWrapper(tx txtypes.Tx, codec codec.Codec) *FeeTxWrapper { + return &FeeTxWrapper{Tx: tx, Codec: codec} +} + +func NewFeeTx(gasLimit uint64, fee sdk.Coins, codec codec.Codec) sdk.Tx { + tx := txtypes.Tx{AuthInfo: &txtypes.AuthInfo{Fee: &txtypes.Fee{Amount: fee, GasLimit: gasLimit}}} + return NewFeeTxWrapper(tx, codec) } -func TestAnteHandle(tt *testing.T) { +func TestAnteHandle(t *testing.T) { var dummyTx sdk.Tx dummyTx = &NonFeeTx{} _, ok := dummyTx.(sdk.FeeTx) - require.False(tt, ok, "NonFeeTx should not implement FeeTx.") + require.False(t, ok, "NonFeeTx should not implement FeeTx.") testSkipMinGasPrices := sdk.NewDecCoins(sdk.NewInt64DecCoin("simfoo", 1000)) testSkipGas := uint64(5) testSkipFee := sdk.NewCoins(sdk.NewInt64Coin("simfoo", 4999)) + encCfg := app.MakeTestEncodingConfig(t) + codec := encCfg.Marshaler + tests := []struct { name string simulate bool @@ -99,7 +114,7 @@ func TestAnteHandle(tt *testing.T) { simulate: true, isCheckTx: true, minGasPrices: testSkipMinGasPrices, - tx: NewFeeTx(testSkipGas, testSkipFee), + tx: NewFeeTx(testSkipGas, testSkipFee, codec), expectedInError: nil, }, { @@ -107,7 +122,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: false, minGasPrices: testSkipMinGasPrices, - tx: NewFeeTx(testSkipGas, testSkipFee), + tx: NewFeeTx(testSkipGas, testSkipFee, codec), expectedInError: nil, }, { @@ -115,7 +130,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: testSkipMinGasPrices, - tx: NewFeeTx(testSkipGas, testSkipFee), + tx: NewFeeTx(testSkipGas, testSkipFee, codec), expectedInError: []string{"insufficient fee", "min-gas-prices not met", "got: 4999simfoo", "required: 5000simfoo"}, }, // end of skip tests. @@ -125,7 +140,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("gascoin", 100)), - tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("feecoin", 500_000))), + tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("feecoin", 500_000)), codec), expectedInError: []string{"insufficient fee", "min-gas-prices not met", "got: 500000feecoin", "required: 500gascoin"}, }, { @@ -133,7 +148,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("onefoo", 10), sdk.NewInt64DecCoin("twofoo", 100)), - tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("onefoo", 49))), + tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("onefoo", 49)), codec), expectedInError: []string{"insufficient fee", "min-gas-prices not met", "got: 49onefoo", "required: 50onefoo,500twofoo"}, }, { @@ -141,7 +156,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("threefoo", 10), sdk.NewInt64DecCoin("fourfoo", 100)), - tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("threefoo", 50))), + tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("threefoo", 50)), codec), expectedInError: nil, }, { @@ -149,7 +164,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("fivefoo", 10), sdk.NewInt64DecCoin("sixfoo", 100)), - tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("sixfoo", 499))), + tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("sixfoo", 499)), codec), expectedInError: []string{"insufficient fee", "min-gas-prices not met", "got: 499sixfoo", "required: 50fivefoo,500sixfoo"}, }, { @@ -157,7 +172,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("sevenfoo", 10), sdk.NewInt64DecCoin("eightfoo", 100)), - tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("eightfoo", 500))), + tx: NewFeeTx(5, sdk.NewCoins(sdk.NewInt64Coin("eightfoo", 500)), codec), expectedInError: nil, }, { @@ -165,7 +180,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("ninefoo", 10), sdk.NewInt64DecCoin("tenfoo", 100)), - tx: NewFeeTx(10, sdk.NewCoins(sdk.NewInt64Coin("ninefoo", 99), sdk.NewInt64Coin("tenfoo", 999))), + tx: NewFeeTx(10, sdk.NewCoins(sdk.NewInt64Coin("ninefoo", 99), sdk.NewInt64Coin("tenfoo", 999)), codec), expectedInError: []string{"insufficient fee", "min-gas-prices not met", "got: 99ninefoo,999tenfoo", "required: 100ninefoo,1000tenfoo"}, }, { @@ -173,7 +188,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("elevenfoo", 10), sdk.NewInt64DecCoin("twelvefoo", 100)), - tx: NewFeeTx(10, sdk.NewCoins(sdk.NewInt64Coin("elevenfoo", 99), sdk.NewInt64Coin("twelvefoo", 1000))), + tx: NewFeeTx(10, sdk.NewCoins(sdk.NewInt64Coin("elevenfoo", 99), sdk.NewInt64Coin("twelvefoo", 1000)), codec), expectedInError: nil, }, { @@ -181,7 +196,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("thirteenfoo", 10), sdk.NewInt64DecCoin("fourteenfoo", 100)), - tx: NewFeeTx(10, sdk.NewCoins(sdk.NewInt64Coin("thirteenfoo", 100), sdk.NewInt64Coin("fourteenfoo", 999))), + tx: NewFeeTx(10, sdk.NewCoins(sdk.NewInt64Coin("thirteenfoo", 100), sdk.NewInt64Coin("fourteenfoo", 999)), codec), expectedInError: nil, }, { @@ -189,7 +204,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("fifteenfoo", 10)), - tx: NewFeeTx(7, sdk.NewCoins(sdk.NewInt64Coin("fifteenfoo", 69), sdk.NewInt64Coin("sixteenfoo", 420))), + tx: NewFeeTx(7, sdk.NewCoins(sdk.NewInt64Coin("fifteenfoo", 69), sdk.NewInt64Coin("sixteenfoo", 420)), codec), expectedInError: []string{"insufficient fee", "min-gas-prices not met", "got: 69fifteenfoo,420sixteenfoo", "required: 70fifteenfoo"}, }, { @@ -197,7 +212,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("seventeenfoo", 10)), - tx: NewFeeTx(1, sdk.NewCoins(sdk.NewInt64Coin("seventeenfoo", 420), sdk.NewInt64Coin("eighteenfoo", 69))), + tx: NewFeeTx(1, sdk.NewCoins(sdk.NewInt64Coin("seventeenfoo", 420), sdk.NewInt64Coin("eighteenfoo", 69)), codec), expectedInError: nil, }, { @@ -205,7 +220,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("nineteenfoo", 50)), - tx: NewFeeTx(2, sdk.NewCoins(sdk.NewInt64Coin("nineteenfoo", 1_000_000))), + tx: NewFeeTx(2, sdk.NewCoins(sdk.NewInt64Coin("nineteenfoo", 1_000_000)), codec), expectedInError: nil, }, { @@ -213,7 +228,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewInt64DecCoin("twentyfoo", 0), sdk.NewInt64DecCoin("twentybar", 0)), - tx: NewFeeTx(100, sdk.NewCoins()), + tx: NewFeeTx(100, sdk.NewCoins(), codec), expectedInError: nil, }, { @@ -221,7 +236,7 @@ func TestAnteHandle(tt *testing.T) { simulate: false, isCheckTx: true, minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec("pcoin", sdkmath.LegacyMustNewDecFromStr("0.15"))), - tx: NewFeeTx(7, sdk.NewCoins(sdk.NewInt64Coin("pcoin", 1))), + tx: NewFeeTx(7, sdk.NewCoins(sdk.NewInt64Coin("pcoin", 1)), codec), expectedInError: []string{"required: 2pcoin"}, }, @@ -261,7 +276,7 @@ func TestAnteHandle(tt *testing.T) { } for _, tc := range tests { - tt.Run(tc.name, func(t *testing.T) { + t.Run(tc.name, func(t *testing.T) { ctx := sdk.NewContext(nil, cmtproto.Header{}, tc.isCheckTx, nil).WithMinGasPrices(tc.minGasPrices) terminator := NewTestTerminator() decorator := antewrapper.NewMinGasPricesDecorator() diff --git a/internal/antewrapper/prov_feegrant_test.go b/internal/antewrapper/prov_feegrant_test.go index cf578e31eb..0a3f275e6f 100644 --- a/internal/antewrapper/prov_feegrant_test.go +++ b/internal/antewrapper/prov_feegrant_test.go @@ -20,6 +20,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" sdksigning "github.com/cosmos/cosmos-sdk/types/tx/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/bank/testutil" @@ -90,32 +91,37 @@ func (s *AnteTestSuite) TestDeductFeesNoDelegation() { signer: addr1, fee: defaultGas, expInErr: []string{"10stake", defaultGasStr, "insufficient funds"}, - }, { + }, + { name: "paying with good funds", signerKey: priv2, signer: addr2, fee: defaultGas, expInErr: nil, - }, { + }, + { name: "paying with no account", signerKey: priv3, signer: addr3, fee: defaultGas, expInErr: []string{"0stake", defaultGasStr, "insufficient funds"}, - }, { + }, + { name: "no fee with no account", signerKey: priv5, signer: addr5, fee: 0, expInErr: []string{"fee payer address", addr5.String(), "does not exist"}, - }, { + }, + { name: "valid fee grant without account", signerKey: priv3, signer: addr3, feeAccount: addr2, fee: defaultGas, expInErr: nil, - }, { + }, + { name: "no fee grant", signerKey: priv3, signer: addr3, @@ -127,10 +133,11 @@ func (s *AnteTestSuite) TestDeductFeesNoDelegation() { fmt.Sprintf("granter: %s", addr1), fmt.Sprintf("grantee: %s", addr3), fmt.Sprintf(`fee: "%s"`, defaultGasStr), - `msgs: ["/testdata.TestMsg"]`, + `msgs: ["/testpb.TestMsg"]`, "fee-grant not found", }, - }, { + }, + { name: "allowance smaller than requested fee", signerKey: priv4, signer: addr4, @@ -142,10 +149,11 @@ func (s *AnteTestSuite) TestDeductFeesNoDelegation() { fmt.Sprintf("granter: %s", addr2), fmt.Sprintf("grantee: %s", addr4), fmt.Sprintf(`fee: "%s"`, defaultGasStr), - `msgs: ["/testdata.TestMsg"]`, + `msgs: ["/testpb.TestMsg"]`, "fee limit exceeded", }, - }, { + }, + { name: "granter cannot cover allowed fee grant", signerKey: priv4, signer: addr4, @@ -157,7 +165,7 @@ func (s *AnteTestSuite) TestDeductFeesNoDelegation() { fmt.Sprintf("granter: %s", addr1), fmt.Sprintf("grantee: %s", addr4), fmt.Sprintf(`fee: "%s"`, defaultGasStr), - `msgs: ["/testdata.TestMsg"]`, + `msgs: ["/testpb.TestMsg"]`, "fee-grant not found", }, }, @@ -169,7 +177,8 @@ func (s *AnteTestSuite) TestDeductFeesNoDelegation() { msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} acc := app.AccountKeeper.GetAccount(ctx, tc.signer) - privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} + privs := []cryptotypes.PrivKey{tc.signerKey} + accNums, seqs := []uint64{0}, []uint64{0} if acc != nil { accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } @@ -243,19 +252,25 @@ func genTxWithFeeGranter(ctx context.Context, gen client.TxConfig, msgs []sdk.Ms AccountNumber: accNums[i], Sequence: accSeqs[i], } - txData := signing.TxData{} // TODO[1760]: signing: Base this off of txb.GetTx(). + + theTx := txb.GetTx() + adaptableTx, ok := theTx.(authsigning.V2AdaptableTx) + if !ok { + return nil, fmt.Errorf("%T does not implement the authsigning.V2AdaptableTx interface", theTx) + } + txData := adaptableTx.GetSigningTxData() signBytes, err := gen.SignModeHandler().GetSignBytes(ctx, signMode, signerData, txData) if err != nil { - panic(err) + return nil, err } sig, err := p.Sign(signBytes) if err != nil { - panic(err) + return nil, err } sigs[i].Data.(*sdksigning.SingleSignatureData).Signature = sig err = txb.SetSignatures(sigs...) if err != nil { - panic(err) + return nil, err } } diff --git a/internal/antewrapper/testutil_test.go b/internal/antewrapper/testutil_test.go index 5230c52f72..0728cde3b8 100644 --- a/internal/antewrapper/testutil_test.go +++ b/internal/antewrapper/testutil_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" - xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -117,7 +118,7 @@ func (s *AnteTestSuite) CreateTestAccounts(numAccs int) []TestAccount { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (s *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (s *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (authsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. var sigsV2 []signing.SignatureV2 @@ -125,7 +126,7 @@ func (s *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint sigV2 := signing.SignatureV2{ PubKey: priv.PubKey(), Data: &signing.SingleSignatureData{ - // SignMode: s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), // TODO[1760]: signing: same type name diff packages. + SignMode: signing.SignMode_SIGN_MODE_DIRECT, Signature: nil, }, Sequence: accSeqs[i], @@ -140,24 +141,21 @@ func (s *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint // Second round: all signer infos are set, so each signer can sign. sigsV2 = []signing.SignatureV2{} - // TODO[1760]: signing: SignWithPrivKey: Uncomment these lines. - /* - for i, priv := range privs { - signerData := xauthsigning.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], - } - sigV2, err := tx.SignWithPrivKey( - s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, - s.txBuilder, priv, s.clientCtx.TxConfig, accSeqs[i]) - if err != nil { - return nil, err - } - - sigsV2 = append(sigsV2, sigV2) + for i, priv := range privs { + signerData := authsigning.SignerData{ + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], } - */ + sigV2, err := tx.SignWithPrivKey(s.ctx, + signing.SignMode_SIGN_MODE_DIRECT, signerData, + s.txBuilder, priv, s.clientCtx.TxConfig, accSeqs[i]) + if err != nil { + return nil, err + } + + sigsV2 = append(sigsV2, sigV2) + } err = s.txBuilder.SetSignatures(sigsV2...) if err != nil { return nil, err diff --git a/internal/handlers/msg_fee_invoker_test.go b/internal/handlers/msg_fee_invoker_test.go index 7b8e91e2f7..5168bf6329 100644 --- a/internal/handlers/msg_fee_invoker_test.go +++ b/internal/handlers/msg_fee_invoker_test.go @@ -10,14 +10,15 @@ import ( "cosmossdk.io/x/feegrant" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/codec" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/cosmos/cosmos-sdk/x/auth/tx" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" @@ -183,7 +184,7 @@ func (s *HandlerTestSuite) TestMsgFeeHandlerBadDecoder() { feeGasMeter := antewrapper.NewFeeGasMeterWrapper(log.NewTestLogger(s.T()), storetypes.NewGasMeter(100), false).(*antewrapper.FeeGasMeter) s.ctx = s.ctx.WithGasMeter(feeGasMeter) - emptyTxCfg := tx.NewTxConfig(codec.NewProtoCodec(codectestutil.CodecOptions{}.NewInterfaceRegistry()), tx.DefaultSignModes) + emptyTxCfg := authtx.NewTxConfig(codec.NewProtoCodec(codectestutil.CodecOptions{}.NewInterfaceRegistry()), authtx.DefaultSignModes) feeChargeFn, err := piohandlers.NewAdditionalMsgFeeHandler(piohandlers.PioBaseAppKeeperOptions{ AccountKeeper: s.app.AccountKeeper, @@ -218,7 +219,7 @@ func createTestApp(t *testing.T) (*simapp.App, sdk.Context) { return app, ctx } -func createTestTx(s *HandlerTestSuite, err error, feeAmount sdk.Coins) (xauthsigning.Tx, sdk.AccountI) { +func createTestTx(s *HandlerTestSuite, err error, feeAmount sdk.Coins) (authsigning.Tx, sdk.AccountI) { // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() acct1 := s.app.AccountKeeper.NewAccountWithAddress(s.ctx, addr1) @@ -238,7 +239,7 @@ func createTestTx(s *HandlerTestSuite, err error, feeAmount sdk.Coins) (xauthsig return testTx, acct1 } -func createTestTxWithFeeGrant(s *HandlerTestSuite, err error, feeAmount sdk.Coins) (xauthsigning.Tx, sdk.AccountI) { +func createTestTxWithFeeGrant(s *HandlerTestSuite, err error, feeAmount sdk.Coins) (authsigning.Tx, sdk.AccountI) { // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() acct1 := s.app.AccountKeeper.NewAccountWithAddress(s.ctx, addr1) @@ -299,7 +300,7 @@ func (s *HandlerTestSuite) CreateMsgFee(fee sdk.Coin, msgs ...sdk.Msg) error { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (s *HandlerTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (s *HandlerTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (authsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. var sigsV2 []signing.SignatureV2 @@ -307,7 +308,7 @@ func (s *HandlerTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []u sigV2 := signing.SignatureV2{ PubKey: priv.PubKey(), Data: &signing.SingleSignatureData{ - // SignMode: s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), // TODO[1760]: signing: same type name diff packages. + SignMode: signing.SignMode_SIGN_MODE_DIRECT, Signature: nil, }, Sequence: accSeqs[i], @@ -322,24 +323,21 @@ func (s *HandlerTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []u // Second round: all signer infos are set, so each signer can sign. sigsV2 = []signing.SignatureV2{} - // TODO[1760]: signing: SignWithPrivKey: Uncomment these lines. - /* - for i, priv := range privs { - signerData := xauthsigning.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], - } - sigV2, err := tx.SignWithPrivKey( - s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, - s.txBuilder, priv, s.clientCtx.TxConfig, accSeqs[i]) - if err != nil { - return nil, err - } - - sigsV2 = append(sigsV2, sigV2) + for i, priv := range privs { + signerData := authsigning.SignerData{ + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], + } + sigV2, err := tx.SignWithPrivKey(s.ctx, + signing.SignMode_SIGN_MODE_DIRECT, signerData, + s.txBuilder, priv, s.clientCtx.TxConfig, accSeqs[i]) + if err != nil { + return nil, err } - */ + + sigsV2 = append(sigsV2, sigV2) + } err = s.txBuilder.SetSignatures(sigsV2...) if err != nil { return nil, err diff --git a/internal/handlers/msg_service_router.go b/internal/handlers/msg_service_router.go index e3024947dd..25c120c8c4 100644 --- a/internal/handlers/msg_service_router.go +++ b/internal/handlers/msg_service_router.go @@ -218,7 +218,6 @@ func (msr *PioMsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler in if err != nil { panic(err) } - // TODO[1760]: msg-service-router: Do we need to add the registration of this? err = msr.registerHybridHandler(sd, method, handler) if err != nil { panic(err)