1
- package app
1
+ package gaia
2
2
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
6
"io"
7
+ stdlog "log"
7
8
"net/http"
8
9
"os"
9
10
"path/filepath"
10
11
11
12
"github.com/cosmos/cosmos-sdk/client"
12
13
"github.com/cosmos/cosmos-sdk/codec/types"
14
+ "github.com/cosmos/cosmos-sdk/simapp"
13
15
"github.com/gorilla/mux"
14
16
"github.com/rakyll/statik/fs"
15
17
@@ -21,6 +23,7 @@ import (
21
23
dbm "github.com/tendermint/tm-db"
22
24
23
25
"github.com/cosmos/cosmos-sdk/baseapp"
26
+ "github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
24
27
"github.com/cosmos/cosmos-sdk/client/rpc"
25
28
"github.com/cosmos/cosmos-sdk/codec"
26
29
"github.com/cosmos/cosmos-sdk/server/api"
@@ -143,14 +146,14 @@ var (
143
146
)
144
147
145
148
var (
146
- _ App = (* GaiaApp )(nil )
149
+ _ simapp. App = (* GaiaApp )(nil )
147
150
_ servertypes.Application = (* GaiaApp )(nil )
148
151
)
149
152
150
- // Gaia extends an ABCI application, but with most of its parameters exported.
153
+ // GaiaApp extends an ABCI application, but with most of its parameters exported.
151
154
// They are exported for convenience in creating helper functions, as object
152
155
// capabilities aren't needed for testing.
153
- type GaiaApp struct {
156
+ type GaiaApp struct { // nolint: golint
154
157
* baseapp.BaseApp
155
158
legacyAmino * codec.LegacyAmino
156
159
appCodec codec.Marshaler
@@ -201,14 +204,13 @@ type GaiaApp struct {
201
204
func init () {
202
205
userHomeDir , err := os .UserHomeDir ()
203
206
if err != nil {
204
- panic ( err )
207
+ stdlog . Println ( "Failed to get home dir %2" , err )
205
208
}
206
209
207
210
DefaultNodeHome = filepath .Join (userHomeDir , ".ag-chain-cosmos" )
208
211
}
209
212
210
- // NewGaia returns a reference to an initialized Gaia.
211
- // NewSimApp returns a reference to an initialized SimApp.
213
+ // NewGaiaApp returns a reference to an initialized Gaia.
212
214
func NewGaiaApp (
213
215
logger log.Logger , db dbm.DB , traceStore io.Writer , loadLatest bool , skipUpgradeHeights map [int64 ]bool ,
214
216
homePath string , invCheckPeriod uint , encodingConfig gaiaappparams.EncodingConfig , appOpts servertypes.AppOptions , baseAppOptions ... func (* baseapp.BaseApp ),
@@ -302,7 +304,7 @@ func NewAgoricApp(
302
304
303
305
// Create IBC Keeper
304
306
app .IBCKeeper = ibckeeper .NewKeeper (
305
- appCodec , keys [ibchost .StoreKey ], app .StakingKeeper , scopedIBCKeeper ,
307
+ appCodec , keys [ibchost .StoreKey ], app .GetSubspace ( ibchost . ModuleName ), app . StakingKeeper , scopedIBCKeeper ,
306
308
)
307
309
308
310
// register the proposal types
@@ -375,6 +377,8 @@ func NewAgoricApp(
375
377
// NOTE: Any module instantiated in the module manager that is later modified
376
378
// must be passed by reference here.
377
379
380
+ // NOTE: Any module instantiated in the module manager that is later modified
381
+ // must be passed by reference here.
378
382
app .mm = module .NewManager (
379
383
genutil .NewAppModule (
380
384
app .AccountKeeper , app .StakingKeeper , app .BaseApp .DeliverTx ,
@@ -491,8 +495,8 @@ type cosmosInitAction struct {
491
495
}
492
496
493
497
// MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by
494
- // simapp . It is useful for tests and clients who do not want to construct the
495
- // full simapp
498
+ // Gaia . It is useful for tests and clients who do not want to construct the
499
+ // full gaia application
496
500
func MakeCodecs () (codec.Marshaler , * codec.LegacyAmino ) {
497
501
config := MakeEncodingConfig ()
498
502
return config .Marshaler , config .Amino
@@ -586,7 +590,7 @@ func (app *GaiaApp) BlockedAddrs() map[string]bool {
586
590
return blockedAddrs
587
591
}
588
592
589
- // LegacyAmino returns SimApp 's amino codec.
593
+ // LegacyAmino returns GaiaApp 's amino codec.
590
594
//
591
595
// NOTE: This is solely to be used for testing purposes as it may be desirable
592
596
// for modules to register their own custom testing types.
@@ -646,17 +650,20 @@ func (app *GaiaApp) SimulationManager() *module.SimulationManager {
646
650
func (app * GaiaApp ) RegisterAPIRoutes (apiSvr * api.Server , apiConfig config.APIConfig ) {
647
651
clientCtx := apiSvr .ClientCtx
648
652
rpc .RegisterRoutes (clientCtx , apiSvr .Router )
653
+ // Register legacy tx routes.
649
654
authrest .RegisterTxRoutes (clientCtx , apiSvr .Router )
650
655
// Register new tx routes from grpc-gateway.
651
- authtx .RegisterGRPCGatewayRoutes (clientCtx , apiSvr .GRPCRouter )
656
+ authtx .RegisterGRPCGatewayRoutes (clientCtx , apiSvr .GRPCGatewayRouter )
657
+ // Register new tendermint queries routes from grpc-gateway.
658
+ tmservice .RegisterGRPCGatewayRoutes (clientCtx , apiSvr .GRPCGatewayRouter )
652
659
653
660
// Register legacy and grpc-gateway routes for all modules.
654
661
ModuleBasics .RegisterRESTRoutes (clientCtx , apiSvr .Router )
655
- ModuleBasics .RegisterGRPCGatewayRoutes (clientCtx , apiSvr .GRPCRouter )
662
+ ModuleBasics .RegisterGRPCGatewayRoutes (clientCtx , apiSvr .GRPCGatewayRouter )
656
663
657
664
// register swagger API from root so that other applications can override easily
658
665
if apiConfig .Swagger {
659
- RegisterSwaggerAPI (clientCtx , apiSvr .Router )
666
+ RegisterSwaggerAPI (apiSvr .Router )
660
667
}
661
668
}
662
669
@@ -665,8 +672,13 @@ func (app *GaiaApp) RegisterTxService(clientCtx client.Context) {
665
672
authtx .RegisterTxService (app .BaseApp .GRPCQueryRouter (), clientCtx , app .BaseApp .Simulate , app .interfaceRegistry )
666
673
}
667
674
675
+ // RegisterTendermintService implements the Application.RegisterTendermintService method.
676
+ func (app * GaiaApp ) RegisterTendermintService (clientCtx client.Context ) {
677
+ tmservice .RegisterTendermintService (app .BaseApp .GRPCQueryRouter (), clientCtx , app .interfaceRegistry )
678
+ }
679
+
668
680
// RegisterSwaggerAPI registers swagger route with API Server
669
- func RegisterSwaggerAPI (ctx client. Context , rtr * mux.Router ) {
681
+ func RegisterSwaggerAPI (rtr * mux.Router ) {
670
682
statikFS , err := fs .New ()
671
683
if err != nil {
672
684
panic (err )
@@ -698,6 +710,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA
698
710
paramsKeeper .Subspace (govtypes .ModuleName ).WithKeyTable (govtypes .ParamKeyTable ())
699
711
paramsKeeper .Subspace (crisistypes .ModuleName )
700
712
paramsKeeper .Subspace (ibctransfertypes .ModuleName )
713
+ paramsKeeper .Subspace (ibchost .ModuleName )
701
714
702
715
return paramsKeeper
703
716
}
0 commit comments