Skip to content

Commit

Permalink
Merge branch 'master' into aleem/9657-msg-leave-group
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Mar 4, 2022
2 parents ea82a8c + 7c0c347 commit a4bfd0c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 0 additions & 2 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const (
FlagReverse = "reverse"
FlagTip = "tip"
FlagAux = "aux"
FlagTipper = "tipper"

// Tendermint logging flags
FlagLogLevel = "log_level"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions client/tx/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions x/auth/client/cli/tips.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -72,6 +76,7 @@ func GetAuxToFeeCommand() *cobra.Command {
}

flags.AddTxFlagsToCmd(cmd)
cmd.Flags().String(flags.FlagChainID, "", "network chain ID")
return cmd
}

Expand Down
26 changes: 12 additions & 14 deletions x/auth/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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",
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit a4bfd0c

Please sign in to comment.