Skip to content

Commit

Permalink
fix(rollapp): allow empty values when registering rollapp (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Sep 6, 2024
1 parent 904c0d1 commit 78c49cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion x/rollapp/client/cli/tx_create_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func parseGenesisInfo(cmd *cobra.Command) (types.GenesisInfo, error) {
return types.GenesisInfo{}, err
}

genesisInfo.NativeDenom = new(types.DenomMetadata)
if nativeDenomFlag != "" {
genesisInfo.NativeDenom = new(types.DenomMetadata)
if err = utils.ParseJsonFromFile(nativeDenomFlag, genesisInfo.NativeDenom); err != nil {
return types.GenesisInfo{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/rollapp/types/message_create_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) {
Bech32Prefix: bech32Prefix,
GenesisChecksum: "checksum",
NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18},
InitialSupply: sdk.Int{},
InitialSupply: sdk.NewInt(-1),
},
},
err: ErrInvalidInitialSupply,
Expand Down
12 changes: 5 additions & 7 deletions x/rollapp/types/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ func (r GenesisInfo) Validate() error {
return errorsmod.Wrap(ErrInvalidGenesisChecksum, "GenesisChecksum")
}

if r.NativeDenom == nil {
return errorsmod.Wrap(ErrInvalidNativeDenom, "NativeDenom")
}

if err := r.NativeDenom.Validate(); err != nil {
return errorsmod.Wrap(ErrInvalidNativeDenom, err.Error())
if r.NativeDenom != nil {
if err := r.NativeDenom.Validate(); err != nil {
return errorsmod.Wrap(ErrInvalidNativeDenom, err.Error())
}
}

if r.InitialSupply.IsNil() {
if !r.InitialSupply.IsNil() && r.InitialSupply.IsNegative() {
return errorsmod.Wrap(ErrInvalidInitialSupply, "InitialSupply")
}

Expand Down

0 comments on commit 78c49cc

Please sign in to comment.