Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: changed the data type for FeePayer and FeeGranter #16272

Merged
merged 25 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d6a5778
changed the data type for FeePayer and FeeGranter
vishal-kanna May 24, 2023
db85847
Merge branch 'main' into typechange
vishal-kanna May 24, 2023
5722e74
uncommented the log
vishal-kanna May 24, 2023
ab71c8d
Merge branch 'typechange' of https://github.com/vishal-kanna/cosmos-s…
vishal-kanna May 24, 2023
9c5a899
Merge branch 'main' of https://github.com/vishal-kanna/cosmos-sdk int…
vishal-kanna May 30, 2023
1f239a5
fix: solved the error in test files
vishal-kanna May 30, 2023
4ca085f
Merge branch 'main' into typechange
atheeshp Jun 5, 2023
4cdb162
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into type…
vishal-kanna Jul 7, 2023
2af76ce
change added in changelog
vishal-kanna Jul 7, 2023
072c86f
mentioned the change in changelog under the API breaking changes
vishal-kanna Jul 7, 2023
616030b
Revert "mentioned the change in changelog under the API breaking chan…
vishal-kanna Jul 7, 2023
40cccf1
mentioned the change in changelog under the API breaking changes
vishal-kanna Jul 7, 2023
eb5bcc2
changed name of the variable and used the Equalfold method
vishal-kanna Jul 7, 2023
717a478
used the strings.EqualFold method
vishal-kanna Jul 7, 2023
3ed1d9d
mades changes as per request
vishal-kanna Jul 7, 2023
56d10d2
removed the extra line in the changelog
vishal-kanna Jul 7, 2023
6d609fa
Update CHANGELOG.md
likhita-809 Jul 7, 2023
40c8d4f
made changes as per the review
vishal-kanna Jul 7, 2023
465261c
Merge branch 'typechange' of https://github.com/vishal-kanna/cosmos-s…
vishal-kanna Jul 7, 2023
9fd6586
Merge branch 'main' into typechange
vishal-kanna Jul 11, 2023
ee10450
removed the extra variable
vishal-kanna Jul 11, 2023
5eaca40
Merge branch 'typechange' of https://github.com/vishal-kanna/cosmos-s…
vishal-kanna Jul 11, 2023
7037cae
reverted the variable
vishal-kanna Jul 11, 2023
d0093c8
removed the variable
vishal-kanna Jul 11, 2023
5142197
made suggested change in the changelog
vishal-kanna Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* (types) [#16272](https://github.com/cosmos/cosmos-sdk/pull/16272) From now the `FeeGranter` in the `FeeTx` interface takes the byte type instead of string.
* (testutil) [#16899](https://github.com/cosmos/cosmos-sdk/pull/16899) The *cli testutil* `QueryBalancesExec` has been removed. Use the gRPC or REST query instead.
* (x/auth) [#16650](https://github.com/cosmos/cosmos-sdk/pull/16650) The *cli testutil* `QueryAccountExec` has been removed. Use the gRPC or REST query instead.
* (types/math) [#16040](https://github.com/cosmos/cosmos-sdk/pull/16798) Remove aliases in `types/math.go` (part 2).
Expand Down
2 changes: 1 addition & 1 deletion types/tx_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type (
GetGas() uint64
GetFee() Coins
FeePayer() []byte
FeeGranter() string
FeeGranter() []byte
}

// TxWithMemo must have GetMemo() method to use ValidateMemoDecorator
Expand Down
7 changes: 2 additions & 5 deletions x/auth/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee

// if feegranter set deduct fee from feegranter account.
// this works with only when feegrant enabled.
if feeGranter != "" {
feeGranterAddr, err := sdk.AccAddressFromBech32(feeGranter)
if err != nil {
return err
}
if feeGranter != nil {
feeGranterAddr := sdk.AccAddress(feeGranter)

if dfd.feegrantKeeper == nil {
return sdkerrors.ErrInvalidRequest.Wrap("fee grants are not enabled")
Expand Down
6 changes: 3 additions & 3 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ func (w *wrapper) FeePayer() []byte {
return signers[0]
}

func (w *wrapper) FeeGranter() string {
func (w *wrapper) FeeGranter() []byte {
feeGranter := w.tx.AuthInfo.Fee.Granter
if feeGranter != "" {
return feeGranter
return sdk.MustAccAddressFromBech32(feeGranter)
}
return ""
return nil
}

func (w *wrapper) GetTip() *tx.Tip {
Expand Down
2 changes: 1 addition & 1 deletion x/auth/tx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,5 +317,5 @@ func TestBuilderFeeGranter(t *testing.T) {

// set fee granter
txBuilder.SetFeeGranter(addr1)
require.Equal(t, addr1.String(), txBuilder.GetTx().FeeGranter())
require.Equal(t, addr1.String(), sdk.AccAddress(txBuilder.GetTx().FeeGranter()).String())
}
11 changes: 3 additions & 8 deletions x/auth/tx/direct_aux.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tx

import (
"bytes"
"fmt"
"strings"

errorsmod "cosmossdk.io/errors"

Expand Down Expand Up @@ -56,13 +56,8 @@ func (signModeDirectAuxHandler) GetSignBytes(

// Fee payer cannot use SIGN_MODE_DIRECT_AUX, because SIGN_MODE_DIRECT_AUX
// does not sign over fees, which would create malleability issues.
addrBz, err := sdk.AccAddressFromBech32(data.Address)
if err != nil {
return nil, err
}

if bytes.Equal(feePayer, addrBz) {
return nil, sdkerrors.ErrUnauthorized.Wrapf("fee payer %s cannot sign with %s", feePayer, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
if strings.EqualFold(sdk.AccAddress(feePayer).String(), data.Address) {
return nil, sdkerrors.ErrUnauthorized.Wrapf("fee payer %s cannot sign with %s", sdk.AccAddress(feePayer).String(), signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
}

signDocDirectAux := types.SignDocDirectAux{
Expand Down
2 changes: 1 addition & 1 deletion x/auth/tx/direct_aux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestDirectAuxHandler(t *testing.T) {

t.Log("verify fee payer cannot use SIGN_MODE_DIRECT_AUX")
_, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, feePayerSigningData, txBuilder.GetTx())
require.EqualError(t, err, fmt.Sprintf("fee payer %s cannot sign with %s: unauthorized", []byte(feePayerAddr), signingtypes.SignMode_SIGN_MODE_DIRECT_AUX))
require.EqualError(t, err, fmt.Sprintf("fee payer %s cannot sign with %s: unauthorized", feePayerAddr.String(), signingtypes.SignMode_SIGN_MODE_DIRECT_AUX))

t.Log("verify GetSignBytes with generating sign bytes by marshaling signDocDirectAux")
signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, signingData, txBuilder.GetTx())
Expand Down