Skip to content

Commit

Permalink
add clock module
Browse files Browse the repository at this point in the history
  • Loading branch information
tubackkhoa committed Jul 30, 2024
1 parent d9f3eaf commit b0e21d4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
27 changes: 25 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/CosmosContracts/juno/v18/x/clock"
clockkeeper "github.com/CosmosContracts/juno/v18/x/clock/keeper"
clocktypes "github.com/CosmosContracts/juno/v18/x/clock/types"
)

const appName = "WasmApp"
Expand Down Expand Up @@ -233,6 +237,9 @@ type WasmApp struct {
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

ContractKeeper *wasmkeeper.PermissionedKeeper
ClockKeeper clockkeeper.Keeper

// the module manager
ModuleManager *module.Manager
BasicModuleManager module.BasicManager
Expand Down Expand Up @@ -274,6 +281,7 @@ func NewWasmApp(

std.RegisterLegacyAminoCodec(legacyAmino)
std.RegisterInterfaces(interfaceRegistry)
clockkeeper.RegisterProposalTypes()

// Below we could construct and set an application specific mempool and
// ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are
Expand Down Expand Up @@ -323,7 +331,7 @@ func NewWasmApp(
// non sdk store keys
capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
wasmtypes.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
icacontrollertypes.StoreKey, clocktypes.StoreKey,
)

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -527,7 +535,8 @@ func NewWasmApp(
// See: https://docs.cosmos.network/main/modules/gov#proposal-messages
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper))
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(clocktypes.RouterKey, clockkeeper.NewClockProposalHandler(app.ClockKeeper))
govConfig := govtypes.DefaultConfig()
/*
Example of setting gov params:
Expand Down Expand Up @@ -651,6 +660,13 @@ func NewWasmApp(
wasmOpts...,
)

app.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)
app.ClockKeeper = clockkeeper.NewKeeper(
app.keys[clocktypes.StoreKey],
appCodec,
*app.ContractKeeper,
)

// Create fee enabled wasm ibc Stack
var wasmStack porttypes.IBCModule
wasmStackIBCHandler := wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
Expand Down Expand Up @@ -737,6 +753,7 @@ func NewWasmApp(
ibctm.AppModule{},
// sdk
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
clock.NewAppModule(appCodec, app.ClockKeeper),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand All @@ -752,6 +769,7 @@ func NewWasmApp(
paramsclient.ProposalHandler,
},
),
clocktypes.ModuleName: clock.AppModuleBasic{},
})
app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.BasicModuleManager.RegisterInterfaces(interfaceRegistry)
Expand Down Expand Up @@ -780,6 +798,7 @@ func NewWasmApp(
icatypes.ModuleName,
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
clocktypes.ModuleName,
)

app.ModuleManager.SetOrderEndBlockers(
Expand All @@ -796,6 +815,7 @@ func NewWasmApp(
icatypes.ModuleName,
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
clocktypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand All @@ -821,6 +841,7 @@ func NewWasmApp(
ibcfeetypes.ModuleName,
// wasm after ibc transfer
wasmtypes.ModuleName,
clocktypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1198,5 +1219,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable())

paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(clocktypes.ModuleName)

return paramsKeeper
}
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21

require (
github.com/CosmWasm/wasmvm/v2 v2.1.0
github.com/CosmosContracts/juno/v18/x/clock v0.0.0-00010101000000-000000000000
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.7
github.com/cosmos/gogogateway v1.2.0 // indirect
Expand Down Expand Up @@ -215,10 +216,13 @@ require (
replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

github.com/CosmosContracts/juno/v18/x/clock => github.com/oraichain/juno/x/clock v0.0.0-20240730044630-b70856e973de

// indexer and timestamp added
github.com/cometbft/cometbft => github.com/oraichain/cometbft v0.38.6-0.20240729034548-028d4fcc0fa4
// go list -m -json github.com/oraichain/[email protected] | jq '.|"\(.Path) \(.Version)"' -r
github.com/cosmos/cosmos-sdk => github.com/oraichain/cosmos-sdk v0.50.5-0.20240729032658-16fb0ec0a540

// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// See: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,8 @@ github.com/oraichain/cometbft v0.38.6-0.20240729034548-028d4fcc0fa4 h1:xxiGoC9su
github.com/oraichain/cometbft v0.38.6-0.20240729034548-028d4fcc0fa4/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc=
github.com/oraichain/cosmos-sdk v0.50.5-0.20240729032658-16fb0ec0a540 h1:eKScpVbDghsaMY/O7QrRZi1BvP6Q0JcQIJ367N0T2+A=
github.com/oraichain/cosmos-sdk v0.50.5-0.20240729032658-16fb0ec0a540/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s=
github.com/oraichain/juno/x/clock v0.0.0-20240730044630-b70856e973de h1:rY6c793v6tOaZC66ExXqt+3b9rY+hAi/Jh/EbmCD61U=
github.com/oraichain/juno/x/clock v0.0.0-20240730044630-b70856e973de/go.mod h1:JAaOF+0j23OoyEgd6uhE3cgNDpZcfVZx4/DBbnMjUsc=
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
Expand Down

0 comments on commit b0e21d4

Please sign in to comment.