@zerc20/cli 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,41 @@
1
- # Temporary Holding Version
1
+ # @zerc20/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A zERC20 account in a terminal: `zerc20` watches an account by its view key, pays from one by its recovery phrase, and
4
+ runs a merge prover on your own machine.
5
+
6
+ ```sh
7
+ npm install -g @zerc20/cli
8
+
9
+ export ZERC20_KEY='zerc20view1…' # a view key to look, or the 24-word recovery phrase to pay
10
+ zerc20 balance
11
+ zerc20 history --csv
12
+ zerc20 send 10 USDC zerc20id1…
13
+ zerc20 prover start # then: zerc20 merge USDC --prover local
14
+ zerc20 install-skill # teaches the coding agents on this machine to use it
15
+ ```
16
+
17
+ `zerc20 --help` lists every command; [docs.zerc20.io](https://docs.zerc20.io/developers/cli) says more.
18
+
19
+ ## Why it looks like this
20
+
21
+ - **One key, never an argument.** A view key and a recovery phrase look nothing alike, so a command takes either and
22
+ does what that key can. It comes from a file, the environment, standard input or a prompt that shows nothing: a
23
+ shell's history and the process list keep arguments.
24
+ - **Nothing secret stays.** The key is never written. What is kept is the account's synced state, which the SDK seals
25
+ under a key of the key's, so that the next command reads only what is new.
26
+ - **A command is a process.** State on disk is all two commands share, and a lock file keeps a second one off an
27
+ account the first has open.
28
+ - **Nothing is paid unasked.** A payment shows its fee and waits for a yes; with no terminal to ask on, only `--yes`
29
+ pays. An operation an earlier command left under way is named before a sync moves it on.
30
+ - **The skill ships with the release.** What an agent must not get wrong (the key, the yes, a payment under way) is
31
+ written beside the code it describes, and installed from it, so the two do not drift apart.
32
+ - **An old release says so.** Once a day a command asks npm for the newest release and names it, or says that this
33
+ one is withdrawn. The answer is only shown: nothing is installed unasked, and no command trusts it.
34
+ - **The networks ship with the release.** Their settings pin the enclaves a wallet seals its witnesses to, so they
35
+ come from the reviewed source, not from a server at run time.
36
+ - **The merge prover is the node's own binary,** a package per machine that npm picks. Run here, it serves this
37
+ machine only: the SDK takes a prover without an enclave at a loopback address alone.
38
+
39
+ ## License
40
+
41
+ [AGPL-3.0](LICENSE). The merge prover's packages are under the nodes' Business Source License.
@@ -0,0 +1,177 @@
1
+ // The account a command works on: its key, taken from anywhere but the arguments and never written down, and its
2
+ // wallet over a state file that only the key opens.
3
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { text } from 'node:stream/consumers';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { mnemonicToEntropy, validateMnemonic } from '@scure/bip39';
8
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
9
+ import { CanisterClient } from '@zerc20/storage-sdk';
10
+ import { Wallet, accountId, accountKey, networkFromJson, viewKeyAccount } from '@zerc20/wallet-sdk';
11
+ import { hexToBytes } from 'viem';
12
+ import { privateKeyToAccount } from 'viem/accounts';
13
+ import { Failure, Usage } from './errors.js';
14
+ import { home, localCircuit } from './files.js';
15
+ export const seedKey = (seed) => ({
16
+ kind: 'seed',
17
+ seed,
18
+ address: privateKeyToAccount(accountKey(seed)).address,
19
+ });
20
+ /** The key `input` is: the two look nothing alike, so a command takes either without being told which. */
21
+ export function parseKey(input) {
22
+ const t = input.trim();
23
+ const watched = viewKeyAccount(t);
24
+ if (watched)
25
+ return { kind: 'view', viewKey: t, address: watched };
26
+ const phrase = t.toLowerCase().split(/\s+/).join(' ');
27
+ if (phrase.split(' ').length === 24 && validateMnemonic(phrase, wordlist))
28
+ return seedKey(mnemonicToEntropy(phrase, wordlist));
29
+ throw new Failure(t
30
+ ? 'not a view key (zerc20view1…) or a 24-word recovery phrase'
31
+ : 'no key: give a view key or a recovery phrase in --key-file, ZERC20_KEY or standard input');
32
+ }
33
+ /** Thrown where Ctrl-C answers a question. */
34
+ export class Interrupted extends Error {
35
+ }
36
+ /** What is typed after `question`, with nothing of it shown. */
37
+ function hidden(question) {
38
+ return new Promise((resolve, reject) => {
39
+ const { stdin } = process;
40
+ let typed = '';
41
+ const end = (settle) => {
42
+ stdin.off('data', read);
43
+ stdin.setRawMode(false);
44
+ stdin.pause();
45
+ process.stderr.write('\n');
46
+ settle();
47
+ };
48
+ const read = (chunk) => {
49
+ for (const ch of chunk) {
50
+ if (ch === '\r' || ch === '\n')
51
+ return end(() => resolve(typed));
52
+ if (ch === '\u0003')
53
+ return end(() => reject(new Interrupted()));
54
+ typed = ch === '\u007f' || ch === '\b' ? typed.slice(0, -1) : typed + ch;
55
+ }
56
+ };
57
+ process.stderr.write(question);
58
+ stdin.setRawMode(true);
59
+ stdin.setEncoding('utf8');
60
+ stdin.on('data', read);
61
+ stdin.resume();
62
+ });
63
+ }
64
+ /** The key `file` holds. */
65
+ export const keyIn = (file) => parseKey(readFileSync(file, 'utf8'));
66
+ /** The key a command opens its account with, from anywhere but the arguments, which a shell's history and the process
67
+ * list would keep: a file, the environment, what is piped in, or what is asked for at the terminal. */
68
+ export async function readKey(file) {
69
+ if (file)
70
+ return keyIn(file);
71
+ const given = process.env.ZERC20_KEY;
72
+ if (given)
73
+ return parseKey(given);
74
+ return parseKey(process.stdin.isTTY ? await hidden('View key or recovery phrase: ') : await text(process.stdin));
75
+ }
76
+ /** `name`'s network: one that ships with this program, pinned as the release that carries it found it, or a
77
+ * network.json of the user's own. */
78
+ export function loadNetwork(name) {
79
+ const file = ['mainnet', 'testnet'].includes(name)
80
+ ? fileURLToPath(new URL(`../networks/${name}.json`, import.meta.url))
81
+ : name;
82
+ if (!existsSync(file))
83
+ throw new Usage(`--network ${name}: mainnet, testnet, or the path of a network.json`);
84
+ return networkFromJson(readFileSync(file, 'utf8'));
85
+ }
86
+ const alive = (pid) => {
87
+ try {
88
+ process.kill(pid, 0);
89
+ return true;
90
+ }
91
+ catch (e) {
92
+ return e.code === 'EPERM';
93
+ }
94
+ };
95
+ /** Keeps `path` to this process until it exits. The SDK keeps two wallets of one page apart, not two processes: a
96
+ * second command saving over the first one's state would undo what it spent. A lock whose process is gone is taken
97
+ * over: one that names no process, as a full disk leaves it, or this process itself, as a container gives each run
98
+ * the pid of the last. */
99
+ export function lock(path) {
100
+ const file = `${path}.lock`;
101
+ const read = (f) => {
102
+ try {
103
+ return readFileSync(f, 'utf8');
104
+ }
105
+ catch {
106
+ return null;
107
+ }
108
+ };
109
+ for (;;) {
110
+ try {
111
+ writeFileSync(file, String(process.pid), { flag: 'wx' });
112
+ break;
113
+ }
114
+ catch (e) {
115
+ if (e.code !== 'EEXIST')
116
+ throw e;
117
+ }
118
+ const left = read(file);
119
+ const pid = Number(left);
120
+ if (pid > 0 && pid !== process.pid && alive(pid))
121
+ throw new Failure(`another zerc20 command (process ${pid}) has this account open: let it end first`);
122
+ // Moved aside under a name of this process's own before it is removed: of two commands taking it over, one finds
123
+ // it gone, and one that moved the other's new lock instead puts it back.
124
+ const aside = `${file}.${process.pid}`;
125
+ try {
126
+ renameSync(file, aside);
127
+ }
128
+ catch {
129
+ continue;
130
+ }
131
+ if (read(aside) === left)
132
+ rmSync(aside, { force: true });
133
+ else
134
+ renameSync(aside, file);
135
+ }
136
+ process.on('exit', () => rmSync(file, { force: true }));
137
+ }
138
+ /** Where `key`'s account on `network` keeps its state, whose name other files of the account's start with. */
139
+ export function stateFile(network, key) {
140
+ const dir = join(home(), network.name);
141
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
142
+ return join(dir, `${key.address.toLowerCase()}.${key.kind === 'view' ? 'view' : 'full'}.bin`);
143
+ }
144
+ /** Opens `key`'s account on `network`. Its state, sealed by the SDK under a key of `key`'s, is all that stays on this
145
+ * machine: without the key it tells nothing, and with it the next run reads only what is new.
146
+ *
147
+ * A recovery phrase whose account was never used is refused unless `create`: the SDK registers an account the first
148
+ * time it opens, so a mistyped phrase would quietly make an empty one. `prove` fetches what a payment proves with. */
149
+ export async function openAccount(network, key, { create = false, prove = false } = {}) {
150
+ const path = stateFile(network, key);
151
+ lock(path);
152
+ const persist = {
153
+ load: () => Promise.resolve(existsSync(path) ? readFileSync(path) : null),
154
+ // whole or not at all: a crash while writing leaves the state before it
155
+ save: (bytes) => {
156
+ writeFileSync(`${path}.tmp`, bytes, { mode: 0o600 });
157
+ renameSync(`${path}.tmp`, path);
158
+ return Promise.resolve();
159
+ },
160
+ };
161
+ if (key.kind === 'view')
162
+ return Wallet.watch({ network, viewKey: key.viewKey, persist });
163
+ if (!create && !existsSync(path)) {
164
+ const storage = await CanisterClient.connect(network.storage.host, network.storage.canisterId);
165
+ if (!(await storage.registration(hexToBytes(key.address))))
166
+ throw new Failure(`this recovery phrase has no account on ${network.name} (it would be ${accountId(key.address)}): ` +
167
+ 'check the phrase, or make the account with `zerc20 new`');
168
+ }
169
+ const circuits = { ...network.circuits, joinsplit: await localCircuit(network.circuits.joinsplit, prove) };
170
+ return Wallet.open({
171
+ network: { ...network, circuits },
172
+ account: privateKeyToAccount(accountKey(key.seed)),
173
+ seed: key.seed,
174
+ persist,
175
+ });
176
+ }
177
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,oDAAoD;AAEpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAgB,MAAM,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