@@ -92,6 +92,7 @@ import (
92
92
gaiaappparams "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
93
93
"github.com/Agoric/agoric-sdk/golang/cosmos/x/dibc"
94
94
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"
95
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/vpurse"
95
96
96
97
// unnamed import of statik for swagger UI support
97
98
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
@@ -123,6 +124,7 @@ var (
123
124
ibc.AppModuleBasic {},
124
125
swingset.AppModuleBasic {},
125
126
dibc.AppModuleBasic {},
127
+ vpurse.AppModuleBasic {},
126
128
upgrade.AppModuleBasic {},
127
129
evidence.AppModuleBasic {},
128
130
transfer.AppModuleBasic {},
@@ -138,6 +140,7 @@ var (
138
140
stakingtypes .NotBondedPoolName : {authtypes .Burner , authtypes .Staking },
139
141
govtypes .ModuleName : {authtypes .Burner },
140
142
ibctransfertypes .ModuleName : {authtypes .Minter , authtypes .Burner },
143
+ vpurse .ModuleName : {authtypes .Minter , authtypes .Burner },
141
144
}
142
145
)
143
146
@@ -155,7 +158,8 @@ type GaiaApp struct { // nolint: golint
155
158
appCodec codec.Marshaler
156
159
interfaceRegistry types.InterfaceRegistry
157
160
158
- ibcPort int
161
+ ibcPort int
162
+ vpursePort int
159
163
160
164
invCheckPeriod uint
161
165
@@ -184,6 +188,7 @@ type GaiaApp struct { // nolint: golint
184
188
185
189
SwingSetKeeper swingset.Keeper
186
190
DibcKeeper dibc.Keeper
191
+ VpurseKeeper vpurse.Keeper
187
192
188
193
// make scoped keepers public for test purposes
189
194
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
@@ -240,7 +245,9 @@ func NewAgoricApp(
240
245
authtypes .StoreKey , banktypes .StoreKey , stakingtypes .StoreKey ,
241
246
minttypes .StoreKey , distrtypes .StoreKey , slashingtypes .StoreKey ,
242
247
govtypes .StoreKey , paramstypes .StoreKey , ibchost .StoreKey , upgradetypes .StoreKey ,
243
- evidencetypes .StoreKey , ibctransfertypes .StoreKey , swingset .StoreKey , dibc .StoreKey , capabilitytypes .StoreKey ,
248
+ evidencetypes .StoreKey , ibctransfertypes .StoreKey ,
249
+ swingset .StoreKey , dibc .StoreKey , vpurse .StoreKey ,
250
+ capabilitytypes .StoreKey ,
244
251
)
245
252
tkeys := sdk .NewTransientStoreKeys (paramstypes .TStoreKey )
246
253
memKeys := sdk .NewMemoryStoreKeys (capabilitytypes .MemStoreKey )
@@ -325,6 +332,7 @@ func NewAgoricApp(
325
332
326
333
// This function is tricky to get right, so we build it ourselves.
327
334
callToController := func (ctx sdk.Context , str string ) (string , error ) {
335
+ app .MustInitController (ctx )
328
336
defer swingset .SetControllerContext (ctx )()
329
337
return sendToController (true , str )
330
338
}
@@ -355,6 +363,14 @@ func NewAgoricApp(
355
363
ibcRouter .AddRoute (dibc .ModuleName , dibcModule )
356
364
app .IBCKeeper .SetRouter (ibcRouter )
357
365
366
+ app .VpurseKeeper = vpurse .NewKeeper (
367
+ appCodec , keys [vpurse .StoreKey ],
368
+ app .BankKeeper ,
369
+ callToController ,
370
+ )
371
+ vpurseModule := vpurse .NewAppModule (app .VpurseKeeper )
372
+ app .vpursePort = swingset .RegisterPortHandler ("bank" , vpurse .NewPortHandler (app .VpurseKeeper ))
373
+
358
374
// create evidence keeper with router
359
375
evidenceKeeper := evidencekeeper .NewKeeper (
360
376
appCodec , keys [evidencetypes .StoreKey ], & app .StakingKeeper , app .SlashingKeeper ,
@@ -396,6 +412,7 @@ func NewAgoricApp(
396
412
params .NewAppModule (app .ParamsKeeper ),
397
413
swingset .NewAppModule (app .SwingSetKeeper ),
398
414
dibcModule ,
415
+ vpurseModule ,
399
416
transferModule ,
400
417
)
401
418
@@ -407,7 +424,7 @@ func NewAgoricApp(
407
424
upgradetypes .ModuleName , minttypes .ModuleName , distrtypes .ModuleName , slashingtypes .ModuleName ,
408
425
evidencetypes .ModuleName , stakingtypes .ModuleName , ibchost .ModuleName , swingset .ModuleName ,
409
426
)
410
- app .mm .SetOrderEndBlockers (swingset .ModuleName , crisistypes .ModuleName , govtypes .ModuleName , stakingtypes .ModuleName )
427
+ app .mm .SetOrderEndBlockers (vpurse . ModuleName , swingset .ModuleName , crisistypes .ModuleName , govtypes .ModuleName , stakingtypes .ModuleName )
411
428
412
429
// NOTE: The genutils module must occur after staking so that pools are
413
430
// properly initialized with tokens from genesis accounts.
@@ -417,7 +434,9 @@ func NewAgoricApp(
417
434
app .mm .SetOrderInitGenesis (
418
435
capabilitytypes .ModuleName , authtypes .ModuleName , banktypes .ModuleName , distrtypes .ModuleName , stakingtypes .ModuleName ,
419
436
slashingtypes .ModuleName , govtypes .ModuleName , minttypes .ModuleName , crisistypes .ModuleName ,
420
- ibchost .ModuleName , genutiltypes .ModuleName , evidencetypes .ModuleName , swingset .ModuleName , ibctransfertypes .ModuleName ,
437
+ ibchost .ModuleName , genutiltypes .ModuleName , evidencetypes .ModuleName ,
438
+ ibctransfertypes .ModuleName ,
439
+ vpurse .ModuleName , swingset .ModuleName ,
421
440
)
422
441
423
442
app .mm .RegisterInvariants (& app .CrisisKeeper )
@@ -484,10 +503,14 @@ func NewAgoricApp(
484
503
}
485
504
486
505
type cosmosInitAction struct {
487
- Type string `json:"type"`
488
- IBCPort int `json:"ibcPort"`
489
- StoragePort int `json:"storagePort"`
490
- ChainID string `json:"chainID"`
506
+ Type string `json:"type"`
507
+ IBCPort int `json:"ibcPort"`
508
+ StoragePort int `json:"storagePort"`
509
+ VPursePort int `json:"vpursePort"`
510
+ ChainID string `json:"chainID"`
511
+ BootstrapAddress string `json:"bootstrapAddress"`
512
+ BootstrapValue string `json:"bootstrapValue"`
513
+ DonationValue string `json:"donationValue"`
491
514
}
492
515
493
516
// MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by
@@ -507,12 +530,27 @@ func (app *GaiaApp) MustInitController(ctx sdk.Context) {
507
530
}
508
531
app .controllerInited = true
509
532
533
+ var bootstrapAddr sdk.AccAddress
534
+ gs := app .VpurseKeeper .GetGenesis (ctx )
535
+ if len (gs .BootstrapAddress ) > 0 {
536
+ ba , err := sdk .AccAddressFromBech32 (gs .BootstrapAddress )
537
+ if err != nil {
538
+ fmt .Fprintln (os .Stderr , "Cannot get bootstrap addr" , err )
539
+ os .Exit (1 )
540
+ }
541
+ bootstrapAddr = ba
542
+ }
543
+
510
544
// Begin initializing the controller here.
511
545
action := & cosmosInitAction {
512
- Type : "AG_COSMOS_INIT" ,
513
- IBCPort : app .ibcPort ,
514
- StoragePort : swingset .GetPort ("storage" ),
515
- ChainID : ctx .ChainID (),
546
+ Type : "AG_COSMOS_INIT" ,
547
+ VPursePort : app .vpursePort ,
548
+ IBCPort : app .ibcPort ,
549
+ StoragePort : swingset .GetPort ("storage" ),
550
+ ChainID : ctx .ChainID (),
551
+ BootstrapAddress : bootstrapAddr .String (),
552
+ BootstrapValue : gs .BootstrapValue .String (),
553
+ DonationValue : gs .DonationValue .String (),
516
554
}
517
555
bz , err := json .Marshal (action )
518
556
if err == nil {
@@ -526,7 +564,6 @@ func (app *GaiaApp) MustInitController(ctx sdk.Context) {
526
564
527
565
// BeginBlocker application updates every begin block
528
566
func (app * GaiaApp ) BeginBlocker (ctx sdk.Context , req abci.RequestBeginBlock ) abci.ResponseBeginBlock {
529
- app .MustInitController (ctx )
530
567
return app .mm .BeginBlock (ctx , req )
531
568
}
532
569
@@ -556,7 +593,6 @@ func updateTransferPort(gs GenesisState, reservedPort, newPort string) error {
556
593
557
594
// InitChainer application update at chain initialization
558
595
func (app * GaiaApp ) InitChainer (ctx sdk.Context , req abci.RequestInitChain ) abci.ResponseInitChain {
559
- app .MustInitController (ctx )
560
596
var genesisState GenesisState
561
597
if err := tmjson .Unmarshal (req .AppStateBytes , & genesisState ); err != nil {
562
598
panic (err )
0 commit comments