-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapp.go
628 lines (516 loc) · 20.1 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
package app
import (
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"strings"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/log"
upgradetypes "cosmossdk.io/x/upgrade/types"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
tmos "github.com/cometbft/cometbft/libs/os"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/cosmos-sdk/version"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/gogoproto/proto"
// ibc imports
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
// initia imports
"github.com/initia-labs/initia/app/params"
cryptocodec "github.com/initia-labs/initia/crypto/codec"
ibctestingtypes "github.com/initia-labs/initia/x/ibc/testing/types"
icaauthkeeper "github.com/initia-labs/initia/x/intertx/keeper"
// skip imports
blockchecktx "github.com/skip-mev/block-sdk/v2/abci/checktx"
// CosmWasm imports
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
// local imports
"github.com/initia-labs/miniwasm/app/keepers"
"github.com/skip-mev/block-sdk/v2/block"
blockservice "github.com/skip-mev/block-sdk/v2/block/service"
// kvindexer
kvindexermodule "github.com/initia-labs/kvindexer/x/kvindexer"
kvindexerkeeper "github.com/initia-labs/kvindexer/x/kvindexer/keeper"
// unnamed import of statik for swagger UI support
_ "github.com/initia-labs/miniwasm/client/docs/statik"
)
var (
// DefaultNodeHome default home directories for the application daemon
DefaultNodeHome string
)
var (
_ servertypes.Application = (*MinitiaApp)(nil)
)
func init() {
userHomeDir, err := os.UserHomeDir()
if err != nil {
tmos.Exit(err.Error())
}
DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName)
}
// MinitiaApp extends an ABCI application, but with most of its parameters exported.
// They are exported for convenience in creating helper functions, as object
// capabilities aren't needed for testing.
type MinitiaApp struct {
*baseapp.BaseApp
keepers.AppKeepers
// address codecs
ac, vc, cc address.Codec
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry types.InterfaceRegistry
// the module manager
ModuleManager *module.Manager
BasicModuleManager module.BasicManager
// the configurator
configurator module.Configurator
// Override of BaseApp's CheckTx
checkTxHandler blockchecktx.CheckTx
// indexer keeper for graceful shutdown
kvIndexerKeeper *kvindexerkeeper.Keeper
// indexer module for grpc-gateway registration
kvIndexerModule *kvindexermodule.AppModuleBasic
}
// NewMinitiaApp returns a reference to an initialized Initia.
func NewMinitiaApp(
logger log.Logger,
db dbm.DB,
kvindexerDB dbm.DB,
traceStore io.Writer,
loadLatest bool,
wasmOpts []wasmkeeper.Option,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *MinitiaApp {
// load the configs
mempoolMaxTxs := cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs))
queryGasLimit := cast.ToInt(appOpts.Get(server.FlagQueryGasLimit))
logger.Info("mempool max txs", "max_txs", mempoolMaxTxs)
logger.Info("query gas limit", "gas_limit", queryGasLimit)
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
cryptocodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
cryptocodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
appCodec := encodingConfig.Codec
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
txConfig := encodingConfig.TxConfig
bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
bApp.SetTxEncoder(txConfig.TxEncoder())
// app opts
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
skipUpgradeHeights := make(map[int64]bool)
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
skipUpgradeHeights[int64(h)] = true
}
app := &MinitiaApp{
BaseApp: bApp,
legacyAmino: legacyAmino,
appCodec: appCodec,
txConfig: txConfig,
interfaceRegistry: interfaceRegistry,
// codecs
ac: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()),
vc: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
cc: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
}
i := 0
moduleAddrs := make([]sdk.AccAddress, len(maccPerms))
for name := range maccPerms {
moduleAddrs[i] = authtypes.NewModuleAddress(name)
i += 1
}
moduleAccountAddresses := app.ModuleAccountAddrs()
blockedModuleAccountAddrs := app.BlockedModuleAccountAddrs(moduleAccountAddresses)
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}
// Setup keepers
app.AppKeepers = keepers.NewAppKeeper(
app.ac, app.vc, app.cc,
appCodec,
txConfig,
bApp,
legacyAmino,
maccPerms,
blockedModuleAccountAddrs,
skipUpgradeHeights,
homePath,
invCheckPeriod,
logger,
wasmConfig,
wasmOpts,
appOpts,
)
/**** Module Options ****/
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.ModuleManager = module.NewManager(appModules(app, skipGenesisInvariants)...)
// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration and genesis verification.
// By default it is composed of all the module from the module manager.
// Additionally, app module basics can be overwritten by passing them as argument.
app.BasicModuleManager = newBasicManagerFromManager(app)
// NOTE: upgrade module is required to be prioritized
app.ModuleManager.SetOrderPreBlockers(
upgradetypes.ModuleName,
)
// set order of module operations
app.ModuleManager.SetOrderBeginBlockers(orderBeginBlockers()...)
app.ModuleManager.SetOrderEndBlockers(orderEndBlockers()...)
genesisModuleOrder := orderInitBlockers()
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
// register invariants for crisis module
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
err = app.ModuleManager.RegisterServices(app.configurator)
if err != nil {
tmos.Exit(err.Error())
}
// setup indexer
if kvIndexerKeeper, kvIndexerModule, streamingManager, err := setupIndexer(app, appOpts, kvindexerDB); err != nil {
tmos.Exit(err.Error())
} else if kvIndexerKeeper != nil && kvIndexerModule != nil && streamingManager != nil {
// register kvindexer keeper and module, and register services
app.SetKVIndexer(kvIndexerKeeper, kvIndexerModule)
// override base-app's streaming manager
app.SetStreamingManager(*streamingManager)
}
// register upgrade handler for later use
app.RegisterUpgradeHandlers(app.configurator)
// register executor change plans for later use
err = app.RegisterExecutorChangePlans()
if err != nil {
tmos.Exit(err.Error())
}
autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules))
reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
tmos.Exit(err.Error())
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)
// initialize stores
app.MountKVStores(app.GetKVStoreKey())
app.MountTransientStores(app.GetTransientStoreKey())
app.MountMemoryStores(app.GetMemoryStoreKey())
// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetPreBlocker(app.PreBlocker)
app.SetBeginBlocker(app.BeginBlocker)
app.setPostHandler()
app.SetEndBlocker(app.EndBlocker)
// setup BlockSDK
mempool, anteHandler, checkTx, prepareProposalHandler, processProposalHandler, err := setupBlockSDK(app, mempoolMaxTxs, wasmConfig, app.GetKVStoreKey()[wasmtypes.StoreKey])
if err != nil {
tmos.Exit(err.Error())
}
// override base-app's mempool
app.SetMempool(mempool)
// override base-app's ante handler
app.SetAnteHandler(anteHandler)
// override base-app's ProcessProposal + PrepareProposal
app.SetPrepareProposal(prepareProposalHandler)
app.SetProcessProposal(processProposalHandler)
// override base-app's CheckTx
app.SetCheckTx(checkTx)
// At startup, after all modules have been registered, check that all proto
// annotations are correct.
protoFiles, err := proto.MergedRegistry()
if err != nil {
tmos.Exit(err.Error())
}
err = msgservice.ValidateProtoAnnotations(protoFiles)
if err != nil {
errMsg := ""
// ignore injective proto annotations comes from github.com/cosoms/relayer
for _, s := range strings.Split(err.Error(), "\n") {
if strings.Contains(s, "injective") {
continue
}
errMsg += s + "\n"
}
if errMsg != "" {
// Once we switch to using protoreflect-based antehandlers, we might
// want to panic here instead of logging a warning.
fmt.Fprintln(os.Stderr, errMsg)
}
}
// must be before Loading version
// requires the snapshot store to be created and registered as a BaseAppOption
// see cmd/wasmd/root.go: 206 - 214 approx
if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), app.WasmKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}
// Load the latest state from disk if necessary, and initialize the base-app. From this point on
// no more modifications to the base-app can be made
if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
}
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 {
tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err))
}
}
return app
}
// CheckTx will check the transaction with the provided checkTxHandler. We override the default
// handler so that we can verify bid transactions before they are inserted into the mempool.
// With the POB CheckTx, we can verify the bid transaction and all of the bundled transactions
// before inserting the bid transaction into the mempool.
func (app *MinitiaApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
return app.checkTxHandler(req)
}
// SetCheckTx sets the checkTxHandler for the app.
func (app *MinitiaApp) SetCheckTx(handler blockchecktx.CheckTx) {
app.checkTxHandler = handler
}
func (app *MinitiaApp) setPostHandler() {
postHandler, err := posthandler.NewPostHandler(
posthandler.HandlerOptions{},
)
if err != nil {
tmos.Exit(err.Error())
}
app.SetPostHandler(postHandler)
}
// SetKVIndexer sets the kvindexer keeper and module for the app and registers the services.
func (app *MinitiaApp) SetKVIndexer(kvIndexerKeeper *kvindexerkeeper.Keeper, kvIndexerModule *kvindexermodule.AppModuleBasic) {
app.kvIndexerKeeper = kvIndexerKeeper
app.kvIndexerModule = kvIndexerModule
app.kvIndexerModule.RegisterServices(app.configurator)
}
// Name returns the name of the App
func (app *MinitiaApp) Name() string { return app.BaseApp.Name() }
// PreBlocker application updates every pre block
func (app *MinitiaApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) {
return app.ModuleManager.PreBlock(ctx)
}
// BeginBlocker application updates every begin block
func (app *MinitiaApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) {
return app.ModuleManager.BeginBlock(ctx)
}
// EndBlocker application updates every end block
func (app *MinitiaApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) {
return app.ModuleManager.EndBlock(ctx)
}
// InitChainer application update at chain initialization
func (app *MinitiaApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
var genesisState GenesisState
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
tmos.Exit(err.Error())
}
if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {
tmos.Exit(err.Error())
}
return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
}
// LoadHeight loads a particular height
func (app *MinitiaApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
}
// ModuleAccountAddrs returns all the app's module account addresses.
func (app *MinitiaApp) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
addrStr, _ := app.ac.BytesToString(authtypes.NewModuleAddress(acc).Bytes())
modAccAddrs[addrStr] = true
}
return modAccAddrs
}
// BlockedModuleAccountAddrs returns all the app's blocked module account
// addresses.
func (app *MinitiaApp) BlockedModuleAccountAddrs(modAccAddrs map[string]bool) map[string]bool {
modules := []string{}
// remove module accounts that are ALLOWED to received funds
for _, module := range modules {
moduleAddr, _ := app.ac.BytesToString(authtypes.NewModuleAddress(module).Bytes())
delete(modAccAddrs, moduleAddr)
}
return modAccAddrs
}
// LegacyAmino returns SimApp's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *MinitiaApp) LegacyAmino() *codec.LegacyAmino {
return app.legacyAmino
}
// AppCodec returns Initia's app codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *MinitiaApp) AppCodec() codec.Codec {
return app.appCodec
}
// InterfaceRegistry returns Initia's InterfaceRegistry
func (app *MinitiaApp) InterfaceRegistry() types.InterfaceRegistry {
return app.interfaceRegistry
}
// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *MinitiaApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register node gRPC service for grpc-gateway.
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register the Block SDK mempool API routes.
blockservice.RegisterGRPCGatewayRoutes(apiSvr.ClientCtx, apiSvr.GRPCGatewayRouter)
// Register grpc-gateway routes for all modules.
app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register grpc-gateway routes for indexer module.
if app.kvIndexerModule != nil {
app.kvIndexerModule.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
}
// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
RegisterSwaggerAPI(apiSvr.Router)
}
}
// Simulate customize gas simulation to add fee deduction gas amount.
func (app *MinitiaApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) {
gasInfo, result, err := app.BaseApp.Simulate(txBytes)
gasInfo.GasUsed += FeeDeductionGasAmount
return gasInfo, result, err
}
// RegisterTxService implements the Application.RegisterTxService method.
func (app *MinitiaApp) RegisterTxService(clientCtx client.Context) {
authtx.RegisterTxService(
app.BaseApp.GRPCQueryRouter(), clientCtx,
app.Simulate, app.interfaceRegistry,
)
// Register the Block SDK mempool transaction service.
mempool, ok := app.Mempool().(block.Mempool)
if !ok {
panic("mempool is not a block.Mempool")
}
blockservice.RegisterMempoolService(app.GRPCQueryRouter(), mempool)
}
// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *MinitiaApp) RegisterTendermintService(clientCtx client.Context) {
cmtservice.RegisterTendermintService(
clientCtx,
app.BaseApp.GRPCQueryRouter(),
app.interfaceRegistry, app.Query,
)
}
func (app *MinitiaApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) {
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg)
}
// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(rtr *mux.Router) {
statikFS, err := fs.New()
if err != nil {
tmos.Exit(err.Error())
}
staticServer := http.FileServer(statikFS)
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer))
}
// GetMaccPerms returns a copy of the module account permissions
func GetMaccPerms() map[string][]string {
dupMaccPerms := make(map[string][]string)
for k, v := range maccPerms {
dupMaccPerms[k] = v
}
return dupMaccPerms
}
//////////////////////////////////////
// TestingApp functions
// GetBaseApp implements the TestingApp interface.
func (app *MinitiaApp) GetBaseApp() *baseapp.BaseApp {
return app.BaseApp
}
// GetAccountKeeper implements the TestingApp interface.
func (app *MinitiaApp) GetAccountKeeper() *authkeeper.AccountKeeper {
return app.AccountKeeper
}
// GetStakingKeeper implements the TestingApp interface.
// It returns opchild instead of original staking keeper.
func (app *MinitiaApp) GetStakingKeeper() ibctestingtypes.StakingKeeper {
return app.OPChildKeeper
}
// GetIBCKeeper implements the TestingApp interface.
func (app *MinitiaApp) GetIBCKeeper() *ibckeeper.Keeper {
return app.IBCKeeper
}
// GetICAControllerKeeper implements the TestingApp interface.
func (app *MinitiaApp) GetICAControllerKeeper() *icacontrollerkeeper.Keeper {
return app.ICAControllerKeeper
}
// GetICAAuthKeeper implements the TestingApp interface.
func (app *MinitiaApp) GetICAAuthKeeper() *icaauthkeeper.Keeper {
return app.ICAAuthKeeper
}
// GetScopedIBCKeeper implements the TestingApp interface.
func (app *MinitiaApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
return app.ScopedIBCKeeper
}
// TxConfig implements the TestingApp interface.
func (app *MinitiaApp) TxConfig() client.TxConfig {
return app.txConfig
}
// Close closes the underlying baseapp, the oracle service, and the prometheus server if required.
// This method blocks on the closure of both the prometheus server, and the oracle-service
func (app *MinitiaApp) Close() error {
if app.kvIndexerKeeper != nil {
if err := app.kvIndexerKeeper.Close(); err != nil {
return err
}
}
if err := app.BaseApp.Close(); err != nil {
return err
}
return nil
}