Make app keepers public (#951)

* use ecosystem convention for keeper names in app.go

* fix linting

* Revert variable renaming

* Deprecate attribute access helper

* Formatting only

* Replace usage of deprecated test helper

* Address linter report

Co-authored-by: faddat <jacobgadikian@gmail.com>
This commit is contained in:
Alexander Peters
2022-08-23 17:01:04 +02:00
committed by GitHub
parent f14c46988a
commit 00082a25b8
18 changed files with 252 additions and 295 deletions

View File

@@ -243,33 +243,33 @@ type WasmApp struct {
memKeys map[string]*sdk.MemoryStoreKey
// keepers
accountKeeper authkeeper.AccountKeeper
bankKeeper bankkeeper.Keeper
capabilityKeeper *capabilitykeeper.Keeper
stakingKeeper stakingkeeper.Keeper
slashingKeeper slashingkeeper.Keeper
mintKeeper mintkeeper.Keeper
distrKeeper distrkeeper.Keeper
govKeeper govkeeper.Keeper
crisisKeeper crisiskeeper.Keeper
upgradeKeeper upgradekeeper.Keeper
paramsKeeper paramskeeper.Keeper
evidenceKeeper evidencekeeper.Keeper
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
icaControllerKeeper icacontrollerkeeper.Keeper
icaHostKeeper icahostkeeper.Keeper
interTxKeeper intertxkeeper.Keeper
transferKeeper ibctransferkeeper.Keeper
feeGrantKeeper feegrantkeeper.Keeper
authzKeeper authzkeeper.Keeper
wasmKeeper wasm.Keeper
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
InterTxKeeper intertxkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
WasmKeeper wasm.Keeper
scopedIBCKeeper capabilitykeeper.ScopedKeeper
scopedICAHostKeeper capabilitykeeper.ScopedKeeper
scopedICAControllerKeeper capabilitykeeper.ScopedKeeper
scopedInterTxKeeper capabilitykeeper.ScopedKeeper
scopedTransferKeeper capabilitykeeper.ScopedKeeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedInterTxKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
// the module manager
mm *module.Manager
@@ -324,7 +324,7 @@ func NewWasmApp(
memKeys: memKeys,
}
app.paramsKeeper = initParamsKeeper(
app.ParamsKeeper = initParamsKeeper(
appCodec,
legacyAmino,
keys[paramstypes.StoreKey],
@@ -332,86 +332,86 @@ func NewWasmApp(
)
// set the BaseApp's parameter store
bApp.SetParamStore(app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
// add capability keeper and ScopeToModule for ibc module
app.capabilityKeeper = capabilitykeeper.NewKeeper(
app.CapabilityKeeper = capabilitykeeper.NewKeeper(
appCodec,
keys[capabilitytypes.StoreKey],
memKeys[capabilitytypes.MemStoreKey],
)
scopedIBCKeeper := app.capabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedICAHostKeeper := app.capabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.capabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedInterTxKeeper := app.capabilityKeeper.ScopeToModule(intertxtypes.ModuleName)
scopedTransferKeeper := app.capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.capabilityKeeper.ScopeToModule(wasm.ModuleName)
app.capabilityKeeper.Seal()
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedInterTxKeeper := app.CapabilityKeeper.ScopeToModule(intertxtypes.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
app.CapabilityKeeper.Seal()
// add keepers
app.accountKeeper = authkeeper.NewAccountKeeper(
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
keys[authtypes.StoreKey],
app.getSubspace(authtypes.ModuleName),
authtypes.ProtoBaseAccount,
maccPerms,
)
app.bankKeeper = bankkeeper.NewBaseKeeper(
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.accountKeeper,
app.AccountKeeper,
app.getSubspace(banktypes.ModuleName),
app.ModuleAccountAddrs(),
)
app.authzKeeper = authzkeeper.NewKeeper(
app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.BaseApp.MsgServiceRouter(),
)
app.feeGrantKeeper = feegrantkeeper.NewKeeper(
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
appCodec,
keys[feegrant.StoreKey],
app.accountKeeper,
app.AccountKeeper,
)
stakingKeeper := stakingkeeper.NewKeeper(
appCodec,
keys[stakingtypes.StoreKey],
app.accountKeeper,
app.bankKeeper,
app.AccountKeeper,
app.BankKeeper,
app.getSubspace(stakingtypes.ModuleName),
)
app.mintKeeper = mintkeeper.NewKeeper(
app.MintKeeper = mintkeeper.NewKeeper(
appCodec,
keys[minttypes.StoreKey],
app.getSubspace(minttypes.ModuleName),
&stakingKeeper,
app.accountKeeper,
app.bankKeeper,
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
)
app.distrKeeper = distrkeeper.NewKeeper(
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec,
keys[distrtypes.StoreKey],
app.getSubspace(distrtypes.ModuleName),
app.accountKeeper,
app.bankKeeper,
app.AccountKeeper,
app.BankKeeper,
&stakingKeeper,
authtypes.FeeCollectorName,
app.ModuleAccountAddrs(),
)
app.slashingKeeper = slashingkeeper.NewKeeper(
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec,
keys[slashingtypes.StoreKey],
&stakingKeeper,
app.getSubspace(slashingtypes.ModuleName),
)
app.crisisKeeper = crisiskeeper.NewKeeper(
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.getSubspace(crisistypes.ModuleName),
invCheckPeriod,
app.bankKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
)
app.upgradeKeeper = upgradekeeper.NewKeeper(
app.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
keys[upgradetypes.StoreKey],
appCodec,
@@ -421,16 +421,16 @@ func NewWasmApp(
// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.stakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()),
app.StakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)
app.ibcKeeper = ibckeeper.NewKeeper(
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
keys[ibchost.StoreKey],
app.getSubspace(ibchost.ModuleName),
app.stakingKeeper,
app.upgradeKeeper,
app.StakingKeeper,
app.UpgradeKeeper,
scopedIBCKeeper,
)
@@ -438,66 +438,66 @@ func NewWasmApp(
govRouter := govtypes.NewRouter()
govRouter.
AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper))
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
// Create Transfer Keepers
app.transferKeeper = ibctransferkeeper.NewKeeper(
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.getSubspace(ibctransfertypes.ModuleName),
app.ibcKeeper.ChannelKeeper,
app.ibcKeeper.ChannelKeeper,
&app.ibcKeeper.PortKeeper,
app.accountKeeper,
app.bankKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
)
transferModule := transfer.NewAppModule(app.transferKeeper)
transferIBCModule := transfer.NewIBCModule(app.transferKeeper)
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
app.icaHostKeeper = icahostkeeper.NewKeeper(
app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
app.getSubspace(icahosttypes.SubModuleName),
app.ibcKeeper.ChannelKeeper,
&app.ibcKeeper.PortKeeper,
app.accountKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
)
app.icaControllerKeeper = icacontrollerkeeper.NewKeeper(
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
keys[icacontrollertypes.StoreKey],
app.getSubspace(icacontrollertypes.SubModuleName),
app.ibcKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee
app.ibcKeeper.ChannelKeeper,
&app.ibcKeeper.PortKeeper,
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper,
app.MsgServiceRouter(),
)
icaModule := ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.icaHostKeeper)
icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)
// For wasmd we use the demo controller from https://github.com/cosmos/interchain-accounts but see notes below
app.interTxKeeper = intertxkeeper.NewKeeper(appCodec, keys[intertxtypes.StoreKey], app.icaControllerKeeper, scopedInterTxKeeper)
app.InterTxKeeper = intertxkeeper.NewKeeper(appCodec, keys[intertxtypes.StoreKey], app.ICAControllerKeeper, scopedInterTxKeeper)
// Note: please do your research before using this in production app, this is a demo and not an officially
// supported IBC team implementation. Do your own research before using it.
interTxModule := intertx.NewAppModule(appCodec, app.interTxKeeper)
interTxIBCModule := intertx.NewIBCModule(app.interTxKeeper)
interTxModule := intertx.NewAppModule(appCodec, app.InterTxKeeper)
interTxIBCModule := intertx.NewIBCModule(app.InterTxKeeper)
// You will likely want to swap out the second argument with your own reviewed and maintained ica auth module
icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, interTxIBCModule)
icaControllerIBCModule := icacontroller.NewIBCModule(app.ICAControllerKeeper, interTxIBCModule)
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec,
keys[evidencetypes.StoreKey],
&app.stakingKeeper,
app.slashingKeeper,
&app.StakingKeeper,
app.SlashingKeeper,
)
app.evidenceKeeper = *evidenceKeeper
app.EvidenceKeeper = *evidenceKeeper
wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
@@ -508,18 +508,18 @@ func NewWasmApp(
// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate"
app.wasmKeeper = wasm.NewKeeper(
app.WasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
app.getSubspace(wasm.ModuleName),
app.accountKeeper,
app.bankKeeper,
app.stakingKeeper,
app.distrKeeper,
app.ibcKeeper.ChannelKeeper,
&app.ibcKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.DistrKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
app.transferKeeper,
app.TransferKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
wasmDir,
@@ -533,22 +533,22 @@ 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(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
}
ibcRouter.
AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.ibcKeeper.ChannelKeeper)).
AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper)).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(intertxtypes.ModuleName, icaControllerIBCModule)
app.ibcKeeper.SetRouter(ibcRouter)
app.IBCKeeper.SetRouter(ibcRouter)
app.govKeeper = govkeeper.NewKeeper(
app.GovKeeper = govkeeper.NewKeeper(
appCodec,
keys[govtypes.StoreKey],
app.getSubspace(govtypes.ModuleName),
app.accountKeeper,
app.bankKeeper,
app.AccountKeeper,
app.BankKeeper,
&stakingKeeper,
govRouter,
)
@@ -562,31 +562,31 @@ func NewWasmApp(
// must be passed by reference here.
app.mm = module.NewManager(
genutil.NewAppModule(
app.accountKeeper,
app.stakingKeeper,
app.AccountKeeper,
app.StakingKeeper,
app.BaseApp.DeliverTx,
encodingConfig.TxConfig,
),
auth.NewAppModule(appCodec, app.accountKeeper, nil),
vesting.NewAppModule(app.accountKeeper, app.bankKeeper),
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper),
capability.NewAppModule(appCodec, *app.capabilityKeeper),
gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper),
slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
evidence.NewAppModule(app.evidenceKeeper),
feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.feeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
auth.NewAppModule(appCodec, app.AccountKeeper, nil),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
icaModule,
interTxModule,
crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them
)
// During begin block slashing happens after distr.BeginBlocker so that
@@ -679,7 +679,7 @@ func NewWasmApp(
// Uncomment if you want to set a custom migration order here.
// app.mm.SetOrderMigrations(custom order)
app.mm.RegisterInvariants(&app.crisisKeeper)
app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
@@ -690,20 +690,20 @@ func NewWasmApp(
// NOTE: this is not required apps that don't use the simulator for fuzz testing
// transactions
app.sm = module.NewSimulationManager(
auth.NewAppModule(appCodec, app.accountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper),
capability.NewAppModule(appCodec, *app.capabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.feeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
params.NewAppModule(app.paramsKeeper),
evidence.NewAppModule(app.evidenceKeeper),
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
ibc.NewAppModule(app.ibcKeeper),
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
)
@@ -716,13 +716,13 @@ func NewWasmApp(
anteHandler, err := NewAnteHandler(
HandlerOptions{
HandlerOptions: ante.HandlerOptions{
AccountKeeper: app.accountKeeper,
BankKeeper: app.bankKeeper,
FeegrantKeeper: app.feeGrantKeeper,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCKeeper: app.ibcKeeper,
IBCKeeper: app.IBCKeeper,
WasmConfig: &wasmConfig,
TXCounterStoreKey: keys[wasm.StoreKey],
},
@@ -741,19 +741,19 @@ func NewWasmApp(
// see cmd/wasmd/root.go: 206 - 214 approx
if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.wasmKeeper),
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}
app.scopedIBCKeeper = scopedIBCKeeper
app.scopedTransferKeeper = scopedTransferKeeper
app.scopedWasmKeeper = scopedWasmKeeper
app.scopedICAHostKeeper = scopedICAHostKeeper
app.scopedICAControllerKeeper = scopedICAControllerKeeper
app.scopedInterTxKeeper = scopedInterTxKeeper
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedInterTxKeeper = scopedInterTxKeeper
if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
@@ -762,7 +762,7 @@ func NewWasmApp(
ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{})
// Initialize pinned codes in wasmvm as they are not persisted there
if err := app.wasmKeeper.InitializePinnedCodes(ctx); err != nil {
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil {
tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err))
}
}
@@ -790,7 +790,7 @@ func (app *WasmApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci
panic(err)
}
app.upgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}
@@ -822,7 +822,7 @@ func (app *WasmApp) LegacyAmino() *codec.LegacyAmino { //nolint:staticcheck
//
// NOTE: This is solely to be used for testing purposes.
func (app *WasmApp) getSubspace(moduleName string) paramstypes.Subspace {
subspace, _ := app.paramsKeeper.GetSubspace(moduleName)
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
return subspace
}

View File

@@ -47,7 +47,7 @@ func TestBlockedAddrs(t *testing.T) {
for acc := range maccPerms {
t.Run(acc, func(t *testing.T) {
require.True(t, gapp.bankKeeper.BlockedAddr(gapp.accountKeeper.GetModuleAddress(acc)),
require.True(t, gapp.BankKeeper.BlockedAddr(gapp.AccountKeeper.GetModuleAddress(acc)),
"ensure that blocked addresses are properly set in bank keeper",
)
})

View File

@@ -35,7 +35,7 @@ func (app *WasmApp) ExportAppStateAndValidators(
return servertypes.ExportedApp{}, err
}
validators, err := staking.WriteValidators(ctx, app.stakingKeeper)
validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
return servertypes.ExportedApp{
AppState: appState,
Validators: validators,
@@ -46,7 +46,8 @@ func (app *WasmApp) ExportAppStateAndValidators(
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
//
// in favour of export at a block height
func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false
@@ -66,18 +67,18 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
}
/* Just to be safe, assert the invariants on current state. */
app.crisisKeeper.AssertInvariants(ctx)
app.CrisisKeeper.AssertInvariants(ctx)
/* Handle fee distribution state. */
// withdraw all validator commission
app.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, _ = app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) //nolint:errcheck
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) //nolint:errcheck
return false
})
// withdraw all delegator rewards
dels := app.stakingKeeper.GetAllDelegations(ctx)
dels := app.StakingKeeper.GetAllDelegations(ctx)
for _, delegation := range dels {
valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
if err != nil {
@@ -88,28 +89,28 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
if err != nil {
panic(err)
}
_, _ = app.distrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) //nolint:errcheck
_, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) //nolint:errcheck
}
// clear validator slash events
app.distrKeeper.DeleteAllValidatorSlashEvents(ctx)
app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx)
// clear validator historical rewards
app.distrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
// set context height to zero
height := ctx.BlockHeight()
ctx = ctx.WithBlockHeight(0)
// reinitialize all validators
app.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
// donate any unwithdrawn outstanding reward fraction tokens to the community pool
scraps := app.distrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
feePool := app.distrKeeper.GetFeePool(ctx)
scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
feePool := app.DistrKeeper.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.distrKeeper.SetFeePool(ctx, feePool)
app.DistrKeeper.SetFeePool(ctx, feePool)
app.distrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
return false
})
@@ -123,8 +124,8 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
if err != nil {
panic(err)
}
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.distrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
}
// reset context height
@@ -133,20 +134,20 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
/* Handle staking state. */
// iterate through redelegations, reset creation height
app.stakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
app.stakingKeeper.SetRedelegation(ctx, red)
app.StakingKeeper.SetRedelegation(ctx, red)
return false
})
// iterate through unbonding delegations, reset creation height
app.stakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
app.stakingKeeper.SetUnbondingDelegation(ctx, ubd)
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
return false
})
@@ -158,7 +159,7 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
for ; iter.Valid(); iter.Next() {
addr := sdk.ValAddress(iter.Key()[1:])
validator, found := app.stakingKeeper.GetValidator(ctx, addr)
validator, found := app.StakingKeeper.GetValidator(ctx, addr)
if !found {
panic("expected validator, not found")
}
@@ -168,13 +169,13 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
validator.Jailed = true
}
app.stakingKeeper.SetValidator(ctx, validator)
app.StakingKeeper.SetValidator(ctx, validator)
counter++
}
iter.Close()
_, err := app.stakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
_, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
if err != nil {
log.Fatal(err)
}
@@ -182,11 +183,11 @@ func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
/* Handle slashing state. */
// reset start height on signing infos
app.slashingKeeper.IterateValidatorSigningInfos(
app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.slashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
return false
},
)

