6
6
"github.com/initia-labs/weave/utils"
7
7
)
8
8
9
- type RunL1Node struct {
9
+ type RunL1NodeNetworkSelect struct {
10
10
utils.Selector [L1NodeNetworkOption ]
11
11
state * RunL1NodeState
12
12
}
@@ -19,8 +19,8 @@ const (
19
19
Local L1NodeNetworkOption = "Local"
20
20
)
21
21
22
- func NewRunL1Node (state * RunL1NodeState ) * RunL1Node {
23
- return & RunL1Node {
22
+ func NewRunL1NodeNetworkSelect (state * RunL1NodeState ) * RunL1NodeNetworkSelect {
23
+ return & RunL1NodeNetworkSelect {
24
24
Selector : utils.Selector [L1NodeNetworkOption ]{
25
25
Options : []L1NodeNetworkOption {
26
26
Mainnet ,
@@ -32,22 +32,27 @@ func NewRunL1Node(state *RunL1NodeState) *RunL1Node {
32
32
}
33
33
}
34
34
35
- func (m * RunL1Node ) Init () tea.Cmd {
35
+ func (m * RunL1NodeNetworkSelect ) Init () tea.Cmd {
36
36
return nil
37
37
}
38
38
39
- func (m * RunL1Node ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
39
+ func (m * RunL1NodeNetworkSelect ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
40
40
selected , cmd := m .Select (msg )
41
41
if selected != nil {
42
42
m .state .network = string (* selected )
43
- fmt .Println ("[info] state " , m .state )
43
+ switch * selected {
44
+ case Mainnet , Testnet :
45
+ fmt .Println ("\n [info] state" , m .state )
46
+ case Local :
47
+ return NewRunL1NodeVersionInput (m .state ), nil
48
+ }
44
49
return m , tea .Quit
45
50
}
46
51
47
52
return m , cmd
48
53
}
49
54
50
- func (m * RunL1Node ) View () string {
55
+ func (m * RunL1NodeNetworkSelect ) View () string {
51
56
view := "? Which network will your node participate in?\n "
52
57
for i , option := range m .Options {
53
58
if i == m .Cursor {
@@ -58,3 +63,94 @@ func (m *RunL1Node) View() string {
58
63
}
59
64
return view + "\n Press Enter to select, or q to quit."
60
65
}
66
+
67
+ type RunL1NodeVersionInput struct {
68
+ utils.TextInput
69
+ state * RunL1NodeState
70
+ }
71
+
72
+ func NewRunL1NodeVersionInput (state * RunL1NodeState ) * RunL1NodeVersionInput {
73
+ return & RunL1NodeVersionInput {
74
+ TextInput : "" ,
75
+ state : state ,
76
+ }
77
+ }
78
+
79
+ func (m * RunL1NodeVersionInput ) Init () tea.Cmd {
80
+ return nil
81
+ }
82
+
83
+ func (m * RunL1NodeVersionInput ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
84
+ input , done := m .TextInput .Update (msg )
85
+ if done {
86
+ m .state .initiadVersion = string (input )
87
+ return NewRunL1NodeChainIdInput (m .state ), nil
88
+ }
89
+ m .TextInput = input
90
+ return m , nil
91
+ }
92
+
93
+ func (m * RunL1NodeVersionInput ) View () string {
94
+ return fmt .Sprintf ("? Please specify the initiad version\n > %s\n " , string (m .TextInput ))
95
+ }
96
+
97
+ type RunL1NodeChainIdInput struct {
98
+ utils.TextInput
99
+ state * RunL1NodeState
100
+ }
101
+
102
+ func NewRunL1NodeChainIdInput (state * RunL1NodeState ) * RunL1NodeChainIdInput {
103
+ return & RunL1NodeChainIdInput {
104
+ TextInput : "" ,
105
+ state : state ,
106
+ }
107
+ }
108
+
109
+ func (m * RunL1NodeChainIdInput ) Init () tea.Cmd {
110
+ return nil
111
+ }
112
+
113
+ func (m * RunL1NodeChainIdInput ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
114
+ input , done := m .TextInput .Update (msg )
115
+ if done {
116
+ m .state .chainId = string (input )
117
+ return NewRunL1NodeMonikerInput (m .state ), nil
118
+ }
119
+ m .TextInput = input
120
+ return m , nil
121
+ }
122
+
123
+ func (m * RunL1NodeChainIdInput ) View () string {
124
+ return fmt .Sprintf ("? Please specify the chain ID\n > %s\n " , string (m .TextInput ))
125
+ }
126
+
127
+ type RunL1NodeMonikerInput struct {
128
+ utils.TextInput
129
+ state * RunL1NodeState
130
+ }
131
+
132
+ func NewRunL1NodeMonikerInput (state * RunL1NodeState ) * RunL1NodeMonikerInput {
133
+ return & RunL1NodeMonikerInput {
134
+ TextInput : "" ,
135
+ state : state ,
136
+ }
137
+ }
138
+
139
+ func (m * RunL1NodeMonikerInput ) Init () tea.Cmd {
140
+ return nil
141
+ }
142
+
143
+ func (m * RunL1NodeMonikerInput ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
144
+ input , done := m .TextInput .Update (msg )
145
+ if done {
146
+ m .state .moniker = string (input )
147
+ fmt .Println ("\n [info] state" , m .state )
148
+ return m , tea .Quit
149
+ }
150
+ m .TextInput = input
151
+ return m , nil
152
+ }
153
+
154
+ func (m * RunL1NodeMonikerInput ) View () string {
155
+ return fmt .Sprintf ("? Please specify the moniker\n > %s\n " , string (m .TextInput ))
156
+ }
0 commit comments