Skip to content
This repository was archived by the owner on Jun 18, 2025. It is now read-only.

Commit 1574562

Browse files
Alex Johnsonlumtis
andauthored
feat(launch): default chain account balances (#936)
* update proto * update sample * validate coins * add validate test * modify tx proto * add msg validation and test * update cli * keeper logic * format * fumpt * add comment * fix merge * rename to AccountBalance * modify tx proto * finish rename * remove defaultAccount* usages Co-authored-by: Lucas Btd <[email protected]>
1 parent ae4ee27 commit 1574562

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+457
-214
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.18
55
require (
66
cosmossdk.io/errors v1.0.0-beta.7
77
cosmossdk.io/math v1.0.0-beta.3
8+
github.com/cosmos/cosmos-proto v1.0.0-alpha7
89
github.com/cosmos/cosmos-sdk v0.46.1
910
github.com/cosmos/ibc-go/v5 v5.0.0-rc0
1011
github.com/gogo/protobuf v1.3.3
@@ -14,7 +15,6 @@ require (
1415
github.com/grpc-ecosystem/grpc-gateway v1.16.0
1516
github.com/ignite/modules v0.0.0-20220830145312-d006783a7a21
1617
github.com/pkg/errors v0.9.1
17-
github.com/regen-network/cosmos-proto v0.3.1
1818
github.com/spf13/cast v1.5.0
1919
github.com/spf13/cobra v1.5.0
2020
github.com/spf13/pflag v1.0.5
@@ -25,7 +25,6 @@ require (
2525
golang.org/x/tools v0.1.12
2626
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc
2727
google.golang.org/grpc v1.48.0
28-
google.golang.org/protobuf v1.28.1
2928
gopkg.in/yaml.v2 v2.4.0
3029
mvdan.cc/gofumpt v0.3.1
3130
)
@@ -73,7 +72,6 @@ require (
7372
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
7473
github.com/confio/ics23/go v0.7.0 // indirect
7574
github.com/cosmos/btcutil v1.0.4 // indirect
76-
github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect
7775
github.com/cosmos/go-bip39 v1.0.0 // indirect
7876
github.com/cosmos/gorocksdb v1.2.0 // indirect
7977
github.com/cosmos/iavl v0.19.1 // indirect
@@ -212,6 +210,7 @@ require (
212210
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
213211
github.com/rakyll/statik v0.1.7 // indirect
214212
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
213+
github.com/regen-network/cosmos-proto v0.3.1 // indirect
215214
github.com/rs/cors v1.8.2 // indirect
216215
github.com/rs/zerolog v1.27.0 // indirect
217216
github.com/ryancurrah/gomodguard v1.2.4 // indirect
@@ -270,6 +269,7 @@ require (
270269
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
271270
google.golang.org/api v0.84.0 // indirect
272271
google.golang.org/appengine v1.6.7 // indirect
272+
google.golang.org/protobuf v1.28.1 // indirect
273273
gopkg.in/ini.v1 v1.66.6 // indirect
274274
gopkg.in/yaml.v3 v3.0.1 // indirect
275275
honnef.co/go/tools v0.3.3 // indirect

pkg/types/monitoring.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/launch/chain.proto

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ syntax = "proto3";
22
package tendermint.spn.launch;
33

44
import "gogoproto/gogo.proto";
5+
import "cosmos/base/v1beta1/coin.proto";
56

67
option go_package = "github.com/tendermint/spn/x/launch/types";
78

@@ -27,7 +28,16 @@ message Chain {
2728

2829
bool monitoringConnected = 14;
2930

30-
bytes metadata = 15;
31+
// account balance is the balance given to approved accounts
32+
// for this chain. If not set, the balances used will be those
33+
// contained in the requests
34+
repeated cosmos.base.v1beta1.Coin accountBalance = 15 [
35+
(gogoproto.nullable) = false,
36+
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin",
37+
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
38+
];
39+
40+
bytes metadata = 16;
3141
}
3242

3343
message InitialGenesis {

proto/launch/tx.proto

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,32 @@ service Msg {
2929
}
3030

3131
message MsgCreateChain {
32-
string coordinator = 1;
33-
string genesisChainID = 2;
34-
string sourceURL = 3;
35-
string sourceHash = 4;
36-
string genesisURL = 5;
37-
string genesisHash = 6;
38-
bool hasCampaign = 7;
39-
uint64 campaignID = 8;
40-
bytes metadata = 9;
32+
string coordinator = 1;
33+
string genesisChainID = 2;
34+
string sourceURL = 3;
35+
string sourceHash = 4;
36+
string genesisURL = 5;
37+
string genesisHash = 6;
38+
bool hasCampaign = 7;
39+
uint64 campaignID = 8;
40+
repeated cosmos.base.v1beta1.Coin AccountBalance = 9 [
41+
(gogoproto.nullable) = false,
42+
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin",
43+
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
44+
];
45+
bytes metadata = 10;
4146
}
4247

4348
message MsgCreateChainResponse {
4449
uint64 launchID = 1;
4550
}
4651

4752
message MsgEditChain {
48-
string coordinator = 1;
49-
uint64 launchID = 2;
50-
bool setCampaignID = 3;
51-
uint64 campaignID = 4;
52-
bytes metadata = 5;
53+
string coordinator = 1;
54+
uint64 launchID = 2;
55+
bool setCampaignID = 3;
56+
uint64 campaignID = 4;
57+
bytes metadata = 5;
5358
}
5459

5560
message MsgEditChainResponse {}

testutil/sample/launch.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func Chain(r *rand.Rand, id, coordinatorID uint64) launch.Chain {
3535
SourceHash: String(r, 10),
3636
LaunchTriggered: false,
3737
InitialGenesis: launch.NewDefaultInitialGenesis(),
38+
AccountBalance: Coins(r),
3839
Metadata: Metadata(r, 20),
3940
}
4041
}
@@ -161,6 +162,7 @@ func MsgCreateChain(r *rand.Rand, coordAddress, genesisURL string, hasCampaign b
161162
genesisHash,
162163
hasCampaign,
163164
campaignID,
165+
Coins(r),
164166
Metadata(r, 20),
165167
)
166168
}

x/campaign/keeper/keeper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type LaunchKeeper interface {
2727
hasCampaign bool,
2828
campaignID uint64,
2929
isMainnet bool,
30+
accountBalance sdk.Coins,
3031
metadata []byte,
3132
) (uint64, error)
3233
}

x/campaign/keeper/msg_initialize_mainnet.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (k msgServer) InitializeMainnet(goCtx context.Context, msg *types.MsgInitia
5353
true,
5454
msg.CampaignID,
5555
true,
56+
sdk.NewCoins(), // no enforced default for mainnet
5657
[]byte{},
5758
)
5859
if err != nil {

x/campaign/types/events.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/campaign/types/mainnet_account.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/campaign/types/params.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)