View File

@@ -213,7 +213,7 @@ func TestAppImportExport(t *testing.T) {
normalizeContractInfo := func(ctx sdk.Context, app *WasmApp) {
var index uint64
app.wasmKeeper.IterateContractInfo(ctx, func(address sdk.AccAddress, info wasmtypes.ContractInfo) bool {
app.WasmKeeper.IterateContractInfo(ctx, func(address sdk.AccAddress, info wasmtypes.ContractInfo) bool {
created := &wasmtypes.AbsoluteTxPosition{
BlockHeight: uint64(0),
TxIndex: index,

View File

@@ -18,6 +18,7 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
)
// Deprecated: use public app attributes directly
type TestSupport struct {
t testing.TB
app *WasmApp
@@ -28,11 +29,11 @@ func NewTestSupport(t testing.TB, app *WasmApp) *TestSupport {
}
func (s TestSupport) IBCKeeper() *ibckeeper.Keeper {
return s.app.ibcKeeper
return s.app.IBCKeeper
}
func (s TestSupport) WasmKeeper() wasm.Keeper {
return s.app.wasmKeeper
return s.app.WasmKeeper
}
func (s TestSupport) AppCodec() codec.Codec {
@@ -40,27 +41,27 @@ func (s TestSupport) AppCodec() codec.Codec {
}
func (s TestSupport) ScopedWasmIBCKeeper() capabilitykeeper.ScopedKeeper {
return s.app.scopedWasmKeeper
return s.app.ScopedWasmKeeper
}
func (s TestSupport) ScopeIBCKeeper() capabilitykeeper.ScopedKeeper {
return s.app.scopedIBCKeeper
return s.app.ScopedIBCKeeper
}
func (s TestSupport) ScopedTransferKeeper() capabilitykeeper.ScopedKeeper {
return s.app.scopedTransferKeeper
return s.app.ScopedTransferKeeper
}
func (s TestSupport) StakingKeeper() stakingkeeper.Keeper {
return s.app.stakingKeeper
return s.app.StakingKeeper
}
func (s TestSupport) BankKeeper() bankkeeper.Keeper {
return s.app.bankKeeper
return s.app.BankKeeper
}
func (s TestSupport) TransferKeeper() ibctransferkeeper.Keeper {
return s.app.transferKeeper
return s.app.TransferKeeper
}
func (s TestSupport) GetBaseApp() *baseapp.BaseApp {

View File

@@ -201,7 +201,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress {
// AddTestAddrsFromPubKeys adds the addresses into the WasmApp providing only the public keys.
func AddTestAddrsFromPubKeys(app *WasmApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int) {
initCoins := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt))
initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))
for _, pk := range pubKeys {
initAccountWithCoins(app, ctx, sdk.AccAddress(pk.Address()), initCoins)
@@ -223,7 +223,7 @@ func AddTestAddrsIncremental(app *WasmApp, ctx sdk.Context, accNum int, accAmt s
func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdk.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
testAddrs := strategy(accNum)
initCoins := sdk.NewCoins(sdk.NewCoin(app.stakingKeeper.BondDenom(ctx), accAmt))
initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))
// fill all the addresses with some coins, set the loose pool tokens simultaneously
for _, addr := range testAddrs {
@@ -234,12 +234,12 @@ func addTestAddrs(app *WasmApp, ctx sdk.Context, accNum int, accAmt sdk.Int, str
}
func initAccountWithCoins(app *WasmApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) {
err := app.bankKeeper.MintCoins(ctx, minttypes.ModuleName, coins)
err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins)
if err != nil {
panic(err)
}
err = app.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins)
err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins)
if err != nil {
panic(err)
}
@@ -280,7 +280,7 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) {
// CheckBalance checks the balance of an account.
func CheckBalance(t *testing.T, app *WasmApp, addr sdk.AccAddress, balances sdk.Coins) {
ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{})
require.True(t, balances.IsEqual(app.bankKeeper.GetAllBalances(ctxCheck, addr)))
require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr)))
}
const DefaultGas = 1200000

View File

@@ -7,7 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
wasmvm "github.com/CosmWasm/wasmvm"
@@ -174,7 +174,7 @@ func GetCmdQueryCode() *cobra.Command {
}
fmt.Printf("Downloading wasm code to %s\n", args[1])
return ioutil.WriteFile(args[1], res.Data, 0o600)
return os.WriteFile(args[1], res.Data, 0o600)
},
}
flags.AddQueryFlagsToCmd(cmd)

