@@ -148,7 +148,6 @@ func (m *RunL1NodeMonikerInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
148
148
input , done := m .TextInput .Update (msg )
149
149
if done {
150
150
m .state .moniker = string (input )
151
- fmt .Println ("\n [info] state" , m .state )
152
151
return NewExistingAppChecker (m .state ), utils .DoTick ()
153
152
}
154
153
m .TextInput = input
@@ -160,14 +159,12 @@ func (m *RunL1NodeMonikerInput) View() string {
160
159
}
161
160
162
161
type ExistingAppChecker struct {
163
- checkComplete bool
164
- state * RunL1NodeState
162
+ state * RunL1NodeState
165
163
}
166
164
167
165
func NewExistingAppChecker (state * RunL1NodeState ) * ExistingAppChecker {
168
166
return & ExistingAppChecker {
169
- checkComplete : false ,
170
- state : state ,
167
+ state : state ,
171
168
}
172
169
}
173
170
@@ -178,26 +175,20 @@ func (m *ExistingAppChecker) Init() tea.Cmd {
178
175
func (m * ExistingAppChecker ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
179
176
switch msg .(type ) {
180
177
case utils.TickMsg :
181
- if ! m .checkComplete {
182
- homeDir , err := os .UserHomeDir ()
183
- if err != nil {
184
- fmt .Printf ("[error] Failed to get user home directory: %v\n " , err )
185
- return m , tea .Quit
186
- }
187
-
188
- configTomlPath := filepath .Join (homeDir , ".initia" , "config" , "config.toml" )
189
- if ! utils .FileOrFolderExists (configTomlPath ) {
190
- fmt .Println ("\n [info] No existing Initia app found" )
191
- } else {
192
- return NewExistingAppReplaceSelect (m .state ), nil
193
- }
194
-
195
- m .checkComplete = true
178
+ homeDir , err := os .UserHomeDir ()
179
+ if err != nil {
180
+ fmt .Printf ("[error] Failed to get user home directory: %v\n " , err )
181
+ return m , tea .Quit
196
182
}
197
- if m .checkComplete {
198
- return NewRunL1NodeNetworkSelect (m .state ), nil
183
+
184
+ configTomlPath := filepath .Join (homeDir , ".initia" , "config" , "config.toml" )
185
+ if ! utils .FileOrFolderExists (configTomlPath ) {
186
+ m .state .existingApp = false
187
+ return NewMinGasPriceInput (m .state ), nil
188
+ } else {
189
+ m .state .existingApp = true
190
+ return NewExistingAppReplaceSelect (m .state ), nil
199
191
}
200
- return m , nil
201
192
default :
202
193
return m , nil
203
194
}
@@ -240,9 +231,11 @@ func (m *ExistingAppReplaceSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
240
231
if selected != nil {
241
232
switch * selected {
242
233
case UseCurrent :
234
+ m .state .replaceExistingApp = false
243
235
fmt .Println ("\n [info] Using current files" )
244
236
case Replace :
245
- fmt .Println ("\n [info] Replacing files" )
237
+ m .state .replaceExistingApp = true
238
+ return NewMinGasPriceInput (m .state ), nil
246
239
}
247
240
return m , tea .Quit
248
241
}
@@ -261,3 +254,37 @@ func (m *ExistingAppReplaceSelect) View() string {
261
254
}
262
255
return view + "\n Press Enter to select, or q to quit."
263
256
}
257
+
258
+ type MinGasPriceInput struct {
259
+ utils.TextInput
260
+ state * RunL1NodeState
261
+ }
262
+
263
+ func NewMinGasPriceInput (state * RunL1NodeState ) * MinGasPriceInput {
264
+ return & MinGasPriceInput {
265
+ TextInput : "" ,
266
+ state : state ,
267
+ }
268
+ }
269
+
270
+ func (m * MinGasPriceInput ) Init () tea.Cmd {
271
+ return nil
272
+ }
273
+
274
+ func (m * MinGasPriceInput ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
275
+ input , done := m .TextInput .Update (msg )
276
+ if done {
277
+ m .state .minGasPrice = string (input )
278
+ return m , tea .Quit
279
+ }
280
+ m .TextInput = input
281
+ return m , nil
282
+ }
283
+
284
+ func (m * MinGasPriceInput ) View () string {
285
+ preText := ""
286
+ if ! m .state .existingApp {
287
+ preText += "No existing .initia directory found. Creating a new one.\n "
288
+ }
289
+ return fmt .Sprintf ("%s? Please specify min-gas-price (uinit)\n > %s\n " , preText , string (m .TextInput ))
290
+ }
0 commit comments