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

[Service] Just scaffold the Service module without any params #37

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
49 changes: 36 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ import (
pocketmodulekeeper "pocket/x/pocket/keeper"
pocketmoduletypes "pocket/x/pocket/types"

servicemodule "pocket/x/service"
servicemodulekeeper "pocket/x/service/keeper"
servicemoduletypes "pocket/x/service/types"

sessionmodule "pocket/x/session"
sessionmodulekeeper "pocket/x/session/keeper"
sessionmoduletypes "pocket/x/session/types"
Expand Down Expand Up @@ -188,9 +192,10 @@ var (
vesting.AppModuleBasic{},
consensus.AppModuleBasic{},
pocketmodule.AppModuleBasic{},
suppliermodule.AppModuleBasic{},
servicemodule.AppModuleBasic{},
sessionmodule.AppModuleBasic{},
applicationmodule.AppModuleBasic{},
suppliermodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand All @@ -205,6 +210,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
suppliermoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
servicemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
applicationmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
Expand Down Expand Up @@ -269,9 +275,10 @@ type App struct {
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper

PocketKeeper pocketmodulekeeper.Keeper
SupplierKeeper suppliermodulekeeper.Keeper
ServiceKeeper servicemodulekeeper.Keeper
SessionKeeper sessionmodulekeeper.Keeper
ApplicationKeeper applicationmodulekeeper.Keeper
SupplierKeeper suppliermodulekeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

Expand Down Expand Up @@ -320,9 +327,10 @@ func New(
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, consensusparamtypes.StoreKey,
pocketmoduletypes.StoreKey,
suppliermoduletypes.StoreKey,
servicemoduletypes.StoreKey,
sessionmoduletypes.StoreKey,
applicationmoduletypes.StoreKey,
suppliermoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -553,15 +561,15 @@ func New(
)
pocketModule := pocketmodule.NewAppModule(appCodec, app.PocketKeeper, app.AccountKeeper, app.BankKeeper)

app.SupplierKeeper = *suppliermodulekeeper.NewKeeper(
app.ServiceKeeper = *servicemodulekeeper.NewKeeper(
appCodec,
keys[suppliermoduletypes.StoreKey],
keys[suppliermoduletypes.MemStoreKey],
app.GetSubspace(suppliermoduletypes.ModuleName),
keys[servicemoduletypes.StoreKey],
keys[servicemoduletypes.MemStoreKey],
app.GetSubspace(servicemoduletypes.ModuleName),

app.BankKeeper,
)
supplierModule := suppliermodule.NewAppModule(appCodec, app.SupplierKeeper, app.AccountKeeper, app.BankKeeper)
serviceModule := servicemodule.NewAppModule(appCodec, app.ServiceKeeper, app.AccountKeeper, app.BankKeeper)

app.SessionKeeper = *sessionmodulekeeper.NewKeeper(
appCodec,
Expand All @@ -581,6 +589,16 @@ func New(
)
applicationModule := applicationmodule.NewAppModule(appCodec, app.ApplicationKeeper, app.AccountKeeper, app.BankKeeper)

app.SupplierKeeper = *suppliermodulekeeper.NewKeeper(
appCodec,
keys[suppliermoduletypes.StoreKey],
keys[suppliermoduletypes.MemStoreKey],
app.GetSubspace(suppliermoduletypes.ModuleName),

app.BankKeeper,
)
supplierModule := suppliermodule.NewAppModule(appCodec, app.SupplierKeeper, app.AccountKeeper, app.BankKeeper)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

/**** IBC Routing ****/
Expand Down Expand Up @@ -643,9 +661,10 @@ func New(
transferModule,
icaModule,
pocketModule,
supplierModule,
serviceModule,
sessionModule,
applicationModule,
supplierModule,
// this line is used by starport scaffolding # stargate/app/appModule

crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
Expand Down Expand Up @@ -679,9 +698,10 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
pocketmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
servicemoduletypes.ModuleName,
sessionmoduletypes.ModuleName,
applicationmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand All @@ -708,9 +728,10 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
pocketmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
servicemoduletypes.ModuleName,
sessionmoduletypes.ModuleName,
applicationmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -742,9 +763,10 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
pocketmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
servicemoduletypes.ModuleName,
sessionmoduletypes.ModuleName,
applicationmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -970,9 +992,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(pocketmoduletypes.ModuleName)
paramsKeeper.Subspace(suppliermoduletypes.ModuleName)
paramsKeeper.Subspace(servicemoduletypes.ModuleName)
paramsKeeper.Subspace(sessionmoduletypes.ModuleName)
paramsKeeper.Subspace(applicationmoduletypes.ModuleName)
paramsKeeper.Subspace(suppliermoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
14 changes: 14 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46509,10 +46509,17 @@ paths:
additionalProperties: {}
tags:
- Query
<<<<<<< HEAD
/pocket/service/params:
get:
summary: Parameters queries the parameters of the module.
operationId: PocketServiceParams
=======
/pocket/session/params:
get:
summary: Parameters queries the parameters of the module.
operationId: PocketSessionParams
>>>>>>> main
responses:
'200':
description: A successful response.
Expand Down Expand Up @@ -75340,10 +75347,17 @@ definitions:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
<<<<<<< HEAD
pocket.service.Params:
type: object
description: Params defines the parameters for the module.
pocket.service.QueryParamsResponse:
=======
pocket.session.Params:
type: object
description: Params defines the parameters for the module.
pocket.session.QueryParamsResponse:
>>>>>>> main
type: object
properties:
params:
Expand Down
12 changes: 12 additions & 0 deletions proto/pocket/service/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package pocket.service;

import "gogoproto/gogo.proto";
import "pocket/service/params.proto";

option go_package = "pocket/x/service/types";

// GenesisState defines the service module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
}
12 changes: 12 additions & 0 deletions proto/pocket/service/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package pocket.service;

import "gogoproto/gogo.proto";

option go_package = "pocket/x/service/types";

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;

}
26 changes: 26 additions & 0 deletions proto/pocket/service/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";
package pocket.service;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "pocket/service/params.proto";

option go_package = "pocket/x/service/types";

// Query defines the gRPC querier service.
service Query {
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/pocket/service/params";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}
7 changes: 7 additions & 0 deletions proto/pocket/service/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package pocket.service;

option go_package = "pocket/x/service/types";

// Msg defines the Msg service.
service Msg {}
53 changes: 53 additions & 0 deletions testutil/keeper/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package keeper

import (
"testing"

tmdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/require"
"pocket/x/service/keeper"
"pocket/x/service/types"
)

func ServiceKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil)
require.NoError(t, stateStore.LoadLatestVersion())

registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
storeKey,
memStoreKey,
"ServiceParams",
)
k := keeper.NewKeeper(
cdc,
storeKey,
memStoreKey,
paramsSubspace,
nil,
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

// Initialize params
k.SetParams(ctx, types.DefaultParams())

return k, ctx
}
31 changes: 31 additions & 0 deletions x/service/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cli

import (
"fmt"
// "strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
// "github.com/cosmos/cosmos-sdk/client/flags"
// sdk "github.com/cosmos/cosmos-sdk/types"

"pocket/x/service/types"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string) *cobra.Command {
// Group service queries under a subcommand
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

cmd.AddCommand(CmdQueryParams())
// this line is used by starport scaffolding # 1

return cmd
}
36 changes: 36 additions & 0 deletions x/service/client/cli/query_params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

"pocket/x/service/types"
)

func CmdQueryParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "shows the parameters of the module",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading