Skip to content

Commit

Permalink
scaffold story module
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-Levitskiy committed Apr 30, 2022
1 parent 16f5d9e commit 686436f
Show file tree
Hide file tree
Showing 58 changed files with 10,491 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ import (
monitoringptypes "github.com/tendermint/spn/x/monitoringp/types"

"github.com/web-tree/story/docs"
storymodule "github.com/web-tree/story/x/story"
storymodulekeeper "github.com/web-tree/story/x/story/keeper"
storymoduletypes "github.com/web-tree/story/x/story/types"
// this line is used by starport scaffolding # stargate/app/moduleImport
)

Expand Down Expand Up @@ -149,6 +152,7 @@ var (
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
monitoringp.AppModuleBasic{},
storymodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -220,6 +224,8 @@ type App struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedMonitoringKeeper capabilitykeeper.ScopedKeeper

ScopedStoryKeeper capabilitykeeper.ScopedKeeper
StoryKeeper storymodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -256,6 +262,7 @@ func New(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, monitoringptypes.StoreKey,
storymoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -369,12 +376,26 @@ func New(
)
monitoringModule := monitoringp.NewAppModule(appCodec, app.MonitoringKeeper)

scopedStoryKeeper := app.CapabilityKeeper.ScopeToModule(storymoduletypes.ModuleName)
app.ScopedStoryKeeper = scopedStoryKeeper
app.StoryKeeper = *storymodulekeeper.NewKeeper(
appCodec,
keys[storymoduletypes.StoreKey],
keys[storymoduletypes.MemStoreKey],
app.GetSubspace(storymoduletypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedStoryKeeper,
)
storyModule := storymodule.NewAppModule(appCodec, app.StoryKeeper, app.AccountKeeper, app.BankKeeper)

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

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
ibcRouter.AddRoute(monitoringptypes.ModuleName, monitoringModule)
ibcRouter.AddRoute(storymoduletypes.ModuleName, storyModule)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

Expand Down Expand Up @@ -409,6 +430,7 @@ func New(
params.NewAppModule(app.ParamsKeeper),
transferModule,
monitoringModule,
storyModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand All @@ -435,6 +457,7 @@ func New(
feegrant.ModuleName,
paramstypes.ModuleName,
monitoringptypes.ModuleName,
storymoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand All @@ -457,6 +480,7 @@ func New(
ibchost.ModuleName,
ibctransfertypes.ModuleName,
monitoringptypes.ModuleName,
storymoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -484,6 +508,7 @@ func New(
ibctransfertypes.ModuleName,
feegrant.ModuleName,
monitoringptypes.ModuleName,
storymoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand All @@ -507,6 +532,7 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
transferModule,
monitoringModule,
storyModule,
// this line is used by starport scaffolding # stargate/app/appModule
)
app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -696,6 +722,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(monitoringptypes.ModuleName)
paramsKeeper.Subspace(storymoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
46 changes: 46 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28270,6 +28270,42 @@ paths:
additionalProperties: {}
tags:
- Query
/webtree/story/story/params:
get:
summary: Parameters queries the parameters of the module.
operationId: WebtreeStoryStoryParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
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.Params:
type: object
Expand Down Expand Up @@ -48466,3 +48502,13 @@ definitions:
title: >-
SignatureCounts contains information about signature reporting for a
number of blocks
webtree.story.story.Params:
type: object
description: Params defines the parameters for the module.
webtree.story.story.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ go 1.16
require (
github.com/cosmos/cosmos-sdk v0.45.3
github.com/cosmos/ibc-go/v2 v2.0.3
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/ignite-hq/cli v0.20.3
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.1
github.com/tendermint/spn v0.1.1-0.20220407154406-5cfd1bf28150
github.com/tendermint/tendermint v0.34.19
github.com/tendermint/tm-db v0.6.6
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e
google.golang.org/grpc v1.45.0
gopkg.in/yaml.v2 v2.4.0
)

replace (
Expand Down
15 changes: 15 additions & 0 deletions proto/story/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package webtree.story.story;

import "gogoproto/gogo.proto";
import "story/params.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/web-tree/story/x/story/types";

// GenesisState defines the story module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
string port_id = 2;
// this line is used by starport scaffolding # genesis/proto/state
}
18 changes: 18 additions & 0 deletions proto/story/packet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package webtree.story.story;

// this line is used by starport scaffolding # proto/packet/import

option go_package = "github.com/web-tree/story/x/story/types";

message StoryPacketData {
oneof packet {
NoData noData = 1;
// this line is used by starport scaffolding # ibc/packet/proto/field
}
}

message NoData {
}

// this line is used by starport scaffolding # ibc/packet/proto/message
12 changes: 12 additions & 0 deletions proto/story/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package webtree.story.story;

import "gogoproto/gogo.proto";

option go_package = "github.com/web-tree/story/x/story/types";

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

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

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "story/params.proto";
// this line is used by starport scaffolding # 1

option go_package = "github.com/web-tree/story/x/story/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 = "/webtree/story/story/params";
}
// this line is used by starport scaffolding # 2
}

// 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];
}

// this line is used by starport scaffolding # 3
13 changes: 13 additions & 0 deletions proto/story/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package webtree.story.story;

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/web-tree/story/x/story/types";

// Msg defines the Msg service.
service Msg {
// this line is used by starport scaffolding # proto/tx/rpc
}

// this line is used by starport scaffolding # proto/tx/message
75 changes: 75 additions & 0 deletions testutil/keeper/story.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package keeper

import (
"testing"

"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"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"
"github.com/web-tree/story/x/story/keeper"
"github.com/web-tree/story/x/story/types"
)

func StoryKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
logger := log.NewNopLogger()

storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

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

registry := codectypes.NewInterfaceRegistry()
appCodec := codec.NewProtoCodec(registry)
capabilityKeeper := capabilitykeeper.NewKeeper(appCodec, storeKey, memStoreKey)

ss := typesparams.NewSubspace(appCodec,
types.Amino,
storeKey,
memStoreKey,
"StorySubSpace",
)
IBCKeeper := ibckeeper.NewKeeper(
appCodec,
storeKey,
ss,
nil,
nil,
capabilityKeeper.ScopeToModule("StoryIBCKeeper"),
)

paramsSubspace := typesparams.NewSubspace(appCodec,
types.Amino,
storeKey,
memStoreKey,
"StoryParams",
)
k := keeper.NewKeeper(
appCodec,
storeKey,
memStoreKey,
paramsSubspace,
IBCKeeper.ChannelKeeper,
&IBCKeeper.PortKeeper,
capabilityKeeper.ScopeToModule("StoryScopedKeeper"),
)

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

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

return k, ctx
}
2 changes: 2 additions & 0 deletions vue/src/store/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import CosmosIbcGoIbcCoreChannelV1 from './cosmos/ibc-go/ibc.core.channel.v1'
import CosmosIbcGoIbcCoreClientV1 from './cosmos/ibc-go/ibc.core.client.v1'
import CosmosIbcGoIbcCoreConnectionV1 from './cosmos/ibc-go/ibc.core.connection.v1'
import CosmosIbcGoIbcCorePortV1 from './cosmos/ibc-go/ibc.core.port.v1'
import WebTreeStoryWebtreeStoryStory from './web-tree/story/webtree.story.story'


export default {
Expand All @@ -43,6 +44,7 @@ export default {
CosmosIbcGoIbcCoreClientV1: load(CosmosIbcGoIbcCoreClientV1, 'ibc.core.client.v1'),
CosmosIbcGoIbcCoreConnectionV1: load(CosmosIbcGoIbcCoreConnectionV1, 'ibc.core.connection.v1'),
CosmosIbcGoIbcCorePortV1: load(CosmosIbcGoIbcCorePortV1, 'ibc.core.port.v1'),
WebTreeStoryWebtreeStoryStory: load(WebTreeStoryWebtreeStoryStory, 'webtree.story.story'),

}

Expand Down
Loading

0 comments on commit 686436f

Please sign in to comment.