Skip to content

Commit

Permalink
fix(rollapp): cli update only metadata (#1708)
Browse files Browse the repository at this point in the history
fix cli update only rollapp metadata
  • Loading branch information
zale144 authored Jan 13, 2025
1 parent 200dd62 commit 942c868
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
3 changes: 1 addition & 2 deletions x/rollapp/client/cli/flags.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
flag "github.com/spf13/pflag"
)

Expand All @@ -21,7 +20,7 @@ func FlagSetUpdateRollapp() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)

fs.String(FlagInitSequencer, "", "The address of the sequencer that will be used to initialize the rollapp")
fs.String(FlagMinSequencerBond, rollapptypes.DefaultMinSequencerBondGlobalCoin.Amount.String(), "Minimum amount of bond required to be a sequencer in DYM (not adym)")
fs.String(FlagMinSequencerBond, "", "Minimum amount of bond required to be a sequencer in DYM (not adym)")
fs.String(FlagGenesisChecksum, "", "The checksum of the genesis file of the rollapp")
fs.String(FlagNativeDenom, "", "The native denomination of the rollapp")
fs.String(FlagInitialSupply, "", "The initial supply of the rollapp")
Expand Down
17 changes: 14 additions & 3 deletions x/rollapp/client/cli/tx_create_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
"github.com/spf13/cobra"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"

"github.com/dymensionxyz/dymension/v3/utils"
"github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)
Expand Down Expand Up @@ -49,6 +50,9 @@ func CmdCreateRollapp() *cobra.Command {
if err != nil {
return err
}
if minSeqBondS == "" {
minSeqBondS = types.DefaultMinSequencerBondGlobalCoin.Amount.String()
}
minSeqBond, ok := sdk.NewIntFromString(minSeqBondS)
if !ok {
return fmt.Errorf("invalid min sequencer bond: %s", minSeqBondS)
Expand Down Expand Up @@ -158,11 +162,18 @@ func parseGenesisInfo(cmd *cobra.Command) (*types.GenesisInfo, error) {
Amount: amt,
})
}
genesisInfo.GenesisAccounts = &types.GenesisAccounts{
Accounts: accounts,
if len(genesisAccounts) > 0 {
genesisInfo.GenesisAccounts = &types.GenesisAccounts{
Accounts: accounts,
}
}
}

if genesisInfo.GenesisChecksum == "" && genesisInfo.GenesisAccounts == nil && genesisInfo.Bech32Prefix == "" &&
genesisInfo.InitialSupply.IsNil() && genesisInfo.NativeDenom.Base == "" {
return nil, nil
}

return genesisInfo, nil
}

Expand Down
16 changes: 11 additions & 5 deletions x/rollapp/client/cli/tx_update_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
"github.com/spf13/cobra"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"

"github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)

Expand Down Expand Up @@ -39,9 +40,14 @@ func CmdUpdateRollapp() *cobra.Command {
if err != nil {
return err
}
minSeqBond, ok := sdk.NewIntFromString(minSeqBondS)
if !ok {
return fmt.Errorf("invalid min sequencer bond: %s", minSeqBondS)

var minSeqBondDym sdk.Coin
if minSeqBondS != "" {
minSeqBond, ok := sdk.NewIntFromString(minSeqBondS)
if !ok {
return fmt.Errorf("invalid min sequencer bond: %s", minSeqBondS)
}
minSeqBondDym = commontypes.ADym(minSeqBond)
}

genesisInfo, err := parseGenesisInfo(cmd)
Expand All @@ -63,7 +69,7 @@ func CmdUpdateRollapp() *cobra.Command {
clientCtx.GetFromAddress().String(),
argRollappId,
initSequencer,
commontypes.ADym(minSeqBond),
minSeqBondDym,
metadata,
genesisInfo,
)
Expand Down
17 changes: 12 additions & 5 deletions x/rollapp/keeper/msg_server_update_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (s *RollappTestSuite) TestUpdateRollapp() {

tests := []struct {
name string
sealed bool
update *types.MsgUpdateRollappInformation
expError error
mallete func(expected *types.Rollapp)
Expand Down Expand Up @@ -98,11 +99,15 @@ func (s *RollappTestSuite) TestUpdateRollapp() {
},
{
name: "Update rollapp: success - update only metadata",
update: &types.MsgUpdateRollappInformation{
Owner: alice,
RollappId: rollappId,
Metadata: &mockRollappMetadata,
},
update: types.NewMsgUpdateRollappInformation(
alice,
rollappId,
"",
sdk.Coin{},
&mockRollappMetadata,
nil,
),
sealed: true,
expError: nil,
mallete: func(expected *types.Rollapp) {
expected.Metadata = &mockRollappMetadata
Expand Down Expand Up @@ -193,6 +198,8 @@ func (s *RollappTestSuite) TestUpdateRollapp() {
goCtx := sdk.WrapSDKContext(s.Ctx)

rollapp := types.NewRollapp(alice, rollappId, "*", types.DefaultMinSequencerBondGlobalCoin, types.Rollapp_EVM, &types.RollappMetadata{}, gInfo)
rollapp.Launched = tc.sealed
rollapp.GenesisInfo.Sealed = tc.sealed
s.k().SetRollapp(s.Ctx, rollapp)

_, err := s.msgServer.UpdateRollappInformation(goCtx, tc.update)
Expand Down

0 comments on commit 942c868

Please sign in to comment.