Deprecate alias.go (#1484)

* Deprecate alias.go

* Fix comments
This commit is contained in:
pinosu
2023-07-06 11:43:08 +02:00
committed by GitHub
parent 63f73d3e6c
commit 0fd9ecd923
15 changed files with 308 additions and 202 deletions

View File

@@ -146,15 +146,15 @@ var (
// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
// produce a list of enabled proposals to pass into wasmd app. // produce a list of enabled proposals to pass into wasmd app.
func GetEnabledProposals() []wasm.ProposalType { func GetEnabledProposals() []wasmtypes.ProposalType {
if EnableSpecificProposals == "" { if EnableSpecificProposals == "" {
if ProposalsEnabled == "true" { if ProposalsEnabled == "true" {
return wasm.EnableAllProposals return wasmtypes.EnableAllProposals
} }
return wasm.DisableAllProposals return wasmtypes.DisableAllProposals
} }
chunks := strings.Split(EnableSpecificProposals, ",") chunks := strings.Split(EnableSpecificProposals, ",")
proposals, err := wasm.ConvertToProposals(chunks) proposals, err := wasmtypes.ConvertToProposals(chunks)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -235,7 +235,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil, ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil, icatypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner}, wasmtypes.ModuleName: {authtypes.Burner},
} }
) )
@@ -281,7 +281,7 @@ type WasmApp struct {
ICAControllerKeeper icacontrollerkeeper.Keeper ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasm.Keeper WasmKeeper wasmkeeper.Keeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
@@ -306,9 +306,9 @@ func NewWasmApp(
db dbm.DB, db dbm.DB,
traceStore io.Writer, traceStore io.Writer,
loadLatest bool, loadLatest bool,
enabledProposals []wasm.ProposalType, enabledProposals []wasmtypes.ProposalType,
appOpts servertypes.AppOptions, appOpts servertypes.AppOptions,
wasmOpts []wasm.Option, wasmOpts []wasmkeeper.Option,
baseAppOptions ...func(*baseapp.BaseApp), baseAppOptions ...func(*baseapp.BaseApp),
) *WasmApp { ) *WasmApp {
encodingConfig := MakeEncodingConfig() encodingConfig := MakeEncodingConfig()
@@ -331,7 +331,7 @@ func NewWasmApp(
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
// non sdk store keys // non sdk store keys
ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
wasm.StoreKey, icahosttypes.StoreKey, wasmtypes.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, icacontrollertypes.StoreKey,
) )
@@ -377,7 +377,7 @@ func NewWasmApp(
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
app.CapabilityKeeper.Seal() app.CapabilityKeeper.Seal()
// add keepers // add keepers
@@ -584,9 +584,9 @@ func NewWasmApp(
// The last arguments can contain custom message handlers, and custom query handlers, // The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks // if we want to allow any custom callbacks
availableCapabilities := strings.Join(AllCapabilities(), ",") availableCapabilities := strings.Join(AllCapabilities(), ",")
app.WasmKeeper = wasm.NewKeeper( app.WasmKeeper = wasmkeeper.NewKeeper(
appCodec, appCodec,
keys[wasm.StoreKey], keys[wasmtypes.StoreKey],
app.AccountKeeper, app.AccountKeeper,
app.BankKeeper, app.BankKeeper,
app.StakingKeeper, app.StakingKeeper,
@@ -607,7 +607,7 @@ func NewWasmApp(
// The gov proposal types can be individually enabled // The gov proposal types can be individually enabled
if len(enabledProposals) != 0 { if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) govRouter.AddRoute(wasmtypes.RouterKey, wasmkeeper.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) //nolint:staticcheck
} }
// Set legacy router for backwards compatibility with gov v1beta1 // Set legacy router for backwards compatibility with gov v1beta1
app.GovKeeper.SetLegacyRouter(govRouter) app.GovKeeper.SetLegacyRouter(govRouter)
@@ -641,7 +641,7 @@ func NewWasmApp(
// Create static IBC router, add app routes, then set and seal it // Create static IBC router, add app routes, then set and seal it
ibcRouter := porttypes.NewRouter(). ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferStack). AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(wasm.ModuleName, wasmStack). AddRoute(wasmtypes.ModuleName, wasmStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack) AddRoute(icahosttypes.SubModuleName, icaHostStack)
app.IBCKeeper.SetRouter(ibcRouter) app.IBCKeeper.SetRouter(ibcRouter)
@@ -702,7 +702,7 @@ func NewWasmApp(
ibcexported.ModuleName, ibcexported.ModuleName,
icatypes.ModuleName, icatypes.ModuleName,
ibcfeetypes.ModuleName, ibcfeetypes.ModuleName,
wasm.ModuleName, wasmtypes.ModuleName,
) )
app.ModuleManager.SetOrderEndBlockers( app.ModuleManager.SetOrderEndBlockers(
@@ -717,7 +717,7 @@ func NewWasmApp(
ibcexported.ModuleName, ibcexported.ModuleName,
icatypes.ModuleName, icatypes.ModuleName,
ibcfeetypes.ModuleName, ibcfeetypes.ModuleName,
wasm.ModuleName, wasmtypes.ModuleName,
) )
// NOTE: The genutils module must occur after staking so that pools are // NOTE: The genutils module must occur after staking so that pools are
@@ -740,7 +740,7 @@ func NewWasmApp(
icatypes.ModuleName, icatypes.ModuleName,
ibcfeetypes.ModuleName, ibcfeetypes.ModuleName,
// wasm after ibc transfer // wasm after ibc transfer
wasm.ModuleName, wasmtypes.ModuleName,
} }
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...) app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
@@ -787,7 +787,7 @@ func NewWasmApp(
app.SetInitChainer(app.InitChainer) app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker) app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker) app.SetEndBlocker(app.EndBlocker)
app.setAnteHandler(encodingConfig.TxConfig, wasmConfig, keys[wasm.StoreKey]) app.setAnteHandler(encodingConfig.TxConfig, wasmConfig, keys[wasmtypes.StoreKey])
// must be before Loading version // must be before Loading version
// requires the snapshot store to be created and registered as a BaseAppOption // requires the snapshot store to be created and registered as a BaseAppOption
@@ -1054,7 +1054,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName) paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(wasm.ModuleName) paramsKeeper.Subspace(wasmtypes.ModuleName)
return paramsKeeper return paramsKeeper
} }

View File

