Skip to content

Commit

Permalink
fix(launch): remove pointer for InitialGenesis in MsgCreateChain (
Browse files Browse the repository at this point in the history
#960)

* proto

* update code

* fix test
  • Loading branch information
lumtis authored Sep 21, 2022
1 parent 142531a commit 8bafad8
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 95 deletions.
2 changes: 1 addition & 1 deletion proto/launch/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ message MsgCreateChain {
string genesisChainID = 2;
string sourceURL = 3;
string sourceHash = 4;
InitialGenesis initialGenesis = 5;
InitialGenesis initialGenesis = 5 [(gogoproto.nullable) = false];
bool hasCampaign = 6;
uint64 campaignID = 7;
repeated cosmos.base.v1beta1.Coin AccountBalance = 8 [
Expand Down
2 changes: 1 addition & 1 deletion testutil/sample/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func MsgCreateChain(r *rand.Rand, coordAddress, genesisURL string, hasCampaign b
GenesisChainID(r),
String(r, 10),
String(r, 10),
&initialGenesis,
initialGenesis,
hasCampaign,
campaignID,
Coins(r),
Expand Down
2 changes: 1 addition & 1 deletion x/campaign/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type LaunchKeeper interface {
genesisChainID,
sourceURL,
sourceHash string,
initialGenesis *launchtypes.InitialGenesis,
initialGenesis launchtypes.InitialGenesis,
hasCampaign bool,
campaignID uint64,
isMainnet bool,
Expand Down
2 changes: 1 addition & 1 deletion x/campaign/keeper/msg_initialize_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (k msgServer) InitializeMainnet(goCtx context.Context, msg *types.MsgInitia
msg.MainnetChainID,
msg.SourceURL,
msg.SourceHash,
&initialGenesis,
initialGenesis,
true,
msg.CampaignID,
true,
Expand Down
2 changes: 1 addition & 1 deletion x/launch/client/cli/tx_create_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func CmdCreateChain() *cobra.Command {
args[0],
args[1],
args[2],
&initialGenesis,
initialGenesis,
hasCampaign,
campaignID,
balanceCoins,
Expand Down
4 changes: 2 additions & 2 deletions x/launch/keeper/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (k Keeper) CreateNewChain(
genesisChainID,
sourceURL,
sourceHash string,
initialGenesis *types.InitialGenesis,
initialGenesis types.InitialGenesis,
hasCampaign bool,
campaignID uint64,
isMainnet bool,
Expand All @@ -36,7 +36,7 @@ func (k Keeper) CreateNewChain(
CreatedAt: ctx.BlockTime().Unix(),
SourceURL: sourceURL,
SourceHash: sourceHash,
InitialGenesis: *initialGenesis,
InitialGenesis: initialGenesis,
HasCampaign: hasCampaign,
CampaignID: campaignID,
IsMainnet: isMainnet,
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestKeeper_CreateNewChain(t *testing.T) {
tc.genesisChainID,
tc.sourceURL,
tc.sourceHash,
&tc.initialGenesis,
tc.initialGenesis,
tc.hasCampaign,
tc.campaignID,
tc.isMainnet,
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/msg_create_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestMsgCreateChain(t *testing.T) {
require.EqualValues(t, tc.msg.SourceURL, chain.SourceURL)
require.EqualValues(t, tc.msg.SourceHash, chain.SourceHash)
require.EqualValues(t, tc.msg.Metadata, chain.Metadata)
require.EqualValues(t, *tc.msg.InitialGenesis, chain.InitialGenesis)
require.EqualValues(t, tc.msg.InitialGenesis, chain.InitialGenesis)

// Chain created from MsgCreateChain is never a mainnet
require.False(t, chain.IsMainnet)
Expand Down
3 changes: 1 addition & 2 deletions x/launch/types/chain.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/launch/types/msg_create_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewMsgCreateChain(
genesisChainID,
sourceURL,
sourceHash string,
initialGenesis *InitialGenesis,
initialGenesis InitialGenesis,
hasCampaign bool,
campaignID uint64,
accountBalance sdk.Coins,
Expand Down
4 changes: 2 additions & 2 deletions x/launch/types/msg_create_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
func TestMsgCreateChain_ValidateBasic(t *testing.T) {
invalidGenesisHash := sample.MsgCreateChain(r, sample.Address(r), "foo.com", false, 0)
invalidInitialGenesis := types.NewGenesisURL("foo.com", "NoHash")
invalidGenesisHash.InitialGenesis = &invalidInitialGenesis
invalidGenesisHash.InitialGenesis = invalidInitialGenesis

invalidConfigFile := sample.MsgCreateChain(r, sample.Address(r), "foo.com", false, 0)
invalidInitialGenesis = types.NewConfigGenesis("")
invalidConfigFile.InitialGenesis = &invalidInitialGenesis
invalidConfigFile.InitialGenesis = invalidInitialGenesis

invalidGenesisChainID := sample.MsgCreateChain(r, sample.Address(r), "", false, 0)
invalidGenesisChainID.GenesisChainID = "invalid"
Expand Down
154 changes: 74 additions & 80 deletions x/launch/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/monitoringc/keeper/msg_create_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Test_msgServer_CreateClient(t *testing.T) {
"orbit-1",
sample.String(r, 10),
sample.String(r, 10),
&initialGenesis,
initialGenesis,
false,
0,
sample.Coins(r),
Expand Down

0 comments on commit 8bafad8

Please sign in to comment.