@oneie/cli 5.7.5 → 5.7.6

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 (56) hide show
  1. package/README.md +1 -0
  2. package/dist/package.json +5 -2
  3. package/dist/src/balances.d.ts +89 -0
  4. package/dist/src/balances.js +202 -0
  5. package/dist/src/hl-run.d.ts +119 -0
  6. package/dist/src/hl-run.js +480 -0
  7. package/dist/src/hl.d.ts +17 -0
  8. package/dist/src/hl.js +148 -0
  9. package/dist/src/index.js +2 -1
  10. package/dist/src/key-sweep.d.ts +19 -3
  11. package/dist/src/key-sweep.js +63 -20
  12. package/dist/src/lib/hl-core/actions.d.ts +99 -0
  13. package/dist/src/lib/hl-core/actions.js +69 -0
  14. package/dist/src/lib/hl-core/eip712.d.ts +33 -0
  15. package/dist/src/lib/hl-core/eip712.js +107 -0
  16. package/dist/src/lib/hl-core/errors.d.ts +10 -0
  17. package/dist/src/lib/hl-core/errors.js +15 -0
  18. package/dist/src/lib/hl-core/exchange.d.ts +24 -0
  19. package/dist/src/lib/hl-core/exchange.js +47 -0
  20. package/dist/src/lib/hl-core/index.d.ts +13 -0
  21. package/dist/src/lib/hl-core/index.js +14 -0
  22. package/dist/src/lib/hl-core/meta.d.ts +57 -0
  23. package/dist/src/lib/hl-core/meta.js +110 -0
  24. package/dist/src/lib/hl-core/msgpack.d.ts +18 -0
  25. package/dist/src/lib/hl-core/msgpack.js +136 -0
  26. package/dist/src/lib/hl-core/net.d.ts +2 -0
  27. package/dist/src/lib/hl-core/net.js +7 -0
  28. package/dist/src/lib/hl-core/signing.d.ts +103 -0
  29. package/dist/src/lib/hl-core/signing.js +295 -0
  30. package/dist/src/lib/hl-core/wire.d.ts +34 -0
  31. package/dist/src/lib/hl-core/wire.js +81 -0
  32. package/dist/src/lib/journey-words.d.ts +54 -3
  33. package/dist/src/lib/journey-words.js +159 -20
  34. package/dist/src/lib/journey.js +1 -1
  35. package/dist/src/lib/key-source.d.ts +9 -0
  36. package/dist/src/lib/key-source.js +33 -0
  37. package/dist/src/lib/network.d.ts +15 -0
  38. package/dist/src/lib/network.js +41 -0
  39. package/dist/src/lib/qr.d.ts +21 -0
  40. package/dist/src/lib/qr.js +402 -0
  41. package/dist/src/lib/sale-card.d.ts +117 -0
  42. package/dist/src/lib/sale-card.js +261 -0
  43. package/dist/src/lib/sui-grpc-send.d.ts +50 -0
  44. package/dist/src/lib/sui-grpc-send.js +89 -0
  45. package/dist/src/lib/wallet-money.d.ts +222 -0
  46. package/dist/src/lib/wallet-money.js +578 -0
  47. package/dist/src/lib/wallet-request.d.ts +50 -0
  48. package/dist/src/lib/wallet-request.js +86 -0
  49. package/dist/src/onboard.js +4 -3
  50. package/dist/src/shop.js +38 -1
  51. package/dist/src/staff.js +10 -0
  52. package/dist/src/start.js +14 -6
  53. package/dist/src/wallet-money.d.ts +152 -0
  54. package/dist/src/wallet-money.js +564 -0
  55. package/dist/src/wallet.js +169 -24
  56. package/package.json +5 -2
@@ -6,11 +6,15 @@ import { generateWallet, recoverWallet, readDerivation } from '@oneie/sdk/wallet
6
6
  import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file';
7
7
  import { proveAddresses } from '@oneie/sdk/address-proof';
8
8
  import { askPath } from './lib/api-path.js';
9
+ import { balancesCmd } from './balances.js';
9
10
  import { workspaceFor } from './lib/keyfile.js';
10
11
  import { resolveKey } from './lib/client.js';
11
- import { wordsStdoutRefusal } from './lib/agent-env.js';
12
+ import { keySourceOf } from './lib/key-source.js';
13
+ import { readMachineKey } from './lib/paths.js';
14
+ import { wordsStdoutRefusal, agentType } from './lib/agent-env.js';
12
15
  import { cliPrefix } from './lib/invoked-as.js';
13
16
  import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
17
+ import { receiveCmd, requestCmd, sendCmd, upgradeBalances } from './wallet-money.js';
14
18
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
15
19
  // Re-exported for existing callers/tests — canonical implementation now lives
16
20
  // in ./lib/api-path.ts so trade.ts/client.ts/coordinate.ts/catalog.ts can share
