Skip to content

Commit 8dae7fa

Browse files
committed
impv: chain id in network selection
1 parent fecd9f6 commit 8dae7fa

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

models/initia/run_l1_node.go

+18-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"path/filepath"
88
"runtime"
99
"strconv"
10-
"strings"
1110
"time"
1211

1312
tea "github.com/charmbracelet/bubbletea"
@@ -24,13 +23,16 @@ type RunL1NodeNetworkSelect struct {
2423

2524
type L1NodeNetworkOption string
2625

27-
const (
28-
Mainnet L1NodeNetworkOption = "Mainnet"
29-
Testnet L1NodeNetworkOption = "Testnet"
30-
Local L1NodeNetworkOption = "Local"
26+
var (
27+
Mainnet L1NodeNetworkOption = ""
28+
Testnet L1NodeNetworkOption = ""
3129
)
3230

31+
const Local L1NodeNetworkOption = "Local"
32+
3333
func NewRunL1NodeNetworkSelect(state *RunL1NodeState) *RunL1NodeNetworkSelect {
34+
Testnet = L1NodeNetworkOption(fmt.Sprintf("Testnet (%s)", utils.GetConfig("constants.chain_id.testnet")))
35+
Mainnet = L1NodeNetworkOption(fmt.Sprintf("Mainnet (%s)", utils.GetConfig("constants.chain_id.mainnet")))
3436
return &RunL1NodeNetworkSelect{
3537
Selector: utils.Selector[L1NodeNetworkOption]{
3638
Options: []L1NodeNetworkOption{
@@ -60,7 +62,10 @@ func (m *RunL1NodeNetworkSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6062
m.state.weave.PushPreviousResponse(styles.RenderPreviousResponse(styles.ArrowSeparator, m.GetQuestion(), []string{"network"}, selectedString))
6163
switch *selected {
6264
case Mainnet, Testnet:
63-
lowerNetwork := strings.ToLower(selectedString)
65+
lowerNetwork := "testnet"
66+
if *selected == Mainnet {
67+
lowerNetwork = "mainnet"
68+
}
6469
chainId := utils.GetConfig(fmt.Sprintf("constants.chain_id.%s", lowerNetwork))
6570
genesisEndpoint, err := utils.GetEndpointURL(lowerNetwork, "genesis")
6671
if err != nil {
@@ -775,7 +780,11 @@ func initializeApp(state *RunL1NodeState) tea.Cmd {
775780
url = state.initiadEndpoint
776781
case string(Mainnet), string(Testnet):
777782
var result map[string]interface{}
778-
err = utils.MakeGetRequestUsingConfig(strings.ToLower(state.network), "lcd", "/cosmos/base/tendermint/v1beta1/node_info", nil, &result)
783+
network := "testnet"
784+
if state.network == string(Mainnet) {
785+
network = "mainnet"
786+
}
787+
err = utils.MakeGetRequestUsingConfig(network, "lcd", "/cosmos/base/tendermint/v1beta1/node_info", nil, &result)
779788
if err != nil {
780789
panic(err)
781790
}
@@ -1055,6 +1064,7 @@ const (
10551064
)
10561065

10571066
func NewExistingDataReplaceSelect(state *RunL1NodeState) *ExistingDataReplaceSelect {
1067+
// TODO: Paraphrase the question and options
10581068
return &ExistingDataReplaceSelect{
10591069
Selector: utils.Selector[SyncConfirmationOption]{
10601070
Options: []SyncConfirmationOption{
@@ -1082,6 +1092,7 @@ func (m *ExistingDataReplaceSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
10821092
switch *selected {
10831093
case Skip:
10841094
m.state.replaceExistingData = false
1095+
// TODO: Terminal state here
10851096
return m, tea.Quit
10861097
case ProceedWithSync:
10871098
m.state.replaceExistingData = true

0 commit comments

Comments
 (0)