@@ -11,10 +11,11 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
) )
var emptyWasmOpts []wasm.Option var emptyWasmOpts []wasmkeeper.Option
func TestWasmdExport(t *testing.T) { func TestWasmdExport(t *testing.T) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
@@ -26,7 +27,7 @@ func TestWasmdExport(t *testing.T) {
gapp.Commit() gapp.Commit()
// Making a new app object with the db, so that initchain hasn't been called // Making a new app object with the db, so that initchain hasn't been called
newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasm.EnableAllProposals, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts) newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasmtypes.EnableAllProposals, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts)
_, err := newGapp.ExportAppStateAndValidators(false, []string{}, nil) _, err := newGapp.ExportAppStateAndValidators(false, []string{}, nil)
require.NoError(t, err, "ExportAppStateAndValidators should not have an error") require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
} }
@@ -57,20 +58,20 @@ func TestGetEnabledProposals(t *testing.T) {
cases := map[string]struct { cases := map[string]struct {
proposalsEnabled string proposalsEnabled string
specificEnabled string specificEnabled string
expected []wasm.ProposalType expected []wasmtypes.ProposalType
}{ }{
"all disabled": { "all disabled": {
proposalsEnabled: "false", proposalsEnabled: "false",
expected: wasm.DisableAllProposals, expected: wasmtypes.DisableAllProposals,
}, },
"all enabled": { "all enabled": {
proposalsEnabled: "true", proposalsEnabled: "true",
expected: wasm.EnableAllProposals, expected: wasmtypes.EnableAllProposals,
}, },
"some enabled": { "some enabled": {
proposalsEnabled: "okay", proposalsEnabled: "okay",
specificEnabled: "StoreCode,InstantiateContract", specificEnabled: "StoreCode,InstantiateContract",
expected: []wasm.ProposalType{wasm.ProposalTypeStoreCode, wasm.ProposalTypeInstantiateContract}, expected: []wasmtypes.ProposalType{wasmtypes.ProposalTypeStoreCode, wasmtypes.ProposalTypeInstantiateContract},
}, },
} }

View File

@@ -36,8 +36,6 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/x/wasm"
) )
// SimAppChainID hardcoded chainID for simulation // SimAppChainID hardcoded chainID for simulation
@@ -131,7 +129,7 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir)) require.NoError(t, os.RemoveAll(newDir))
}() }()
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasm.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "WasmApp", newApp.Name()) require.Equal(t, "WasmApp", newApp.Name())
var genesisState GenesisState var genesisState GenesisState
@@ -234,7 +232,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir)) require.NoError(t, os.RemoveAll(newDir))
}() }()
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasm.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "WasmApp", newApp.Name()) require.Equal(t, "WasmApp", newApp.Name())
newApp.InitChain(abci.RequestInitChain{ newApp.InitChain(abci.RequestInitChain{
@@ -275,7 +273,7 @@ func setupSimulationApp(t *testing.T, msg string) (simtypes.Config, dbm.DB, simt
appOptions[flags.FlagHome] = dir // ensure a unique folder appOptions[flags.FlagHome] = dir // ensure a unique folder
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
app := NewWasmApp(logger, db, nil, true, wasm.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) app := NewWasmApp(logger, db, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "WasmApp", app.Name()) require.Equal(t, "WasmApp", app.Name())
return config, db, appOptions, app return config, db, appOptions, app
} }
@@ -314,7 +312,7 @@ func TestAppStateDeterminism(t *testing.T) {
} }
db := dbm.NewMemDB() db := dbm.NewMemDB()
app := NewWasmApp(logger, db, nil, true, wasm.EnableAllProposals, appOptions, emptyWasmOpts, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID)) app := NewWasmApp(logger, db, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID))
fmt.Printf( fmt.Printf(
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",

View File

@@ -42,7 +42,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
) )
@@ -51,10 +51,10 @@ type SetupOptions struct {
Logger log.Logger Logger log.Logger
DB *dbm.MemDB DB *dbm.MemDB
AppOpts servertypes.AppOptions AppOpts servertypes.AppOptions
WasmOpts []wasm.Option WasmOpts []wasmkeeper.Option
} }
func setup(t testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*WasmApp, GenesisState) { func setup(t testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*WasmApp, GenesisState) {
db := dbm.NewMemDB() db := dbm.NewMemDB()
nodeHome := t.TempDir() nodeHome := t.TempDir()
snapshotDir := filepath.Join(nodeHome, "data", "snapshots") snapshotDir := filepath.Join(nodeHome, "data", "snapshots")
@@ -118,7 +118,7 @@ func NewWasmAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOpti
} }
// Setup initializes a new WasmApp. A Nop logger is set in WasmApp. // Setup initializes a new WasmApp. A Nop logger is set in WasmApp.
func Setup(t *testing.T, opts ...wasm.Option) *WasmApp { func Setup(t *testing.T, opts ...wasmkeeper.Option) *WasmApp {
t.Helper() t.Helper()
privVal := mock.NewPV() privVal := mock.NewPV()
@@ -146,7 +146,7 @@ func Setup(t *testing.T, opts ...wasm.Option) *WasmApp {
// that also act as delegators. For simplicity, each validator is bonded with a delegation // that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit in the default token of the WasmApp from first genesis // of one consensus engine unit in the default token of the WasmApp from first genesis
// account. A Nop logger is set in WasmApp. // account. A Nop logger is set in WasmApp.
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasm.Option, balances ...banktypes.Balance) *WasmApp { func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) *WasmApp {
t.Helper() t.Helper()
app, genesisState := setup(t, chainID, true, 5, opts...) app, genesisState := setup(t, chainID, true, 5, opts...)
@@ -268,7 +268,7 @@ func ModuleAccountAddrs() map[string]bool {
return BlockedAddresses() return BlockedAddresses()
} }
var emptyWasmOptions []wasm.Option var emptyWasmOptions []wasmkeeper.Option
// NewTestNetworkFixture returns a new WasmApp AppConstructor for network simulation tests // NewTestNetworkFixture returns a new WasmApp AppConstructor for network simulation tests
func NewTestNetworkFixture() network.TestFixture { func NewTestNetworkFixture() network.TestFixture {

View File

@@ -8,7 +8,7 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
) )
func (app *WasmApp) GetIBCKeeper() *ibckeeper.Keeper { func (app *WasmApp) GetIBCKeeper() *ibckeeper.Keeper {
@@ -35,6 +35,6 @@ func (app *WasmApp) GetAccountKeeper() authkeeper.AccountKeeper {
return app.AccountKeeper return app.AccountKeeper
} }
func (app *WasmApp) GetWasmKeeper() wasm.Keeper { func (app *WasmApp) GetWasmKeeper() wasmkeeper.Keeper {
return app.WasmKeeper return app.WasmKeeper
} }

View File

@@ -24,7 +24,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -34,8 +34,8 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
) )
func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*app.WasmApp, app.GenesisState) { //nolint:unparam func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*app.WasmApp, app.GenesisState) { //nolint:unparam
wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasm.EnableAllProposals, simtestutil.EmptyAppOptions{}, nil) wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasmtypes.EnableAllProposals, simtestutil.EmptyAppOptions{}, nil)
if withGenesis { if withGenesis {
return wasmApp, app.NewDefaultGenesisState(wasmApp.AppCodec()) return wasmApp, app.NewDefaultGenesisState(wasmApp.AppCodec())

View File

@@ -245,7 +245,7 @@ func newApp(
) servertypes.Application { ) servertypes.Application {
baseappOptions := server.DefaultBaseappOptions(appOpts) baseappOptions := server.DefaultBaseappOptions(appOpts)
var wasmOpts []wasm.Option var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) { if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
} }
@@ -285,7 +285,7 @@ func appExport(
viperAppOpts.Set(server.FlagInvCheckPeriod, 1) viperAppOpts.Set(server.FlagInvCheckPeriod, 1)
appOpts = viperAppOpts appOpts = viperAppOpts
var emptyWasmOpts []wasm.Option var emptyWasmOpts []wasmkeeper.Option
wasmApp = app.NewWasmApp( wasmApp = app.NewWasmApp(
logger, logger,
db, db,

View File

@@ -10,115 +10,215 @@ import (
) )
const ( const (
firstCodeID = 1 // Deprecated: Do not use.
ModuleName = types.ModuleName ModuleName = types.ModuleName
StoreKey = types.StoreKey // Deprecated: Do not use.
TStoreKey = types.TStoreKey StoreKey = types.StoreKey
QuerierRoute = types.QuerierRoute // Deprecated: Do not use.
RouterKey = types.RouterKey TStoreKey = types.TStoreKey
WasmModuleEventType = types.WasmModuleEventType // Deprecated: Do not use.
AttributeKeyContractAddr = types.AttributeKeyContractAddr QuerierRoute = types.QuerierRoute
ProposalTypeStoreCode = types.ProposalTypeStoreCode // Deprecated: Do not use.
RouterKey = types.RouterKey
// Deprecated: Do not use.
WasmModuleEventType = types.WasmModuleEventType
// Deprecated: Do not use.
AttributeKeyContractAddr = types.AttributeKeyContractAddr
// Deprecated: Do not use.
ProposalTypeStoreCode = types.ProposalTypeStoreCode
// Deprecated: Do not use.
ProposalTypeInstantiateContract = types.ProposalTypeInstantiateContract ProposalTypeInstantiateContract = types.ProposalTypeInstantiateContract
ProposalTypeMigrateContract = types.ProposalTypeMigrateContract // Deprecated: Do not use.
ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin ProposalTypeMigrateContract = types.ProposalTypeMigrateContract
ProposalTypeClearAdmin = types.ProposalTypeClearAdmin // Deprecated: Do not use.
ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin
// Deprecated: Do not use.
ProposalTypeClearAdmin = types.ProposalTypeClearAdmin
) )
var ( var (
// functions aliases // functions aliases
RegisterCodec = types.RegisterLegacyAminoCodec // Deprecated: Do not use.
RegisterInterfaces = types.RegisterInterfaces RegisterCodec = types.RegisterLegacyAminoCodec
ValidateGenesis = types.ValidateGenesis // Deprecated: Do not use.
ConvertToProposals = types.ConvertToProposals RegisterInterfaces = types.RegisterInterfaces
GetCodeKey = types.GetCodeKey // Deprecated: Do not use.
GetContractAddressKey = types.GetContractAddressKey ValidateGenesis = types.ValidateGenesis
// Deprecated: Do not use.
ConvertToProposals = types.ConvertToProposals
// Deprecated: Do not use.
GetCodeKey = types.GetCodeKey
// Deprecated: Do not use.
GetContractAddressKey = types.GetContractAddressKey
// Deprecated: Do not use.
GetContractStorePrefixKey = types.GetContractStorePrefix GetContractStorePrefixKey = types.GetContractStorePrefix
NewCodeInfo = types.NewCodeInfo // Deprecated: Do not use.
NewAbsoluteTxPosition = types.NewAbsoluteTxPosition NewCodeInfo = types.NewCodeInfo
NewContractInfo = types.NewContractInfo // Deprecated: Do not use.
NewEnv = types.NewEnv NewAbsoluteTxPosition = types.NewAbsoluteTxPosition
NewWasmCoins = types.NewWasmCoins // Deprecated: Do not use.
DefaultWasmConfig = types.DefaultWasmConfig NewContractInfo = types.NewContractInfo
DefaultParams = types.DefaultParams // Deprecated: Do not use.
InitGenesis = keeper.InitGenesis NewEnv = types.NewEnv
ExportGenesis = keeper.ExportGenesis // Deprecated: Do not use.
NewMessageHandler = keeper.NewDefaultMessageHandler NewWasmCoins = types.NewWasmCoins
DefaultEncoders = keeper.DefaultEncoders // Deprecated: Do not use.
EncodeBankMsg = keeper.EncodeBankMsg DefaultWasmConfig = types.DefaultWasmConfig
NoCustomMsg = keeper.NoCustomMsg // Deprecated: Do not use.
EncodeStakingMsg = keeper.EncodeStakingMsg DefaultParams = types.DefaultParams
EncodeWasmMsg = keeper.EncodeWasmMsg // Deprecated: Do not use.
NewKeeper = keeper.NewKeeper InitGenesis = keeper.InitGenesis
DefaultQueryPlugins = keeper.DefaultQueryPlugins // Deprecated: Do not use.
BankQuerier = keeper.BankQuerier ExportGenesis = keeper.ExportGenesis
NoCustomQuerier = keeper.NoCustomQuerier // Deprecated: Do not use.
StakingQuerier = keeper.StakingQuerier NewMessageHandler = keeper.NewDefaultMessageHandler
WasmQuerier = keeper.WasmQuerier // Deprecated: Do not use.
CreateTestInput = keeper.CreateTestInput DefaultEncoders = keeper.DefaultEncoders
TestHandler = keeper.TestHandler // Deprecated: Do not use.
NewWasmProposalHandler = keeper.NewWasmProposalHandler //nolint:staticcheck EncodeBankMsg = keeper.EncodeBankMsg
NewQuerier = keeper.Querier // Deprecated: Do not use.
ContractFromPortID = keeper.ContractFromPortID NoCustomMsg = keeper.NoCustomMsg
WithWasmEngine = keeper.WithWasmEngine // Deprecated: Do not use.
NewCountTXDecorator = keeper.NewCountTXDecorator EncodeStakingMsg = keeper.EncodeStakingMsg
// Deprecated: Do not use.
EncodeWasmMsg = keeper.EncodeWasmMsg
// Deprecated: Do not use.
NewKeeper = keeper.NewKeeper
// Deprecated: Do not use.
DefaultQueryPlugins = keeper.DefaultQueryPlugins
// Deprecated: Do not use.
BankQuerier = keeper.BankQuerier
// Deprecated: Do not use.
NoCustomQuerier = keeper.NoCustomQuerier
// Deprecated: Do not use.
StakingQuerier = keeper.StakingQuerier
// Deprecated: Do not use.
WasmQuerier = keeper.WasmQuerier
// Deprecated: Do not use.
CreateTestInput = keeper.CreateTestInput
// Deprecated: Do not use.
TestHandler = keeper.TestHandler
// Deprecated: Do not use.
NewWasmProposalHandler = keeper.NewWasmProposalHandler //nolint:staticcheck
// Deprecated: Do not use.
NewQuerier = keeper.Querier
// Deprecated: Do not use.
ContractFromPortID = keeper.ContractFromPortID
// Deprecated: Do not use.
WithWasmEngine = keeper.WithWasmEngine
// Deprecated: Do not use.
NewCountTXDecorator = keeper.NewCountTXDecorator
// variable aliases // variable aliases
ModuleCdc = types.ModuleCdc // Deprecated: Do not use.
DefaultCodespace = types.DefaultCodespace ModuleCdc = types.ModuleCdc
ErrCreateFailed = types.ErrCreateFailed // Deprecated: Do not use.
ErrAccountExists = types.ErrAccountExists DefaultCodespace = types.DefaultCodespace
// Deprecated: Do not use.
ErrCreateFailed = types.ErrCreateFailed
// Deprecated: Do not use.
ErrAccountExists = types.ErrAccountExists
// Deprecated: Do not use.
ErrInstantiateFailed = types.ErrInstantiateFailed ErrInstantiateFailed = types.ErrInstantiateFailed
ErrExecuteFailed = types.ErrExecuteFailed // Deprecated: Do not use.
ErrGasLimit = types.ErrGasLimit ErrExecuteFailed = types.ErrExecuteFailed
ErrInvalidGenesis = types.ErrInvalidGenesis // Deprecated: Do not use.
ErrNotFound = types.ErrNotFound ErrGasLimit = types.ErrGasLimit
ErrQueryFailed = types.ErrQueryFailed // Deprecated: Do not use.
ErrInvalidMsg = types.ErrInvalidMsg ErrInvalidGenesis = types.ErrInvalidGenesis
KeyLastCodeID = types.KeyLastCodeID // Deprecated: Do not use.
KeyLastInstanceID = types.KeyLastInstanceID ErrNotFound = types.ErrNotFound
CodeKeyPrefix = types.CodeKeyPrefix // Deprecated: Do not use.
ContractKeyPrefix = types.ContractKeyPrefix ErrQueryFailed = types.ErrQueryFailed
ContractStorePrefix = types.ContractStorePrefix // Deprecated: Do not use.
EnableAllProposals = types.EnableAllProposals ErrInvalidMsg = types.ErrInvalidMsg
DisableAllProposals = types.DisableAllProposals // Deprecated: Do not use.
KeyLastCodeID = types.KeyLastCodeID
// Deprecated: Do not use.
KeyLastInstanceID = types.KeyLastInstanceID
// Deprecated: Do not use.
CodeKeyPrefix = types.CodeKeyPrefix
// Deprecated: Do not use.
ContractKeyPrefix = types.ContractKeyPrefix
// Deprecated: Do not use.
ContractStorePrefix = types.ContractStorePrefix
// Deprecated: Do not use.
EnableAllProposals = types.EnableAllProposals
// Deprecated: Do not use.
DisableAllProposals = types.DisableAllProposals
) )
type ( type (
ProposalType = types.ProposalType // Deprecated: Do not use.
GenesisState = types.GenesisState ProposalType = types.ProposalType
Code = types.Code // Deprecated: Do not use.
Contract = types.Contract GenesisState = types.GenesisState
MsgStoreCode = types.MsgStoreCode // Deprecated: Do not use.
MsgStoreCodeResponse = types.MsgStoreCodeResponse Code = types.Code
MsgInstantiateContract = types.MsgInstantiateContract // Deprecated: Do not use.
MsgInstantiateContract2 = types.MsgInstantiateContract2 Contract = types.Contract
// Deprecated: Do not use.
MsgStoreCode = types.MsgStoreCode
// Deprecated: Do not use.
MsgStoreCodeResponse = types.MsgStoreCodeResponse
// Deprecated: Do not use.
MsgInstantiateContract = types.MsgInstantiateContract
// Deprecated: Do not use.
MsgInstantiateContract2 = types.MsgInstantiateContract2
// Deprecated: Do not use.
MsgInstantiateContractResponse = types.MsgInstantiateContractResponse MsgInstantiateContractResponse = types.MsgInstantiateContractResponse
MsgExecuteContract = types.MsgExecuteContract // Deprecated: Do not use.
MsgExecuteContractResponse = types.MsgExecuteContractResponse MsgExecuteContract = types.MsgExecuteContract
MsgMigrateContract = types.MsgMigrateContract // Deprecated: Do not use.
MsgMigrateContractResponse = types.MsgMigrateContractResponse MsgExecuteContractResponse = types.MsgExecuteContractResponse
MsgUpdateAdmin = types.MsgUpdateAdmin // Deprecated: Do not use.
MsgUpdateAdminResponse = types.MsgUpdateAdminResponse MsgMigrateContract = types.MsgMigrateContract
MsgClearAdmin = types.MsgClearAdmin // Deprecated: Do not use.
MsgWasmIBCCall = types.MsgIBCSend MsgMigrateContractResponse = types.MsgMigrateContractResponse
MsgClearAdminResponse = types.MsgClearAdminResponse // Deprecated: Do not use.
MsgServer = types.MsgServer MsgUpdateAdmin = types.MsgUpdateAdmin
Model = types.Model // Deprecated: Do not use.
CodeInfo = types.CodeInfo MsgUpdateAdminResponse = types.MsgUpdateAdminResponse
ContractInfo = types.ContractInfo // Deprecated: Do not use.
CreatedAt = types.AbsoluteTxPosition MsgClearAdmin = types.MsgClearAdmin
Config = types.WasmConfig // Deprecated: Do not use.
CodeInfoResponse = types.CodeInfoResponse MsgWasmIBCCall = types.MsgIBCSend
MessageHandler = keeper.SDKMessageHandler // Deprecated: Do not use.
BankEncoder = keeper.BankEncoder MsgClearAdminResponse = types.MsgClearAdminResponse
CustomEncoder = keeper.CustomEncoder // Deprecated: Do not use.
StakingEncoder = keeper.StakingEncoder MsgServer = types.MsgServer
WasmEncoder = keeper.WasmEncoder // Deprecated: Do not use.
MessageEncoders = keeper.MessageEncoders Model = types.Model
Keeper = keeper.Keeper // Deprecated: Do not use.
QueryHandler = keeper.QueryHandler CodeInfo = types.CodeInfo
CustomQuerier = keeper.CustomQuerier // Deprecated: Do not use.
QueryPlugins = keeper.QueryPlugins ContractInfo = types.ContractInfo
Option = keeper.Option // Deprecated: Do not use.
CreatedAt = types.AbsoluteTxPosition
// Deprecated: Do not use.
Config = types.WasmConfig
// Deprecated: Do not use.
CodeInfoResponse = types.CodeInfoResponse
// Deprecated: Do not use.
MessageHandler = keeper.SDKMessageHandler
// Deprecated: Do not use.
BankEncoder = keeper.BankEncoder
// Deprecated: Do not use.
CustomEncoder = keeper.CustomEncoder
// Deprecated: Do not use.
StakingEncoder = keeper.StakingEncoder
// Deprecated: Do not use.
WasmEncoder = keeper.WasmEncoder
// Deprecated: Do not use.
MessageEncoders = keeper.MessageEncoders
// Deprecated: Do not use.
Keeper = keeper.Keeper
// Deprecated: Do not use.
QueryHandler = keeper.QueryHandler
// Deprecated: Do not use.
CustomQuerier = keeper.CustomQuerier
// Deprecated: Do not use.
QueryPlugins = keeper.QueryPlugins
// Deprecated: Do not use.
Option = keeper.Option
) )

View File

@@ -5,25 +5,29 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/x/wasm/types"
) )
const firstCodeID = 1
// ensure store code returns the expected response // ensure store code returns the expected response
func assertStoreCodeResponse(t *testing.T, data []byte, expected uint64) { func assertStoreCodeResponse(t *testing.T, data []byte, expected uint64) {
var pStoreResp MsgStoreCodeResponse var pStoreResp types.MsgStoreCodeResponse
require.NoError(t, pStoreResp.Unmarshal(data)) require.NoError(t, pStoreResp.Unmarshal(data))
require.Equal(t, pStoreResp.CodeID, expected) require.Equal(t, pStoreResp.CodeID, expected)
} }
// ensure execution returns the expected data // ensure execution returns the expected data
func assertExecuteResponse(t *testing.T, data []byte, expected []byte) { func assertExecuteResponse(t *testing.T, data []byte, expected []byte) {
var pExecResp MsgExecuteContractResponse var pExecResp types.MsgExecuteContractResponse
require.NoError(t, pExecResp.Unmarshal(data)) require.NoError(t, pExecResp.Unmarshal(data))
require.Equal(t, pExecResp.Data, expected) require.Equal(t, pExecResp.Data, expected)
} }
// ensures this returns a valid bech32 address and returns it // ensures this returns a valid bech32 address and returns it
func parseInitResponse(t *testing.T, data []byte) string { func parseInitResponse(t *testing.T, data []byte) string {
var pInstResp MsgInstantiateContractResponse var pInstResp types.MsgInstantiateContractResponse
require.NoError(t, pInstResp.Unmarshal(data)) require.NoError(t, pInstResp.Unmarshal(data))
require.NotEmpty(t, pInstResp.Address) require.NotEmpty(t, pInstResp.Address)
addr := pInstResp.Address addr := pInstResp.Address

View File

@@ -6,6 +6,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/types"
) )
func TestInitGenesis(t *testing.T) { func TestInitGenesis(t *testing.T) {
@@ -16,7 +19,7 @@ func TestInitGenesis(t *testing.T) {
creator := data.faucet.NewFundedRandomAccount(data.ctx, deposit.Add(deposit...)...) creator := data.faucet.NewFundedRandomAccount(data.ctx, deposit.Add(deposit...)...)
fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...) fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...)
msg := MsgStoreCode{ msg := types.MsgStoreCode{
Sender: creator.String(), Sender: creator.String(),
WASMByteCode: testContract, WASMByteCode: testContract,
} }
@@ -38,7 +41,7 @@ func TestInitGenesis(t *testing.T) {
initMsgBz, err := json.Marshal(initMsg) initMsgBz, err := json.Marshal(initMsg)
require.NoError(t, err) require.NoError(t, err)
instMsg := MsgInstantiateContract{ instMsg := types.MsgInstantiateContract{
Sender: creator.String(), Sender: creator.String(),
CodeID: firstCodeID, CodeID: firstCodeID,
Msg: initMsgBz, Msg: initMsgBz,
@@ -50,7 +53,7 @@ func TestInitGenesis(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
contractBech32Addr := parseInitResponse(t, res.Data) contractBech32Addr := parseInitResponse(t, res.Data)
execMsg := MsgExecuteContract{ execMsg := types.MsgExecuteContract{
Sender: fred.String(), Sender: fred.String(),
Contract: contractBech32Addr, Contract: contractBech32Addr,
Msg: []byte(`{"release":{}}`), Msg: []byte(`{"release":{}}`),
@@ -75,14 +78,14 @@ func TestInitGenesis(t *testing.T) {
}, data.encConf.Marshaler) }, data.encConf.Marshaler)
// export into genstate // export into genstate
genState := ExportGenesis(data.ctx, &data.keeper) genState := keeper.ExportGenesis(data.ctx, &data.keeper)
// create new app to import genstate into // create new app to import genstate into
newData := setupTest(t) newData := setupTest(t)
q2 := newData.grpcQueryRouter q2 := newData.grpcQueryRouter
// initialize new app with genstate // initialize new app with genstate
_, err = InitGenesis(newData.ctx, &newData.keeper, *genState) _, err = keeper.InitGenesis(newData.ctx, &newData.keeper, *genState)
require.NoError(t, err) require.NoError(t, err)
// run same checks again on newdata, to make sure it was reinitialized correctly // run same checks again on newdata, to make sure it was reinitialized correctly

View File

@@ -12,6 +12,7 @@ import (
host "github.com/cosmos/ibc-go/v7/modules/core/24-host" host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/types" "github.com/CosmWasm/wasmd/x/wasm/types"
) )
@@ -48,7 +49,7 @@ func (i IBCHandler) OnChanOpenInit(
if err := ValidateChannelParams(channelID); err != nil { if err := ValidateChannelParams(channelID); err != nil {
return "", err return "", err
} }
contractAddr, err := ContractFromPortID(portID) contractAddr, err := keeper.ContractFromPortID(portID)
if err != nil { if err != nil {
return "", errorsmod.Wrapf(err, "contract port id") return "", errorsmod.Wrapf(err, "contract port id")
} }
@@ -97,7 +98,7 @@ func (i IBCHandler) OnChanOpenTry(
return "", err return "", err
} }
contractAddr, err := ContractFromPortID(portID) contractAddr, err := keeper.ContractFromPortID(portID)
if err != nil { if err != nil {
return "", errorsmod.Wrapf(err, "contract port id") return "", errorsmod.Wrapf(err, "contract port id")
} }
@@ -145,7 +146,7 @@ func (i IBCHandler) OnChanOpenAck(
counterpartyChannelID string, counterpartyChannelID string,
counterpartyVersion string, counterpartyVersion string,
) error { ) error {
contractAddr, err := ContractFromPortID(portID) contractAddr, err := keeper.ContractFromPortID(portID)
if err != nil { if err != nil {
return errorsmod.Wrapf(err, "contract port id") return errorsmod.Wrapf(err, "contract port id")
} }
@@ -171,7 +172,7 @@ func (i IBCHandler) OnChanOpenAck(
// OnChanOpenConfirm implements the IBCModule interface // OnChanOpenConfirm implements the IBCModule interface
func (i IBCHandler) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error { func (i IBCHandler) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error {
contractAddr, err := ContractFromPortID(portID) contractAddr, err := keeper.ContractFromPortID(portID)
if err != nil { if err != nil {
return errorsmod.Wrapf(err, "contract port id") return errorsmod.Wrapf(err, "contract port id")
} }
@@ -193,7 +194,7 @@ func (i IBCHandler) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string)
// OnChanCloseInit implements the IBCModule interface // OnChanCloseInit implements the IBCModule interface
func (i IBCHandler) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error { func (i IBCHandler) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error {
contractAddr, err := ContractFromPortID(portID) contractAddr, err := keeper.ContractFromPortID(portID)
if err != nil { if err != nil {
return errorsmod.Wrapf(err, "contract port id") return errorsmod.Wrapf(err, "contract port id")
} }
@@ -221,7 +222,7 @@ func (i IBCHandler) OnChanCloseInit(ctx sdk.Context, portID, channelID string) e
// OnChanCloseConfirm implements the IBCModule interface // OnChanCloseConfirm implements the IBCModule interface
func (i IBCHandler) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error { func (i IBCHandler) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error {
// counterparty has closed the channel // counterparty has closed the channel
contractAddr, err := ContractFromPortID(portID) contractAddr, err := keeper.ContractFromPortID(portID)
if err != nil { if err != nil {
return errorsmod.Wrapf(err, "contract port id") return errorsmod.Wrapf(err, "contract port id")
} }
@@ -262,7 +263,7 @@ func (i IBCHandler) OnRecvPacket(
packet channeltypes.Packet, packet channeltypes.Packet,
relayer sdk.AccAddress, relayer sdk.AccAddress,
) ibcexported.Acknowledgement { ) ibcexported.Acknowledgement {
contractAddr, err := ContractFromPortID(packet.DestinationPort) contractAddr, err := keeper.ContractFromPortID(packet.DestinationPort)
if err != nil { if err != nil {
// this must not happen as ports were registered before // this must not happen as ports were registered before
panic(errorsmod.Wrapf(err, "contract port id")) panic(errorsmod.Wrapf(err, "contract port id"))
@@ -290,7 +291,7 @@ func (i IBCHandler) OnAcknowledgementPacket(
acknowledgement []byte, acknowledgement []byte,
relayer sdk.AccAddress, relayer sdk.AccAddress,
) error { ) error {
contractAddr, err := ContractFromPortID(packet.SourcePort) contractAddr, err := keeper.ContractFromPortID(packet.SourcePort)
if err != nil { if err != nil {
return errorsmod.Wrapf(err, "contract port id") return errorsmod.Wrapf(err, "contract port id")
} }
@@ -308,7 +309,7 @@ func (i IBCHandler) OnAcknowledgementPacket(
// OnTimeoutPacket implements the IBCModule interface // OnTimeoutPacket implements the IBCModule interface
func (i IBCHandler) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error { func (i IBCHandler) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error {
contractAddr, err := ContractFromPortID(packet.SourcePort) contractAddr, err := keeper.ContractFromPortID(packet.SourcePort)
if err != nil { if err != nil {
return errorsmod.Wrapf(err, "contract port id") return errorsmod.Wrapf(err, "contract port id")
} }

View File

@@ -43,7 +43,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
) )
var MaxAccounts = 10 var MaxAccounts = 10
@@ -68,7 +68,7 @@ type ChainApp interface {
GetBankKeeper() bankkeeper.Keeper GetBankKeeper() bankkeeper.Keeper
GetStakingKeeper() *stakingkeeper.Keeper GetStakingKeeper() *stakingkeeper.Keeper
GetAccountKeeper() authkeeper.AccountKeeper GetAccountKeeper() authkeeper.AccountKeeper
GetWasmKeeper() wasm.Keeper GetWasmKeeper() wasmkeeper.Keeper
} }
// TestChain is a testing struct that wraps a simapp with the last TM Header, the current ABCI // TestChain is a testing struct that wraps a simapp with the last TM Header, the current ABCI
@@ -113,22 +113,22 @@ type PacketAck struct {
} }
// ChainAppFactory abstract factory method that usually implemented by app.SetupWithGenesisValSet // ChainAppFactory abstract factory method that usually implemented by app.SetupWithGenesisValSet
type ChainAppFactory func(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasm.Option, balances ...banktypes.Balance) ChainApp type ChainAppFactory func(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp
// DefaultWasmAppFactory instantiates and sets up the default wasmd app // DefaultWasmAppFactory instantiates and sets up the default wasmd app
func DefaultWasmAppFactory(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasm.Option, balances ...banktypes.Balance) ChainApp { func DefaultWasmAppFactory(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp {
return app.SetupWithGenesisValSet(t, valSet, genAccs, chainID, opts, balances...) return app.SetupWithGenesisValSet(t, valSet, genAccs, chainID, opts, balances...)
} }
// NewDefaultTestChain initializes a new test chain with a default of 4 validators // NewDefaultTestChain initializes a new test chain with a default of 4 validators
// Use this function if the tests do not need custom control over the validator set // Use this function if the tests do not need custom control over the validator set
func NewDefaultTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm.Option) *TestChain { func NewDefaultTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasmkeeper.Option) *TestChain {
return NewTestChain(t, coord, DefaultWasmAppFactory, chainID, opts...) return NewTestChain(t, coord, DefaultWasmAppFactory, chainID, opts...)
} }
// NewTestChain initializes a new test chain with a default of 4 validators // NewTestChain initializes a new test chain with a default of 4 validators
// Use this function if the tests do not need custom control over the validator set // Use this function if the tests do not need custom control over the validator set
func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, opts ...wasm.Option) *TestChain { func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, opts ...wasmkeeper.Option) *TestChain {
// generate validators private/public key // generate validators private/public key
var ( var (
validatorsPerChain = 4 validatorsPerChain = 4
@@ -167,7 +167,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory,
// //
// CONTRACT: Validator array must be provided in the order expected by Tendermint. // CONTRACT: Validator array must be provided in the order expected by Tendermint.
// i.e. sorted first by power and then lexicographically by address. // i.e. sorted first by power and then lexicographically by address.
func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, valSet *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator, opts ...wasm.Option) *TestChain { func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, valSet *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator, opts ...wasmkeeper.Option) *TestChain {
genAccs := []authtypes.GenesisAccount{} genAccs := []authtypes.GenesisAccount{}
genBals := []banktypes.Balance{} genBals := []banktypes.Balance{}
senderAccs := []SenderAccount{} senderAccs := []SenderAccount{}

View File

@@ -13,7 +13,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/x/wasm"
) )
func TestModuleMigrations(t *testing.T) { func TestModuleMigrations(t *testing.T) {
@@ -55,7 +54,7 @@ func TestModuleMigrations(t *testing.T) {
spec.setup(ctx) spec.setup(ctx)
fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx)
fromVM[wasm.ModuleName] = spec.startVersion fromVM[types.ModuleName] = spec.startVersion
_, err := upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM) _, err := upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM)
require.NoError(t, err) require.NoError(t, err)
@@ -65,7 +64,7 @@ func TestModuleMigrations(t *testing.T) {
// then // then
require.NoError(t, err) require.NoError(t, err)
var expModuleVersion uint64 = 4 var expModuleVersion uint64 = 4
assert.Equal(t, expModuleVersion, gotVM[wasm.ModuleName]) assert.Equal(t, expModuleVersion, gotVM[types.ModuleName])
gotParams := wasmApp.WasmKeeper.GetParams(ctx) gotParams := wasmApp.WasmKeeper.GetParams(ctx)
assert.Equal(t, spec.exp, gotParams) assert.Equal(t, spec.exp, gotParams)
}) })
@@ -98,7 +97,7 @@ func TestAccessConfigMigrations(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx) fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx)
fromVM[wasm.ModuleName] = wasmApp.ModuleManager.GetVersionMap()[types.ModuleName] fromVM[types.ModuleName] = wasmApp.ModuleManager.GetVersionMap()[types.ModuleName]
_, err = upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM) _, err = upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM)
require.NoError(t, err) require.NoError(t, err)
@@ -108,7 +107,7 @@ func TestAccessConfigMigrations(t *testing.T) {
// then // then
require.NoError(t, err) require.NoError(t, err)
var expModuleVersion uint64 = 4 var expModuleVersion uint64 = 4
assert.Equal(t, expModuleVersion, gotVM[wasm.ModuleName]) assert.Equal(t, expModuleVersion, gotVM[types.ModuleName])
// any address was not migrated // any address was not migrated
assert.Equal(t, types.AccessTypeAnyOfAddresses.With(address), wasmApp.WasmKeeper.GetCodeInfo(ctx, code1).InstantiateConfig) assert.Equal(t, types.AccessTypeAnyOfAddresses.With(address), wasmApp.WasmKeeper.GetCodeInfo(ctx, code1).InstantiateConfig)

View File

@@ -49,7 +49,7 @@ const (
type AppModuleBasic struct{} type AppModuleBasic struct{}
func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {
RegisterCodec(amino) types.RegisterLegacyAminoCodec(amino)
} }
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) {
@@ -61,25 +61,25 @@ func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serv
// Name returns the wasm module's name. // Name returns the wasm module's name.
func (AppModuleBasic) Name() string { func (AppModuleBasic) Name() string {
return ModuleName return types.ModuleName
} }
// DefaultGenesis returns default genesis state as raw bytes for the wasm // DefaultGenesis returns default genesis state as raw bytes for the wasm
// module. // module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(&GenesisState{ return cdc.MustMarshalJSON(&types.GenesisState{
Params: DefaultParams(), Params: types.DefaultParams(),
}) })
} }
// ValidateGenesis performs genesis state validation for the wasm module. // ValidateGenesis performs genesis state validation for the wasm module.
func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error { func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error {
var data GenesisState var data types.GenesisState
err := marshaler.UnmarshalJSON(message, &data) err := marshaler.UnmarshalJSON(message, &data)
if err != nil { if err != nil {
return err return err
} }
return ValidateGenesis(data) return types.ValidateGenesis(data)
} }
// GetTxCmd returns the root tx command for the wasm module. // GetTxCmd returns the root tx command for the wasm module.
@@ -104,7 +104,7 @@ var _ appmodule.AppModule = AppModule{}
type AppModule struct { type AppModule struct {
AppModuleBasic AppModuleBasic
cdc codec.Codec cdc codec.Codec
keeper *Keeper keeper *keeper.Keeper
validatorSetSource keeper.ValidatorSetSource validatorSetSource keeper.ValidatorSetSource
accountKeeper types.AccountKeeper // for simulation accountKeeper types.AccountKeeper // for simulation
bankKeeper simulation.BankKeeper bankKeeper simulation.BankKeeper
@@ -116,7 +116,7 @@ type AppModule struct {
// NewAppModule creates a new AppModule object // NewAppModule creates a new AppModule object
func NewAppModule( func NewAppModule(
cdc codec.Codec, cdc codec.Codec,
keeper *Keeper, keeper *keeper.Keeper,
validatorSetSource keeper.ValidatorSetSource, validatorSetSource keeper.ValidatorSetSource,
ak types.AccountKeeper, ak types.AccountKeeper,
bk simulation.BankKeeper, bk simulation.BankKeeper,
@@ -151,7 +151,7 @@ func (AppModule) ConsensusVersion() uint64 { return 4 }
func (am AppModule) RegisterServices(cfg module.Configurator) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), NewQuerier(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.Querier(am.keeper))
m := keeper.NewMigrator(*am.keeper, am.legacySubspace) m := keeper.NewMigrator(*am.keeper, am.legacySubspace)
err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
@@ -173,15 +173,15 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
// QuerierRoute returns the wasm module's querier route name. // QuerierRoute returns the wasm module's querier route name.
func (AppModule) QuerierRoute() string { func (AppModule) QuerierRoute() string {
return QuerierRoute return types.QuerierRoute
} }
// InitGenesis performs genesis initialization for the wasm module. It returns // InitGenesis performs genesis initialization for the wasm module. It returns
// no validator updates. // no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState GenesisState var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState) cdc.MustUnmarshalJSON(data, &genesisState)
validators, err := InitGenesis(ctx, am.keeper, genesisState) validators, err := keeper.InitGenesis(ctx, am.keeper, genesisState)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -191,7 +191,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
// ExportGenesis returns the exported genesis state as raw bytes for the wasm // ExportGenesis returns the exported genesis state as raw bytes for the wasm
// module. // module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := ExportGenesis(ctx, am.keeper) gs := keeper.ExportGenesis(ctx, am.keeper)
return cdc.MustMarshalJSON(gs) return cdc.MustMarshalJSON(gs)
} }
@@ -231,7 +231,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
// AddModuleInitFlags implements servertypes.ModuleInitFlags interface. // AddModuleInitFlags implements servertypes.ModuleInitFlags interface.
func AddModuleInitFlags(startCmd *cobra.Command) { func AddModuleInitFlags(startCmd *cobra.Command) {
defaults := DefaultWasmConfig() defaults := types.DefaultWasmConfig()
startCmd.Flags().Uint32(flagWasmMemoryCacheSize, defaults.MemoryCacheSize, "Sets the size in MiB (NOT bytes) of an in-memory cache for Wasm modules. Set to 0 to disable.") startCmd.Flags().Uint32(flagWasmMemoryCacheSize, defaults.MemoryCacheSize, "Sets the size in MiB (NOT bytes) of an in-memory cache for Wasm modules. Set to 0 to disable.")
startCmd.Flags().Uint64(flagWasmQueryGasLimit, defaults.SmartQueryGasLimit, "Set the max gas that can be spent on executing a query with a Wasm contract") startCmd.Flags().Uint64(flagWasmQueryGasLimit, defaults.SmartQueryGasLimit, "Set the max gas that can be spent on executing a query with a Wasm contract")
startCmd.Flags().String(flagWasmSimulationGasLimit, "", "Set the max gas that can be spent when executing a simulation TX") startCmd.Flags().String(flagWasmSimulationGasLimit, "", "Set the max gas that can be spent when executing a simulation TX")

View File

@@ -46,7 +46,7 @@ type testData struct {
module AppModule module AppModule
ctx sdk.Context ctx sdk.Context
acctKeeper authkeeper.AccountKeeper acctKeeper authkeeper.AccountKeeper
keeper Keeper keeper keeper.Keeper
bankKeeper bankkeeper.Keeper bankKeeper bankkeeper.Keeper
stakingKeeper *stakingkeeper.Keeper stakingKeeper *stakingkeeper.Keeper
faucet *keeper.TestFaucet faucet *keeper.TestFaucet
@@ -56,7 +56,7 @@ type testData struct {
} }
func setupTest(t *testing.T) testData { func setupTest(t *testing.T) testData {
ctx, keepers := CreateTestInput(t, false, "iterator,staking,stargate,cosmwasm_1_1") ctx, keepers := keeper.CreateTestInput(t, false, "iterator,staking,stargate,cosmwasm_1_1")
encConf := keeper.MakeEncodingConfig(t) encConf := keeper.MakeEncodingConfig(t)
queryRouter := baseapp.NewGRPCQueryRouter() queryRouter := baseapp.NewGRPCQueryRouter()
serviceRouter := baseapp.NewMsgServiceRouter() serviceRouter := baseapp.NewMsgServiceRouter()
@@ -107,32 +107,32 @@ func TestHandleCreate(t *testing.T) {
isValid bool isValid bool
}{ }{
"empty": { "empty": {
msg: &MsgStoreCode{}, msg: &types.MsgStoreCode{},
isValid: false, isValid: false,
}, },
"invalid wasm": { "invalid wasm": {
msg: &MsgStoreCode{ msg: &types.MsgStoreCode{
Sender: addr1, Sender: addr1,
WASMByteCode: []byte("foobar"), WASMByteCode: []byte("foobar"),
}, },
isValid: false, isValid: false,
}, },
"valid wasm": { "valid wasm": {
msg: &MsgStoreCode{ msg: &types.MsgStoreCode{
Sender: addr1, Sender: addr1,
WASMByteCode: testContract, WASMByteCode: testContract,
}, },
isValid: true, isValid: true,
}, },
"other valid wasm": { "other valid wasm": {
msg: &MsgStoreCode{ msg: &types.MsgStoreCode{
Sender: addr1, Sender: addr1,
WASMByteCode: maskContract, WASMByteCode: maskContract,
}, },
isValid: true, isValid: true,
}, },
"old wasm (0.7)": { "old wasm (0.7)": {
msg: &MsgStoreCode{ msg: &types.MsgStoreCode{
Sender: addr1, Sender: addr1,
WASMByteCode: oldContract, WASMByteCode: oldContract,
}, },
@@ -177,7 +177,7 @@ func TestHandleInstantiate(t *testing.T) {
data := setupTest(t) data := setupTest(t)
creator := data.faucet.NewFundedRandomAccount(data.ctx, sdk.NewInt64Coin("denom", 100000)) creator := data.faucet.NewFundedRandomAccount(data.ctx, sdk.NewInt64Coin("denom", 100000))
msg := &MsgStoreCode{ msg := &types.MsgStoreCode{
Sender: creator.String(), Sender: creator.String(),
WASMByteCode: testContract, WASMByteCode: testContract,
} }
@@ -200,7 +200,7 @@ func TestHandleInstantiate(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// create with no balance is also legal // create with no balance is also legal
initMsg := &MsgInstantiateContract{ initMsg := &types.MsgInstantiateContract{
Sender: creator.String(), Sender: creator.String(),
CodeID: firstCodeID, CodeID: firstCodeID,
Msg: initMsgBz, Msg: initMsgBz,
@@ -240,7 +240,7 @@ func TestHandleExecute(t *testing.T) {
creator := data.faucet.NewFundedRandomAccount(data.ctx, deposit.Add(deposit...)...) creator := data.faucet.NewFundedRandomAccount(data.ctx, deposit.Add(deposit...)...)
fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...) fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...)
msg := &MsgStoreCode{ msg := &types.MsgStoreCode{
Sender: creator.String(), Sender: creator.String(),
WASMByteCode: testContract, WASMByteCode: testContract,
} }
@@ -258,7 +258,7 @@ func TestHandleExecute(t *testing.T) {
initMsgBz, err := json.Marshal(initMsg) initMsgBz, err := json.Marshal(initMsg)
require.NoError(t, err) require.NoError(t, err)
initCmd := &MsgInstantiateContract{ initCmd := &types.MsgInstantiateContract{
Sender: creator.String(), Sender: creator.String(),
CodeID: firstCodeID, CodeID: firstCodeID,
Msg: initMsgBz, Msg: initMsgBz,
@@ -296,7 +296,7 @@ func TestHandleExecute(t *testing.T) {
require.NotNil(t, contractAcct) require.NotNil(t, contractAcct)
assert.Equal(t, deposit, data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress())) assert.Equal(t, deposit, data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress()))
execCmd := &MsgExecuteContract{ execCmd := &types.MsgExecuteContract{
Sender: fred.String(), Sender: fred.String(),
Contract: contractBech32Addr, Contract: contractBech32Addr,
Msg: []byte(`{"release":{}}`), Msg: []byte(`{"release":{}}`),
@@ -374,7 +374,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
data.faucet.Fund(data.ctx, creator, sdk.NewInt64Coin("denom", 100000)) data.faucet.Fund(data.ctx, creator, sdk.NewInt64Coin("denom", 100000))
fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...) fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...)
msg := &MsgStoreCode{ msg := &types.MsgStoreCode{
Sender: creator.String(), Sender: creator.String(),
WASMByteCode: testContract, WASMByteCode: testContract,
} }
@@ -391,7 +391,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
initMsgBz, err := json.Marshal(initMsg) initMsgBz, err := json.Marshal(initMsg)
require.NoError(t, err) require.NoError(t, err)
initCmd := MsgInstantiateContract{ initCmd := types.MsgInstantiateContract{
Sender: creator.String(), Sender: creator.String(),
CodeID: firstCodeID, CodeID: firstCodeID,
Msg: initMsgBz, Msg: initMsgBz,
@@ -410,7 +410,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
handleMsgBz, err := json.Marshal(handleMsg) handleMsgBz, err := json.Marshal(handleMsg)
require.NoError(t, err) require.NoError(t, err)
execCmd := MsgExecuteContract{ execCmd := types.MsgExecuteContract{
Sender: fred.String(), Sender: fred.String(),
Contract: contractBech32Addr, Contract: contractBech32Addr,
Msg: handleMsgBz, Msg: handleMsgBz,
@@ -443,7 +443,7 @@ func TestReadWasmConfig(t *testing.T) {
return v return v
} }
var one uint64 = 1 var one uint64 = 1
defaults := DefaultWasmConfig() defaults := types.DefaultWasmConfig()
specs := map[string]struct { specs := map[string]struct {
src servertypes.AppOptions src servertypes.AppOptions