Skip to content

Commit

Permalink
keep fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica committed Oct 18, 2023
1 parent 0d0a609 commit 42e5bb0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 61 deletions.
9 changes: 7 additions & 2 deletions x/feegrant/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ Examples:
return err
}

grantee, err := ac.StringToBytes(args[1])
grantee := args[1]
_, err = ac.StringToBytes(grantee)
if err != nil {
return err
}

granter := clientCtx.GetFromAddress()
granterStr, err := ac.BytesToString(granter)
if err != nil {
return err
}
sl, err := cmd.Flags().GetString(FlagSpendLimit)
if err != nil {
return err
Expand Down Expand Up @@ -168,7 +173,7 @@ Examples:
}
}

msg, err := feegrant.NewMsgGrantAllowance(grant, granter, grantee)
msg, err := feegrant.NewMsgGrantAllowance(grant, granterStr, grantee)
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion x/feegrant/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ func (s *CLITestSuite) SetupSuite() {

s.createGrant(granter, grantee)

grant, err := feegrant.NewGrant(granter, grantee, &feegrant.BasicAllowance{
ac := codecaddress.NewBech32Codec("cosmos")
granteeStr, err := ac.BytesToString(grantee)
s.Require().NoError(err)
granterStr, err := ac.BytesToString(granter)
s.Require().NoError(err)

grant, err := feegrant.NewGrant(granterStr, granteeStr, &feegrant.BasicAllowance{
SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(100))),
})
s.Require().NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions x/feegrant/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
cosmossdk.io/api v0.7.2
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/core v0.11.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.0
cosmossdk.io/log v1.2.1
Expand Down Expand Up @@ -155,4 +155,4 @@ require (
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
)
6 changes: 4 additions & 2 deletions x/feegrant/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ cosmossdk.io/api v0.7.2 h1:BO3i5fvKMKvfaUiMkCznxViuBEfyWA/k6w2eAF6q1C4=
cosmossdk.io/api v0.7.2/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=
cosmossdk.io/core v0.12.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w=
cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo=
cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w=
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU=
cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04=
Expand Down Expand Up @@ -182,6 +182,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0
github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U=
github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o=
github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I=
github.com/cosmos/cosmos-sdk v0.50.0-rc.1 h1:1Z+SgLg8S2+DoiePz9aO5dSjJUgag8VFhFUSD/HGvOU=
github.com/cosmos/cosmos-sdk v0.50.0-rc.1/go.mod h1:JbgPLZrh+yX+4+n1CPJ/uL9HrhZw6QVg0q7cTq2Iwq0=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
Expand Down
47 changes: 0 additions & 47 deletions x/feegrant/key_test.go

This file was deleted.

6 changes: 4 additions & 2 deletions x/feegrant/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"

modulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
Expand Down Expand Up @@ -43,6 +44,7 @@ var (
// AppModuleBasic defines the basic application module used by the feegrant module.
type AppModuleBasic struct {
cdc codec.Codec
ac address.Codec
}

// Name returns the feegrant module's name.
Expand Down Expand Up @@ -97,7 +99,7 @@ func (ab AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context,

// GetTxCmd returns the root tx command for the feegrant module.
func (ab AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.GetTxCmd()
return cli.GetTxCmd(ab.ac)
}

// ----------------------------------------------------------------------------
Expand All @@ -117,7 +119,7 @@ type AppModule struct {
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, keeper keeper.Keeper, registry cdctypes.InterfaceRegistry) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
AppModuleBasic: AppModuleBasic{cdc: cdc, ac: ak.AddressCodec()},
keeper: keeper,
accountKeeper: ak,
bankKeeper: bk,
Expand Down
10 changes: 5 additions & 5 deletions x/feegrant/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
)

// NewMsgGrantAllowance creates a new MsgGrantAllowance.
func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantAllowance, error) {
func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee string) (*MsgGrantAllowance, error) {
msg, ok := feeAllowance.(proto.Message)
if !ok {
return nil, errorsmod.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", msg)
Expand All @@ -27,8 +27,8 @@ func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAd
}

return &MsgGrantAllowance{
Granter: granter.String(),
Grantee: grantee.String(),
Granter: granter,
Grantee: grantee,
Allowance: any,
}, nil
}
Expand All @@ -51,6 +51,6 @@ func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error

// NewMsgRevokeAllowance returns a message to revoke a fee allowance for a given
// granter and grantee
func NewMsgRevokeAllowance(granter, grantee sdk.AccAddress) MsgRevokeAllowance {
return MsgRevokeAllowance{Granter: granter.String(), Grantee: grantee.String()}
func NewMsgRevokeAllowance(granter, grantee string) MsgRevokeAllowance {
return MsgRevokeAllowance{Granter: granter, Grantee: grantee}
}

0 comments on commit 42e5bb0

Please sign in to comment.