@@ -8,6 +8,7 @@ import pacote from "pacote"
8
8
import { dirname } from "path"
9
9
import { fileURLToPath } from "url"
10
10
import checkLatestVersion from "./checkLatestVersion.js"
11
+ import getGroupIds from "./getGroupIds.js"
11
12
import { getGroupId , getProjectName , getSupportedNetwork } from "./inquirerPrompts.js"
12
13
import Spinner from "./spinner.js"
13
14
@@ -95,37 +96,9 @@ program
95
96
return
96
97
}
97
98
98
- let groupIds : string [ ]
99
+ const groupIds = await getGroupIds ( network )
99
100
100
- const spinner = new Spinner ( "Fetching groups" )
101
-
102
- spinner . start ( )
103
-
104
- try {
105
- const semaphoreSubgraph = new SemaphoreSubgraph ( network )
106
-
107
- groupIds = await semaphoreSubgraph . getGroupIds ( )
108
-
109
- spinner . stop ( )
110
- } catch {
111
- try {
112
- const semaphoreEthers = new SemaphoreEthers ( network )
113
-
114
- groupIds = await semaphoreEthers . getGroupIds ( )
115
-
116
- spinner . stop ( )
117
- } catch {
118
- spinner . stop ( )
119
-
120
- console . info ( `\n ${ logSymbols . error } ` , "error: unexpected error with the SemaphoreEthers package" )
121
-
122
- return
123
- }
124
- }
125
- if ( groupIds . length === 0 ) {
126
- console . info ( `\n ${ logSymbols . info } ` , "info: there are no groups in this network\n" )
127
- return
128
- }
101
+ if ( groupIds === null ) return
129
102
130
103
const content = `\n${ groupIds . map ( ( id : any ) => ` - ${ id } ` ) . join ( "\n" ) } `
131
104
@@ -149,38 +122,9 @@ program
149
122
}
150
123
151
124
if ( ! groupId ) {
152
- let groupIds : string [ ]
153
-
154
- const spinnerGroups = new Spinner ( "Fetching groups" )
155
-
156
- spinnerGroups . start ( )
157
-
158
- try {
159
- const semaphoreSubgraphGroups = new SemaphoreSubgraph ( network )
160
-
161
- groupIds = await semaphoreSubgraphGroups . getGroupIds ( )
162
-
163
- spinnerGroups . stop ( )
164
- } catch {
165
- try {
166
- const semaphoreEthersGroups = new SemaphoreEthers ( network )
167
-
168
- groupIds = await semaphoreEthersGroups . getGroupIds ( )
125
+ const groupIds = await getGroupIds ( network )
169
126
170
- spinnerGroups . stop ( )
171
- } catch {
172
- spinnerGroups . stop ( )
173
-
174
- console . info ( `\n ${ logSymbols . error } ` , "error: unexpected error with the SemaphoreEthers package" )
175
-
176
- return
177
- }
178
- }
179
-
180
- if ( groupIds . length === 0 ) {
181
- console . info ( `\n ${ logSymbols . info } ` , "info: there are no groups in this network\n" )
182
- return
183
- }
127
+ if ( groupIds === null ) return
184
128
185
129
groupId = await getGroupId ( groupIds )
186
130
}
@@ -241,36 +185,9 @@ program
241
185
}
242
186
243
187
if ( ! groupId ) {
244
- let groupIds : string [ ]
245
-
246
- const spinnerGroups = new Spinner ( "Fetching groups" )
247
-
248
- spinnerGroups . start ( )
249
-
250
- try {
251
- const semaphoreSubgraphGroups = new SemaphoreSubgraph ( network )
252
-
253
- groupIds = await semaphoreSubgraphGroups . getGroupIds ( )
254
-
255
- spinnerGroups . stop ( )
256
- } catch {
257
- try {
258
- const semaphoreEthersGroups = new SemaphoreEthers ( network )
259
-
260
- groupIds = await semaphoreEthersGroups . getGroupIds ( )
261
-
262
- spinnerGroups . stop ( )
263
- } catch {
264
- spinnerGroups . stop ( )
265
- console . info ( `\n ${ logSymbols . error } ` , "error: unexpected error with the SemaphoreEthers package" )
266
- return
267
- }
268
- }
188
+ const groupIds = await getGroupIds ( network )
269
189
270
- if ( groupIds . length === 0 ) {
271
- console . info ( `\n ${ logSymbols . info } ` , "info: there are no groups in this network\n" )
272
- return
273
- }
190
+ if ( groupIds === null ) return
274
191
275
192
groupId = await getGroupId ( groupIds )
276
193
}
@@ -332,36 +249,9 @@ program
332
249
}
333
250
334
251
if ( ! groupId ) {
335
- let groupIds : string [ ]
336
-
337
- const spinnerGroups = new Spinner ( "Fetching groups" )
338
-
339
- spinnerGroups . start ( )
340
-
341
- try {
342
- const semaphoreSubgraphGroups = new SemaphoreSubgraph ( network )
343
-
344
- groupIds = await semaphoreSubgraphGroups . getGroupIds ( )
252
+ const groupIds = await getGroupIds ( network )
345
253
346
- spinnerGroups . stop ( )
347
- } catch {
348
- try {
349
- const semaphoreEthersGroups = new SemaphoreEthers ( network )
350
-
351
- groupIds = await semaphoreEthersGroups . getGroupIds ( )
352
-
353
- spinnerGroups . stop ( )
354
- } catch {
355
- spinnerGroups . stop ( )
356
- console . info ( `\n ${ logSymbols . error } ` , "error: unexpected error with the SemaphoreEthers package" )
357
- return
358
- }
359
- }
360
-
361
- if ( groupIds . length === 0 ) {
362
- console . info ( `\n ${ logSymbols . info } ` , "info: there are no groups in this network\n" )
363
- return
364
- }
254
+ if ( groupIds === null ) return
365
255
366
256
groupId = await getGroupId ( groupIds )
367
257
}
0 commit comments