@@ -134,17 +138,37 @@ export function okWrap(result) {
134
138
  export function walletCmd() {
135
139
  const cmd = new Command('wallet').description('Read balances, provision a wallet row, fund from testnet, send crypto — wallet:* receivers + pay.one.ie');
136
140
  cmd.command('get')
137
- .description('Credits, spend ceiling, wallet rows, live chain balances, delegated wallets')
141
+ .description('Credits, spend ceiling, wallet rows, live chain balances (sui · evm · solana · btc · hyperliquid), delegated wallets')
138
142
  .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
139
143
  .option('--actor <id>', 'Actor within the workspace (defaults to workspace)')
144
+ .option('--net <network>', 'mainnet | testnet — the one network every balance is read on (defaults to the deploy\'s; ask mainnet for real money)')
140
145
  .option('--api <url>', 'API base URL', DEFAULT_API)
141
146
  .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
142
147
  .action(async (opts) => {
148
+ if (opts.net && opts.net !== 'mainnet' && opts.net !== 'testnet') {
149
+ out(cmd, { ok: false, error: '--net must be mainnet or testnet' });
150
+ process.exitCode = 1;
151
+ return;
152
+ }
143
153
  const { base, key } = resolveAuth(opts);
144
154
  const workspace = resolveWorkspace(opts.workspace);
145
- const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
155
+ const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor, ...(opts.net ? { net: opts.net } : {}) });
146
156
  out(cmd, okWrap(result));
147
157
  });
158
+ // balances — the REAL mainnet balances of the loaded wallet, read from the chains (src/balances.ts).
159
+ // `get` above is ONE's own ledger and shows test money for most chains.
160
+ cmd.addCommand(balancesCmd({
161
+ fetch: (url, init) => fetch(url, init),
162
+ addresses: async (opts) => {
163
+ const { base, key } = resolveAuth(opts);
164
+ const workspace = resolveWorkspace(opts.workspace);
165
+ const w = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
166
+ const rows = Array.isArray(w['addresses']) ? w['addresses'] : [];
167
+ const who = opts.actor ?? workspace;
168
+ const mine = (chain) => rows.find((x) => x.chain === chain && x.actor === who && typeof x.address === 'string')?.address;
169
+ return { evm: mine('evm'), sui: mine('sui') };
170
+ },
171
+ }, DEFAULT_API));
148
172
  // list — every wallet in the workspace with the words it wears (treasury · agent · person ·
149
173
  // limit · paused · no-limit · sweep · vault · no-address). The tags are wallet:get's own,
150
174
  // derived on the server from the rows, the caps and the signed sweep rules.
@@ -227,27 +251,46 @@ export function walletCmd() {
227
251
  const results = (data.results ?? []);
228
252
  out(cmd, { ok: faucetOk(results), results, manualFaucets: data.manualFaucets });
229
253
  });
230
- cmd.command('send <to>')
231
- .description('Send crypto via pay.one.ie payment links, incl. Bitcoin — sign the transfer yourself first, pass the tx hash')
232
- .requiredOption('--chain <chain>', 'SUI | EVM | SOL | BTC | BASE | ARB | OPT')
233
- .requiredOption('--amount <n>', 'Amount to send')
234
- .requiredOption('--payment-tx <hash>', 'The transaction hash from signing & broadcasting client-side — this command never signs')
235
- .option('--workspace <slug>', 'Source workspace (defaults to AGENCY_SLUG)')
236
- .option('--unit <unit>', 'usd | token', 'usd')
237
- .option('--currency <currency>', 'NATIVE | USDC', 'NATIVE')
238
- .option('--user-address <address>', 'Sender address (defaults to --to)')
239
- .option('--memo <text>', 'Payment memo')
240
- .option('--api <url>', 'API base URL', DEFAULT_API)
241
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
242
- .action(async (to, opts) => {
243
- const { base, key } = resolveAuth(opts);
244
- const workspace = resolveWorkspace(opts.workspace);
245
- const result = await ask(base, key, 'wallet:send', {
246
- workspace, to, chain: opts.chain, amount: Number(opts.amount), paymentTx: opts.paymentTx,
247
- unit: opts.unit, currency: opts.currency, userAddress: opts.userAddress, memo: opts.memo,
248
- });
249
- out(cmd, okWrap(result));
250
- });
254
+ // receive · send · request, and --net on balances — the loaded wallet's money (src/wallet-money.ts).
255
+ // `send <amount> <asset>[@chain] <to>` signs with the sealed vault on --live; the older
256
+ // `send <to> --chain --amount --payment-tx` form still records a transfer signed elsewhere.
257
+ const money = {
258
+ ask: (o, receiver, data) => { const { base, key } = resolveAuth(o); return ask(base, key, receiver, data); },
259
+ workspace: resolveWorkspace,
260
+ // Who the key acts as and where it came from — wallet:challenge names the actor; the key itself is never printed.
261
+ identity: async (o, which) => {
262
+ const src = keySourceOf(o);
263
+ if (which === 'machine' && !src.local)
264
+ return null;
265
+ const { base, key } = resolveAuth(o);
266
+ const useKey = which === 'machine' ? readMachineKey() : key;
267
+ const from = which === 'machine' ? keySourceOf({}, '/nonexistent-folder', {}).label : src.label;
268
+ let actor;
269
+ try {
270
+ actor = String((await ask(base, useKey, 'wallet:challenge', {}))['actor'] ?? '') || undefined;
271
+ }
272
+ catch { /* unread: the header says so */ }
273
+ return { actor, from, local: which === 'machine' ? false : src.local };
274
+ },
275
+ unlock: (dir) => unlock(dir),
276
+ defaultApi: DEFAULT_API,
277
+ relay: async (_c, to, o) => {
278
+ const opts = o;
279
+ const { base, key } = resolveAuth(opts);
280
+ const workspace = resolveWorkspace(opts.workspace);
281
+ const result = await ask(base, key, 'wallet:send', {
282
+ workspace, to, chain: opts.chain, amount: Number(opts.amount), paymentTx: opts.paymentTx,
283
+ unit: opts.unit, currency: opts.currency, userAddress: opts.userAddress, memo: opts.memo,
284
+ });
285
+ out(cmd, okWrap(result));
286
+ },
287
+ };
288
+ const balances = cmd.commands.find((c) => c.name() === 'balances');
289
+ if (balances)
290
+ upgradeBalances(balances, money);
291
+ cmd.addCommand(receiveCmd(money));
292
+ cmd.addCommand(sendCmd(money));
293
+ cmd.addCommand(requestCmd(money));
251
294
  cmd.command('register')
