@super-protocol/sp-cli 0.0.2-beta.9 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +134 -65
  2. package/bin/dev.js +1 -1
  3. package/dist/commands/account/get-sppi.d.ts +8 -0
  4. package/dist/commands/account/get-sppi.js +23 -0
  5. package/dist/commands/account/info.d.ts +1 -0
  6. package/dist/commands/account/info.js +5 -2
  7. package/dist/commands/auth/login.d.ts +4 -1
  8. package/dist/commands/auth/login.js +4 -2
  9. package/dist/commands/config/add.js +1 -16
  10. package/dist/commands/config/base.d.ts +1 -0
  11. package/dist/commands/config/base.js +22 -4
  12. package/dist/commands/config/create.js +1 -11
  13. package/dist/commands/config/list.js +20 -19
  14. package/dist/commands/files/download.js +8 -6
  15. package/dist/commands/files/upload.js +8 -6
  16. package/dist/commands/storage/base.js +3 -1
  17. package/dist/commands/storage/select.d.ts +4 -4
  18. package/dist/commands/storage/select.js +15 -21
  19. package/dist/commands/storage/show.d.ts +17 -0
  20. package/dist/commands/storage/show.js +36 -0
  21. package/dist/commands/workflows/extend-lease.d.ts +17 -0
  22. package/dist/commands/workflows/extend-lease.js +94 -0
  23. package/dist/config/config.schema.d.ts +9 -0
  24. package/dist/config/config.schema.js +5 -0
  25. package/dist/constants.d.ts +3 -0
  26. package/dist/constants.js +3 -0
  27. package/dist/hooks/finally/shutdown-blockchain.d.ts +3 -0
  28. package/dist/hooks/finally/shutdown-blockchain.js +8 -0
  29. package/dist/lib/container.d.ts +1 -0
  30. package/dist/lib/container.js +23 -1
  31. package/dist/managers/account-manager.d.ts +1 -0
  32. package/dist/managers/account-manager.js +17 -13
  33. package/dist/managers/config-file-manager.d.ts +1 -1
  34. package/dist/managers/config-file-manager.js +16 -4
  35. package/dist/services/storage.service.d.ts +3 -1
  36. package/dist/services/storage.service.js +87 -44
  37. package/dist/utils/helper.d.ts +1 -0
  38. package/dist/utils/helper.js +1 -0
  39. package/dist/utils/progress.js +10 -2
  40. package/oclif.manifest.json +190 -151
  41. package/package.json +10 -6
  42. package/dist/config/resource.schema.d.ts +0 -31
  43. package/dist/config/resource.schema.js +0 -14
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @super-protocol/sp-cli
21
21
  $ sp COMMAND
22
22
  running command...
23
23
  $ sp (--version)
24
- @super-protocol/sp-cli/0.0.2-beta.9 linux-x64 node-v22.21.1
24
+ @super-protocol/sp-cli/0.0.3 linux-x64 node-v22.21.1
25
25
  $ sp --help [COMMAND]
26
26
  USAGE
27
27
  $ sp COMMAND
@@ -30,13 +30,13 @@ USAGE
30
30
  <!-- usagestop -->
31
31
  # Commands
32
32
  <!-- commands -->