View File

@@ -3,7 +3,7 @@ package cli
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"github.com/cosmos/cosmos-sdk/client"
@@ -81,7 +81,7 @@ func StoreCodeCmd() *cobra.Command {
}
func parseStoreCodeArgs(file string, sender sdk.AccAddress, flags *flag.FlagSet) (types.MsgStoreCode, error) {
wasm, err := ioutil.ReadFile(file)
wasm, err := os.ReadFile(file)
if err != nil {
return types.MsgStoreCode{}, err
}

View File

@@ -6,7 +6,6 @@ import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@@ -17,7 +16,6 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
@@ -25,10 +23,8 @@ import (
commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types"
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/cosmos/ibc-go/v3/modules/core/types"
ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
"github.com/cosmos/ibc-go/v3/testing/mock"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
@@ -38,7 +34,9 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
tmversion "github.com/tendermint/tendermint/version"
wasmd "github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/app/params"
"github.com/CosmWasm/wasmd/x/wasm"
)
@@ -51,7 +49,7 @@ type TestChain struct {
t *testing.T
Coordinator *Coordinator
App ibctesting.TestingApp
App *app.WasmApp
ChainID string
LastHeader *ibctmtypes.Header // header for last block height committed
CurrentHeader tmproto.Header // header for current block height
@@ -104,7 +102,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amount)),
}
app := NewTestingAppDecorator(t, wasmd.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, opts, balance))
wasmApp := app.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, opts, balance)
// create current header and call begin block
header := tmproto.Header{
@@ -113,18 +111,18 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm
Time: coord.CurrentTime.UTC(),
}
txConfig := app.GetTxConfig()
txConfig := params.MakeEncodingConfig().TxConfig
// create an account to send transactions from
chain := &TestChain{
t: t,
Coordinator: coord,
ChainID: chainID,
App: app,
App: wasmApp,
CurrentHeader: header,
QueryServer: app.GetIBCKeeper(),
QueryServer: wasmApp.IBCKeeper,
TxConfig: txConfig,
Codec: app.AppCodec(),
Codec: wasmApp.AppCodec(),
Vals: valSet,
Signers: signers,
senderPrivKey: senderPrivKey,
@@ -138,7 +136,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasm
// GetContext returns the current context for the application.
func (chain *TestChain) GetContext() sdk.Context {
return chain.App.GetBaseApp().NewContext(false, chain.CurrentHeader)
return chain.App.BaseApp.NewContext(false, chain.CurrentHeader)
}
// QueryProof performs an abci query with the given key and returns the proto encoded merkle proof
@@ -244,10 +242,10 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) {
// ensure the chain has the latest time
chain.Coordinator.UpdateTimeForChain(chain)
_, r, err := wasmd.SignAndDeliver(
_, r, err := app.SignAndDeliver(
chain.t,
chain.TxConfig,
chain.App.GetBaseApp(),
chain.App.BaseApp,
chain.GetContext().BlockHeader(),
msgs,
chain.ChainID,
@@ -291,7 +289,7 @@ func (chain *TestChain) captureIBCEvents(r *sdk.Result) {
// GetClientState retrieves the client state for the provided clientID. The client is
// expected to exist otherwise testing will fail.
func (chain *TestChain) GetClientState(clientID string) exported.ClientState {
clientState, found := chain.App.GetIBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID)
clientState, found := chain.App.IBCKeeper.ClientKeeper.GetClientState(chain.GetContext(), clientID)
require.True(chain.t, found)
return clientState
@@ -300,13 +298,13 @@ func (chain *TestChain) GetClientState(clientID string) exported.ClientState {
// GetConsensusState retrieves the consensus state for the provided clientID and height.
// It will return a success boolean depending on if consensus state exists or not.
func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool) {
return chain.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height)
return chain.App.IBCKeeper.ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height)
}
// GetValsAtHeight will return the validator set of the chain at a given height. It will return
// a success boolean depending on if the validator set exists or not at that height.
func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bool) {
histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height)
histInfo, ok := chain.App.StakingKeeper.GetHistoricalInfo(chain.GetContext(), height)
if !ok {
return nil, false
}
@@ -323,7 +321,7 @@ func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bo
// GetAcknowledgement retrieves an acknowledgement for the provided packet. If the
// acknowledgement does not exist then testing will fail.
func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte {
ack, found := chain.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
ack, found := chain.App.IBCKeeper.ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
require.True(chain.t, found)
return ack
@@ -331,7 +329,7 @@ func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte {
// GetPrefix returns the prefix for used by a chain in connection creation
func (chain *TestChain) GetPrefix() commitmenttypes.MerklePrefix {
return commitmenttypes.NewMerklePrefix(chain.App.GetIBCKeeper().ConnectionKeeper.GetCommitmentPrefix().Bytes())
return commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())
}
// ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the
@@ -490,10 +488,10 @@ func CreateSortedSignerArray(altPrivVal, suitePrivVal tmtypes.PrivValidator,
// Other applications must bind to the port in InitGenesis or modify this code.
func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string) {
// check if the portId is already binded, if not bind it
_, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID))
_, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID))
if !ok {
// create capability using the IBC capability keeper
cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID))
cap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), host.PortPath(portID))
require.NoError(chain.t, err)
// claim capability using the scopedKeeper
@@ -509,7 +507,7 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope
// GetPortCapability returns the port capability for the given portID. The capability must
// exist, otherwise testing will fail.
func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability {
cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID))
cap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID))
require.True(chain.t, ok)
return cap
@@ -521,9 +519,9 @@ func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capabi
func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string) {
capName := host.ChannelCapabilityPath(portID, channelID)
// check if the portId is already binded, if not bind it
_, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName)
_, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), capName)
if !ok {
cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName)
cap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), capName)
require.NoError(chain.t, err)
err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName)
require.NoError(chain.t, err)
@@ -537,55 +535,16 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc
// GetChannelCapability returns the channel capability for the given portID and channelID.
// The capability must exist, otherwise testing will fail.
func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability {
cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID))
cap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID))
require.True(chain.t, ok)
return cap
}
func (chain *TestChain) Balance(acc sdk.AccAddress, denom string) sdk.Coin {
return chain.GetTestSupport().BankKeeper().GetBalance(chain.GetContext(), acc, denom)
return chain.App.BankKeeper.GetBalance(chain.GetContext(), acc, denom)
}
func (chain *TestChain) AllBalances(acc sdk.AccAddress) sdk.Coins {
return chain.GetTestSupport().BankKeeper().GetAllBalances(chain.GetContext(), acc)
}
func (chain TestChain) GetTestSupport() *wasmd.TestSupport {
return chain.App.(*TestingAppDecorator).TestSupport()
}
var _ ibctesting.TestingApp = TestingAppDecorator{}
type TestingAppDecorator struct {
*wasmd.WasmApp
t *testing.T
}
func NewTestingAppDecorator(t *testing.T, wasmApp *wasmd.WasmApp) *TestingAppDecorator {
return &TestingAppDecorator{WasmApp: wasmApp, t: t}
}
func (a TestingAppDecorator) GetBaseApp() *baseapp.BaseApp {
return a.TestSupport().GetBaseApp()
}
func (a TestingAppDecorator) GetStakingKeeper() stakingkeeper.Keeper {
return a.TestSupport().StakingKeeper()
}
func (a TestingAppDecorator) GetIBCKeeper() *ibckeeper.Keeper {
return a.TestSupport().IBCKeeper()
}
func (a TestingAppDecorator) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
return a.TestSupport().ScopeIBCKeeper()
}
func (a TestingAppDecorator) GetTxConfig() client.TxConfig {
return a.TestSupport().GetTxConfig()
}
func (a TestingAppDecorator) TestSupport() *wasmd.TestSupport {
return wasmd.NewTestSupport(a.t, a.WasmApp)
return chain.App.BankKeeper.GetAllBalances(chain.GetContext(), acc)
}

