@semaphore-protocol/cli 0.0.1 → 0.1.0

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.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * @module @semaphore-protocol/cli
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @file A command line tool to set up a Semaphore project and query groups.
7
7
  * @copyright Ethereum Foundation 2022
8
8
  * @license MIT
@@ -30,17 +30,16 @@ program
30
30
  .addHelpCommand("help [command]", "Display help for a specific command.");
31
31
  program
32
32
  .command("get-group")
33
- .description("Get group data from a supported network.")
33
+ .description("Get the data of a group from a supported network.")
34
34
  .argument("<group-id>", "Identifier of the group.")
35
35
  .option("-n, --network <network-name>", "Supported Ethereum network.", "goerli")
36
36
  .option("--members", "Show group members.")
37
37
  .option("--signals", "Show group signals.")
38
- .usage("<group-id> [options]")
39
38
  .action(async (groupId, { network, members, signals }) => {
40
39
  const subgraph = new Subgraph(network);
41
40
  const spinner = ora({
42
41
  text: `Fetching group ${groupId}`,
43
- spinner: "boxBounce"
42
+ indent: 1
44
43
  }).start();
45
44
  const group = await subgraph.getGroup(groupId, { members, verifiedProofs: signals });
46
45
  let content = `\n ${chalk.bold("Id")}: ${group.id}\n`;
@@ -52,15 +51,30 @@ program
52
51
  content += ` Number of leaves: ${group.merkleTree.numberOfLeaves}`;
53
52
  if (members) {
54
53
  content += `\n\n ${chalk.bold("Members")}: \n${group.members
55
- .map((member, i) => ` [${i}] ${member}`)
54
+ .map((member, i) => ` ${i}. ${member}`)
56
55
  .join("\n")}`;
57
56
  }
58
57
  if (signals) {
59
58
  content += `\n\n ${chalk.bold("Signals")}: \n${group.verifiedProofs
60
- .map(({ signal }, i) => ` [${i}] ${signal}`)
59
+ .map(({ signal }) => ` - ${signal}`)
61
60
  .join("\n")}`;
62
61
  }
63
62
  spinner.stop();
64
63
  console.log(`${content}\n`);
65
64
  });
65
+ program
66
+ .command("get-groups")
67
+ .description("Get the list of groups from a supported network.")
68
+ .option("-n, --network <network-name>", "Supported Ethereum network.", "goerli")
69
+ .action(async ({ network }) => {
70
+ const subgraph = new Subgraph(network);
71
+ const spinner = ora({
72
+ text: `Fetching groups`,
73
+ indent: 1
74
+ }).start();
75
+ const groups = await subgraph.getGroups();
76
+ const content = `\n${groups.map(({ id }) => ` - ${id}`).join("\n")}`;
77
+ spinner.stop();
78
+ console.log(`${content}\n`);
79
+ });
66
80
  program.parse();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/cli",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.1.0",
5
5
  "description": "A command line tool to set up a Semaphore project and query groups.",
6
6
  "license": "MIT",
7
7
  "bin": {
package/src/index.ts CHANGED
@@ -21,18 +21,17 @@ program
21
21
 
22
22
  program
23
23
  .command("get-group")
24
- .description("Get group data from a supported network.")
24
+ .description("Get the data of a group from a supported network.")
25
25
  .argument("<group-id>", "Identifier of the group.")
26
26
  .option("-n, --network <network-name>", "Supported Ethereum network.", "goerli")
27
27
  .option("--members", "Show group members.")
28
28
  .option("--signals", "Show group signals.")
29
- .usage("<group-id> [options]")
30
29
  .action(async (groupId, { network, members, signals }) => {
31
30
  const subgraph = new Subgraph(network)
32
31
 
33
32
  const spinner = ora({
34
33
  text: `Fetching group ${groupId}`,
35
- spinner: "boxBounce"
34
+ indent: 1
36
35
  }).start()
37
36
 
38
37
  const group = await subgraph.getGroup(groupId, { members, verifiedProofs: signals })
@@ -47,13 +46,13 @@ program
47
46
 
48
47
  if (members) {
49
48
  content += `\n\n ${chalk.bold("Members")}: \n${group.members
50
- .map((member: string, i: number) => ` [${i}] ${member}`)
49
+ .map((member: string, i: number) => ` ${i}. ${member}`)
51
50
  .join("\n")}`
52
51
  }
53
52
 
54
53
  if (signals) {
55
54
  content += `\n\n ${chalk.bold("Signals")}: \n${group.verifiedProofs
56
- .map(({ signal }: any, i: number) => ` [${i}] ${signal}`)
55
+ .map(({ signal }: any) => ` - ${signal}`)
57
56
  .join("\n")}`
58
57
  }
59
58
 
@@ -62,4 +61,25 @@ program
62
61
  console.log(`${content}\n`)
63
62
  })
64
63
 
64
+ program
65
+ .command("get-groups")
66
+ .description("Get the list of groups from a supported network.")
67
+ .option("-n, --network <network-name>", "Supported Ethereum network.", "goerli")
68
+ .action(async ({ network }) => {
69
+ const subgraph = new Subgraph(network)
70
+
71
+ const spinner = ora({
72
+ text: `Fetching groups`,
73
+ indent: 1
74
+ }).start()
75
+
76
+ const groups = await subgraph.getGroups()
77
+
78
+ const content = `\n${groups.map(({ id }: any) => ` - ${id}`).join("\n")}`
79
+
80
+ spinner.stop()
81
+
82
+ console.log(`${content}\n`)
83
+ })
84
+
65
85
  program.parse()