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

chore: scaffold supplier module #33

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 23 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ import (
pocketmodulekeeper "pocket/x/pocket/keeper"
pocketmoduletypes "pocket/x/pocket/types"

suppliermodule "pocket/x/supplier"
suppliermodulekeeper "pocket/x/supplier/keeper"
suppliermoduletypes "pocket/x/supplier/types"
// this line is used by starport scaffolding # stargate/app/moduleImport

appparams "pocket/app/params"
Expand Down Expand Up @@ -176,6 +179,7 @@ var (
vesting.AppModuleBasic{},
consensus.AppModuleBasic{},
pocketmodule.AppModuleBasic{},
suppliermodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand All @@ -189,6 +193,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
suppliermoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -252,6 +257,8 @@ type App struct {
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper

PocketKeeper pocketmodulekeeper.Keeper

SupplierKeeper suppliermodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -299,6 +306,7 @@ func New(
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, consensusparamtypes.StoreKey,
pocketmoduletypes.StoreKey,
suppliermoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -529,6 +537,16 @@ func New(
)
pocketModule := pocketmodule.NewAppModule(appCodec, app.PocketKeeper, 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 @@ -591,6 +609,7 @@ func New(
transferModule,
icaModule,
pocketModule,
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 @@ -624,6 +643,7 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
pocketmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand All @@ -650,6 +670,7 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
pocketmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -681,6 +702,7 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
pocketmoduletypes.ModuleName,
suppliermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -906,6 +928,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(pocketmoduletypes.ModuleName)
paramsKeeper.Subspace(suppliermoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
103 changes: 103 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46473,6 +46473,61 @@ paths:
additionalProperties: {}
tags:
- Query
/pocket/supplier/params:
get:
summary: Parameters queries the parameters of the module.
operationId: PocketSupplierParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
earlietClaimSubmissionOffset:
type: integer
format: int32
earliestProofSubmissionOffset:
type: integer
format: int32
latestClaimSubmissionBlocksInterval:
type: integer
format: int32
latestProofSubmissionBlocksInterval:
type: integer
format: int32
claimSubmissionBlocksWindow:
type: integer
format: int32
proofSubmissionBlocksWindow:
type: integer
format: int32
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
definitions:
cosmos.auth.v1beta1.AddressBytesToStringResponse:
type: object
Expand Down Expand Up @@ -75222,3 +75277,51 @@ definitions:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
pocket.supplier.Params:
type: object
properties:
earlietClaimSubmissionOffset:
type: integer
format: int32
earliestProofSubmissionOffset:
type: integer
format: int32
latestClaimSubmissionBlocksInterval:
type: integer
format: int32
latestProofSubmissionBlocksInterval:
type: integer
format: int32
claimSubmissionBlocksWindow:
type: integer
format: int32
proofSubmissionBlocksWindow:
type: integer
format: int32
description: Params defines the parameters for the module.
pocket.supplier.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
earlietClaimSubmissionOffset:
type: integer
format: int32
earliestProofSubmissionOffset:
type: integer
format: int32
latestClaimSubmissionBlocksInterval:
type: integer
format: int32
latestProofSubmissionBlocksInterval:
type: integer
format: int32
claimSubmissionBlocksWindow:
type: integer
format: int32
proofSubmissionBlocksWindow:
type: integer
format: int32
description: QueryParamsResponse is response type for the Query/Params RPC method.
12 changes: 12 additions & 0 deletions proto/pocket/supplier/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package pocket.supplier;

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

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

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

import "gogoproto/gogo.proto";

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

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

int32 earlietClaimSubmissionOffset = 1 [(gogoproto.moretags) = "yaml:\"earliet_claim_submission_offset\""];
int32 earliestProofSubmissionOffset = 2 [(gogoproto.moretags) = "yaml:\"earliest_proof_submission_offset\""];
int32 latestClaimSubmissionBlocksInterval = 3 [(gogoproto.moretags) = "yaml:\"latest_claim_submission_blocks_interval\""];
int32 latestProofSubmissionBlocksInterval = 4 [(gogoproto.moretags) = "yaml:\"latest_proof_submission_blocks_interval\""];
int32 claimSubmissionBlocksWindow = 5 [(gogoproto.moretags) = "yaml:\"claim_submission_blocks_window\""];
int32 proofSubmissionBlocksWindow = 6 [(gogoproto.moretags) = "yaml:\"proof_submission_blocks_window\""];
}
26 changes: 26 additions & 0 deletions proto/pocket/supplier/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";
package pocket.supplier;

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

option go_package = "pocket/x/supplier/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/supplier/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/supplier/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package pocket.supplier;

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

// Msg defines the Msg service.
service Msg {}
53 changes: 53 additions & 0 deletions testutil/keeper/supplier.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/supplier/keeper"
"pocket/x/supplier/types"
)

func SupplierKeeper(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,
"SupplierParams",
)
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/supplier/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/supplier/types"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string) *cobra.Command {
// Group supplier 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
}
Loading