diff --git a/utils/sequencer/sequencer.go b/utils/sequencer/sequencer.go index 817301c2..8c506284 100644 --- a/utils/sequencer/sequencer.go +++ b/utils/sequencer/sequencer.go @@ -1,5 +1,7 @@ package sequencer +// TODO: most of the functions here should be a part of sequencer_manager + import ( "encoding/json" "fmt" @@ -25,10 +27,13 @@ import ( "github.com/dymensionxyz/roller/utils/tx" ) -func Register(raCfg roller.RollappConfig, desiredBond cosmossdktypes.Coin) error { +func getCreateSequencerCmd( + raCfg roller.RollappConfig, + desiredBond cosmossdktypes.Coin, +) (*exec.Cmd, error) { seqPubKey, err := keys.GetSequencerPubKey(raCfg) if err != nil { - return err + return nil, err } seqMetadataPath := filepath.Join( @@ -37,14 +42,30 @@ func Register(raCfg roller.RollappConfig, desiredBond cosmossdktypes.Coin) error "init", "sequencer-metadata.json", ) + _, err = isValidSequencerMetadata(seqMetadataPath) if err != nil { - return err + return nil, err } - home := roller.GetRootDir() + customRewardAddress, _ := pterm.DefaultInteractiveTextInput.WithDefaultText( + "would you like to use a custom reward address (leave empty to use the sequencer address)", + ).Show() + customRewardAddress = strings.TrimSpace(customRewardAddress) + + // TODO: improve ux + relayerAddresses, _ := pterm.DefaultInteractiveTextInput.WithDefaultText( + "provide a comma separated list of addresses that you want to enable relay IBC packets (example: addr1,addr2)", + ).Show() + relayerAddresses = strings.TrimSpace(relayerAddresses) + + cmd := exec.Command( + consts.Executables.Dymension, + + home := raCfg.Home args := []string{ + "tx", "sequencer", "create-sequencer", @@ -61,6 +82,25 @@ func Register(raCfg roller.RollappConfig, desiredBond cosmossdktypes.Coin) error "--node", raCfg.HubData.RpcUrl, "--chain-id", raCfg.HubData.ID, } + if customRewardAddress != "" { + args := []string{"--reward-address", customRewardAddress} + cmd.Args = append(cmd.Args, args...) + } + + if relayerAddresses != "" { + args := []string{"--whitelisted-relayers", relayerAddresses} + cmd.Args = append(cmd.Args, args...) + } + + return cmd, err +} + +func Register(raCfg roller.RollappConfig, desiredBond cosmossdktypes.Coin) error { + cmd, err := getCreateSequencerCmd(raCfg, desiredBond) + if err != nil { + return err + } + displayBond, err := BaseDenomToDenom(desiredBond, 18) if err != nil { return err