33
+ * [`sp account get-sppi`](#sp-account-get-sppi)
33
34
  * [`sp account info`](#sp-account-info)
34
35
  * [`sp auth login`](#sp-auth-login)
35
36
  * [`sp auth me`](#sp-auth-me)
36
- * [`sp base`](#sp-base)
37
+ * [`sp autocomplete [SHELL]`](#sp-autocomplete-shell)
37
38
  * [`sp config`](#sp-config)
38
39
  * [`sp config add [FILE]`](#sp-config-add-file)
39
- * [`sp config base`](#sp-config-base)
40
40
  * [`sp config create`](#sp-config-create)
41
41
  * [`sp config delete`](#sp-config-delete)
42
42
  * [`sp config list`](#sp-config-list)
@@ -46,13 +46,37 @@ USAGE
46
46
  * [`sp files upload PATH`](#sp-files-upload-path)
47
47
  * [`sp help [COMMAND]`](#sp-help-command)
48
48
  * [`sp login`](#sp-login)
49
- * [`sp storage base`](#sp-storage-base)
50
49
  * [`sp storage create`](#sp-storage-create)
51
50
  * [`sp storage select`](#sp-storage-select)
51
+ * [`sp storage show`](#sp-storage-show)
52
52
  * [`sp storage update`](#sp-storage-update)
53
+ * [`sp workflows extend-lease ORDERID`](#sp-workflows-extend-lease-orderid)
54
+
55
+ ## `sp account get-sppi`
56
+
57
+ Get SPPI (Super Protocol incentive tokens)
58
+
59
+ ```
60
+ USAGE
61
+ $ sp account get-sppi [--json] [--config <value>]
62
+
63
+ GLOBAL FLAGS
64
+ --config=<value> Specify config file.
65
+ --json Format output as json.
66
+
67
+ DESCRIPTION
68
+ Get SPPI (Super Protocol incentive tokens)
69
+
70
+ EXAMPLES
71
+ $ sp account get-sppi
72
+ ```
73
+
74
+ _See code: [src/commands/account/get-sppi.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/account/get-sppi.ts)_
53
75
 
54
76
  ## `sp account info`
55
77
 
78
+ Information about current authorized user
79
+
56
80
  ```
57
81
  USAGE
58
82
  $ sp account info [--json] [--config <value>]
@@ -60,13 +84,16 @@ USAGE
60
84
  GLOBAL FLAGS
61
85
  --config=<value> Specify config file.
62
86
  --json Format output as json.
87
+
88
+ DESCRIPTION
89
+ Information about current authorized user
63
90
  ```
64
91
 
65
- _See code: [src/commands/account/info.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/account/info.ts)_
92
+ _See code: [src/commands/account/info.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/account/info.ts)_
66
93
 
67
94
  ## `sp auth login`
68
95
 
69
- Authorization
96
+ Login to SuperProtocol (sign up or sign in).
70
97
 
71
98
  ```
72
99
  USAGE
@@ -77,7 +104,7 @@ GLOBAL FLAGS
77
104
  --json Format output as json.
78
105
 
79
106
  DESCRIPTION
80
- Authorization
107
+ Login to SuperProtocol (sign up or sign in).
81
108
 
82
109
  ALIASES
83
110
  $ sp login
@@ -86,7 +113,7 @@ EXAMPLES
86
113
  $ sp auth login
87
114
  ```
88
115
 
89
- _See code: [src/commands/auth/login.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/auth/login.ts)_
116
+ _See code: [src/commands/auth/login.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/auth/login.ts)_
90
117
 
91
118
  ## `sp auth me`
92
119
 
@@ -99,20 +126,38 @@ GLOBAL FLAGS
99
126
  --json Format output as json.
100
127
  ```
101
128
 
102
- _See code: [src/commands/auth/me.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/auth/me.ts)_
129
+ _See code: [src/commands/auth/me.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/auth/me.ts)_
103
130
 
104
- ## `sp base`
131
+ ## `sp autocomplete [SHELL]`
132
+
133
+ Display autocomplete installation instructions.
105
134
 
106
135
  ```
107
136
  USAGE
108
- $ sp base [--json] [--config <value>]
137
+ $ sp autocomplete [SHELL] [-r]
109
138
 
110
- GLOBAL FLAGS
111
- --config=<value> Specify config file.
112
- --json Format output as json.
139
+ ARGUMENTS
140
+ [SHELL] (zsh|bash|powershell) Shell type
141
+
142
+ FLAGS
143
+ -r, --refresh-cache Refresh cache (ignores displaying instructions)
144
+
145
+ DESCRIPTION
146
+ Display autocomplete installation instructions.
147
+
148
+ EXAMPLES
149
+ $ sp autocomplete
150
+
151
+ $ sp autocomplete bash
152
+
153
+ $ sp autocomplete zsh
154
+
155
+ $ sp autocomplete powershell
156
+
157
+ $ sp autocomplete --refresh-cache
113
158
  ```
114
159
 
115
- _See code: [src/commands/base.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/base.ts)_
160
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.39/src/commands/autocomplete/index.ts)_
116
161
 
117
162
  ## `sp config`
118
163
 
@@ -142,7 +187,7 @@ EXAMPLES
142
187
  $ sp config delete - Delete a configuration
143
188
  ```
144
189
 
145
- _See code: [src/commands/config/index.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/index.ts)_
190
+ _See code: [src/commands/config/index.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/index.ts)_
146
191
 
147
192
  ## `sp config add [FILE]`
148
193
 
@@ -181,19 +226,7 @@ EXAMPLES
181
226
  }
182
227
  ```
183
228
 
184
- _See code: [src/commands/config/add.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/add.ts)_
185
-
186
- ## `sp config base`
187
-
188
- ```
189
- USAGE
190
- $ sp config base [--json]
191
-
192
- GLOBAL FLAGS
193
- --json Format output as json.
194
- ```
195
-
196
- _See code: [src/commands/config/base.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/base.ts)_
229
+ _See code: [src/commands/config/add.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/add.ts)_
197
230
 
198
231
  ## `sp config create`
199
232
 
@@ -220,7 +253,7 @@ EXAMPLES
220
253
  $ sp config create --name "Production" --url "https://api.dp.superprotocol.com"
221
254
  ```
222
255
 
223
- _See code: [src/commands/config/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/create.ts)_
256
+ _See code: [src/commands/config/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/create.ts)_
224
257
 
225
258
  ## `sp config delete`
226
259
 
@@ -248,7 +281,7 @@ EXAMPLES
248
281
  $ sp config delete --name "My Config" --force
249
282
  ```
250
283
 
251
- _See code: [src/commands/config/delete.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/delete.ts)_
284
+ _See code: [src/commands/config/delete.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/delete.ts)_
252
285
 
253
286
  ## `sp config list`
254
287
 
@@ -268,7 +301,7 @@ EXAMPLES
268
301
  $ sp config list
269
302
  ```
270
303
 
271
- _See code: [src/commands/config/list.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/list.ts)_
304
+ _See code: [src/commands/config/list.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/list.ts)_
272
305
 
273
306
  ## `sp config show`
274
307
 
@@ -288,7 +321,7 @@ EXAMPLES
288
321
  $ sp config show
289
322
  ```
290
323
 
291
- _See code: [src/commands/config/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/show.ts)_
324
+ _See code: [src/commands/config/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/show.ts)_
292
325
 
293
326
  ## `sp config use`
294
327
 
@@ -308,11 +341,11 @@ EXAMPLES
308
341
  $ sp config use
309
342
  ```
310
343
 
311
- _See code: [src/commands/config/use.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/config/use.ts)_
344
+ _See code: [src/commands/config/use.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/config/use.ts)_
312
345
 
313
346
  ## `sp files download RESOURCEFILE LOCALDIRECTORY`
314
347
 
315
- describe the command here
348
+ Download file or directory described in resource file
316
349
 
317
350
  ```
318
351
  USAGE
@@ -323,24 +356,24 @@ ARGUMENTS
323
356
  LOCALDIRECTORY Path to save downloaded file
324
357
 
325
358
  FLAGS
326
- --maximum-concurrent=<value> [default: 1] Maximum concurrent pieces to upload at once per transfer
359
+ --maximum-concurrent=<value> [default: 1] Maximum concurrent pieces to download at once per transfer
327
360
 
328
361
  GLOBAL FLAGS
329
362
  --config=<value> Specify config file.
330
363
  --json Format output as json.
331
364
 
332
365
  DESCRIPTION
333
- describe the command here
366
+ Download file or directory described in resource file
334
367
 
335
368
  EXAMPLES
336
369
  $ sp files download ./resource.json ./pathToDownload
337
370
  ```
338
371
 
339
- _See code: [src/commands/files/download.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/files/download.ts)_
372
+ _See code: [src/commands/files/download.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/files/download.ts)_
340
373
 
341
374
  ## `sp files upload PATH`
342
375
 
343
- describe the command here
376
+ Upload file or directory to remote storage
344
377
 
345
378
  ```
346
379
  USAGE
@@ -364,13 +397,13 @@ GLOBAL FLAGS
364
397
  --json Format output as json.
365
398
 
366
399
  DESCRIPTION
367
- describe the command here
400
+ Upload file or directory to remote storage
368
401
 
369
402
  EXAMPLES
370
403
  $ sp files upload ./file.txt
371
404
  ```
372
405
 
373
- _See code: [src/commands/files/upload.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/files/upload.ts)_
406
+ _See code: [src/commands/files/upload.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/files/upload.ts)_
374
407
 
375
408
  ## `sp help [COMMAND]`
376
409
 
@@ -390,11 +423,11 @@ DESCRIPTION
390
423
  Display help for sp.
391
424
  ```
392
425
 
393
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.33/src/commands/help.ts)_
426
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
394
427
 
395
428
  ## `sp login`
396
429
 
397
- Authorization
430
+ Login to SuperProtocol (sign up or sign in).
398
431
 
399
432
  ```
400
433
  USAGE
@@ -405,7 +438,7 @@ GLOBAL FLAGS
405
438
  --json Format output as json.
406
439
 
407
440
  DESCRIPTION
408
- Authorization
441
+ Login to SuperProtocol (sign up or sign in).
409
442
 
410
443
  ALIASES
411
444
  $ sp login
@@ -414,19 +447,6 @@ EXAMPLES
414
447
  $ sp login
415
448
  ```
416
449
 
417
- ## `sp storage base`
418
-
419
- ```
420
- USAGE
421
- $ sp storage base [--json] [--config <value>]
422
-
423
- GLOBAL FLAGS
424
- --config=<value> Specify config file.
425
- --json Format output as json.
426
- ```
427
-
428
- _See code: [src/commands/storage/base.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/storage/base.ts)_
429
-
430
450
  ## `sp storage create`
431
451
 
432
452
  Create a new storage entry from file or interactive prompts.
@@ -454,7 +474,7 @@ EXAMPLES
454
474
  $ sp storage create --not-default
455
475
  ```
456
476
 
457
- _See code: [src/commands/storage/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/storage/create.ts)_
477
+ _See code: [src/commands/storage/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/storage/create.ts)_
458
478
 
459
479
  ## `sp storage select`
460
480
 
@@ -462,10 +482,7 @@ Select a storage that will be used by subsequent commands.
462
482
 
463
483
  ```
464
484
  USAGE
465
- $ sp storage select [--json] [--config <value>] [-i <value>]
466
-
467
- FLAGS
468
- -i, --id=<value> Storage ID to select
485
+ $ sp storage select [--json] [--config <value>]
469
486
 
470
487
  GLOBAL FLAGS
471
488
  --config=<value> Specify config file.
@@ -476,11 +493,30 @@ DESCRIPTION
476
493
 
477
494
  EXAMPLES
478
495
  $ sp storage select
496
+ ```
497
+
498
+ _See code: [src/commands/storage/select.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/storage/select.ts)_
499
+
500
+ ## `sp storage show`
501
+
502
+ Show current selected storage
479
503
 
480
- $ sp storage select --id=2de3e3a4-0000-1111-2222-333344445555
481
504
  ```
505
+ USAGE
506
+ $ sp storage show [--json] [--config <value>]
482
507
 
483
- _See code: [src/commands/storage/select.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/storage/select.ts)_
508
+ GLOBAL FLAGS
509
+ --config=<value> Specify config file.
510
+ --json Format output as json.
511
+
512
+ DESCRIPTION
513
+ Show current selected storage
514
+
515
+ EXAMPLES
516
+ $ sp storage show
517
+ ```
518
+
519
+ _See code: [src/commands/storage/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/storage/show.ts)_
484
520
 
485
521
  ## `sp storage update`
486
522
 
@@ -507,5 +543,38 @@ EXAMPLES
507
543
  $ sp storage update --id=2de3e3a4-0000-1111-2222-333344445555
508
544
  ```
509
545
 
510
- _See code: [src/commands/storage/update.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.9/src/commands/storage/update.ts)_
546
+ _See code: [src/commands/storage/update.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/storage/update.ts)_
547
+
548
+ ## `sp workflows extend-lease ORDERID`
549
+
550
+ Replenish deposit for a workflow to extend its lease time
551
+
552
+ ```
553
+ USAGE
554
+ $ sp workflows extend-lease ORDERID [--json] [--config <value>] [--minutes <value>] [--sppi <value>] [-y]
555
+
556
+ ARGUMENTS
557
+ ORDERID Order ID
558
+
559
+ FLAGS
560
+ -y, --yes Skip confirmation prompt
561
+ --minutes=<value> Time to extend order in minutes (automatically calculates tokens)
562
+ --sppi=<value> SPPI token amount to add to the order
563
+
564
+ GLOBAL FLAGS
565
+ --config=<value> Specify config file.
566
+ --json Format output as json.
567
+
568
+ DESCRIPTION
569
+ Replenish deposit for a workflow to extend its lease time
570
+
571
+ EXAMPLES
572
+ $ sp workflows extend-lease <orderId> --sppi 1.5
573
+
574
+ $ sp workflows extend-lease <orderId> --minutes 120
575
+
576
+ $ sp workflows extend-lease <orderId> --sppi 2 --yes
577
+ ```
578
+
579
+ _See code: [src/commands/workflows/extend-lease.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.3/src/commands/workflows/extend-lease.ts)_
511
580
  <!-- commandsstop -->
package/bin/dev.js CHANGED
@@ -2,6 +2,6 @@
2
2
  import { execute } from '@oclif/core';
3
3
 
4
4
  await execute({
5
- development: true,
5
+ development: Boolean(process.env.SP_LOG_LEVEL),
6
6
  dir: import.meta.url,
7
7
  });
@@ -0,0 +1,8 @@
1
+ import { BaseCommand } from '../base.js';
2
+ export default class AccountGetSppi extends BaseCommand<typeof AccountGetSppi> {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<{
6
+ tokens: string;
7
+ }>;
8
+ }
@@ -0,0 +1,23 @@
1
+ import { formatEther } from 'viem';
2
+ import { BaseCommand } from '../base.js';
3
+ export default class AccountGetSppi extends BaseCommand {
4
+ static description = 'Get SPPI (Super Protocol incentive tokens) ';
5
+ static examples = [
6
+ '<%= config.bin %> <%= command.id %>',
7
+ ];
8
+ async run() {
9
+ const { providerClient } = await this.container
10
+ .initConfigFileManager()
11
+ .initConfigManager()
12
+ .initAccountManager()
13
+ .initProviderClient()
14
+ .build();
15
+ const { data, error } = await providerClient.POST('/api/faucet/request-tokens');
16
+ if (error) {
17
+ this.error(`Request tokens failed. Reason ${error.message}`);
18
+ }
19
+ const tokens = formatEther(BigInt(data.amount || '0'));
20
+ this.log(`Requested tokens: ${tokens} SPPI`);
21
+ return { tokens };
22
+ }
23
+ }
@@ -1,5 +1,6 @@
1
1
  import { BaseCommand } from '../base.js';
2
2
  export declare class InfoCommand extends BaseCommand<typeof InfoCommand> {
3
+ static description: string;
3
4
  init(): Promise<void>;
4
5
  run(): Promise<{
5
6
  address: string;
@@ -2,6 +2,7 @@ import { formatEther } from 'viem';
2
2
  import { StorageService } from '../../services/storage.service.js';
3
3
  import { BaseCommand } from '../base.js';
4
4
  export class InfoCommand extends BaseCommand {
5
+ static description = 'Information about current authorized user';
5
6
  async init() {
6
7
  await super.init();
7
8
  await this.container.initProviderClient().initAccountManager().initConfigManager().build();
@@ -21,7 +22,7 @@ export class InfoCommand extends BaseCommand {
21
22
  this.error('Failed to retrieve wallet information');
22
23
  }
23
24
  const storage = await storageService.getCurrentStorage();
24
- const balance = formatEther(BigInt(wallet?.teeBalance || '0'), 'wei');
25
+ const balance = formatEther(BigInt(wallet?.teeBalance || '0'));
25
26
  this.log(`Login: ${data.address}`);
26
27
  this.log(`Super Wallet: ${data.internalAddress}`);
27
28
  this.log(`Balance: ${balance} SPPI`);
@@ -31,7 +32,9 @@ export class InfoCommand extends BaseCommand {
31
32
  else {
32
33
  this.log('Active storage:');
33
34
  this.log(` bucket: ${storage.bucket}`);
34
- this.log(` prefix: ${storage.prefix}`);
35
+ if (storage.prefix) {
36
+ this.log(` prefix: ${storage.prefix}`);
37
+ }
35
38
  }
36
39
  return {
37
40
  address: data.address,
@@ -5,5 +5,8 @@ export default class SpLogin extends BaseCommand<typeof SpLogin> {
5
5
  static examples: string[];
6
6
  checkStorage(): Promise<void>;
7
7
  init(): Promise<void>;
8
- run(): Promise<void>;
8
+ run(): Promise<{
9
+ account: string;
10
+ success: boolean;
11
+ }>;
9
12
  }
@@ -3,7 +3,7 @@ import { StorageService } from '../../services/storage.service.js';
3
3
  import { BaseCommand } from '../base.js';
4
4
  export default class SpLogin extends BaseCommand {
5
5
  static aliases = ['login'];
6
- static description = 'Authorization';
6
+ static description = 'Login to SuperProtocol (sign up or sign in).';
7
7
  static examples = [
8
8
  `<%= config.bin %> <%= command.id %>
9
9
  `,
@@ -43,6 +43,8 @@ export default class SpLogin extends BaseCommand {
43
43
  this.logger.error({ err: error }, 'Storage initialization failed');
44
44
  this.warn('Storage initialization failed. You can set up storage later using "sp storage create" or "sp storage select".');
45
45
  }
46
- this.log('Successfully authorized');
46
+ const account = accountManager.getAddress();
47
+ this.log(`Logged in with account ${account}`);
48
+ return { account, success: true };
47
49
  }
48
50
  }
@@ -64,22 +64,7 @@ export default class ConfigAdd extends BaseConfigCommand {
64
64
  const displayName = importedConfig?.name || importedFileName;
65
65
  this.log(`Successfully imported configuration: ${displayName}`);
66
66
  this.log(`Configuration file: ${importedFileName}`);
67
- const shouldSwitch = this.flags.yes || await this.selectPrompt({
68
- message: 'Switch to this configuration now?',
69
- options: [
70
- { label: 'Yes', value: true },
71
- { label: 'No', value: false },
72
- ],
73
- });
74
- if (shouldSwitch) {
75
- await this.configFileManager.setCurrentConfig(importedFileName);
76
- this.log(`Switched to configuration: ${displayName}`);
77
- await this.container
78
- .initConfigFileManager(true)
79
- .initConfigManager(true)
80
- .initAccountManager(true)
81
- .build();
82
- }
67
+ await this.switchToNewConfig(importedFileName, displayName, this.flags.yes);
83
68
  }
84
69
  catch (error) {
85
70
  this.error(`Failed to import configuration: ${error instanceof Error ? error.message : String(error)}`);
@@ -11,5 +11,6 @@ export declare abstract class BaseConfigCommand<T extends typeof Command> extend
11
11
  init(): Promise<void>;
12
12
  protected inputPrompt(options: TextOptions): Promise<string>;
13
13
  protected selectPrompt<Value>(options: SelectOptions<Value>): Promise<Value>;
14
+ protected switchToNewConfig(configFile: string, displayName: string, yes: boolean): Promise<void>;
14
15
  }
15
16
  export {};
@@ -25,16 +25,16 @@ export class BaseConfigCommand extends BaseCommand {
25
25
  this.log(` Provider URL: ${PROVIDER_URL} (using default)`);
26
26
  }
27
27
  if (configData.auth?.accessKey) {
28
- this.log(' Authorization: [OK] Configured');
28
+ this.log(' Authorization: Configured');
29
29
  }
30
30
  else {
31
- this.log(' Authorization: [--] Not configured');
31
+ this.log(' Authorization: Unauthorized');
32
32
  }
33
33
  if (configData.account?.address) {
34
- this.log(` Account: [OK] ${configData.account.address}`);
34
+ this.log(` Account: ${configData.account.address}`);
35
35
  }
36
36
  else {
37
- this.log(' Account: [--] Not configured');
37
+ this.log(' Account: Not configured');
38
38
  }
39
39
  }
40
40
  }
@@ -57,4 +57,22 @@ export class BaseConfigCommand extends BaseCommand {
57
57
  const result = await select(options);
58
58
  return this.ensurePromptValue(result);
59
59
  }
60
+ async switchToNewConfig(configFile, displayName, yes) {
61
+ const shouldSwitch = yes || await this.selectPrompt({
62
+ message: 'Switch to this configuration now?',
63
+ options: [
64
+ { label: 'Yes', value: true },
65
+ { label: 'No', value: false },
66
+ ],
67
+ });
68
+ if (shouldSwitch) {
69
+ await this.configFileManager.setCurrentConfig(configFile);
70
+ this.log(`Switched to configuration: ${displayName}`);
71
+ await this.container
72
+ .initConfigFileManager(true)
73
+ .initConfigManager(true)
74
+ .initAccountManager(true)
75
+ .build();
76
+ }
77
+ }
60
78
  }
@@ -32,17 +32,7 @@ export default class ConfigCreate extends BaseConfigCommand {
32
32
  if (url) {
33
33
  this.log(`Provider URL: ${url}`);
34
34
  }
35
- const shouldSwitch = yes || await this.selectPrompt({
36
- message: 'Switch to this configuration now?',
37
- options: [
38
- { label: 'Yes', value: true },
39
- { label: 'No', value: false },
40
- ],
41
- });
42
- if (shouldSwitch) {
43
- await this.configFileManager.setCurrentConfig(fileName);
44
- this.log(`Switched to configuration: ${name}`);
45
- }
35
+ await this.switchToNewConfig(fileName, name, yes);
46
36
  }
47
37
  catch (error) {
48
38
  this.error(`Failed to create configuration: ${error instanceof Error ? error.message : String(error)}`);
@@ -1,3 +1,5 @@
1
+ import { printTable } from 'console-table-printer';
2
+ import { PROVIDER_URL } from '../../constants.js';
1
3
  import { BaseConfigCommand } from './base.js';
2
4
  export default class ConfigList extends BaseConfigCommand {
3
5
  static description = 'List all configurations';
@@ -12,28 +14,27 @@ export default class ConfigList extends BaseConfigCommand {
12
14
  this.log('Create a new configuration with: sp config create --name "Config Name"');
13
15
  return;
14
16
  }
15
- this.log('Available configurations:\n');
17
+ const rows = [];
16
18
  for (const config of configs) {
17
19
  const marker = config.file === current ? '* ' : ' ';
18
20
  const configData = this.configFileManager.getConfigData(config.file);
19
- let statusInfo = '';
20
- if (configData) {
21
- const parts = [];
22
- if (configData.providerUrl) {
23
- parts.push(`URL: ${configData.providerUrl}`);
24
- }
25
- if (configData.auth) {
26
- parts.push('Auth: [OK]');
27
- }
28
- if (configData.account) {
29
- parts.push(`Account: [OK] ${configData.account.address} `);
30
- }
31
- if (parts.length > 0) {
32
- statusInfo = ` | ${parts.join(', ')}`;
33
- }
34
- }
35
- this.log(`${marker}${config.name}${statusInfo}`);
36
- this.log(` File: ${config.file}`);
21
+ const row = {
22
+ account: configData?.account?.address ?? '[not found in config file]',
23
+ current: marker,
24
+ file: config.file,
25
+ name: config.name,
26
+ url: configData?.providerUrl ?? PROVIDER_URL,
27
+ };
28
+ rows.push(row);
37
29
  }
30
+ printTable(rows, {
31
+ columns: [
32
+ { name: 'current', title: 'Current' },
33
+ { name: 'name', title: 'Config name' },
34
+ { name: 'account', title: 'Account' },
35
+ { name: 'url', title: 'Provider Url' },
36
+ { name: 'file', title: 'Configuration File' },
37
+ ], title: 'Available configurations',
38
+ });
38
39
  }
39
40
  }