diff --git a/cmd/rollapp/setup/setup.go b/cmd/rollapp/setup/setup.go index e5b3e13f..f33d1873 100644 --- a/cmd/rollapp/setup/setup.go +++ b/cmd/rollapp/setup/setup.go @@ -204,12 +204,18 @@ RollApp's IRO time: %v`, ) if !isSequencerRegistered { - minBond, _ := sequencer.GetMinSequencerBondInBaseDenom( + minBond, err := sequencer.GetMinSequencerBondInBaseDenom( rollappConfig.RollappID, rollappConfig.HubData, ) + if err != nil { + pterm.Error.Println("failed to get min bond: ", err) + return + } + var bondAmount cosmossdktypes.Coin bondAmount.Denom = consts.Denoms.Hub + floatDenomRepresentation := displayRegularDenom(*minBond, 18) displayDenom := fmt.Sprintf( "%s%s", diff --git a/utils/rollapp/rollapp.go b/utils/rollapp/rollapp.go index 365046ca..95a7c41d 100644 --- a/utils/rollapp/rollapp.go +++ b/utils/rollapp/rollapp.go @@ -8,6 +8,7 @@ import ( "path/filepath" "strings" + cosmossdktypes "github.com/cosmos/cosmos-sdk/types" dymensiontypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" "github.com/pterm/pterm" @@ -275,3 +276,39 @@ func Show(raID string, hd consts.HubData) (*ShowRollappResponse, error) { return &raResponse, nil } + +type RaParams struct { + Params MinSequencerBond `json:"params"` +} + +type MinSequencerBond struct { + MinSequencerBondGlobal cosmossdktypes.Coin `json:"min_sequencer_bond_global"` +} + +func GetRollappParams(hd consts.HubData) (*RaParams, error) { + var resp RaParams + cmd := exec.Command( + consts.Executables.Dymension, + "q", + "rollapp", + "params", + "--node", + hd.RpcUrl, + "--chain-id", + hd.ID, + "-o", + "json", + ) + + out, err := bash.ExecCommandWithStdout(cmd) + if err != nil { + return nil, err + } + + err = json.Unmarshal(out.Bytes(), &resp) + if err != nil { + return nil, err + } + + return &resp, nil +} diff --git a/utils/rollapp/types.go b/utils/rollapp/types.go index 46a9f475..de57c9e0 100644 --- a/utils/rollapp/types.go +++ b/utils/rollapp/types.go @@ -3,6 +3,7 @@ package rollapp import ( "time" + cosmossdktypes "github.com/cosmos/cosmos-sdk/types" tmtypes "github.com/tendermint/tendermint/types" ) @@ -21,21 +22,21 @@ type Summary struct { } type Rollapp struct { - RollappId string `json:"rollapp_id,omitempty"` - Owner string `json:"owner,omitempty"` - PreLaunchTime string `json:"pre_launch_time,omitempty"` - GenesisState RollappGenesisState `json:"genesis_state"` - ChannelId string `json:"channel_id,omitempty"` - Frozen bool `json:"frozen,omitempty"` - RegisteredDenoms []string `json:"registeredDenoms,omitempty"` - Metadata *RollappMetadata `json:"metadata,omitempty"` - GenesisInfo GenesisInfo `json:"genesis_info"` - InitialSequencer string `json:"initial_sequencer,omitempty"` - VmType string `json:"vm_type,omitempty"` - Launched bool `json:"launched,omitempty"` - LivenessEventHeight string `json:"liveness_event_height,omitempty"` - LastStateUpdateHeight string `json:"last_state_update_height,omitempty"` - MinSequencerBond string `json:"min_sequencer_bond,omitempty"` + RollappId string `json:"rollapp_id,omitempty"` + Owner string `json:"owner,omitempty"` + PreLaunchTime string `json:"pre_launch_time,omitempty"` + GenesisState RollappGenesisState `json:"genesis_state"` + ChannelId string `json:"channel_id,omitempty"` + Frozen bool `json:"frozen,omitempty"` + RegisteredDenoms []string `json:"registeredDenoms,omitempty"` + Metadata *RollappMetadata `json:"metadata,omitempty"` + GenesisInfo GenesisInfo `json:"genesis_info"` + InitialSequencer string `json:"initial_sequencer,omitempty"` + VmType string `json:"vm_type,omitempty"` + Launched bool `json:"launched,omitempty"` + LivenessEventHeight string `json:"liveness_event_height,omitempty"` + LastStateUpdateHeight string `json:"last_state_update_height,omitempty"` + MinSequencerBond []cosmossdktypes.Coin `json:"min_sequencer_bond,omitempty"` } type GenesisInfo struct { diff --git a/utils/sequencer/sequencer.go b/utils/sequencer/sequencer.go index b383540f..845a8169 100644 --- a/utils/sequencer/sequencer.go +++ b/utils/sequencer/sequencer.go @@ -238,7 +238,17 @@ func GetMinSequencerBondInBaseDenom(raID string, hd consts.HubData) (*cosmossdkt _ = json.Unmarshal(out.Bytes(), &qra) - c := qra.MinSequencerBond[0] + var c cosmossdktypes.Coin + if qra.MinSequencerBond != nil { + c = qra.MinSequencerBond[0] + } else { + params, err := rollapp.GetRollappParams(hd) + if err != nil { + return nil, err + } + c = params.Params.MinSequencerBondGlobal + } + return &c, nil }