@@ -4,10 +4,14 @@ import (
4
4
"encoding/json"
5
5
"fmt"
6
6
"io"
7
+ "net/http"
7
8
"os"
9
+ "path/filepath"
8
10
11
+ "github.com/cosmos/cosmos-sdk/client"
9
12
"github.com/cosmos/cosmos-sdk/codec/types"
10
- "github.com/cosmos/cosmos-sdk/std"
13
+ "github.com/gorilla/mux"
14
+ "github.com/rakyll/statik/fs"
11
15
12
16
abci "github.com/tendermint/tendermint/abci/types"
13
17
"github.com/tendermint/tendermint/libs/log"
@@ -18,6 +22,7 @@ import (
18
22
"github.com/cosmos/cosmos-sdk/client/rpc"
19
23
"github.com/cosmos/cosmos-sdk/codec"
20
24
"github.com/cosmos/cosmos-sdk/server/api"
25
+ "github.com/cosmos/cosmos-sdk/server/config"
21
26
"github.com/cosmos/cosmos-sdk/testutil/testdata"
22
27
sdk "github.com/cosmos/cosmos-sdk/types"
23
28
"github.com/cosmos/cosmos-sdk/types/module"
@@ -28,6 +33,7 @@ import (
28
33
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
29
34
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
30
35
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
36
+ "github.com/cosmos/cosmos-sdk/x/auth/vesting"
31
37
"github.com/cosmos/cosmos-sdk/x/bank"
32
38
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
33
39
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
@@ -50,11 +56,11 @@ import (
50
56
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
51
57
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
52
58
"github.com/cosmos/cosmos-sdk/x/ibc"
53
- transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
54
- ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc-transfer/keeper"
55
- ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
56
59
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types"
57
60
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
61
+ transfer "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer"
62
+ ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/keeper"
63
+ ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"
58
64
ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/keeper"
59
65
"github.com/cosmos/cosmos-sdk/x/mint"
60
66
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
@@ -78,13 +84,16 @@ import (
78
84
79
85
gaiaappparams "github.com/Agoric/cosmic-swingset/app/params"
80
86
"github.com/Agoric/cosmic-swingset/x/swingset"
87
+
88
+ // This is for the swagger file for legacy support
89
+ _ "github.com/cosmos/cosmos-sdk/client/docs/statik"
81
90
)
82
91
83
92
const appName = "agoric"
84
93
85
94
var (
86
95
// DefaultNodeHome default home directories for the application daemon
87
- DefaultNodeHome = os . ExpandEnv ( "$HOME/.ag-chain-cosmos" )
96
+ DefaultNodeHome string
88
97
89
98
// ModuleBasics defines the module BasicManager is in charge of setting up basic,
90
99
// non-dependant module elements, such as codec registration
@@ -179,6 +188,15 @@ type GaiaApp struct {
179
188
sm * module.SimulationManager
180
189
}
181
190
191
+ func init () {
192
+ userHomeDir , err := os .UserHomeDir ()
193
+ if err != nil {
194
+ panic (err )
195
+ }
196
+
197
+ DefaultNodeHome = filepath .Join (userHomeDir , ".ag-chain-cosmos" )
198
+ }
199
+
182
200
// NewGaia returns a reference to an initialized Gaia.
183
201
// NewSimApp returns a reference to an initialized SimApp.
184
202
func NewGaiaApp (
@@ -209,7 +227,7 @@ func NewAgoricApp(
209
227
bApp .SetCommitMultiStoreTracer (traceStore )
210
228
bApp .SetAppVersion (version .Version )
211
229
bApp .GRPCQueryRouter ().SetInterfaceRegistry (interfaceRegistry )
212
- bApp .GRPCQueryRouter ().RegisterSimulateService (bApp .Simulate , interfaceRegistry , std. DefaultPublicKeyCodec {} )
230
+ bApp .GRPCQueryRouter ().RegisterSimulateService (bApp .Simulate , interfaceRegistry )
213
231
214
232
keys := sdk .NewKVStoreKeys (
215
233
authtypes .StoreKey , banktypes .StoreKey , stakingtypes .StoreKey ,
@@ -339,6 +357,7 @@ func NewAgoricApp(
339
357
encodingConfig .TxConfig ,
340
358
),
341
359
auth .NewAppModule (appCodec , app .AccountKeeper , nil ),
360
+ vesting .NewAppModule (app .AccountKeeper , app .BankKeeper ),
342
361
bank .NewAppModule (appCodec , app .BankKeeper , app .AccountKeeper ),
343
362
capability .NewAppModule (appCodec , * app .CapabilityKeeper ),
344
363
crisis .NewAppModule (& app .CrisisKeeper ),
@@ -371,7 +390,7 @@ func NewAgoricApp(
371
390
// so that other modules that want to create or claim capabilities afterwards in InitChain
372
391
// can do so safely.
373
392
app .mm .SetOrderInitGenesis (
374
- capabilitytypes .ModuleName , authtypes .ModuleName , distrtypes .ModuleName , stakingtypes .ModuleName , banktypes .ModuleName ,
393
+ capabilitytypes .ModuleName , authtypes .ModuleName , banktypes .ModuleName , distrtypes .ModuleName , stakingtypes .ModuleName ,
375
394
slashingtypes .ModuleName , govtypes .ModuleName , minttypes .ModuleName , crisistypes .ModuleName ,
376
395
ibchost .ModuleName , genutiltypes .ModuleName , evidencetypes .ModuleName , swingset .ModuleName , ibctransfertypes .ModuleName ,
377
396
)
@@ -600,12 +619,28 @@ func (app *GaiaApp) SimulationManager() *module.SimulationManager {
600
619
601
620
// RegisterAPIRoutes registers all application module routes with the provided
602
621
// API server.
603
- func (app * GaiaApp ) RegisterAPIRoutes (apiSvr * api.Server ) {
622
+ func (app * GaiaApp ) RegisterAPIRoutes (apiSvr * api.Server , apiConfig config. APIConfig ) {
604
623
clientCtx := apiSvr .ClientCtx
605
624
rpc .RegisterRoutes (clientCtx , apiSvr .Router )
606
625
authrest .RegisterTxRoutes (clientCtx , apiSvr .Router )
607
626
ModuleBasics .RegisterRESTRoutes (clientCtx , apiSvr .Router )
608
627
ModuleBasics .RegisterGRPCRoutes (apiSvr .ClientCtx , apiSvr .GRPCRouter )
628
+
629
+ // register swagger API from root so that other applications can override easily
630
+ if apiConfig .Swagger {
631
+ RegisterSwaggerAPI (clientCtx , apiSvr .Router )
632
+ }
633
+ }
634
+
635
+ // RegisterSwaggerAPI registers the swagger routes on the API router
636
+ func RegisterSwaggerAPI (ctx client.Context , rtr * mux.Router ) {
637
+ statikFS , err := fs .New ()
638
+ if err != nil {
639
+ panic (err )
640
+ }
641
+
642
+ staticServer := http .FileServer (statikFS )
643
+ rtr .PathPrefix ("/swagger" ).Handler (http .StripPrefix ("/swagger/" , staticServer ))
609
644
}
610
645
611
646
// GetMaccPerms returns a copy of the module account permissions
0 commit comments