Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
fix wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
nghuyenthevinh2000 committed Feb 15, 2022
1 parent 7d3b447 commit 1f56d06
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 23 deletions.
54 changes: 33 additions & 21 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,6 @@ func New(
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

// register wasm gov proposal types
enabledProposals := GetEnabledProposals()
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.wasmKeeper, enabledProposals))
}

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
Expand All @@ -401,18 +395,6 @@ func New(
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
)

app.AnoneKeeper = *anonemodulekeeper.NewKeeper(
appCodec,
keys[anonemoduletypes.StoreKey],
keys[anonemoduletypes.MemStoreKey],
)
anoneModule := anonemodule.NewAppModule(appCodec, app.AnoneKeeper)

wasmDir := filepath.Join(homePath, "data")

wasmConfig, err := wasm.ReadWasmConfig(appOpts)
Expand Down Expand Up @@ -443,6 +425,24 @@ func New(
wasmOpts...,
)

// register wasm gov proposal types
enabledProposals := GetEnabledProposals()
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.wasmKeeper, enabledProposals))
}

app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
)

app.AnoneKeeper = *anonemodulekeeper.NewKeeper(
appCodec,
keys[anonemoduletypes.StoreKey],
keys[anonemoduletypes.MemStoreKey],
)
anoneModule := anonemodule.NewAppModule(appCodec, app.AnoneKeeper)

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

// Create static IBC router, add transfer route, then set and seal it
Expand Down Expand Up @@ -493,12 +493,24 @@ func New(
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
ibchost.ModuleName,
feegrant.ModuleName,
wasm.ModuleName,
)

app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
wasm.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
Expand Down
4 changes: 2 additions & 2 deletions app/wasm_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
)

const (
// DefaultJunoInstanceCost is initially set the same as in wasmd
// DefaultAnoneInstanceCost is initially set the same as in wasmd
DefaultAnOneInstanceCost uint64 = 60_000
// DefaultJunoCompileCost set to a large number for testing
// DefaultAnoneCompileCost set to a large number for testing
DefaultAnOneCompileCost uint64 = 100
)

Expand Down
44 changes: 44 additions & 0 deletions cmd/anoned/genwasm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/notional-labs/anone/app"
"github.com/spf13/cobra"
"github.com/tendermint/spm/cosmoscmd"

"github.com/CosmWasm/wasmd/x/wasm"
wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli"
)

func AddGenesisWasmMsgCmd(defaultNodeHome string) *cobra.Command {
txCmd := &cobra.Command{
Use: "add-wasm-genesis-message",
Short: "Wasm genesis subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
genesisIO := wasmcli.NewDefaultGenesisIO()
txCmd.AddCommand(
wasmcli.GenesisStoreCodeCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisInstantiateContractCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisExecuteContractCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisListContractsCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisListCodesCmd(defaultNodeHome, genesisIO),
)

return txCmd
}

func GetWasmCmdOptions() []cosmoscmd.Option {
var options []cosmoscmd.Option

options = append(options,
cosmoscmd.CustomizeStartCmd(func(startCmd *cobra.Command) {
wasm.AddModuleInitFlags(startCmd)
}),
cosmoscmd.AddSubCmd(AddGenesisWasmMsgCmd(app.DefaultNodeHome)),
)

return options
}
2 changes: 2 additions & 0 deletions cmd/anoned/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func main() {
cmdOptions := GetWasmCmdOptions()
rootCmd, _ := cosmoscmd.NewRootCmd(
app.Name,
app.AccountAddressPrefix,
Expand All @@ -17,6 +18,7 @@ func main() {
app.ModuleBasics,
app.New,
// this line is used by starport scaffolding # root/arguments
cmdOptions...,
)
if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
os.Exit(1)
Expand Down

0 comments on commit 1f56d06

Please sign in to comment.