Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 686436f

Browse files
committed
scaffold story module
1 parent 16f5d9e commit 686436f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10491
-0
lines changed

app/app.go

+27
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ import (
9696
monitoringptypes "github.com/tendermint/spn/x/monitoringp/types"
9797

9898
"github.com/web-tree/story/docs"
99+
storymodule "github.com/web-tree/story/x/story"
100+
storymodulekeeper "github.com/web-tree/story/x/story/keeper"
101+
storymoduletypes "github.com/web-tree/story/x/story/types"
99102
// this line is used by starport scaffolding # stargate/app/moduleImport
100103
)
101104

@@ -149,6 +152,7 @@ var (
149152
transfer.AppModuleBasic{},
150153
vesting.AppModuleBasic{},
151154
monitoringp.AppModuleBasic{},
155+
storymodule.AppModuleBasic{},
152156
// this line is used by starport scaffolding # stargate/app/moduleBasic
153157
)
154158

@@ -220,6 +224,8 @@ type App struct {
220224
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
221225
ScopedMonitoringKeeper capabilitykeeper.ScopedKeeper
222226

227+
ScopedStoryKeeper capabilitykeeper.ScopedKeeper
228+
StoryKeeper storymodulekeeper.Keeper
223229
// this line is used by starport scaffolding # stargate/app/keeperDeclaration
224230

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

379+
scopedStoryKeeper := app.CapabilityKeeper.ScopeToModule(storymoduletypes.ModuleName)
380+
app.ScopedStoryKeeper = scopedStoryKeeper
381+
app.StoryKeeper = *storymodulekeeper.NewKeeper(
382+
appCodec,
383+
keys[storymoduletypes.StoreKey],
384+
keys[storymoduletypes.MemStoreKey],
385+
app.GetSubspace(storymoduletypes.ModuleName),
386+
app.IBCKeeper.ChannelKeeper,
387+
&app.IBCKeeper.PortKeeper,
388+
scopedStoryKeeper,
389+
)
390+
storyModule := storymodule.NewAppModule(appCodec, app.StoryKeeper, app.AccountKeeper, app.BankKeeper)
391+
372392
// this line is used by starport scaffolding # stargate/app/keeperDefinition
373393

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

@@ -409,6 +430,7 @@ func New(
409430
params.NewAppModule(app.ParamsKeeper),
410431
transferModule,
411432
monitoringModule,
433+
storyModule,
412434
// this line is used by starport scaffolding # stargate/app/appModule
413435
)
414436

@@ -435,6 +457,7 @@ func New(
435457
feegrant.ModuleName,
436458
paramstypes.ModuleName,
437459
monitoringptypes.ModuleName,
460+
storymoduletypes.ModuleName,
438461
// this line is used by starport scaffolding # stargate/app/beginBlockers
439462
)
440463

@@ -457,6 +480,7 @@ func New(
457480
ibchost.ModuleName,
458481
ibctransfertypes.ModuleName,
459482
monitoringptypes.ModuleName,
483+
storymoduletypes.ModuleName,
460484
// this line is used by starport scaffolding # stargate/app/endBlockers
461485
)
462486

@@ -484,6 +508,7 @@ func New(
484508
ibctransfertypes.ModuleName,
485509
feegrant.ModuleName,
486510
monitoringptypes.ModuleName,
511+
storymoduletypes.ModuleName,
487512
// this line is used by starport scaffolding # stargate/app/initGenesis
488513
)
489514

@@ -507,6 +532,7 @@ func New(
507532
ibc.NewAppModule(app.IBCKeeper),
508533
transferModule,
509534
monitoringModule,
535+
storyModule,
510536
// this line is used by starport scaffolding # stargate/app/appModule
511537
)
512538
app.sm.RegisterStoreDecoders()
@@ -696,6 +722,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
696722
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
697723
paramsKeeper.Subspace(ibchost.ModuleName)
698724
paramsKeeper.Subspace(monitoringptypes.ModuleName)
725+
paramsKeeper.Subspace(storymoduletypes.ModuleName)
699726
// this line is used by starport scaffolding # stargate/app/paramSubspace
700727

701728
return paramsKeeper

docs/static/openapi.yml

+46
Original file line numberDiff line numberDiff line change
@@ -28270,6 +28270,42 @@ paths:
2827028270
additionalProperties: {}
2827128271
tags:
2827228272
- Query
28273+
/webtree/story/story/params:
28274+
get:
28275+
summary: Parameters queries the parameters of the module.
28276+
operationId: WebtreeStoryStoryParams
28277+
responses:
28278+
'200':
28279+
description: A successful response.
28280+
schema:
28281+
type: object
28282+
properties:
28283+
params:
28284+
description: params holds all the parameters of this module.
28285+
type: object
28286+
description: >-
28287+
QueryParamsResponse is response type for the Query/Params RPC
28288+
method.
28289+
default:
28290+
description: An unexpected error response.
28291+
schema:
28292+
type: object
28293+
properties:
28294+
code:
28295+
type: integer
28296+
format: int32
28297+
message:
28298+
type: string
28299+
details:
28300+
type: array
28301+
items:
28302+
type: object
28303+
properties:
28304+
'@type':
28305+
type: string
28306+
additionalProperties: {}
28307+
tags:
28308+
- Query
2827328309
definitions:
2827428310
cosmos.auth.v1beta1.Params:
2827528311
type: object
@@ -48466,3 +48502,13 @@ definitions:
4846648502
title: >-
4846748503
SignatureCounts contains information about signature reporting for a
4846848504
number of blocks
48505+
webtree.story.story.Params:
48506+
type: object
48507+
description: Params defines the parameters for the module.
48508+
webtree.story.story.QueryParamsResponse:
48509+
type: object
48510+
properties:
48511+
params:
48512+
description: params holds all the parameters of this module.
48513+
type: object
48514+
description: QueryParamsResponse is response type for the Query/Params RPC method.

go.mod

+8
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ go 1.16
55
require (
66
github.com/cosmos/cosmos-sdk v0.45.3
77
github.com/cosmos/ibc-go/v2 v2.0.3
8+
github.com/gogo/protobuf v1.3.3
9+
github.com/golang/protobuf v1.5.2
10+
github.com/gorilla/mux v1.8.0
11+
github.com/grpc-ecosystem/grpc-gateway v1.16.0
812
github.com/ignite-hq/cli v0.20.3
913
github.com/spf13/cast v1.4.1
14+
github.com/spf13/cobra v1.4.0
1015
github.com/stretchr/testify v1.7.1
1116
github.com/tendermint/spn v0.1.1-0.20220407154406-5cfd1bf28150
1217
github.com/tendermint/tendermint v0.34.19
1318
github.com/tendermint/tm-db v0.6.6
19+
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e
20+
google.golang.org/grpc v1.45.0
21+
gopkg.in/yaml.v2 v2.4.0
1422
)
1523

1624
replace (

proto/story/genesis.proto

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
package webtree.story.story;
3+
4+
import "gogoproto/gogo.proto";
5+
import "story/params.proto";
6+
// this line is used by starport scaffolding # genesis/proto/import
7+
8+
option go_package = "github.com/web-tree/story/x/story/types";
9+
10+
// GenesisState defines the story module's genesis state.
11+
message GenesisState {
12+
Params params = 1 [(gogoproto.nullable) = false];
13+
string port_id = 2;
14+
// this line is used by starport scaffolding # genesis/proto/state
15+
}

proto/story/packet.proto

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
syntax = "proto3";
2+
package webtree.story.story;
3+
4+
// this line is used by starport scaffolding # proto/packet/import
5+
6+
option go_package = "github.com/web-tree/story/x/story/types";
7+
8+
message StoryPacketData {
9+
oneof packet {
10+
NoData noData = 1;
11+
// this line is used by starport scaffolding # ibc/packet/proto/field
12+
}
13+
}
14+
15+
message NoData {
16+
}
17+
18+
// this line is used by starport scaffolding # ibc/packet/proto/message

proto/story/params.proto

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto3";
2+
package webtree.story.story;
3+
4+
import "gogoproto/gogo.proto";
5+
6+
option go_package = "github.com/web-tree/story/x/story/types";
7+
8+
// Params defines the parameters for the module.
9+
message Params {
10+
option (gogoproto.goproto_stringer) = false;
11+
12+
}

proto/story/query.proto

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
syntax = "proto3";
2+
package webtree.story.story;
3+
4+
import "gogoproto/gogo.proto";
5+
import "google/api/annotations.proto";
6+
import "cosmos/base/query/v1beta1/pagination.proto";
7+
import "story/params.proto";
8+
// this line is used by starport scaffolding # 1
9+
10+
option go_package = "github.com/web-tree/story/x/story/types";
11+
12+
// Query defines the gRPC querier service.
13+
service Query {
14+
// Parameters queries the parameters of the module.
15+
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
16+
option (google.api.http).get = "/webtree/story/story/params";
17+
}
18+
// this line is used by starport scaffolding # 2
19+
}
20+
21+
// QueryParamsRequest is request type for the Query/Params RPC method.
22+
message QueryParamsRequest {}
23+
24+
// QueryParamsResponse is response type for the Query/Params RPC method.
25+
message QueryParamsResponse {
26+
// params holds all the parameters of this module.
27+
Params params = 1 [(gogoproto.nullable) = false];
28+
}
29+
30+
// this line is used by starport scaffolding # 3

proto/story/tx.proto

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
syntax = "proto3";
2+
package webtree.story.story;
3+
4+
// this line is used by starport scaffolding # proto/tx/import
5+
6+
option go_package = "github.com/web-tree/story/x/story/types";
7+
8+
// Msg defines the Msg service.
9+
service Msg {
10+
// this line is used by starport scaffolding # proto/tx/rpc
11+
}
12+
13+
// this line is used by starport scaffolding # proto/tx/message

testutil/keeper/story.go

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package keeper
2+
3+
import (
4+
"testing"
5+
6+
"github.com/cosmos/cosmos-sdk/codec"
7+
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
8+
"github.com/cosmos/cosmos-sdk/store"
9+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
10+
sdk "github.com/cosmos/cosmos-sdk/types"
11+
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
12+
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
13+
ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper"
14+
"github.com/stretchr/testify/require"
15+
"github.com/tendermint/tendermint/libs/log"
16+
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
17+
tmdb "github.com/tendermint/tm-db"
18+
"github.com/web-tree/story/x/story/keeper"
19+
"github.com/web-tree/story/x/story/types"
20+
)
21+
22+
func StoryKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
23+
logger := log.NewNopLogger()
24+
25+
storeKey := sdk.NewKVStoreKey(types.StoreKey)
26+
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
27+
28+
db := tmdb.NewMemDB()
29+
stateStore := store.NewCommitMultiStore(db)
30+
stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db)
31+
stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil)
32+
require.NoError(t, stateStore.LoadLatestVersion())
33+
34+
registry := codectypes.NewInterfaceRegistry()
35+
appCodec := codec.NewProtoCodec(registry)
36+
capabilityKeeper := capabilitykeeper.NewKeeper(appCodec, storeKey, memStoreKey)
37+
38+
ss := typesparams.NewSubspace(appCodec,
39+
types.Amino,
40+
storeKey,
41+
memStoreKey,
42+
"StorySubSpace",
43+
)
44+
IBCKeeper := ibckeeper.NewKeeper(
45+
appCodec,
46+
storeKey,
47+
ss,
48+
nil,
49+
nil,
50+
capabilityKeeper.ScopeToModule("StoryIBCKeeper"),
51+
)
52+
53+
paramsSubspace := typesparams.NewSubspace(appCodec,
54+
types.Amino,
55+
storeKey,
56+
memStoreKey,
57+
"StoryParams",
58+
)
59+
k := keeper.NewKeeper(
60+
appCodec,
61+
storeKey,
62+
memStoreKey,
63+
paramsSubspace,
64+
IBCKeeper.ChannelKeeper,
65+
&IBCKeeper.PortKeeper,
66+
capabilityKeeper.ScopeToModule("StoryScopedKeeper"),
67+
)
68+
69+
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, logger)
70+
71+
// Initialize params
72+
k.SetParams(ctx, types.DefaultParams())
73+
74+
return k, ctx
75+
}

