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

Move x/feegrant/types to x/feegrant #9273

Merged
merged 6 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/feegrant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";

// BasicAllowance implements Allowance with a one-time grant of tokens
// that optionally expires. The grantee can use up to SpendLimit to cover fees.
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package cosmos.feegrant.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos/feegrant/v1beta1/feegrant.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";

// GenesisState contains a set of fee allowances, persisted from the store
message GenesisState {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "cosmos/feegrant/v1beta1/feegrant.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";

// Query defines the gRPC querier service.
service Query {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";

// Msg defines the feegrant msg service.
service Msg {
Expand Down
16 changes: 8 additions & 8 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant/types"
feegrant_m "github.com/cosmos/cosmos-sdk/x/feegrant/module"
Copy link
Contributor

@atheeshp atheeshp May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this package name okay? shouldn't we consider feegrantmodule here? I can see a name feegrantkeeper which is similar to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to make it consistent with @robert-zaremba's PR on authz updates #9042 but I'm open to change it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for feegrantmodule even though it's longer because it's easier to read.

"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
Expand Down Expand Up @@ -113,7 +113,7 @@ var (
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
feegrant.AppModuleBasic{},
feegrant_m.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
authz.AppModuleBasic{},
Expand Down Expand Up @@ -206,7 +206,7 @@ func NewSimApp(
keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegranttypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
authztypes.StoreKey,
)
Expand Down Expand Up @@ -256,7 +256,7 @@ func NewSimApp(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey], app.AccountKeeper)
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

// register the staking hooks
Expand Down Expand Up @@ -309,7 +309,7 @@ func NewSimApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
feegrant_m.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -340,7 +340,7 @@ func NewSimApp(
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
genutiltypes.ModuleName, evidencetypes.ModuleName, authztypes.ModuleName,
feegranttypes.ModuleName,
feegrant.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand All @@ -359,7 +359,7 @@ func NewSimApp(
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
feegrant_m.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
Expand Down
6 changes: 3 additions & 3 deletions simapp/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/evidence"
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant"
feegrant_m "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/mint"
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestRunMigrations(t *testing.T) {
"params": params.AppModule{}.ConsensusVersion(),
"upgrade": upgrade.AppModule{}.ConsensusVersion(),
"vesting": vesting.AppModule{}.ConsensusVersion(),
"feegrant": feegrant.AppModule{}.ConsensusVersion(),
"feegrant": feegrant_m.AppModule{}.ConsensusVersion(),
"evidence": evidence.AppModule{}.ConsensusVersion(),
"crisis": crisis.AppModule{}.ConsensusVersion(),
"genutil": genutil.AppModule{}.ConsensusVersion(),
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"params": params.AppModule{}.ConsensusVersion(),
"upgrade": upgrade.AppModule{}.ConsensusVersion(),
"vesting": vesting.AppModule{}.ConsensusVersion(),
"feegrant": feegrant.AppModule{}.ConsensusVersion(),
"feegrant": feegrant_m.AppModule{}.ConsensusVersion(),
"evidence": evidence.AppModule{}.ConsensusVersion(),
"crisis": crisis.AppModule{}.ConsensusVersion(),
"genutil": genutil.AppModule{}.ConsensusVersion(),
Expand Down
6 changes: 3 additions & 3 deletions x/auth/ante/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
authsign "github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

func (suite *AnteTestSuite) TestDeductFeesNoDelegation() {
Expand Down Expand Up @@ -54,13 +54,13 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() {
suite.Require().NoError(err)

// grant fee allowance from `addr2` to `addr3` (plenty to pay)
err = app.FeeGrantKeeper.GrantAllowance(ctx, addr2, addr3, &types.BasicAllowance{
err = app.FeeGrantKeeper.GrantAllowance(ctx, addr2, addr3, &feegrant.BasicAllowance{
SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)),
})
suite.Require().NoError(err)

// grant low fee allowance (20atom), to check the tx requesting more than allowed.
err = app.FeeGrantKeeper.GrantAllowance(ctx, addr2, addr4, &types.BasicAllowance{
err = app.FeeGrantKeeper.GrantAllowance(ctx, addr2, addr4, &feegrant.BasicAllowance{
SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)),
})
suite.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion x/feegrant/types/basic_fee.go → x/feegrant/basic_fee.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types
package feegrant

import (
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
26 changes: 13 additions & 13 deletions x/feegrant/types/basic_fee_test.go → x/feegrant/basic_fee_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types_test
package feegrant_test

import (
"testing"
Expand All @@ -10,15 +10,15 @@ import (

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

func TestBasicFeeValidAllow(t *testing.T) {
app := simapp.Setup(false)

ctx := app.BaseApp.NewContext(false, tmproto.Header{})
badTime := ctx.BlockTime().AddDate(0, 0, -1)
allowace := &types.BasicAllowance{
allowace := &feegrant.BasicAllowance{
Expiration: &badTime,
}
require.Error(t, allowace.ValidateBasic())
Expand All @@ -35,7 +35,7 @@ func TestBasicFeeValidAllow(t *testing.T) {
oneHour := now.Add(1 * time.Hour)

cases := map[string]struct {
allowance *types.BasicAllowance
allowance *feegrant.BasicAllowance
// all other checks are ignored if valid=false
fee sdk.Coins
blockTime time.Time
Expand All @@ -45,11 +45,11 @@ func TestBasicFeeValidAllow(t *testing.T) {
remains sdk.Coins
}{
"empty": {
allowance: &types.BasicAllowance{},
allowance: &feegrant.BasicAllowance{},
accept: true,
},
"small fee without expire": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
SpendLimit: atom,
},
fee: smallAtom,
Expand All @@ -58,22 +58,22 @@ func TestBasicFeeValidAllow(t *testing.T) {
remains: leftAtom,
},
"all fee without expire": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
SpendLimit: smallAtom,
},
fee: smallAtom,
accept: true,
remove: true,
},
"wrong fee": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
SpendLimit: smallAtom,
},
fee: eth,
accept: false,
},
"non-expired": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
SpendLimit: atom,
Expiration: &oneHour,
},
Expand All @@ -85,7 +85,7 @@ func TestBasicFeeValidAllow(t *testing.T) {
remains: leftAtom,
},
"expired": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
SpendLimit: atom,
Expiration: &now,
},
Expand All @@ -96,7 +96,7 @@ func TestBasicFeeValidAllow(t *testing.T) {
remove: true,
},
"fee more than allowed": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
SpendLimit: atom,
Expiration: &oneHour,
},
Expand All @@ -106,7 +106,7 @@ func TestBasicFeeValidAllow(t *testing.T) {
accept: false,
},
"with out spend limit": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
Expiration: &oneHour,
},
valid: true,
Expand All @@ -115,7 +115,7 @@ func TestBasicFeeValidAllow(t *testing.T) {
accept: true,
},
"expired no spend limit": {
allowance: &types.BasicAllowance{
allowance: &feegrant.BasicAllowance{
Expiration: &now,
},
valid: true,
Expand Down
12 changes: 6 additions & 6 deletions x/feegrant/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/feegrant/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd() *cobra.Command {
feegrantQueryCmd := &cobra.Command{
Use: types.ModuleName,
Use: feegrant.ModuleName,
Short: "Querying commands for the feegrant module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
Expand Down Expand Up @@ -47,7 +47,7 @@ $ %s query feegrant grant [granter] [grantee]
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := types.NewQueryClient(clientCtx)
queryClient := feegrant.NewQueryClient(clientCtx)

granterAddr, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand All @@ -61,7 +61,7 @@ $ %s query feegrant grant [granter] [grantee]

res, err := queryClient.Allowance(
cmd.Context(),
&types.QueryAllowanceRequest{
&feegrant.QueryAllowanceRequest{
Granter: granterAddr.String(),
Grantee: granteeAddr.String(),
},
Expand Down Expand Up @@ -95,7 +95,7 @@ $ %s query feegrant grants [grantee]
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := types.NewQueryClient(clientCtx)
queryClient := feegrant.NewQueryClient(clientCtx)

granteeAddr, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand All @@ -109,7 +109,7 @@ $ %s query feegrant grants [grantee]

res, err := queryClient.Allowances(
cmd.Context(),
&types.QueryAllowancesRequest{
&feegrant.QueryAllowancesRequest{
Grantee: granteeAddr.String(),
Pagination: pageReq,
},
Expand Down
Loading