-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cb9ed3
commit ba017d7
Showing
12 changed files
with
62 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,52 @@ | ||
package set | ||
|
||
import ( | ||
"github.com/dymensionxyz/roller/relayer" | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/pterm/pterm" | ||
|
||
"github.com/dymensionxyz/roller/cmd/consts" | ||
"github.com/dymensionxyz/roller/utils/config/tomlconfig" | ||
"github.com/dymensionxyz/roller/utils/config/yamlconfig" | ||
"github.com/dymensionxyz/roller/utils/roller" | ||
"github.com/dymensionxyz/roller/utils/sequencer" | ||
servicemanager "github.com/dymensionxyz/roller/utils/service_manager" | ||
) | ||
|
||
// setHubRPC function | ||
func setHubRPC(rlpCfg roller.RollappConfig, value string) error { | ||
pterm.Info.Println("updating roller config file with the new hub rpc endpoint") | ||
rlpCfg.HubData.RpcUrl = value | ||
rlpCfg.HubData.ArchiveRpcUrl = value | ||
if err := roller.WriteConfig(rlpCfg); err != nil { | ||
return err | ||
} | ||
if err := relayer.UpdateRlyConfigValue( | ||
rlpCfg, []string{"chains", rlpCfg.HubData.ID, "value", "rpc-addr"}, | ||
value, | ||
); err != nil { | ||
|
||
pterm.Info.Println("updating relayer config file with the new hub rpc endpoint") | ||
updates := map[string]interface{}{ | ||
fmt.Sprintf("chains.%s.value.rpc-addr", rlpCfg.HubData.ID): value, | ||
} | ||
|
||
rlyConfigPath := filepath.Join( | ||
rlpCfg.Home, | ||
consts.ConfigDirName.Relayer, | ||
"config", | ||
"config.yaml", | ||
) | ||
err := yamlconfig.UpdateNestedYAML(rlyConfigPath, updates) | ||
if err != nil { | ||
pterm.Error.Printf("Error updating YAML: %v\n", err) | ||
return err | ||
} | ||
|
||
pterm.Info.Println("updating dymint config file with the new hub rpc endpoint") | ||
dymintTomlPath := sequencer.GetDymintFilePath(rlpCfg.Home) | ||
err := tomlconfig.UpdateFieldInFile(dymintTomlPath, "settlement_node_address", value) | ||
err = tomlconfig.UpdateFieldInFile(dymintTomlPath, "settlement_node_address", value) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pterm.Info.Println("restarting system services to apply the changes") | ||
return servicemanager.RestartSystemServices([]string{"rollapp", "relayer"}, rlpCfg.Home) | ||
} |
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
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
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
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