Skip to content

Commit f5b22a8

Browse files
authored
adding a little cli to quickly convert space names to dids (#611)
1 parent d2c2e1d commit f5b22a8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

cli/deno.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"google-importer": "deno run --allow-read --allow-env --allow-net google-importer.ts",
55
"memorydemo": "deno run --allow-read --allow-env --allow-net memory_demo.ts",
66
"test": "deno test",
7-
"charmdemo": "deno run --allow-read --allow-env --allow-net charm_demo.ts"
7+
"charmdemo": "deno run --allow-read --allow-env --allow-net charm_demo.ts",
8+
"name2did": "deno run -A name2did.ts"
89
},
910
"imports": {
1011
"open": "https://deno.land/x/open@v0.0.6/index.ts"

cli/name2did.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Identity } from "@commontools/identity";
2+
3+
const OPERATOR_PASS = Deno.env.get("OPERATOR_PASS") ?? "implicit trust";
4+
5+
export const name2did = async (name: string) => {
6+
const account = await Identity.fromPassphrase(OPERATOR_PASS);
7+
const space = await account.derive(name);
8+
console.log(" NAME:", name);
9+
console.log("SPACE:", space.did());
10+
};
11+
12+
const args = Deno.args;
13+
14+
if (args.length < 1) {
15+
console.error("Error: Please provide a name argument.");
16+
console.log("Usage: deno task name2did <name>");
17+
Deno.exit(1);
18+
}
19+
20+
await name2did(args[0]);
21+
Deno.exit(0);

0 commit comments

Comments
 (0)