vue/src/store/generated/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import CosmosIbcGoIbcCoreChannelV1 from './cosmos/ibc-go/ibc.core.channel.v1'
2020
import CosmosIbcGoIbcCoreClientV1 from './cosmos/ibc-go/ibc.core.client.v1'
2121
import CosmosIbcGoIbcCoreConnectionV1 from './cosmos/ibc-go/ibc.core.connection.v1'
2222
import CosmosIbcGoIbcCorePortV1 from './cosmos/ibc-go/ibc.core.port.v1'
23+
import WebTreeStoryWebtreeStoryStory from './web-tree/story/webtree.story.story'
2324

2425

2526
export default {
@@ -43,6 +44,7 @@ export default {
4344
CosmosIbcGoIbcCoreClientV1: load(CosmosIbcGoIbcCoreClientV1, 'ibc.core.client.v1'),
4445
CosmosIbcGoIbcCoreConnectionV1: load(CosmosIbcGoIbcCoreConnectionV1, 'ibc.core.connection.v1'),
4546
CosmosIbcGoIbcCorePortV1: load(CosmosIbcGoIbcCorePortV1, 'ibc.core.port.v1'),
47+
WebTreeStoryWebtreeStoryStory: load(WebTreeStoryWebtreeStoryStory, 'webtree.story.story'),
4648

4749
}
4850

0 commit comments

Comments
 (0)