Skip to content

Commit

Permalink
fix: Remove --tipper flag, set it to msg signer (#11322)
Browse files Browse the repository at this point in the history
## Description

Closes: #11321 



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
amaury1093 authored Mar 4, 2022
1 parent 89ea390 commit 7c0c347
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 7c0c347

Please sign in to comment.