@semaphore-protocol/cli 3.15.1 → 4.0.0-alpha
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/LICENSE +1 -1
- package/README.md +4 -4
- package/dist/index.js +15 -16
- package/package.json +3 -3
- package/src/index.ts +17 -16
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -76,9 +76,9 @@ Options:
|
|
|
76
76
|
|
|
77
77
|
Commands:
|
|
78
78
|
create [options] [project-directory] Create a Semaphore project with a supported template.
|
|
79
|
-
get-groups [options] Get the list of groups from a supported network (e.g.
|
|
80
|
-
get-group [options] [group-id] Get the data of a group from a supported network (e.g.
|
|
81
|
-
get-members [options] [group-id] Get the members of a group from a supported network (e.g.
|
|
82
|
-
get-proofs [options] [group-id] Get the proofs of a group from a supported network (e.g.
|
|
79
|
+
get-groups [options] Get the list of groups from a supported network (e.g. sepolia or arbitrum).
|
|
80
|
+
get-group [options] [group-id] Get the data of a group from a supported network (e.g. sepolia or arbitrum).
|
|
81
|
+
get-members [options] [group-id] Get the members of a group from a supported network (e.g. sepolia or arbitrum).
|
|
82
|
+
get-proofs [options] [group-id] Get the proofs of a group from a supported network (e.g. sepolia or arbitrum).
|
|
83
83
|
help [command] Display help for a specific command.
|
|
84
84
|
```
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @module @semaphore-protocol/cli
|
|
5
|
-
* @version
|
|
5
|
+
* @version 4.0.0-alpha
|
|
6
6
|
* @file A command line tool to set up your Semaphore project and get group data.
|
|
7
|
-
* @copyright Ethereum Foundation
|
|
7
|
+
* @copyright Ethereum Foundation 2024
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli}
|
|
10
10
|
*/
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
import { SemaphoreSubgraph, SemaphoreEthers, getSupportedNetworks } from '@semaphore-protocol/data';
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import { program } from 'commander';
|
|
15
|
+
import decompress from 'decompress';
|
|
15
16
|
import figlet from 'figlet';
|
|
16
17
|
import { readFileSync, existsSync, unlinkSync, copyFileSync } from 'fs';
|
|
17
18
|
import logSymbols from 'log-symbols';
|
|
18
19
|
import pacote from 'pacote';
|
|
19
|
-
import decompress from 'decompress';
|
|
20
20
|
import { dirname } from 'path';
|
|
21
21
|
import { fileURLToPath } from 'url';
|
|
22
22
|
import axios from 'axios';
|
|
@@ -221,7 +221,7 @@ program
|
|
|
221
221
|
});
|
|
222
222
|
program
|
|
223
223
|
.command("get-groups")
|
|
224
|
-
.description("Get the list of groups from a supported network (e.g.
|
|
224
|
+
.description("Get the list of groups from a supported network (e.g. sepolia or arbitrum).")
|
|
225
225
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
226
226
|
.allowExcessArguments(false)
|
|
227
227
|
.action(async ({ network }) => {
|
|
@@ -244,7 +244,7 @@ program
|
|
|
244
244
|
});
|
|
245
245
|
program
|
|
246
246
|
.command("get-group")
|
|
247
|
-
.description("Get the data of a group from a supported network (e.g.
|
|
247
|
+
.description("Get the data of a group from a supported network (e.g. sepolia or arbitrum).")
|
|
248
248
|
.argument("[group-id]", "Identifier of the group.")
|
|
249
249
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
250
250
|
.allowExcessArguments(false)
|
|
@@ -294,13 +294,12 @@ program
|
|
|
294
294
|
content += ` ${chalk.bold("Merkle tree")}:\n`;
|
|
295
295
|
content += ` Root: ${group.merkleTree.root}\n`;
|
|
296
296
|
content += ` Depth: ${group.merkleTree.depth}\n`;
|
|
297
|
-
content += `
|
|
298
|
-
content += ` Number of leaves: ${group.merkleTree.numberOfLeaves}`;
|
|
297
|
+
content += ` Size: ${group.merkleTree.size}`;
|
|
299
298
|
console.info(`\n${content}\n`);
|
|
300
299
|
});
|
|
301
300
|
program
|
|
302
301
|
.command("get-members")
|
|
303
|
-
.description("Get the members of a group from a supported network (e.g.
|
|
302
|
+
.description("Get the members of a group from a supported network (e.g. sepolia or arbitrum).")
|
|
304
303
|
.argument("[group-id]", "Identifier of the group.")
|
|
305
304
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
306
305
|
.allowExcessArguments(false)
|
|
@@ -352,7 +351,7 @@ program
|
|
|
352
351
|
});
|
|
353
352
|
program
|
|
354
353
|
.command("get-proofs")
|
|
355
|
-
.description("Get the proofs of a group from a supported network (e.g.
|
|
354
|
+
.description("Get the proofs of a group from a supported network (e.g. sepolia or arbitrum).")
|
|
356
355
|
.argument("[group-id]", "Identifier of the group.")
|
|
357
356
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
358
357
|
.allowExcessArguments(false)
|
|
@@ -372,19 +371,19 @@ program
|
|
|
372
371
|
}
|
|
373
372
|
groupId = await getGroupId(groupIds);
|
|
374
373
|
}
|
|
375
|
-
let
|
|
374
|
+
let validatedProofs;
|
|
376
375
|
const spinner = new Spinner(`Fetching proofs of group ${groupId}`);
|
|
377
376
|
spinner.start();
|
|
378
377
|
try {
|
|
379
378
|
const semaphoreSubgraph = new SemaphoreSubgraph(network);
|
|
380
|
-
const group = await semaphoreSubgraph.getGroup(groupId, {
|
|
381
|
-
|
|
379
|
+
const group = await semaphoreSubgraph.getGroup(groupId, { validatedProofs: true });
|
|
380
|
+
validatedProofs = group.validatedProofs;
|
|
382
381
|
spinner.stop();
|
|
383
382
|
}
|
|
384
383
|
catch {
|
|
385
384
|
try {
|
|
386
385
|
const semaphoreEthers = new SemaphoreEthers(network);
|
|
387
|
-
|
|
386
|
+
validatedProofs = await semaphoreEthers.getGroupValidatedProofs(groupId);
|
|
388
387
|
spinner.stop();
|
|
389
388
|
}
|
|
390
389
|
catch {
|
|
@@ -393,12 +392,12 @@ program
|
|
|
393
392
|
return;
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
|
-
if (
|
|
395
|
+
if (validatedProofs.length === 0) {
|
|
397
396
|
console.info(`\n ${logSymbols.info}`, "info: there are no proofs in this group\n");
|
|
398
397
|
return;
|
|
399
398
|
}
|
|
400
|
-
const content = `${chalk.bold("Proofs")} (${
|
|
401
|
-
.map(({
|
|
399
|
+
const content = `${chalk.bold("Proofs")} (${validatedProofs.length}): \n${validatedProofs
|
|
400
|
+
.map(({ message, merkleTreeRoot, merkleTreeDepth, scope, nullifier, proof }, i) => ` ${i}. message: ${message} \n merkleTreeRoot: ${merkleTreeRoot} \n merkleTreeDepth: ${merkleTreeDepth} \n scope: ${scope} \n nullifier: ${nullifier} \n proof: [${proof.join(", ")}]`)
|
|
402
401
|
.join("\n")}`;
|
|
403
402
|
console.info(`\n${content}\n`);
|
|
404
403
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semaphore-protocol/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-alpha",
|
|
5
5
|
"description": "A command line tool to set up your Semaphore project and get group data.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": ">=14.16"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"start": "ts-node --
|
|
26
|
+
"start": "node --loader ts-node/esm --no-warnings src/index.ts",
|
|
27
27
|
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
|
|
28
28
|
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
|
29
29
|
"prepublishOnly": "yarn build"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ts-node": "^10.9.1"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@semaphore-protocol/data": "
|
|
45
|
+
"@semaphore-protocol/data": "4.0.0-alpha",
|
|
46
46
|
"axios": "^1.3.2",
|
|
47
47
|
"boxen": "^7.0.1",
|
|
48
48
|
"chalk": "^5.1.2",
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { GroupResponse, SemaphoreEthers, SemaphoreSubgraph, getSupportedNetworks } from "@semaphore-protocol/data"
|
|
2
2
|
import chalk from "chalk"
|
|
3
3
|
import { program } from "commander"
|
|
4
|
+
import decompress from "decompress"
|
|
4
5
|
import figlet from "figlet"
|
|
5
|
-
import { existsSync, readFileSync, unlinkSync
|
|
6
|
+
import { copyFileSync, existsSync, readFileSync, unlinkSync } from "fs"
|
|
6
7
|
import logSymbols from "log-symbols"
|
|
7
8
|
import pacote from "pacote"
|
|
8
|
-
import decompress from "decompress"
|
|
9
9
|
import { dirname } from "path"
|
|
10
10
|
import { fileURLToPath } from "url"
|
|
11
11
|
import checkLatestVersion from "./checkLatestVersion.js"
|
|
@@ -117,7 +117,7 @@ program
|
|
|
117
117
|
|
|
118
118
|
program
|
|
119
119
|
.command("get-groups")
|
|
120
|
-
.description("Get the list of groups from a supported network (e.g.
|
|
120
|
+
.description("Get the list of groups from a supported network (e.g. sepolia or arbitrum).")
|
|
121
121
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
122
122
|
.allowExcessArguments(false)
|
|
123
123
|
.action(async ({ network }) => {
|
|
@@ -146,7 +146,7 @@ program
|
|
|
146
146
|
|
|
147
147
|
program
|
|
148
148
|
.command("get-group")
|
|
149
|
-
.description("Get the data of a group from a supported network (e.g.
|
|
149
|
+
.description("Get the data of a group from a supported network (e.g. sepolia or arbitrum).")
|
|
150
150
|
.argument("[group-id]", "Identifier of the group.")
|
|
151
151
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
152
152
|
.allowExcessArguments(false)
|
|
@@ -209,15 +209,14 @@ program
|
|
|
209
209
|
content += ` ${chalk.bold("Merkle tree")}:\n`
|
|
210
210
|
content += ` Root: ${group.merkleTree.root}\n`
|
|
211
211
|
content += ` Depth: ${group.merkleTree.depth}\n`
|
|
212
|
-
content += `
|
|
213
|
-
content += ` Number of leaves: ${group.merkleTree.numberOfLeaves}`
|
|
212
|
+
content += ` Size: ${group.merkleTree.size}`
|
|
214
213
|
|
|
215
214
|
console.info(`\n${content}\n`)
|
|
216
215
|
})
|
|
217
216
|
|
|
218
217
|
program
|
|
219
218
|
.command("get-members")
|
|
220
|
-
.description("Get the members of a group from a supported network (e.g.
|
|
219
|
+
.description("Get the members of a group from a supported network (e.g. sepolia or arbitrum).")
|
|
221
220
|
.argument("[group-id]", "Identifier of the group.")
|
|
222
221
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
223
222
|
.allowExcessArguments(false)
|
|
@@ -283,7 +282,7 @@ program
|
|
|
283
282
|
|
|
284
283
|
program
|
|
285
284
|
.command("get-proofs")
|
|
286
|
-
.description("Get the proofs of a group from a supported network (e.g.
|
|
285
|
+
.description("Get the proofs of a group from a supported network (e.g. sepolia or arbitrum).")
|
|
287
286
|
.argument("[group-id]", "Identifier of the group.")
|
|
288
287
|
.option("-n, --network <network-name>", "Supported Ethereum network.")
|
|
289
288
|
.allowExcessArguments(false)
|
|
@@ -308,7 +307,7 @@ program
|
|
|
308
307
|
groupId = await getGroupId(groupIds)
|
|
309
308
|
}
|
|
310
309
|
|
|
311
|
-
let
|
|
310
|
+
let validatedProofs: any[]
|
|
312
311
|
|
|
313
312
|
const spinner = new Spinner(`Fetching proofs of group ${groupId}`)
|
|
314
313
|
|
|
@@ -317,15 +316,15 @@ program
|
|
|
317
316
|
try {
|
|
318
317
|
const semaphoreSubgraph = new SemaphoreSubgraph(network)
|
|
319
318
|
|
|
320
|
-
const group = await semaphoreSubgraph.getGroup(groupId, {
|
|
321
|
-
|
|
319
|
+
const group = await semaphoreSubgraph.getGroup(groupId, { validatedProofs: true })
|
|
320
|
+
validatedProofs = group.validatedProofs
|
|
322
321
|
|
|
323
322
|
spinner.stop()
|
|
324
323
|
} catch {
|
|
325
324
|
try {
|
|
326
325
|
const semaphoreEthers = new SemaphoreEthers(network)
|
|
327
326
|
|
|
328
|
-
|
|
327
|
+
validatedProofs = await semaphoreEthers.getGroupValidatedProofs(groupId)
|
|
329
328
|
|
|
330
329
|
spinner.stop()
|
|
331
330
|
} catch {
|
|
@@ -335,15 +334,17 @@ program
|
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
336
|
|
|
338
|
-
if (
|
|
337
|
+
if (validatedProofs.length === 0) {
|
|
339
338
|
console.info(`\n ${logSymbols.info}`, "info: there are no proofs in this group\n")
|
|
340
339
|
return
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
const content = `${chalk.bold("Proofs")} (${
|
|
342
|
+
const content = `${chalk.bold("Proofs")} (${validatedProofs.length}): \n${validatedProofs
|
|
344
343
|
.map(
|
|
345
|
-
({
|
|
346
|
-
` ${i}.
|
|
344
|
+
({ message, merkleTreeRoot, merkleTreeDepth, scope, nullifier, proof }: any, i: number) =>
|
|
345
|
+
` ${i}. message: ${message} \n merkleTreeRoot: ${merkleTreeRoot} \n merkleTreeDepth: ${merkleTreeDepth} \n scope: ${scope} \n nullifier: ${nullifier} \n proof: [${proof.join(
|
|
346
|
+
", "
|
|
347
|
+
)}]`
|
|
347
348
|
)
|
|
348
349
|
.join("\n")}`
|
|
349
350
|
|