Skip to content

Commit

Permalink
moved SequencerPubKey to shared pacakge
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Jul 2, 2023
1 parent 6c132e8 commit e244fe1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/config/init/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func initializeRollappConfig(initConfig utils.RollappConfig) error {
return err
}

seqPubKey, err := showSequencerPubKey(initConfig.RollappBinary, home)
seqPubKey, err := utils.GetSequencerPubKey(initConfig)
if err != nil {
return err
}
Expand Down
22 changes: 3 additions & 19 deletions cmd/register/bash_commands.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package register

import (
"github.com/dymensionxyz/roller/cmd/utils"
"os/exec"
"path/filepath"

"fmt"
"github.com/dymensionxyz/roller/cmd/utils"

"strings"
"fmt"

"github.com/dymensionxyz/roller/cmd/consts"
)
Expand All @@ -22,23 +21,8 @@ func getRegisterRollappCmd(rollappConfig utils.RollappConfig) *exec.Cmd {
)
}

func showSequencerPubKey(rollappConfig utils.RollappConfig) (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 utils.RollappConfig) (*exec.Cmd, error) {
seqPubKey, err := showSequencerPubKey(rollappConfig)
seqPubKey, err := utils.GetSequencerPubKey(rollappConfig)
if err != nil {
return nil, err
}
Expand Down
15 changes: 15 additions & 0 deletions cmd/utils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,18 @@ func PrintAddresses(addresses []AddressData) {
table.AppendBulk(data)
table.Render()
}

func GetSequencerPubKey(rollappConfig RollappConfig) (string, error) {
cmd := exec.Command(
rollappConfig.RollappBinary,
"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
}

0 comments on commit e244fe1

Please sign in to comment.