38
app/app.go
38
app/app.go
@@ -146,15 +146,15 @@ var (
|
||||
|
||||
// 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)
|
||||
}
|
||||
@@ -235,7 +235,7 @@ var (
|
||||
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
ibcfeetypes.ModuleName: nil,
|
||||
icatypes.ModuleName: nil,
|
||||
wasm.ModuleName: {authtypes.Burner},
|
||||
wasmtypes.ModuleName: {authtypes.Burner},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -281,7 +281,7 @@ type WasmApp struct {
|
||||
ICAControllerKeeper icacontrollerkeeper.Keeper
|
||||
ICAHostKeeper icahostkeeper.Keeper
|
||||
TransferKeeper ibctransferkeeper.Keeper
|
||||
WasmKeeper wasm.Keeper
|
||||
WasmKeeper wasmkeeper.Keeper
|
||||
|
||||
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
||||
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
|
||||
@@ -306,9 +306,9 @@ func NewWasmApp(
|
||||
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),
|
||||
) *WasmApp {
|
||||
encodingConfig := MakeEncodingConfig()
|
||||
@@ -331,7 +331,7 @@ func NewWasmApp(
|
||||
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
|
||||
// non sdk store keys
|
||||
ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
|
||||
wasm.StoreKey, icahosttypes.StoreKey,
|
||||
wasmtypes.StoreKey, icahosttypes.StoreKey,
|
||||
icacontrollertypes.StoreKey,
|
||||
)
|
||||
|
||||
@@ -377,7 +377,7 @@ func NewWasmApp(
|
||||
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
|
||||
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
|
||||
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
|
||||
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
|
||||
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
|
||||
app.CapabilityKeeper.Seal()
|
||||
|
||||
// add keepers
|
||||
@@ -584,9 +584,9 @@ func NewWasmApp(
|
||||
// The last arguments can contain custom message handlers, and custom query handlers,
|
||||
// if we want to allow any custom callbacks
|
||||
availableCapabilities := strings.Join(AllCapabilities(), ",")
|
||||
app.WasmKeeper = wasm.NewKeeper(
|
||||
app.WasmKeeper = wasmkeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[wasm.StoreKey],
|
||||
keys[wasmtypes.StoreKey],
|
||||
app.AccountKeeper,
|
||||
app.BankKeeper,
|
||||
app.StakingKeeper,
|
||||
@@ -607,7 +607,7 @@ func NewWasmApp(
|
||||
|
||||
// The gov proposal types can be individually enabled
|
||||
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
|
||||
app.GovKeeper.SetLegacyRouter(govRouter)
|
||||
@@ -641,7 +641,7 @@ func NewWasmApp(
|
||||
// Create static IBC router, add app routes, 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)
|
||||
app.IBCKeeper.SetRouter(ibcRouter)
|
||||
@@ -702,7 +702,7 @@ func NewWasmApp(
|
||||
ibcexported.ModuleName,
|
||||
icatypes.ModuleName,
|
||||
ibcfeetypes.ModuleName,
|
||||
wasm.ModuleName,
|
||||
wasmtypes.ModuleName,
|
||||
)
|
||||
|
||||
app.ModuleManager.SetOrderEndBlockers(
|
||||
@@ -717,7 +717,7 @@ func NewWasmApp(
|
||||
ibcexported.ModuleName,
|
||||
icatypes.ModuleName,
|
||||
ibcfeetypes.ModuleName,
|
||||
wasm.ModuleName,
|
||||
wasmtypes.ModuleName,
|
||||
)
|
||||
|
||||
// NOTE: The genutils module must occur after staking so that pools are
|
||||
@@ -740,7 +740,7 @@ func NewWasmApp(
|
||||
icatypes.ModuleName,
|
||||
ibcfeetypes.ModuleName,
|
||||
// wasm after ibc transfer
|
||||
wasm.ModuleName,
|
||||
wasmtypes.ModuleName,
|
||||
}
|
||||
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
|
||||
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
|
||||
@@ -787,7 +787,7 @@ func NewWasmApp(
|
||||
app.SetInitChainer(app.InitChainer)
|
||||
app.SetBeginBlocker(app.BeginBlocker)
|
||||
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
|
||||
// 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(icahosttypes.SubModuleName)
|
||||
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
|
||||
paramsKeeper.Subspace(wasm.ModuleName)
|
||||
paramsKeeper.Subspace(wasmtypes.ModuleName)
|
||||
|
||||
return paramsKeeper
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"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) {
|
||||
db := dbm.NewMemDB()
|
||||
@@ -26,7 +27,7 @@ func TestWasmdExport(t *testing.T) {
|
||||
gapp.Commit()
|
||||
|
||||
// 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)
|
||||
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
||||
}
|
||||
@@ -57,20 +58,20 @@ func TestGetEnabledProposals(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
proposalsEnabled string
|
||||
specificEnabled string
|
||||
expected []wasm.ProposalType
|
||||
expected []wasmtypes.ProposalType
|
||||
}{
|
||||
"all disabled": {
|
||||
proposalsEnabled: "false",
|
||||
expected: wasm.DisableAllProposals,
|
||||
expected: wasmtypes.DisableAllProposals,
|
||||
},
|
||||
"all enabled": {
|
||||
proposalsEnabled: "true",
|
||||
expected: wasm.EnableAllProposals,
|
||||
expected: wasmtypes.EnableAllProposals,
|
||||
},
|
||||
"some enabled": {
|
||||
proposalsEnabled: "okay",
|
||||
specificEnabled: "StoreCode,InstantiateContract",
|
||||
expected: []wasm.ProposalType{wasm.ProposalTypeStoreCode, wasm.ProposalTypeInstantiateContract},
|
||||
expected: []wasmtypes.ProposalType{wasmtypes.ProposalTypeStoreCode, wasmtypes.ProposalTypeInstantiateContract},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@ import (
|
||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/CosmWasm/wasmd/x/wasm"
|
||||
)
|
||||
|
||||
// SimAppChainID hardcoded chainID for simulation
|
||||
@@ -131,7 +129,7 @@ func TestAppImportExport(t *testing.T) {
|
||||
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())
|
||||
|
||||
var genesisState GenesisState
|
||||
@@ -234,7 +232,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
|
||||
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())
|
||||
|
||||
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[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())
|
||||
return config, db, appOptions, app
|
||||
}
|
||||
@@ -314,7 +312,7 @@ func TestAppStateDeterminism(t *testing.T) {
|
||||
}
|
||||
|
||||
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(
|
||||
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -51,10 +51,10 @@ type SetupOptions struct {
|
||||
Logger log.Logger
|
||||
DB *dbm.MemDB
|
||||
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()
|
||||
nodeHome := t.TempDir()
|
||||
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.
|
||||
func Setup(t *testing.T, opts ...wasm.Option) *WasmApp {
|
||||
func Setup(t *testing.T, opts ...wasmkeeper.Option) *WasmApp {
|
||||
t.Helper()
|
||||
|
||||
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
|
||||
// of one consensus engine unit in the default token of the WasmApp from first genesis
|
||||
// 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()
|
||||
|
||||
app, genesisState := setup(t, chainID, true, 5, opts...)
|
||||
@@ -268,7 +268,7 @@ func ModuleAccountAddrs() map[string]bool {
|
||||
return BlockedAddresses()
|
||||
}
|
||||
|
||||
var emptyWasmOptions []wasm.Option
|
||||
var emptyWasmOptions []wasmkeeper.Option
|
||||
|
||||
// NewTestNetworkFixture returns a new WasmApp AppConstructor for network simulation tests
|
||||
func NewTestNetworkFixture() network.TestFixture {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/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 {
|
||||
@@ -35,6 +35,6 @@ func (app *WasmApp) GetAccountKeeper() authkeeper.AccountKeeper {
|
||||
return app.AccountKeeper
|
||||
}
|
||||
|
||||
func (app *WasmApp) GetWasmKeeper() wasm.Keeper {
|
||||
func (app *WasmApp) GetWasmKeeper() wasmkeeper.Keeper {
|
||||
return app.WasmKeeper
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
|
||||
"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"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@@ -34,8 +34,8 @@ import (
|
||||
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
|
||||
wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasm.EnableAllProposals, simtestutil.EmptyAppOptions{}, nil)
|
||||
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, wasmtypes.EnableAllProposals, simtestutil.EmptyAppOptions{}, nil)
|
||||
|
||||
if withGenesis {
|
||||
return wasmApp, app.NewDefaultGenesisState(wasmApp.AppCodec())
|
||||
|
||||
@@ -245,7 +245,7 @@ func newApp(
|
||||
) servertypes.Application {
|
||||
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
||||
|
||||
var wasmOpts []wasm.Option
|
||||
var wasmOpts []wasmkeeper.Option
|
||||
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
|
||||
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
|
||||
}
|
||||
@@ -285,7 +285,7 @@ func appExport(
|
||||
viperAppOpts.Set(server.FlagInvCheckPeriod, 1)
|
||||
appOpts = viperAppOpts
|
||||
|
||||
var emptyWasmOpts []wasm.Option
|
||||
var emptyWasmOpts []wasmkeeper.Option
|
||||
wasmApp = app.NewWasmApp(
|
||||
logger,
|
||||
db,
|
||||
|
||||
296
x/wasm/alias.go
296
x/wasm/alias.go
@@ -10,115 +10,215 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
firstCodeID = 1
|
||||
ModuleName = types.ModuleName
|
||||
StoreKey = types.StoreKey
|
||||
TStoreKey = types.TStoreKey
|
||||
QuerierRoute = types.QuerierRoute
|
||||
RouterKey = types.RouterKey
|
||||
WasmModuleEventType = types.WasmModuleEventType
|
||||
AttributeKeyContractAddr = types.AttributeKeyContractAddr
|
||||
ProposalTypeStoreCode = types.ProposalTypeStoreCode
|
||||
// Deprecated: Do not use.
|
||||
ModuleName = types.ModuleName
|
||||
// Deprecated: Do not use.
|
||||
StoreKey = types.StoreKey
|
||||
// Deprecated: Do not use.
|
||||
TStoreKey = types.TStoreKey
|
||||
// Deprecated: Do not use.
|
||||
QuerierRoute = types.QuerierRoute
|
||||
// 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
|
||||
ProposalTypeMigrateContract = types.ProposalTypeMigrateContract
|
||||
ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin
|
||||
ProposalTypeClearAdmin = types.ProposalTypeClearAdmin
|
||||
// Deprecated: Do not use.
|
||||
ProposalTypeMigrateContract = types.ProposalTypeMigrateContract
|
||||
// Deprecated: Do not use.
|
||||
ProposalTypeUpdateAdmin = types.ProposalTypeUpdateAdmin
|
||||
// Deprecated: Do not use.
|
||||
ProposalTypeClearAdmin = types.ProposalTypeClearAdmin
|
||||
)
|
||||
|
||||
var (
|
||||
// functions aliases
|
||||
RegisterCodec = types.RegisterLegacyAminoCodec
|
||||
RegisterInterfaces = types.RegisterInterfaces
|
||||
ValidateGenesis = types.ValidateGenesis
|
||||
ConvertToProposals = types.ConvertToProposals
|
||||
GetCodeKey = types.GetCodeKey
|
||||
GetContractAddressKey = types.GetContractAddressKey
|
||||
// Deprecated: Do not use.
|
||||
RegisterCodec = types.RegisterLegacyAminoCodec
|
||||
// Deprecated: Do not use.
|
||||
RegisterInterfaces = types.RegisterInterfaces
|
||||
// Deprecated: Do not use.
|
||||
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
|
||||
NewCodeInfo = types.NewCodeInfo
|
||||
NewAbsoluteTxPosition = types.NewAbsoluteTxPosition
|
||||
NewContractInfo = types.NewContractInfo
|
||||
NewEnv = types.NewEnv
|
||||
NewWasmCoins = types.NewWasmCoins
|
||||
DefaultWasmConfig = types.DefaultWasmConfig
|
||||
DefaultParams = types.DefaultParams
|
||||
InitGenesis = keeper.InitGenesis
|
||||
ExportGenesis = keeper.ExportGenesis
|
||||
NewMessageHandler = keeper.NewDefaultMessageHandler
|
||||
DefaultEncoders = keeper.DefaultEncoders
|
||||
EncodeBankMsg = keeper.EncodeBankMsg
|
||||
NoCustomMsg = keeper.NoCustomMsg
|
||||
EncodeStakingMsg = keeper.EncodeStakingMsg
|
||||
EncodeWasmMsg = keeper.EncodeWasmMsg
|
||||
NewKeeper = keeper.NewKeeper
|
||||
DefaultQueryPlugins = keeper.DefaultQueryPlugins
|
||||
BankQuerier = keeper.BankQuerier
|
||||
NoCustomQuerier = keeper.NoCustomQuerier
|
||||
StakingQuerier = keeper.StakingQuerier
|
||||
WasmQuerier = keeper.WasmQuerier
|
||||
CreateTestInput = keeper.CreateTestInput
|
||||
TestHandler = keeper.TestHandler
|
||||
NewWasmProposalHandler = keeper.NewWasmProposalHandler //nolint:staticcheck
|
||||
NewQuerier = keeper.Querier
|
||||
ContractFromPortID = keeper.ContractFromPortID
|
||||
WithWasmEngine = keeper.WithWasmEngine
|
||||
NewCountTXDecorator = keeper.NewCountTXDecorator
|
||||
// Deprecated: Do not use.
|
||||
NewCodeInfo = types.NewCodeInfo
|
||||
// Deprecated: Do not use.
|
||||
NewAbsoluteTxPosition = types.NewAbsoluteTxPosition
|
||||
// Deprecated: Do not use.
|
||||
NewContractInfo = types.NewContractInfo
|
||||
// Deprecated: Do not use.
|
||||
NewEnv = types.NewEnv
|
||||
// Deprecated: Do not use.
|
||||
NewWasmCoins = types.NewWasmCoins
|
||||
// Deprecated: Do not use.
|
||||
DefaultWasmConfig = types.DefaultWasmConfig
|
||||
// Deprecated: Do not use.
|
||||
DefaultParams = types.DefaultParams
|
||||
// Deprecated: Do not use.
|
||||
InitGenesis = keeper.InitGenesis
|
||||
// Deprecated: Do not use.
|
||||
ExportGenesis = keeper.ExportGenesis
|
||||
// Deprecated: Do not use.
|
||||
NewMessageHandler = keeper.NewDefaultMessageHandler
|
||||
// Deprecated: Do not use.
|
||||
DefaultEncoders = keeper.DefaultEncoders
|
||||
// Deprecated: Do not use.
|
||||
EncodeBankMsg = keeper.EncodeBankMsg
|
||||
// Deprecated: Do not use.
|
||||
NoCustomMsg = keeper.NoCustomMsg
|
||||
// Deprecated: Do not use.
|
||||
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
|
||||
ModuleCdc = types.ModuleCdc
|
||||
DefaultCodespace = types.DefaultCodespace
|
||||
ErrCreateFailed = types.ErrCreateFailed
|
||||
ErrAccountExists = types.ErrAccountExists
|
||||
// Deprecated: Do not use.
|
||||
ModuleCdc = types.ModuleCdc
|
||||
// Deprecated: Do not use.
|
||||
DefaultCodespace = types.DefaultCodespace
|
||||
// Deprecated: Do not use.
|
||||
ErrCreateFailed = types.ErrCreateFailed
|
||||
// Deprecated: Do not use.
|
||||
ErrAccountExists = types.ErrAccountExists
|
||||
// Deprecated: Do not use.
|
||||
ErrInstantiateFailed = types.ErrInstantiateFailed
|
||||
ErrExecuteFailed = types.ErrExecuteFailed
|
||||
ErrGasLimit = types.ErrGasLimit
|
||||
ErrInvalidGenesis = types.ErrInvalidGenesis
|
||||
ErrNotFound = types.ErrNotFound
|
||||
ErrQueryFailed = types.ErrQueryFailed
|
||||
ErrInvalidMsg = types.ErrInvalidMsg
|
||||
KeyLastCodeID = types.KeyLastCodeID
|
||||
KeyLastInstanceID = types.KeyLastInstanceID
|
||||
CodeKeyPrefix = types.CodeKeyPrefix
|
||||
ContractKeyPrefix = types.ContractKeyPrefix
|
||||
ContractStorePrefix = types.ContractStorePrefix
|
||||
EnableAllProposals = types.EnableAllProposals
|
||||
DisableAllProposals = types.DisableAllProposals
|
||||
// Deprecated: Do not use.
|
||||
ErrExecuteFailed = types.ErrExecuteFailed
|
||||
// Deprecated: Do not use.
|
||||
ErrGasLimit = types.ErrGasLimit
|
||||
// Deprecated: Do not use.
|
||||
ErrInvalidGenesis = types.ErrInvalidGenesis
|
||||
// Deprecated: Do not use.
|
||||
ErrNotFound = types.ErrNotFound
|
||||
// Deprecated: Do not use.
|
||||
ErrQueryFailed = types.ErrQueryFailed
|
||||
// Deprecated: Do not use.
|
||||
ErrInvalidMsg = types.ErrInvalidMsg
|
||||
// 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 (
|
||||
ProposalType = types.ProposalType
|
||||
GenesisState = types.GenesisState
|
||||
Code = types.Code
|
||||
Contract = types.Contract
|
||||
MsgStoreCode = types.MsgStoreCode
|
||||
MsgStoreCodeResponse = types.MsgStoreCodeResponse
|
||||
MsgInstantiateContract = types.MsgInstantiateContract
|
||||
MsgInstantiateContract2 = types.MsgInstantiateContract2
|
||||
// Deprecated: Do not use.
|
||||
ProposalType = types.ProposalType
|
||||
// Deprecated: Do not use.
|
||||
GenesisState = types.GenesisState
|
||||
// Deprecated: Do not use.
|
||||
Code = types.Code
|
||||
// Deprecated: Do not use.
|
||||
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
|
||||
MsgExecuteContract = types.MsgExecuteContract
|
||||
MsgExecuteContractResponse = types.MsgExecuteContractResponse
|
||||
MsgMigrateContract = types.MsgMigrateContract
|
||||
MsgMigrateContractResponse = types.MsgMigrateContractResponse
|
||||
MsgUpdateAdmin = types.MsgUpdateAdmin
|
||||
MsgUpdateAdminResponse = types.MsgUpdateAdminResponse
|
||||
MsgClearAdmin = types.MsgClearAdmin
|
||||
MsgWasmIBCCall = types.MsgIBCSend
|
||||
MsgClearAdminResponse = types.MsgClearAdminResponse
|
||||
MsgServer = types.MsgServer
|
||||
Model = types.Model
|
||||
CodeInfo = types.CodeInfo
|
||||
ContractInfo = types.ContractInfo
|
||||
CreatedAt = types.AbsoluteTxPosition
|
||||
Config = types.WasmConfig
|
||||
CodeInfoResponse = types.CodeInfoResponse
|
||||
MessageHandler = keeper.SDKMessageHandler
|
||||
BankEncoder = keeper.BankEncoder
|
||||
CustomEncoder = keeper.CustomEncoder
|
||||
StakingEncoder = keeper.StakingEncoder
|
||||
WasmEncoder = keeper.WasmEncoder
|
||||
MessageEncoders = keeper.MessageEncoders
|
||||
Keeper = keeper.Keeper
|
||||
QueryHandler = keeper.QueryHandler
|
||||
CustomQuerier = keeper.CustomQuerier
|
||||
QueryPlugins = keeper.QueryPlugins
|
||||
Option = keeper.Option
|
||||
// Deprecated: Do not use.
|
||||
MsgExecuteContract = types.MsgExecuteContract
|
||||
// Deprecated: Do not use.
|
||||
MsgExecuteContractResponse = types.MsgExecuteContractResponse
|
||||
// Deprecated: Do not use.
|
||||
MsgMigrateContract = types.MsgMigrateContract
|
||||
// Deprecated: Do not use.
|
||||
MsgMigrateContractResponse = types.MsgMigrateContractResponse
|
||||
// Deprecated: Do not use.
|
||||
MsgUpdateAdmin = types.MsgUpdateAdmin
|
||||
// Deprecated: Do not use.
|
||||
MsgUpdateAdminResponse = types.MsgUpdateAdminResponse
|
||||
// Deprecated: Do not use.
|
||||
MsgClearAdmin = types.MsgClearAdmin
|
||||
// Deprecated: Do not use.
|
||||
MsgWasmIBCCall = types.MsgIBCSend
|
||||
// Deprecated: Do not use.
|
||||
MsgClearAdminResponse = types.MsgClearAdminResponse
|
||||
// Deprecated: Do not use.
|
||||
MsgServer = types.MsgServer
|
||||
// Deprecated: Do not use.
|
||||
Model = types.Model
|
||||
// Deprecated: Do not use.
|
||||
CodeInfo = types.CodeInfo
|
||||
// Deprecated: Do not use.
|
||||
ContractInfo = types.ContractInfo
|
||||
// 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
|
||||
)
|
||||
|
||||
@@ -5,25 +5,29 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/CosmWasm/wasmd/x/wasm/types"
|
||||
)
|
||||
|
||||
const firstCodeID = 1
|
||||
|
||||
// ensure store code returns the expected response
|
||||
func assertStoreCodeResponse(t *testing.T, data []byte, expected uint64) {
|
||||
var pStoreResp MsgStoreCodeResponse
|
||||
var pStoreResp types.MsgStoreCodeResponse
|
||||
require.NoError(t, pStoreResp.Unmarshal(data))
|
||||
require.Equal(t, pStoreResp.CodeID, expected)
|
||||
}
|
||||
|
||||
// ensure execution returns the expected data
|
||||
func assertExecuteResponse(t *testing.T, data []byte, expected []byte) {
|
||||
var pExecResp MsgExecuteContractResponse
|
||||
var pExecResp types.MsgExecuteContractResponse
|
||||
require.NoError(t, pExecResp.Unmarshal(data))
|
||||
require.Equal(t, pExecResp.Data, expected)
|
||||
}
|
||||
|
||||
// ensures this returns a valid bech32 address and returns it
|
||||
func parseInitResponse(t *testing.T, data []byte) string {
|
||||
var pInstResp MsgInstantiateContractResponse
|
||||
var pInstResp types.MsgInstantiateContractResponse
|
||||
require.NoError(t, pInstResp.Unmarshal(data))
|
||||
require.NotEmpty(t, pInstResp.Address)
|
||||
addr := pInstResp.Address
|
||||
|
||||
@@ -6,6 +6,9 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/CosmWasm/wasmd/x/wasm/keeper"
|
||||
"github.com/CosmWasm/wasmd/x/wasm/types"
|
||||
)
|
||||
|
||||
func TestInitGenesis(t *testing.T) {
|
||||
@@ -16,7 +19,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
creator := data.faucet.NewFundedRandomAccount(data.ctx, deposit.Add(deposit...)...)
|
||||
fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...)
|
||||
|
||||
msg := MsgStoreCode{
|
||||
msg := types.MsgStoreCode{
|
||||
Sender: creator.String(),
|
||||
WASMByteCode: testContract,
|
||||
}
|
||||
@@ -38,7 +41,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
initMsgBz, err := json.Marshal(initMsg)
|
||||
require.NoError(t, err)
|
||||
|
||||
instMsg := MsgInstantiateContract{
|
||||
instMsg := types.MsgInstantiateContract{
|
||||
Sender: creator.String(),
|
||||
CodeID: firstCodeID,
|
||||
Msg: initMsgBz,
|
||||
@@ -50,7 +53,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
contractBech32Addr := parseInitResponse(t, res.Data)
|
||||
|
||||
execMsg := MsgExecuteContract{
|
||||
execMsg := types.MsgExecuteContract{
|
||||
Sender: fred.String(),
|
||||
Contract: contractBech32Addr,
|
||||
Msg: []byte(`{"release":{}}`),
|
||||
@@ -75,14 +78,14 @@ func TestInitGenesis(t *testing.T) {
|
||||
}, data.encConf.Marshaler)
|
||||
|
||||
// export into genstate
|
||||
genState := ExportGenesis(data.ctx, &data.keeper)
|
||||
genState := keeper.ExportGenesis(data.ctx, &data.keeper)
|
||||
|
||||
// create new app to import genstate into
|
||||
newData := setupTest(t)
|
||||
q2 := newData.grpcQueryRouter
|
||||
|
||||
// initialize new app with genstate
|
||||
_, err = InitGenesis(newData.ctx, &newData.keeper, *genState)
|
||||
_, err = keeper.InitGenesis(newData.ctx, &newData.keeper, *genState)
|
||||
require.NoError(t, err)
|
||||
|
||||
// run same checks again on newdata, to make sure it was reinitialized correctly
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
|
||||
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
|
||||
|
||||
"github.com/CosmWasm/wasmd/x/wasm/keeper"
|
||||
"github.com/CosmWasm/wasmd/x/wasm/types"
|
||||
)
|
||||
|
||||
@@ -48,7 +49,7 @@ func (i IBCHandler) OnChanOpenInit(
|
||||
if err := ValidateChannelParams(channelID); err != nil {
|
||||
return "", err
|
||||
}
|
||||
contractAddr, err := ContractFromPortID(portID)
|
||||
contractAddr, err := keeper.ContractFromPortID(portID)
|
||||
if err != nil {
|
||||
return "", errorsmod.Wrapf(err, "contract port id")
|
||||
}
|
||||
@@ -97,7 +98,7 @@ func (i IBCHandler) OnChanOpenTry(
|
||||
return "", err
|
||||
}
|
||||
|
||||
contractAddr, err := ContractFromPortID(portID)
|
||||
contractAddr, err := keeper.ContractFromPortID(portID)
|
||||
if err != nil {
|
||||
return "", errorsmod.Wrapf(err, "contract port id")
|
||||
}
|
||||
@@ -145,7 +146,7 @@ func (i IBCHandler) OnChanOpenAck(
|
||||
counterpartyChannelID string,
|
||||
counterpartyVersion string,
|
||||
) error {
|
||||
contractAddr, err := ContractFromPortID(portID)
|
||||
contractAddr, err := keeper.ContractFromPortID(portID)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(err, "contract port id")
|
||||
}
|
||||
@@ -171,7 +172,7 @@ func (i IBCHandler) OnChanOpenAck(
|
||||
|
||||
// OnChanOpenConfirm implements the IBCModule interface
|
||||
func (i IBCHandler) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error {
|
||||
contractAddr, err := ContractFromPortID(portID)
|
||||
contractAddr, err := keeper.ContractFromPortID(portID)
|
||||
if err != nil {
|
||||
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
|
||||
func (i IBCHandler) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error {
|
||||
contractAddr, err := ContractFromPortID(portID)
|
||||
contractAddr, err := keeper.ContractFromPortID(portID)
|
||||
if err != nil {
|
||||
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
|
||||
func (i IBCHandler) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error {
|
||||
// counterparty has closed the channel
|
||||
contractAddr, err := ContractFromPortID(portID)
|
||||
contractAddr, err := keeper.ContractFromPortID(portID)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(err, "contract port id")
|
||||
}
|
||||
@@ -262,7 +263,7 @@ func (i IBCHandler) OnRecvPacket(
|
||||
packet channeltypes.Packet,
|
||||
relayer sdk.AccAddress,
|
||||
) ibcexported.Acknowledgement {
|
||||
contractAddr, err := ContractFromPortID(packet.DestinationPort)
|
||||
contractAddr, err := keeper.ContractFromPortID(packet.DestinationPort)
|
||||
if err != nil {
|
||||
// this must not happen as ports were registered before
|
||||
panic(errorsmod.Wrapf(err, "contract port id"))
|
||||
@@ -290,7 +291,7 @@ func (i IBCHandler) OnAcknowledgementPacket(
|
||||
acknowledgement []byte,
|
||||
relayer sdk.AccAddress,
|
||||
) error {
|
||||
contractAddr, err := ContractFromPortID(packet.SourcePort)
|
||||
contractAddr, err := keeper.ContractFromPortID(packet.SourcePort)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(err, "contract port id")
|
||||
}
|
||||
@@ -308,7 +309,7 @@ func (i IBCHandler) OnAcknowledgementPacket(
|
||||
|
||||
// OnTimeoutPacket implements the IBCModule interface
|
||||
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 {
|
||||
return errorsmod.Wrapf(err, "contract port id")
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/CosmWasm/wasmd/app"
|
||||
"github.com/CosmWasm/wasmd/x/wasm"
|
||||
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
|
||||
)
|
||||
|
||||
var MaxAccounts = 10
|
||||
@@ -68,7 +68,7 @@ type ChainApp interface {
|
||||
GetBankKeeper() bankkeeper.Keeper
|
||||
GetStakingKeeper() *stakingkeeper.Keeper
|
||||
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
|
||||
@@ -113,22 +113,22 @@ type PacketAck struct {
|
||||
}
|
||||
|
||||
// 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
|
||||
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...)
|
||||
}
|
||||
|
||||
// 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
|
||||
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...)
|
||||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
var (
|
||||
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.
|
||||
// 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{}
|
||||
genBals := []banktypes.Balance{}
|
||||
senderAccs := []SenderAccount{}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/CosmWasm/wasmd/app"
|
||||
"github.com/CosmWasm/wasmd/x/wasm"
|
||||
)
|
||||
|
||||
func TestModuleMigrations(t *testing.T) {
|
||||
@@ -55,7 +54,7 @@ func TestModuleMigrations(t *testing.T) {
|
||||
spec.setup(ctx)
|
||||
|
||||
fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx)
|
||||
fromVM[wasm.ModuleName] = spec.startVersion
|
||||
fromVM[types.ModuleName] = spec.startVersion
|
||||
_, err := upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -65,7 +64,7 @@ func TestModuleMigrations(t *testing.T) {
|
||||
// then
|
||||
require.NoError(t, err)
|
||||
var expModuleVersion uint64 = 4
|
||||
assert.Equal(t, expModuleVersion, gotVM[wasm.ModuleName])
|
||||
assert.Equal(t, expModuleVersion, gotVM[types.ModuleName])
|
||||
gotParams := wasmApp.WasmKeeper.GetParams(ctx)
|
||||
assert.Equal(t, spec.exp, gotParams)
|
||||
})
|
||||
@@ -98,7 +97,7 @@ func TestAccessConfigMigrations(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
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)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -108,7 +107,7 @@ func TestAccessConfigMigrations(t *testing.T) {
|
||||
// then
|
||||
require.NoError(t, err)
|
||||
var expModuleVersion uint64 = 4
|
||||
assert.Equal(t, expModuleVersion, gotVM[wasm.ModuleName])
|
||||
assert.Equal(t, expModuleVersion, gotVM[types.ModuleName])
|
||||
|
||||
// any address was not migrated
|
||||
assert.Equal(t, types.AccessTypeAnyOfAddresses.With(address), wasmApp.WasmKeeper.GetCodeInfo(ctx, code1).InstantiateConfig)
|
||||
|
||||
@@ -49,7 +49,7 @@ const (
|
||||
type AppModuleBasic struct{}
|
||||
|
||||
func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {
|
||||
RegisterCodec(amino)
|
||||
types.RegisterLegacyAminoCodec(amino)
|
||||
}
|
||||
|
||||
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.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return ModuleName
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the wasm
|
||||
// module.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(&GenesisState{
|
||||
Params: DefaultParams(),
|
||||
return cdc.MustMarshalJSON(&types.GenesisState{
|
||||
Params: types.DefaultParams(),
|
||||
})
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the wasm module.
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ValidateGenesis(data)
|
||||
return types.ValidateGenesis(data)
|
||||
}
|
||||
|
||||
// GetTxCmd returns the root tx command for the wasm module.
|
||||
@@ -104,7 +104,7 @@ var _ appmodule.AppModule = AppModule{}
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
cdc codec.Codec
|
||||
keeper *Keeper
|
||||
keeper *keeper.Keeper
|
||||
validatorSetSource keeper.ValidatorSetSource
|
||||
accountKeeper types.AccountKeeper // for simulation
|
||||
bankKeeper simulation.BankKeeper
|
||||
@@ -116,7 +116,7 @@ type AppModule struct {
|
||||
// NewAppModule creates a new AppModule object
|
||||
func NewAppModule(
|
||||
cdc codec.Codec,
|
||||
keeper *Keeper,
|
||||
keeper *keeper.Keeper,
|
||||
validatorSetSource keeper.ValidatorSetSource,
|
||||
ak types.AccountKeeper,
|
||||
bk simulation.BankKeeper,
|
||||
@@ -151,7 +151,7 @@ func (AppModule) ConsensusVersion() uint64 { return 4 }
|
||||
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
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)
|
||||
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.
|
||||
func (AppModule) QuerierRoute() string {
|
||||
return QuerierRoute
|
||||
return types.QuerierRoute
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the wasm module. It returns
|
||||
// no validator updates.
|
||||
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)
|
||||
validators, err := InitGenesis(ctx, am.keeper, genesisState)
|
||||
validators, err := keeper.InitGenesis(ctx, am.keeper, genesisState)
|
||||
if err != nil {
|
||||
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
|
||||
// module.
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
|
||||
// AddModuleInitFlags implements servertypes.ModuleInitFlags interface.
|
||||
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().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")
|
||||
|
||||
@@ -46,7 +46,7 @@ type testData struct {
|
||||
module AppModule
|
||||
ctx sdk.Context
|
||||
acctKeeper authkeeper.AccountKeeper
|
||||
keeper Keeper
|
||||
keeper keeper.Keeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
faucet *keeper.TestFaucet
|
||||
@@ -56,7 +56,7 @@ type testData struct {
|
||||
}
|
||||
|
||||
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)
|
||||
queryRouter := baseapp.NewGRPCQueryRouter()
|
||||
serviceRouter := baseapp.NewMsgServiceRouter()
|
||||
@@ -107,32 +107,32 @@ func TestHandleCreate(t *testing.T) {
|
||||
isValid bool
|
||||
}{
|
||||
"empty": {
|
||||
msg: &MsgStoreCode{},
|
||||
msg: &types.MsgStoreCode{},
|
||||
isValid: false,
|
||||
},
|
||||
"invalid wasm": {
|
||||
msg: &MsgStoreCode{
|
||||
msg: &types.MsgStoreCode{
|
||||
Sender: addr1,
|
||||
WASMByteCode: []byte("foobar"),
|
||||
},
|
||||
isValid: false,
|
||||
},
|
||||
"valid wasm": {
|
||||
msg: &MsgStoreCode{
|
||||
msg: &types.MsgStoreCode{
|
||||
Sender: addr1,
|
||||
WASMByteCode: testContract,
|
||||
},
|
||||
isValid: true,
|
||||
},
|
||||
"other valid wasm": {
|
||||
msg: &MsgStoreCode{
|
||||
msg: &types.MsgStoreCode{
|
||||
Sender: addr1,
|
||||
WASMByteCode: maskContract,
|
||||
},
|
||||
isValid: true,
|
||||
},
|
||||
"old wasm (0.7)": {
|
||||
msg: &MsgStoreCode{
|
||||
msg: &types.MsgStoreCode{
|
||||
Sender: addr1,
|
||||
WASMByteCode: oldContract,
|
||||
},
|
||||
@@ -177,7 +177,7 @@ func TestHandleInstantiate(t *testing.T) {
|
||||
data := setupTest(t)
|
||||
creator := data.faucet.NewFundedRandomAccount(data.ctx, sdk.NewInt64Coin("denom", 100000))
|
||||
|
||||
msg := &MsgStoreCode{
|
||||
msg := &types.MsgStoreCode{
|
||||
Sender: creator.String(),
|
||||
WASMByteCode: testContract,
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func TestHandleInstantiate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// create with no balance is also legal
|
||||
initMsg := &MsgInstantiateContract{
|
||||
initMsg := &types.MsgInstantiateContract{
|
||||
Sender: creator.String(),
|
||||
CodeID: firstCodeID,
|
||||
Msg: initMsgBz,
|
||||
@@ -240,7 +240,7 @@ func TestHandleExecute(t *testing.T) {
|
||||
creator := data.faucet.NewFundedRandomAccount(data.ctx, deposit.Add(deposit...)...)
|
||||
fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...)
|
||||
|
||||
msg := &MsgStoreCode{
|
||||
msg := &types.MsgStoreCode{
|
||||
Sender: creator.String(),
|
||||
WASMByteCode: testContract,
|
||||
}
|
||||
@@ -258,7 +258,7 @@ func TestHandleExecute(t *testing.T) {
|
||||
initMsgBz, err := json.Marshal(initMsg)
|
||||
require.NoError(t, err)
|
||||
|
||||
initCmd := &MsgInstantiateContract{
|
||||
initCmd := &types.MsgInstantiateContract{
|
||||
Sender: creator.String(),
|
||||
CodeID: firstCodeID,
|
||||
Msg: initMsgBz,
|
||||
@@ -296,7 +296,7 @@ func TestHandleExecute(t *testing.T) {
|
||||
require.NotNil(t, contractAcct)
|
||||
assert.Equal(t, deposit, data.bankKeeper.GetAllBalances(data.ctx, contractAcct.GetAddress()))
|
||||
|
||||
execCmd := &MsgExecuteContract{
|
||||
execCmd := &types.MsgExecuteContract{
|
||||
Sender: fred.String(),
|
||||
Contract: contractBech32Addr,
|
||||
Msg: []byte(`{"release":{}}`),
|
||||
@@ -374,7 +374,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
|
||||
data.faucet.Fund(data.ctx, creator, sdk.NewInt64Coin("denom", 100000))
|
||||
fred := data.faucet.NewFundedRandomAccount(data.ctx, topUp...)
|
||||
|
||||
msg := &MsgStoreCode{
|
||||
msg := &types.MsgStoreCode{
|
||||
Sender: creator.String(),
|
||||
WASMByteCode: testContract,
|
||||
}
|
||||
@@ -391,7 +391,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
|
||||
initMsgBz, err := json.Marshal(initMsg)
|
||||
require.NoError(t, err)
|
||||
|
||||
initCmd := MsgInstantiateContract{
|
||||
initCmd := types.MsgInstantiateContract{
|
||||
Sender: creator.String(),
|
||||
CodeID: firstCodeID,
|
||||
Msg: initMsgBz,
|
||||
@@ -410,7 +410,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
|
||||
handleMsgBz, err := json.Marshal(handleMsg)
|
||||
require.NoError(t, err)
|
||||
|
||||
execCmd := MsgExecuteContract{
|
||||
execCmd := types.MsgExecuteContract{
|
||||
Sender: fred.String(),
|
||||
Contract: contractBech32Addr,
|
||||
Msg: handleMsgBz,
|
||||
@@ -443,7 +443,7 @@ func TestReadWasmConfig(t *testing.T) {
|
||||
return v
|
||||
}
|
||||
var one uint64 = 1
|
||||
defaults := DefaultWasmConfig()
|
||||
defaults := types.DefaultWasmConfig()
|
||||
|
||||
specs := map[string]struct {
|
||||
src servertypes.AppOptions
|
||||
|
||||
Reference in New Issue
Block a user