-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented sequencer registration on roller register command
- Loading branch information
1 parent
eaa2728
commit 11cd784
Showing
13 changed files
with
241 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package register | ||
|
||
import ( | ||
"os/exec" | ||
"path/filepath" | ||
|
||
"fmt" | ||
|
||
"strings" | ||
|
||
initconfig "github.com/dymensionxyz/roller/cmd/config/init" | ||
"github.com/dymensionxyz/roller/cmd/consts" | ||
) | ||
|
||
func getRegisterRollappCmd(rollappConfig initconfig.InitConfig) *exec.Cmd { | ||
cmdArgs := []string{ | ||
"tx", "rollapp", "create-rollapp", rollappConfig.RollappID, "stamp1", "genesis-path/1", "3", "3", `{"Addresses":[]}`, | ||
} | ||
cmdArgs = append(cmdArgs, GetCommonFlags(rollappConfig)...) | ||
return exec.Command( | ||
consts.Executables.Dymension, cmdArgs..., | ||
) | ||
} | ||
|
||
func showSequencerPubKey(rollappConfig initconfig.InitConfig) (string, error) { | ||
cmd := exec.Command( | ||
consts.Executables.RollappEVM, | ||
"dymint", | ||
"show-sequencer", | ||
"--home", | ||
filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp), | ||
) | ||
out, err := cmd.Output() | ||
if err != nil { | ||
return "", err | ||
} | ||
return strings.ReplaceAll(strings.ReplaceAll(string(out), "\n", ""), "\\", ""), nil | ||
} | ||
|
||
func getRegisterSequencerCmd(rollappConfig initconfig.InitConfig) (*exec.Cmd, error) { | ||
seqPubKey, err := showSequencerPubKey(rollappConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
description := fmt.Sprintf(`{"Moniker":"%s","Identity":"","Website":"","SecurityContact":"","Details":""}`, | ||
consts.KeyNames.HubSequencer) | ||
cmdArgs := []string{ | ||
"tx", "sequencer", "create-sequencer", | ||
seqPubKey, | ||
rollappConfig.RollappID, | ||
description, | ||
} | ||
cmdArgs = append(cmdArgs, GetCommonFlags(rollappConfig)...) | ||
return exec.Command(consts.Executables.Dymension, cmdArgs...), nil | ||
} | ||
|
||
func GetCommonFlags(rollappConfig initconfig.InitConfig) []string { | ||
return []string{ | ||
"--from", consts.KeyNames.HubSequencer, | ||
"--keyring-backend", "test", | ||
"--keyring-dir", filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp), | ||
"--node", rollappConfig.HubData.RPC_URL, "--output", "json", | ||
"--yes", "--broadcast-mode", "block", "--chain-id", rollappConfig.HubData.ID, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func AddGlobalFlags(command *cobra.Command) { | ||
command.Flags().StringP(FlagNames.Home, "", GetRollerRootDir(), "The directory of the roller config files") | ||
} | ||
|
||
var FlagNames = struct { | ||
Home string | ||
}{ | ||
Home: "home", | ||
} | ||
|
||
func GetRollerRootDir() string { | ||
return filepath.Join(os.Getenv("HOME"), ".roller") | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.