diff --git a/client/flags/flags.go b/client/flags/flags.go index a76559074861..461fcb783a05 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -77,7 +77,6 @@ const ( FlagReverse = "reverse" FlagTip = "tip" FlagAux = "aux" - FlagTipper = "tipper" // Tendermint logging flags FlagLogLevel = "log_level" @@ -121,7 +120,6 @@ func AddTxFlagsToCmd(cmd *cobra.Command) { cmd.Flags().String(FlagFeePayer, "", "Fee payer pays fees for the transaction instead of deducting from the signer") cmd.Flags().String(FlagFeeGranter, "", "Fee granter grants fees for the transaction") cmd.Flags().String(FlagTip, "", "Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux") - cmd.Flags().String(FlagTipper, "", "Tipper will pay for tips for executing the tx on the target chain. This flag is only valid when used with --aux") cmd.Flags().Bool(FlagAux, false, "Generate aux signer data instead of sending a tx") // --gas can accept integers and "auto" diff --git a/client/tx/factory.go b/client/tx/factory.go index 15032250a813..5653b2f89ec9 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -83,8 +83,9 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory { f = f.WithFees(feesStr) tipsStr, _ := flagSet.GetString(flags.FlagTip) - tipper, _ := flagSet.GetString(flags.FlagTipper) - f = f.WithTips(tipsStr, tipper) + // Add tips to factory. The tipper is necessarily the Msg signer, i.e. + // the from address. + f = f.WithTips(tipsStr, clientCtx.FromAddress.String()) gasPricesStr, _ := flagSet.GetString(flags.FlagGasPrices) f = f.WithGasPrices(gasPricesStr) diff --git a/x/auth/client/cli/tips.go b/x/auth/client/cli/tips.go index 5e356b6dc03d..773ad6d619f7 100644 --- a/x/auth/client/cli/tips.go +++ b/x/auth/client/cli/tips.go @@ -31,6 +31,10 @@ func GetAuxToFeeCommand() *cobra.Command { return err } + if auxSignerData.SignDoc.ChainId != clientCtx.ChainID { + return fmt.Errorf("expected chain-id %s, got %s in aux signer data", clientCtx.ChainID, auxSignerData.SignDoc.ChainId) + } + f := clienttx.NewFactoryCLI(clientCtx, cmd.Flags()) txBuilder := clientCtx.TxConfig.NewTxBuilder() @@ -72,6 +76,7 @@ func GetAuxToFeeCommand() *cobra.Command { } flags.AddTxFlagsToCmd(cmd) + cmd.Flags().String(flags.FlagChainID, "", "network chain ID") return cmd } diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 4c9d7da5d132..8bb26a22d07c 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -1563,7 +1563,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirect), fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, expectErrAux: true, @@ -1600,7 +1599,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1619,7 +1617,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1637,7 +1634,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.Moniker), Amount: sdk.NewInt(0)}, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1656,7 +1652,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1674,7 +1669,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1685,23 +1679,24 @@ func (s *IntegrationTestSuite) TestAuxToFee() { }, }, { - name: "wrong tipper address: error", + name: "chain-id mismatch: error", tipper: tipper, feePayer: feePayer, tip: tip, tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=%s", flags.FlagTipper, "foobar"), fmt.Sprintf("--%s=true", flags.FlagAux), }, - expectErrAux: true, + expectErrAux: false, feePayerArgs: []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer), fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()), + fmt.Sprintf("--%s=%s", flags.FlagChainID, "foobar"), }, + expectErrBroadCast: true, }, { name: "wrong denom in tip: error", @@ -1711,7 +1706,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagTip, "1000wrongDenom"), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1731,7 +1725,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs: []string{ fmt.Sprintf("--%s=%s", flags.FlagTip, tip), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux), - fmt.Sprintf("--%s=%s", flags.FlagTipper, tipper.String()), fmt.Sprintf("--%s=true", flags.FlagAux), }, feePayerArgs: []string{ @@ -1769,16 +1762,21 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tc.feePayerArgs..., ) - var txRes sdk.TxResponse - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) - if tc.expectErrBroadCast { require.Error(err) } else if tc.errMsg != "" { + require.NoError(err) + + var txRes sdk.TxResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) + require.Contains(txRes.RawLog, tc.errMsg) } else { require.NoError(err) + var txRes sdk.TxResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) + s.Require().Equal(uint32(0), txRes.Code) s.Require().NotNil(int64(0), txRes.Height)