Skip to content

Commit ede09ec

Browse files
committed
feat: genesis checker and replace
1 parent 6937dbd commit ede09ec

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

models/weaveinit/run_l1_node.go

+46-4
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,16 @@ func (m *EnableFeaturesCheckbox) Init() tea.Cmd {
319319
func (m *EnableFeaturesCheckbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
320320
cb, cmd, done := m.Select(msg)
321321
if done {
322-
// TODO: Remove and pull this logic
322+
for idx, isSelected := range cb.Selected {
323+
if isSelected {
324+
switch cb.Options[idx] {
325+
case LCD:
326+
m.state.enableLCD = true
327+
case gRPC:
328+
m.state.enableGRPC = true
329+
}
330+
}
331+
}
323332
return NewSeedsInput(m.state), nil
324333
}
325334

@@ -416,10 +425,13 @@ func (m *ExistingGenesisChecker) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
416425
}
417426

418427
initiaConfigPath := filepath.Join(homeDir, utils.InitiaConfigDirectory)
419-
genesisFilePath := filepath.Join(initiaConfigPath, "genesis.json")
428+
genesisFilePath := filepath.Join(initiaConfigPath, "genesis.jsona")
420429
if !utils.FileOrFolderExists(genesisFilePath) {
421430
m.state.existingGenesis = false
422-
// TODO: Continue
431+
if m.state.network == string(Local) {
432+
return m, tea.Quit
433+
}
434+
return NewGenesisEndpointInput(m.state), nil
423435
} else {
424436
m.state.existingGenesis = true
425437
return NewExistingGenesisReplaceSelect(m.state), nil
@@ -469,7 +481,7 @@ func (m *ExistingGenesisReplaceSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd)
469481
// TODO: Continue
470482
fmt.Println("\n[info] Using current genesis")
471483
case ReplaceGenesis:
472-
return NewMinGasPriceInput(m.state), nil
484+
fmt.Println("\n[info] Replacing genesis")
473485
}
474486
return m, tea.Quit
475487
}
@@ -488,3 +500,33 @@ func (m *ExistingGenesisReplaceSelect) View() string {
488500
}
489501
return view + "\nPress Enter to select, or q to quit."
490502
}
503+
504+
type GenesisEndpointInput struct {
505+
utils.TextInput
506+
state *RunL1NodeState
507+
}
508+
509+
func NewGenesisEndpointInput(state *RunL1NodeState) *GenesisEndpointInput {
510+
return &GenesisEndpointInput{
511+
TextInput: utils.NewTextInput(),
512+
state: state,
513+
}
514+
}
515+
516+
func (m *GenesisEndpointInput) Init() tea.Cmd {
517+
return nil
518+
}
519+
520+
func (m *GenesisEndpointInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
521+
input, done := m.TextInput.Update(msg)
522+
if done {
523+
m.state.genesisEndpoint = input.Text
524+
return m, tea.Quit
525+
}
526+
m.TextInput = input
527+
return m, nil
528+
}
529+
530+
func (m *GenesisEndpointInput) View() string {
531+
return fmt.Sprintf("i There is no config/genesis.json available. You will need to enter the required information to proceed.\n\nPlease specify the endpoint to fetch genesis.json\n> %s\n", m.TextInput.View())
532+
}

models/weaveinit/state.go

+3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ type RunL1NodeState struct {
88
existingApp bool
99
replaceExistingApp bool
1010
minGasPrice string
11+
enableLCD bool
12+
enableGRPC bool
1113
seeds string
1214
persistentPeers string
1315
existingGenesis bool
16+
genesisEndpoint string
1417
}

0 commit comments

Comments
 (0)