Skip to content

Commit

Permalink
wasmd 0.41 + wasmvm 1.3 (no more type/keeper alias)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Aug 1, 2023
1 parent 20e6d0b commit b52df27
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 104 deletions.
4 changes: 2 additions & 2 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
builderante "github.com/skip-mev/pob/x/builder/ante"
builderkeeper "github.com/skip-mev/pob/x/builder/keeper"

Expand Down Expand Up @@ -38,7 +38,7 @@ type HandlerOptions struct {
FeeShareKeeper feesharekeeper.Keeper
BankKeeperFork feeshareante.BankKeeper
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
WasmConfig wasmtypes.WasmConfig
Cdc codec.BinaryCodec

BypassMinFeeMsgTypes []string
Expand Down
20 changes: 10 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"strings"

"github.com/CosmWasm/wasmd/x/wasm"
wasm "github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -152,23 +152,23 @@ func SetAddressPrefixes() {

// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
// produce a list of enabled proposals to pass into wasmd app.
func GetEnabledProposals() []wasm.ProposalType {
func GetEnabledProposals() []wasmtypes.ProposalType {
if EnableSpecificProposals == "" {
if ProposalsEnabled == "true" {
return wasm.EnableAllProposals
return wasmtypes.EnableAllProposals
}
return wasm.DisableAllProposals
return wasmtypes.DisableAllProposals
}
chunks := strings.Split(EnableSpecificProposals, ",")
proposals, err := wasm.ConvertToProposals(chunks)
proposals, err := wasmtypes.ConvertToProposals(chunks)
if err != nil {
panic(err)
}
return proposals
}

func GetWasmOpts(appOpts servertypes.AppOptions) []wasm.Option {
var wasmOpts []wasm.Option
func GetWasmOpts(appOpts servertypes.AppOptions) []wasmkeeper.Option {
var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}
Expand Down Expand Up @@ -229,9 +229,9 @@ func New(
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
enabledProposals []wasm.ProposalType,
enabledProposals []wasmtypes.ProposalType,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
wasmOpts []wasmkeeper.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
encodingConfig := MakeEncodingConfig()
Expand Down Expand Up @@ -354,7 +354,7 @@ func New(
IBCKeeper: app.AppKeepers.IBCKeeper,
FeeShareKeeper: app.AppKeepers.FeeShareKeeper,
BankKeeperFork: app.AppKeepers.BankKeeper, // since we need extra methods
TxCounterStoreKey: app.AppKeepers.GetKey(wasm.StoreKey),
TxCounterStoreKey: app.AppKeepers.GetKey(wasmtypes.StoreKey),
WasmConfig: wasmConfig,
Cdc: appCodec,

Expand Down
25 changes: 13 additions & 12 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
builderkeeper "github.com/skip-mev/pob/x/builder/keeper"
buildertypes "github.com/skip-mev/pob/x/builder/types"
"github.com/spf13/cast"
Expand Down Expand Up @@ -93,7 +94,7 @@ import (
)

var (
wasmCapabilities = "iterator,staking,stargate,token_factory,cosmwasm_1_1,cosmwasm_1_2"
wasmCapabilities = "iterator,staking,stargate,token_factory,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3"

tokenFactoryCapabilities = []string{
tokenfactorytypes.EnableBurnFrom,
Expand All @@ -115,7 +116,7 @@ var maccPerms = map[string][]string{
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
ibcfeetypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
wasmtypes.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
globalfee.ModuleName: nil,
buildertypes.ModuleName: nil,
Expand Down Expand Up @@ -167,7 +168,7 @@ type AppKeepers struct {
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

WasmKeeper wasm.Keeper
WasmKeeper wasmkeeper.Keeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper
TokenFactoryKeeper tokenfactorykeeper.Keeper

Expand All @@ -181,9 +182,9 @@ func NewAppKeepers(
bApp *baseapp.BaseApp,
cdc *codec.LegacyAmino,
maccPerms map[string][]string,
enabledProposals []wasm.ProposalType,
enabledProposals []wasmtypes.ProposalType,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
wasmOpts []wasmkeeper.Option,
) AppKeepers {
appKeepers := AppKeepers{}

Expand Down Expand Up @@ -218,7 +219,7 @@ func NewAppKeepers(
scopedICAHostKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICQKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)
scopedTransferKeeper := appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := appKeepers.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
scopedWasmKeeper := appKeepers.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)

// add keepers
Bech32Prefix := "juno"
Expand Down Expand Up @@ -513,9 +514,9 @@ func NewAppKeepers(
})
wasmOpts = append(wasmOpts, querierOpts)

appKeepers.WasmKeeper = wasm.NewKeeper(
appKeepers.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
appKeepers.keys[wasm.StoreKey],
appKeepers.keys[wasmtypes.StoreKey],
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.StakingKeeper,
Expand Down Expand Up @@ -553,7 +554,7 @@ func NewAppKeepers(
// register wasm gov proposal types
// The gov proposal types can be individually enabled
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(appKeepers.WasmKeeper, enabledProposals))
govRouter.AddRoute(wasmtypes.RouterKey, wasm.NewWasmProposalHandler(appKeepers.WasmKeeper, enabledProposals)) //nolint:staticcheck // we still need this despite the deprecation of the gov handler
}
// Set legacy router for backwards compatibility with gov v1beta1
appKeepers.GovKeeper.SetLegacyRouter(govRouter)
Expand Down Expand Up @@ -593,7 +594,7 @@ func NewAppKeepers(
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(wasm.ModuleName, wasmStack).
AddRoute(wasmtypes.ModuleName, wasmStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(icqtypes.ModuleName, icqModule)
Expand Down Expand Up @@ -639,7 +640,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(globalfee.ModuleName)
paramsKeeper.Subspace(tokenfactorytypes.ModuleName)
paramsKeeper.Subspace(feesharetypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(buildertypes.ModuleName)

return paramsKeeper
Expand Down Expand Up @@ -667,7 +668,7 @@ func (appKeepers *AppKeepers) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper
}

// GetWasmKeeper implements the TestingApp interface.
func (appKeepers *AppKeepers) GetWasmKeeper() wasm.Keeper {
func (appKeepers *AppKeepers) GetWasmKeeper() wasmkeeper.Keeper {
return appKeepers.WasmKeeper
}

Expand Down
4 changes: 2 additions & 2 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keepers

import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
buildertypes "github.com/skip-mev/pob/x/builder/types"

packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
Expand Down Expand Up @@ -47,7 +47,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {

// non sdk store keys
ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
wasm.StoreKey, icahosttypes.StoreKey,
wasmtypes.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, icqtypes.StoreKey,
packetforwardtypes.StoreKey,
ibchookstypes.StoreKey,
Expand Down
8 changes: 4 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app

import (
"github.com/CosmWasm/wasmd/x/wasm"
wasm "github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
buildermodule "github.com/skip-mev/pob/x/builder"
buildertypes "github.com/skip-mev/pob/x/builder/types"
Expand Down Expand Up @@ -221,7 +221,7 @@ func orderBeginBlockers() []string {
tokenfactorytypes.ModuleName,
feesharetypes.ModuleName,
globalfee.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
ibchookstypes.ModuleName,
}
}
Expand Down Expand Up @@ -257,7 +257,7 @@ func orderEndBlockers() []string {
tokenfactorytypes.ModuleName,
feesharetypes.ModuleName,
globalfee.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
ibchookstypes.ModuleName,
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ func orderInitBlockers() []string {
tokenfactorytypes.ModuleName,
feesharetypes.ModuleName,
globalfee.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
ibchookstypes.ModuleName,
}
}
7 changes: 4 additions & 3 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"path/filepath"
"testing"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/stretchr/testify/require"

dbm "github.com/cometbft/cometbft-db"
Expand Down Expand Up @@ -103,13 +104,13 @@ func TestFullAppSimulation(t *testing.T) {
appOptions[flags.FlagHome] = DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

var emptyWasmOption []wasm.Option
var emptyWasmOption []wasmkeeper.Option
app := New(
logger,
db,
nil,
true,
wasm.EnableAllProposals,
wasmtypes.EnableAllProposals,
appOptions,
emptyWasmOption,
fauxMerkleModeOpt,
Expand Down
10 changes: 5 additions & 5 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"
"time"

"github.com/CosmWasm/wasmd/x/wasm"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/stretchr/testify/require"

dbm "github.com/cometbft/cometbft-db"
Expand Down Expand Up @@ -136,7 +136,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
return junoApp
}

func setup(t *testing.T, withGenesis bool, opts ...wasm.Option) (*App, GenesisState) {
func setup(t *testing.T, withGenesis bool, opts ...wasmkeeper.Option) (*App, GenesisState) {
db := dbm.NewMemDB()
nodeHome := t.TempDir()
snapshotDir := filepath.Join(nodeHome, "data", "snapshots")
Expand All @@ -156,7 +156,7 @@ func setup(t *testing.T, withGenesis bool, opts ...wasm.Option) (*App, GenesisSt
db,
nil,
true,
wasm.EnableAllProposals,
wasmtypes.EnableAllProposals,
EmptyAppOptions{},
opts,
bam.SetChainID("testing"),
Expand Down Expand Up @@ -264,7 +264,7 @@ func ExecuteRawCustom(t *testing.T, ctx sdk.Context, app *App, contract sdk.AccA
coins = sdk.Coins{funds}
}

contractKeeper := keeper.NewDefaultPermissionKeeper(app.AppKeepers.WasmKeeper)
contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(app.AppKeepers.WasmKeeper)
_, err = contractKeeper.Execute(ctx, contract, sender, oracleBz, coins)
return err
}
6 changes: 3 additions & 3 deletions cmd/junod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"path/filepath"

"github.com/CosmWasm/wasmd/x/wasm"
wasm "github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -292,7 +292,7 @@ func (ac appCreator) newApp(
skipUpgradeHeights[int64(h)] = true
}

var wasmOpts []wasm.Option
var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}
Expand Down Expand Up @@ -330,7 +330,7 @@ func (ac appCreator) appExport(
}

loadLatest := height == -1
var emptyWasmOpts []wasm.Option
var emptyWasmOpts []wasmkeeper.Option
junoApp = app.New(
logger,
db,
Expand Down
Loading

0 comments on commit b52df27

Please sign in to comment.