View File

@@ -381,7 +381,7 @@ func (endpoint *Endpoint) SendPacket(packet exported.PacketI) error {
channelCap := endpoint.Chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel())
// no need to send message, acting as a module
err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet)
err := endpoint.Chain.App.IBCKeeper.ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet)
if err != nil {
return err
}
@@ -415,7 +415,7 @@ func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, pac
channelCap := endpoint.Chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel())
// no need to send message, acting as a handler
err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.WriteAcknowledgement(endpoint.Chain.GetContext(), channelCap, packet, ack)
err := endpoint.Chain.App.IBCKeeper.ChannelKeeper.WriteAcknowledgement(endpoint.Chain.GetContext(), channelCap, packet, ack)
if err != nil {
return err
}
@@ -452,7 +452,7 @@ func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error {
}
proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey)
nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
nextSeqRecv, found := endpoint.Counterparty.Chain.App.IBCKeeper.ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
require.True(endpoint.Chain.t, found)
timeoutMsg := channeltypes.NewMsgTimeout(
@@ -468,7 +468,7 @@ func (endpoint *Endpoint) SetChannelClosed() error {
channel := endpoint.GetChannel()
channel.State = channeltypes.CLOSED
endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel)
endpoint.Chain.App.IBCKeeper.ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel)
endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain)
@@ -483,7 +483,7 @@ func (endpoint *Endpoint) GetClientState() exported.ClientState {
// SetClientState sets the client state for this endpoint.
func (endpoint *Endpoint) SetClientState(clientState exported.ClientState) {
endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, clientState)
endpoint.Chain.App.IBCKeeper.ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, clientState)
}
// GetConsensusState retrieves the Consensus State for this endpoint at the provided height.
@@ -497,13 +497,13 @@ func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.Con
// SetConsensusState sets the consensus state for this endpoint.
func (endpoint *Endpoint) SetConsensusState(consensusState exported.ConsensusState, height exported.Height) {
endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(endpoint.Chain.GetContext(), endpoint.ClientID, height, consensusState)
endpoint.Chain.App.IBCKeeper.ClientKeeper.SetClientConsensusState(endpoint.Chain.GetContext(), endpoint.ClientID, height, consensusState)
}
// GetConnection retrieves an IBC Connection for the endpoint. The
// connection is expected to exist otherwise testing will fail.
func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd {
connection, found := endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.GetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID)
connection, found := endpoint.Chain.App.IBCKeeper.ConnectionKeeper.GetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID)
require.True(endpoint.Chain.t, found)
return connection
@@ -511,13 +511,13 @@ func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd {
// SetConnection sets the connection for this endpoint.
func (endpoint *Endpoint) SetConnection(connection connectiontypes.ConnectionEnd) {
endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.SetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID, connection)
endpoint.Chain.App.IBCKeeper.ConnectionKeeper.SetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID, connection)
}
// GetChannel retrieves an IBC Channel for the endpoint. The channel
// is expected to exist otherwise testing will fail.
func (endpoint *Endpoint) GetChannel() channeltypes.Channel {
channel, found := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
channel, found := endpoint.Chain.App.IBCKeeper.ChannelKeeper.GetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID)
require.True(endpoint.Chain.t, found)
return channel
@@ -525,7 +525,7 @@ func (endpoint *Endpoint) GetChannel() channeltypes.Channel {
// SetChannel sets the channel for this endpoint.
func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel) {
endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel)
endpoint.Chain.App.IBCKeeper.ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel)
}
// QueryClientStateProof performs and abci query for a client stat associated

