Skip to content

Commit 759d6ab

Browse files
committed
feat: send AG_COSMOS_INIT supplyCoins instead of vpurse genesis
1 parent bd93574 commit 759d6ab

File tree

5 files changed

+23
-234
lines changed

5 files changed

+23
-234
lines changed

golang/cosmos/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ proto-check-breaking: proto-tools
9090
buf check breaking --against-input '.git#branch=master'
9191

9292
TMVER = v0.34.3
93-
COSMOSVER = v0.41.0
93+
COSMOSVER = v0.42.4
9494

9595
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/$(TMVER)/proto/tendermint
9696
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos

golang/cosmos/app/app.go

+12-27
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,12 @@ func NewAgoricApp(
503503
}
504504

505505
type cosmosInitAction struct {
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"`
506+
Type string `json:"type"`
507+
ChainID string `json:"chainID"`
508+
IBCPort int `json:"ibcPort"`
509+
StoragePort int `json:"storagePort"`
510+
SupplyCoins sdk.Coins `json:"supplyCoins"`
511+
VPursePort int `json:"vpursePort"`
514512
}
515513

516514
// MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by
@@ -530,27 +528,14 @@ func (app *GaiaApp) MustInitController(ctx sdk.Context) {
530528
}
531529
app.controllerInited = true
532530

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-
544531
// Begin initializing the controller here.
545532
action := &cosmosInitAction{
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(),
533+
Type: "AG_COSMOS_INIT",
534+
ChainID: ctx.ChainID(),
535+
IBCPort: app.ibcPort,
536+
StoragePort: swingset.GetPort("storage"),
537+
SupplyCoins: app.BankKeeper.GetSupply(ctx).GetTotal(),
538+
VPursePort: app.vpursePort,
554539
}
555540
bz, err := json.Marshal(action)
556541
if err == nil {

golang/cosmos/proto/agoric/vpurse/genesis.proto

-17
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,4 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vpurse/types";
88
message GenesisState {
99
option (gogoproto.equal) = false;
1010

11-
// These are passed as part of the AG_COSMOS_INIT message.
12-
// They are plumbed through to configure the bootstrap of the treasury:
13-
14-
// Cosmos-SDK layer bech32 address to receive bootstrap_value urun.
15-
string bootstrap_address = 1;
16-
17-
// Number of urun to have the treasury send to bootstrap_address.
18-
string bootstrap_value = 2 [
19-
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
20-
(gogoproto.nullable) = false
21-
];
22-
23-
// Number of urun to send from bootstrap_address to new ag-solo clients.
24-
string donation_value = 3 [
25-
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
26-
(gogoproto.nullable) = false
27-
];
2811
}

golang/cosmos/x/vpurse/genesis.go

+1-25
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,27 @@ import (
1111
)
1212

1313
func NewGenesisState() *types.GenesisState {
14-
return &types.GenesisState{
15-
BootstrapAddress: "",
16-
BootstrapValue: sdk.NewInt(0),
17-
DonationValue: sdk.NewInt(0),
18-
}
14+
return &types.GenesisState{}
1915
}
2016

2117
func ValidateGenesis(data *types.GenesisState) error {
2218
if data == nil {
2319
return fmt.Errorf("vpurse genesis data cannot be nil")
2420
}
25-
if len(data.BootstrapAddress) > 0 {
26-
if _, err := sdk.AccAddressFromBech32(data.BootstrapAddress); err != nil {
27-
return fmt.Errorf("vpurse genesis invalid bootstrapAdddress %s: %w", data.BootstrapAddress, err)
28-
}
29-
}
30-
if data.BootstrapValue.IsNil() {
31-
return fmt.Errorf("vpurse genesis bootstrapValue cannot be nil")
32-
}
33-
if data.BootstrapValue.IsNegative() {
34-
return fmt.Errorf("vpurse genesis bootstrapValue %s cannot be negative", data.DonationValue.String())
35-
}
36-
if data.DonationValue.IsNil() {
37-
return fmt.Errorf("vpurse genesis donationValue cannot be nil")
38-
}
39-
if data.DonationValue.IsNegative() {
40-
return fmt.Errorf("vpurse genesis donationValue %s cannot be negative", data.DonationValue.String())
41-
}
4221
return nil
4322
}
4423

4524
func DefaultGenesisState() *types.GenesisState {
4625
gs := NewGenesisState()
47-
fmt.Println("default gen", gs)
4826
return gs
4927
}
5028

5129
func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
5230
keeper.SetGenesis(ctx, *data)
53-
fmt.Println("initialising gen", *data)
5431
return []abci.ValidatorUpdate{}
5532
}
5633

5734
func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState {
5835
gs := k.GetGenesis(ctx)
59-
fmt.Println("exporting gen", gs)
6036
return &gs
6137
}

golang/cosmos/x/vpurse/types/genesis.pb.go

+9-164
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)