252
295
  .description('Register a keygen output\'s PUBLIC receiving addresses with a workspace — sends addresses only, never a key or a mnemonic. With --kind agent the keys in --from (or the sealed wallet in --dir) sign a server challenge locally, and only the signatures are sent. First write wins per chain and is permanent')
253
296
  .option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
@@ -478,6 +521,108 @@ export function walletCmd() {
478
521
  const k = keychainStore(String(blob.authPub ?? ''), pass);
479
522
  out(cmd, k.ok ? { ok: true, note: 'Touch ID now opens this wallet' } : { ok: false, error: k.error });
480
523
  });
524
+ // The browser's /w/restore "Key file" door opens a vault sealed with a TYPED
525
+ // passphrase — it cannot read this machine's Keychain. This writes that copy:
526
+ // the same 24 words, the same derivation, a passphrase the person types twice.
527
+ // Nothing secret reaches stdout; the file is useless without the passphrase.
528
+ cmd.command('file')
529
+ .description('Write a browser copy of this wallet — the same key re-sealed with a passphrase you type, for the Key file door on /w/restore (drag and drop). Prints only the path and the addresses')
530
+ .option('--dir <path>', 'Project directory', '.')
531
+ .option('--out <path>', 'Where to write it', '')
532
+ .action(async (opts) => {
533
+ if (!process.stdin.isTTY) {
534
+ out(cmd, { ok: false, error: 'a passphrase is typed at a terminal, never piped — run this yourself' });
535
+ process.exitCode = 1;
536
+ return;
537
+ }
538
+ const agentHere = agentType(process.env);
539
+ if (agentHere) {
540
+ out(cmd, { ok: false, error: `refusing: this shell is driven by ${agentHere}. Run it yourself in a terminal no agent drives` });
541
+ process.exitCode = 1;
542
+ return;
543
+ }
544
+ const r = await unlock(opts.dir);
545
+ if ('error' in r) {
546
+ out(cmd, { ok: false, error: r.error });
547
+ return;
548
+ }
549
+ const p1 = await promptSecret('Passphrase for the browser copy (12+ characters): ');
550
+ if (p1.length < 12) {
551
+ out(cmd, { ok: false, error: 'too short — nothing written' });
552
+ return;
553
+ }
554
+ const p2 = await promptSecret('Again: ');
555
+ if (p1 !== p2) {
556
+ out(cmd, { ok: false, error: 'they differ — nothing written' });
557
+ return;
558
+ }
559
+ const blob = await sealVault(r.mnemonic, p1, { wrap: 'passphrase', derivation: r.blob.derivation });
560
+ const target = opts.out || `${opts.dir.replace(/\/$/, '')}/wallet-file.json`;
561
+ writeFileSync(target, JSON.stringify(blob, null, 1) + '\n');
562
+ chmodSync(target, 0o600);
563
+ out(cmd, { ok: true, out: target, addresses: r.addresses, next: 'drop it on /w/restore → Key file, type the passphrase; delete the copy once the browser holds the key' });
564
+ });
565
+ // One chain's private key, to the CLIPBOARD and nowhere else — for MetaMask,
566
+ // Phantom, Slush, Sparrow. Never stdout: a terminal scrollback, a CI log or an
567
+ // agent transcript would keep it. The key is derived on demand and dropped.
568
+ cmd.command('key')
569
+ .description('Copy one chain\'s private key to the clipboard for another wallet app (MetaMask, Phantom, Slush, Sparrow). Clipboard only — it is never printed. Prints the address it belongs to')
570
+ .option('--dir <path>', 'Project directory', '.')
571
+ .option('--chain <chain>', 'evm | sui | sol | btc | asi', 'evm')
572
+ .option('--clipboard', 'Required: the only destination this command has')
573
+ .action(async (opts) => {
574
+ if (!opts.clipboard) {
575
+ out(cmd, { ok: false, error: 'add --clipboard — the key goes to the clipboard, never to the screen' });
576
+ process.exitCode = 1;
577
+ return;
578
+ }
579
+ // The same gate as `paper`, BEFORE unlock: a shell an agent drives must not
580
+ // move a private key anywhere — a clipboard is one paste from a transcript.
581
+ // And a terminal, so the hand on the keyboard is a person's.
582
+ const agent = agentType(process.env);
583
+ if (agent) {
584
+ out(cmd, { ok: false, error: `refusing: this shell is driven by ${agent}. Run it yourself in a terminal no agent drives` });
585
+ process.exitCode = 1;
586
+ return;
587
+ }
588
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
589
+ out(cmd, { ok: false, error: 'refusing: not a terminal (a pipe, a file or a log)' });
590
+ process.exitCode = 1;
591
+ return;
592
+ }
593
+ const want = opts.chain.toLowerCase();
594
+ const r = await unlock(opts.dir);
595
+ if ('error' in r) {
596
+ out(cmd, { ok: false, error: r.error });
597
+ return;
598
+ }
599
+ const k = r.keys.find((x) => String(x.chain).toLowerCase() === want || (want === 'evm' && ['eth', 'ethereum'].includes(String(x.chain).toLowerCase())) || (want === 'sol' && String(x.chain).toLowerCase() === 'solana'));
600
+ if (!k) {
601
+ out(cmd, { ok: false, error: `no ${want} key in this wallet` });
602
+ return;
603
+ }
604
+ const { spawnSync, spawn } = await import('node:child_process');
605
+ // Fixed system paths only — never a PATH or cwd lookup, which a project-local
606
+ // `pbcopy` could shadow and read the key.
607
+ const copier = process.platform === 'darwin' ? ['/usr/bin/pbcopy']
608
+ : process.platform === 'win32' ? [`${process.env.SystemRoot ?? 'C:\\Windows'}\\System32\\clip.exe`]
609
+ : existsSync('/usr/bin/wl-copy') ? ['/usr/bin/wl-copy'] : ['/usr/bin/xclip', '-selection', 'clipboard'];
610
+ if (!existsSync(copier[0])) {
611
+ out(cmd, { ok: false, error: `no clipboard tool at ${copier[0]} — nothing was printed` });
612
+ return;
613
+ }
614
+ const p = spawnSync(copier[0], copier.slice(1), { input: k.privateKeyHex.replace(/^0x/, '') });
615
+ if (p.status !== 0) {
616
+ out(cmd, { ok: false, error: `clipboard tool ${copier[0]} failed — nothing was printed` });
617
+ return;
618
+ }
619
+ // Clear it after the paste window: the key must not sit on the clipboard.
620
+ // --clear-after defaults to 60 s; the clear is a second spawn of the same tool.
621
+ const seconds = 60;
622
+ const sweeper = spawn(process.execPath, ['-e', `setTimeout(()=>{require('child_process').spawnSync(${JSON.stringify(copier[0])},${JSON.stringify(copier.slice(1))},{input:'cleared'})},${seconds * 1000})`], { detached: true, stdio: 'ignore' });
623
+ sweeper.unref();
624
+ out(cmd, { ok: true, chain: want, address: k.address, note: `private key on the clipboard for ${seconds} s — paste it into the wallet app now; it clears itself after` });
625
+ });
481
626
  return cmd;
482
627
  }
483
628
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "5.7.5",
3
+ "version": "5.7.6",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,10 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "commander": "^12.0.0",
23
- "@oneie/sdk": "^0.17.6"
23
+ "@oneie/sdk": "^0.17.6",
24
+ "@noble/curves": "^2.2.0",
25
+ "@noble/hashes": "^2.2.0",
26
+ "@mysten/sui": "^2.20.0"
24
27
  },
25
28
  "devDependencies": {
26
29
  "@oneie/evals": "^0.2.0",