View File

@@ -40,7 +40,7 @@ func (path *Path) SetChannelOrdered() {
// if EndpointA does not contain a packet commitment for that packet. An error is returned
// if a relay step fails or the packet commitment does not exist on either endpoint.
func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error {
pc := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
pc := path.EndpointA.Chain.App.IBCKeeper.ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) {
// packet found, relay from A to B
@@ -59,7 +59,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error {
}
pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
pc = path.EndpointB.Chain.App.IBCKeeper.ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointB.Chain.App.AppCodec(), packet)) {
// packet found, relay B to A

View File

@@ -5,11 +5,9 @@ import (
"compress/gzip"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
wasmd "github.com/CosmWasm/wasmd/app"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -37,7 +35,7 @@ func (chain *TestChain) SeedNewContractInstance() sdk.AccAddress {
}
func (chain *TestChain) StoreCodeFile(filename string) types.MsgStoreCodeResponse {
wasmCode, err := ioutil.ReadFile(filename)
wasmCode, err := os.ReadFile(filename)
require.NoError(chain.t, err)
if strings.HasSuffix(filename, "wasm") { // compress for gas limit
var buf bytes.Buffer
@@ -135,8 +133,5 @@ func (chain *TestChain) parseSDKResultData(r *sdk.Result) sdk.TxMsgData {
// ContractInfo is a helper function to returns the ContractInfo for the given contract address
func (chain *TestChain) ContractInfo(contractAddr sdk.AccAddress) *types.ContractInfo {
type testSupporter interface {
TestSupport() *wasmd.TestSupport
}
return chain.App.(testSupporter).TestSupport().WasmKeeper().GetContractInfo(chain.GetContext(), contractAddr)
return chain.App.WasmKeeper.GetContractInfo(chain.GetContext(), contractAddr)
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"compress/gzip"
"io"
"io/ioutil"
"github.com/CosmWasm/wasmd/x/wasm/types"
)
@@ -26,7 +25,7 @@ func Uncompress(src []byte, limit uint64) ([]byte, error) {
}
zr.Multistream(false)
defer zr.Close()
return ioutil.ReadAll(LimitReader(zr, int64(limit)))
return io.ReadAll(LimitReader(zr, int64(limit)))
}
// LimitReader returns a Reader that reads from r

View File

@@ -4,7 +4,7 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"testing"
"time"
@@ -558,7 +558,7 @@ func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wa
creator, _, creatorAddr := keyPubAddr()
fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount)
wasmCode, err := ioutil.ReadFile(wasmFile)
wasmCode, err := os.ReadFile(wasmFile)
require.NoError(t, err)
codeID, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil)

View File

@@ -326,7 +326,7 @@ func (p player) incrementCounter(key []byte, store wasmvm.KVStore) uint64 {
}
func (p player) QueryState(key []byte) uint64 {
raw := p.chain.GetTestSupport().WasmKeeper().QueryRaw(p.chain.GetContext(), p.contractAddr, key)
raw := p.chain.App.WasmKeeper.QueryRaw(p.chain.GetContext(), p.contractAddr, key)
return sdk.BigEndianToUint64(raw)
}

View File

@@ -193,7 +193,7 @@ func TestContractCanInitiateIBCTransferMsg(t *testing.T) {
require.Equal(t, 0, len(chainB.PendingSendPackets))
// and dest chain balance contains voucher
bankKeeperB := chainB.GetTestSupport().BankKeeper()
bankKeeperB := chainB.App.BankKeeper
expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, coinToSendToB.Amount)
gotBalance := chainB.Balance(chainB.SenderAccount.GetAddress(), expBalance.Denom)
assert.Equal(t, expBalance, gotBalance, "got total balance: %s", bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress()))
@@ -268,7 +268,7 @@ func TestContractCanEmulateIBCTransferMessage(t *testing.T) {
require.Equal(t, 0, len(chainB.PendingSendPackets))
// and dest chain balance contains voucher
bankKeeperB := chainB.GetTestSupport().BankKeeper()
bankKeeperB := chainB.App.BankKeeper
expBalance := ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, coinToSendToB.Amount)
gotBalance := chainB.Balance(chainB.SenderAccount.GetAddress(), expBalance.Denom)
assert.Equal(t, expBalance, gotBalance, "got total balance: %s", bankKeeperB.GetAllBalances(chainB.GetContext(), chainB.SenderAccount.GetAddress()))
@@ -535,7 +535,7 @@ func (c *ackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmv
// call original ibctransfer keeper to not copy all code into this
ibcPacket := toIBCPacket(packet)
ctx := c.chain.GetContext() // HACK: please note that this is not reverted after checkTX
err := c.chain.GetTestSupport().TransferKeeper().OnRecvPacket(ctx, ibcPacket, src)
err := c.chain.App.TransferKeeper.OnRecvPacket(ctx, ibcPacket, src)
if err != nil {
return nil, 0, sdkerrors.Wrap(err, "within our smart contract")
}
@@ -560,7 +560,7 @@ func (c *ackReceiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtyp
// call original ibctransfer keeper to not copy all code into this
ctx := c.chain.GetContext() // HACK: please note that this is not reverted after checkTX
ibcPacket := toIBCPacket(msg.OriginalPacket)
err := c.chain.GetTestSupport().TransferKeeper().OnAcknowledgementPacket(ctx, ibcPacket, data, ack)
err := c.chain.App.TransferKeeper.OnAcknowledgementPacket(ctx, ibcPacket, data, ack)
if err != nil {
return nil, 0, sdkerrors.Wrap(err, "within our smart contract")
}

View File

@@ -2,8 +2,8 @@ package simulation
import (
"encoding/json"
"io/ioutil"
"math/rand"
"os"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@@ -21,6 +21,7 @@ import (
)
// Simulation operation weights constants
//
//nolint:gosec
const (
OpWeightMsgStoreCode = "op_weight_msg_store_code"
@@ -83,7 +84,7 @@ func WeightedOperations(
wasmBz = testdata.ReflectContractWasm()
} else {
var err error
wasmBz, err = ioutil.ReadFile(wasmContractPath)
wasmBz, err = os.ReadFile(wasmContractPath)
if err != nil {
panic(err)
}

View File

@@ -128,10 +128,11 @@ func (c *ContractInfo) SetExtension(ext ContractInfoExtension) error {
// ReadExtension copies the extension value to the pointer passed as argument so that there is no need to cast
// For example with a custom extension of type `MyContractDetails` it will look as following:
// var d MyContractDetails
// if err := info.ReadExtension(&d); err != nil {
// return nil, sdkerrors.Wrap(err, "extension")
// }
//
// var d MyContractDetails
// if err := info.ReadExtension(&d); err != nil {
// return nil, sdkerrors.Wrap(err, "extension")
// }
func (c *ContractInfo) ReadExtension(e ContractInfoExtension) error {
rv := reflect.ValueOf(e)
if rv.Kind() != reflect.Ptr || rv.IsNil() {