Wire up wasm module to the application

This commit is contained in:
Ethan Frey
2019-11-22 18:15:14 +01:00
parent d79ff0cd19
commit 35aab0ee65
2 changed files with 19 additions and 3 deletions

View File

@@ -3,8 +3,12 @@ package app
import (
"io"
"os"
"path/filepath"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
@@ -29,6 +33,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
"github.com/cosmwasm/wasmd/x/wasm"
)
const appName = "WasmApp"
@@ -52,6 +58,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(paramsclient.ProposalHandler, distr.ProposalHandler),
params.AppModuleBasic{},
wasm.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
supply.AppModuleBasic{},
@@ -106,6 +113,7 @@ type WasmApp struct {
crisisKeeper crisis.Keeper
paramsKeeper params.Keeper
evidenceKeeper *evidence.Keeper
wasmKeeper wasm.Keeper
// the module manager
mm *module.Manager
@@ -129,7 +137,7 @@ func NewWasmApp(
keys := sdk.NewKVStoreKeys(
bam.MainStoreKey, auth.StoreKey, staking.StoreKey, supply.StoreKey,
mint.StoreKey, distr.StoreKey, slashing.StoreKey, gov.StoreKey,
params.StoreKey, evidence.StoreKey,
params.StoreKey, evidence.StoreKey, wasm.StoreKey,
)
tKeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)
@@ -168,6 +176,13 @@ func NewWasmApp(
)
app.crisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.supplyKeeper, auth.FeeCollectorName)
// just re-use the full router - do we want to limit this more?
var wasmRouter = bApp.Router()
// better way to get this dir???
homeDir := viper.GetString(cli.HomeFlag)
wasmDir := filepath.Join(homeDir, "wasm")
app.wasmKeeper = wasm.NewKeeper(app.cdc, keys[wasm.StoreKey], app.accountKeeper, app.bankKeeper, wasmRouter, wasmDir)
// create evidence keeper with evidence router
app.evidenceKeeper = evidence.NewKeeper(
app.cdc, keys[evidence.StoreKey], evidenceSubspace, evidence.DefaultCodespace,
@@ -206,6 +221,7 @@ func NewWasmApp(
slashing.NewAppModule(app.slashingKeeper, app.stakingKeeper),
staking.NewAppModule(app.stakingKeeper, app.accountKeeper, app.supplyKeeper),
evidence.NewAppModule(*app.evidenceKeeper),
wasm.NewAppModule(app.wasmKeeper),
)
// During begin block slashing happens after distr.BeginBlocker so that
@@ -220,7 +236,7 @@ func NewWasmApp(
app.mm.SetOrderInitGenesis(
distr.ModuleName, staking.ModuleName, auth.ModuleName, bank.ModuleName,
slashing.ModuleName, gov.ModuleName, mint.ModuleName, supply.ModuleName,
crisis.ModuleName, genutil.ModuleName, evidence.ModuleName,
crisis.ModuleName, genutil.ModuleName, evidence.ModuleName, wasm.ModuleName,
)
app.mm.RegisterInvariants(&app.crisisKeeper)

View File

@@ -60,7 +60,7 @@ func main() {
rootCmd.AddCommand(genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics))
rootCmd.AddCommand(AddGenesisAccountCmd(ctx, cdc, app.DefaultNodeHome, app.DefaultCLIHome))
rootCmd.AddCommand(client.NewCompletionCmd(rootCmd, true))
rootCmd.AddCommand(testnetCmd(ctx, cdc, app.ModuleBasics, auth.GenesisAccountIterator{}))
// rootCmd.AddCommand(testnetCmd(ctx, cdc, app.ModuleBasics, auth.GenesisAccountIterator{}))
rootCmd.AddCommand(replayCmd())
rootCmd.AddCommand(debug.Cmd(cdc))