oneie 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.
- package/README.md +1 -0
- package/dist/package.json +5 -2
- package/dist/src/balances.d.ts +89 -0
- package/dist/src/balances.js +202 -0
- package/dist/src/hl-run.d.ts +119 -0
- package/dist/src/hl-run.js +480 -0
- package/dist/src/hl.d.ts +17 -0
- package/dist/src/hl.js +148 -0
- package/dist/src/index.js +2 -1
- package/dist/src/key-sweep.d.ts +19 -3
- package/dist/src/key-sweep.js +63 -20
- package/dist/src/lib/hl-core/actions.d.ts +99 -0
- package/dist/src/lib/hl-core/actions.js +69 -0
- package/dist/src/lib/hl-core/eip712.d.ts +33 -0
- package/dist/src/lib/hl-core/eip712.js +107 -0
- package/dist/src/lib/hl-core/errors.d.ts +10 -0
- package/dist/src/lib/hl-core/errors.js +15 -0
- package/dist/src/lib/hl-core/exchange.d.ts +24 -0
- package/dist/src/lib/hl-core/exchange.js +47 -0
- package/dist/src/lib/hl-core/index.d.ts +13 -0
- package/dist/src/lib/hl-core/index.js +14 -0
- package/dist/src/lib/hl-core/meta.d.ts +57 -0
- package/dist/src/lib/hl-core/meta.js +110 -0
- package/dist/src/lib/hl-core/msgpack.d.ts +18 -0
- package/dist/src/lib/hl-core/msgpack.js +136 -0
- package/dist/src/lib/hl-core/net.d.ts +2 -0
- package/dist/src/lib/hl-core/net.js +7 -0
- package/dist/src/lib/hl-core/signing.d.ts +103 -0
- package/dist/src/lib/hl-core/signing.js +295 -0
- package/dist/src/lib/hl-core/wire.d.ts +34 -0
- package/dist/src/lib/hl-core/wire.js +81 -0
- package/dist/src/lib/journey-words.d.ts +54 -3
- package/dist/src/lib/journey-words.js +159 -20
- package/dist/src/lib/journey.js +1 -1
- package/dist/src/lib/key-source.d.ts +9 -0
- package/dist/src/lib/key-source.js +33 -0
- package/dist/src/lib/network.d.ts +15 -0
- package/dist/src/lib/network.js +41 -0
- package/dist/src/lib/qr.d.ts +21 -0
- package/dist/src/lib/qr.js +402 -0
- package/dist/src/lib/sale-card.d.ts +117 -0
- package/dist/src/lib/sale-card.js +261 -0
- package/dist/src/lib/sui-grpc-send.d.ts +50 -0
- package/dist/src/lib/sui-grpc-send.js +89 -0
- package/dist/src/lib/wallet-money.d.ts +222 -0
- package/dist/src/lib/wallet-money.js +578 -0
- package/dist/src/lib/wallet-request.d.ts +50 -0
- package/dist/src/lib/wallet-request.js +86 -0
- package/dist/src/onboard.js +4 -3
- package/dist/src/shop.js +38 -1
- package/dist/src/staff.js +10 -0
- package/dist/src/start.js +14 -6
- package/dist/src/wallet-money.d.ts +152 -0
- package/dist/src/wallet-money.js +564 -0
- package/dist/src/wallet.js +169 -24
- package/package.json +5 -2
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wallet-request.ts — the agent's half of "an agent asks, the owner's fingerprint decides".
|
|
3
|
+
*
|
|
4
|
+
* The agent builds a SENTENCE the owner's own chat already understands and wraps it in a link:
|
|
5
|
+
* `https://one.ie/chat#money=<sentence>`. Opening it types the sentence as the owner's line and
|
|
6
|
+
* shows the send card they sign with Touch ID. Nothing here signs, holds or opens a key; it only
|
|
7
|
+
* names the agent's own PUBLIC receiving address.
|
|
8
|
+
*
|
|
9
|
+
* The grammar is MIRRORED from one.ie/web/src/lib/chat/money-intent.ts (SEND, amountOk,
|
|
10
|
+
* chainsFor, moneyLink) — copied, never imported: the CLI ships alone. If the web's send pattern
|
|
11
|
+
* moves, tests/wallet-request.test.ts is the place that says so.
|
|
12
|
+
*/
|
|
13
|
+
import { SUI } from './wallet-money.js';
|
|
14
|
+
const WORD = { ethereum: 'ethereum', eth: 'ethereum', base: 'base', sui: 'sui' };
|
|
15
|
+
/** `USDC` · `SUI` · `ETH@base` · `USDC@ethereum` — anything the web grammar would not read is refused by name. */
|
|
16
|
+
export function parseRequestAsset(word) {
|
|
17
|
+
const [a = '', c] = word.trim().split('@');
|
|
18
|
+
const asset = a.toUpperCase();
|
|
19
|
+
if (asset !== 'ETH' && asset !== 'USDC' && asset !== 'SUI') {
|
|
20
|
+
return { ok: false, error: 'unsupported_asset', message: `Ask for USDC or SUI on Sui, or ETH or USDC on Ethereum or Base — not "${word}".` };
|
|
21
|
+
}
|
|
22
|
+
if (c === undefined) {
|
|
23
|
+
if (asset === 'ETH')
|
|
24
|
+
return { ok: false, error: 'chain_needed', message: 'ETH lives on Ethereum and Base — say which: ETH@ethereum or ETH@base.' };
|
|
25
|
+
return { ok: true, asset, chain: 'sui', defaulted: asset === 'USDC' };
|
|
26
|
+
}
|
|
27
|
+
const chain = WORD[c.toLowerCase()];
|
|
28
|
+
if (!chain)
|
|
29
|
+
return { ok: false, error: 'unsupported_chain', message: `"${c}" is not a chain a request link can name — ethereum, base or sui.` };
|
|
30
|
+
if (asset === 'ETH' && chain === 'sui')
|
|
31
|
+
return { ok: false, error: 'asset_not_on_chain', message: 'ETH does not live on Sui.' };
|
|
32
|
+
if (asset === 'SUI' && chain !== 'sui')
|
|
33
|
+
return { ok: false, error: 'asset_not_on_chain', message: `SUI lives on Sui, not ${chain}.` };
|
|
34
|
+
return { ok: true, asset, chain, defaulted: false };
|
|
35
|
+
}
|
|
36
|
+
/** The web's amountOk: a positive plain decimal, at most 18 places. */
|
|
37
|
+
export const amountOk = (a) => /^(?:\d+(?:\.\d{1,18})?|\.\d{1,18})$/.test(a) && Number.parseFloat(a) > 0;
|
|
38
|
+
/** `send 20 USDC on sui to 0x…` — the chain is always said, so the card never has to ask which. */
|
|
39
|
+
export const sentenceFor = (amount, asset, chain, to) => `send ${amount} ${asset} on ${chain} to ${to}`;
|
|
40
|
+
/** The web's moneyLink: the sentence is capped at 200 characters. */
|
|
41
|
+
export const linkFor = (sentence, origin = 'https://one.ie') => `${origin.replace(/\/$/, '')}/chat#money=${encodeURIComponent(sentence.trim().slice(0, 200))}`;
|
|
42
|
+
// The web's SEND pattern (money-intent.ts), verbatim.
|
|
43
|
+
const LEAD = "(?:(?:please|pls|ok|okay)\\s+)?(?:(?:can|could|will|would)\\s+you\\s+)?(?:(?:i\\s+(?:want|need)\\s+to|i'?d\\s+like\\s+to|let'?s|lets)\\s+)?";
|
|
44
|
+
const END = '[\\s.!]*$';
|
|
45
|
+
const AMOUNT = '(\\d+(?:\\.\\d+)?|\\.\\d+)';
|
|
46
|
+
const SEND = new RegExp(`^${LEAD}(?:send|pay|transfer)\\s+${AMOUNT}\\s*(eth|usdc|sui)(?:\\s*(?:on\\s+|@)(ethereum|eth|mainnet|base|sui))?\\s+to\\s+(\\S+)(?:\\s+on\\s+(ethereum|eth|mainnet|base|sui))?${END}`, 'i');
|
|
47
|
+
/** What the web's `matchMoneyIntent` would make of this sentence, as far as a send goes — or null. */
|
|
48
|
+
export function matchSend(text) {
|
|
49
|
+
const line = text.trim().replace(/\s+/g, ' ');
|
|
50
|
+
if (!line || line.length > 200)
|
|
51
|
+
return null;
|
|
52
|
+
const m = SEND.exec(line);
|
|
53
|
+
if (!m || !amountOk(m[1]))
|
|
54
|
+
return null;
|
|
55
|
+
const symbol = m[2].toUpperCase();
|
|
56
|
+
const to = m[4];
|
|
57
|
+
const family = /^0x[0-9a-fA-F]{40}$/.test(to) ? 'evm' : /^0x[0-9a-fA-F]{64}$/.test(to) ? 'sui' : null;
|
|
58
|
+
if (!family)
|
|
59
|
+
return null;
|
|
60
|
+
const possible = symbol === 'SUI' ? (family === 'evm' ? [] : ['sui']) : symbol === 'ETH' ? (family === 'sui' ? [] : ['eth', 'base']) : family === 'sui' ? ['sui'] : ['eth', 'base'];
|
|
61
|
+
if (possible.length === 0)
|
|
62
|
+
return null;
|
|
63
|
+
const said = (m[3] ?? m[5])?.toLowerCase();
|
|
64
|
+
const word = said === undefined ? null : { ethereum: 'eth', eth: 'eth', mainnet: 'eth', base: 'base', sui: 'sui' }[said] ?? null;
|
|
65
|
+
if (word && !possible.includes(word))
|
|
66
|
+
return null;
|
|
67
|
+
return { amount: m[1], symbol, chain: word ?? (possible.length === 1 ? possible[0] : null), to };
|
|
68
|
+
}
|
|
69
|
+
export const shortAddr = (a) => (a.length > 14 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a);
|
|
70
|
+
/** The latest transaction that touched `address` on Sui — what an arrival most likely is. Null when it cannot be read. */
|
|
71
|
+
export async function latestSuiDigest(f, net, address) {
|
|
72
|
+
try {
|
|
73
|
+
const res = await f(SUI[net].graphql, {
|
|
74
|
+
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
75
|
+
body: JSON.stringify({ query: 'query($a: SuiAddress!) { transactions(last: 1, filter: { affectedAddress: $a }) { nodes { digest } } }', variables: { a: address } }),
|
|
76
|
+
});
|
|
77
|
+
if (!res.ok)
|
|
78
|
+
return null;
|
|
79
|
+
const r = (await res.json());
|
|
80
|
+
const d = r.data?.transactions?.nodes?.[0]?.digest;
|
|
81
|
+
return typeof d === 'string' && d ? d : null;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
package/dist/src/onboard.js
CHANGED
|
@@ -34,10 +34,10 @@ async function ask(base, key, receiver, data) {
|
|
|
34
34
|
// agent has a key to call the substrate with.
|
|
35
35
|
const STAGE_GUIDE = {
|
|
36
36
|
registered: 'done — your identity exists (uid + apiKey minted).',
|
|
37
|
-
bootstrapped: 'done — your own
|
|
37
|
+
bootstrapped: 'done — your own group exists (gid + aid + scopedKey minted).',
|
|
38
38
|
active: 'publish a capability or place a market offer: `one agent publish` or `one trade market`.',
|
|
39
39
|
settled: 'complete a sale: `one trade hire` (as a buyer) or accept + settle an offer (as the seller).',
|
|
40
|
-
adopted: 'get adopted by another
|
|
40
|
+
adopted: 'get adopted by another group — accept an invite, or have your capability hired long-term.',
|
|
41
41
|
};
|
|
42
42
|
const STAGE_ORDER = ['registered', 'bootstrapped', 'active', 'settled', 'adopted'];
|
|
43
43
|
function out(cmd, data) {
|
|
@@ -52,7 +52,7 @@ function out(cmd, data) {
|
|
|
52
52
|
}
|
|
53
53
|
const stages = data.stages ?? [];
|
|
54
54
|
process.stdout.write(`✓ onboarded as ${data.uid ?? '?'}\n`);
|
|
55
|
-
process.stdout.write(`
|
|
55
|
+
process.stdout.write(` group: ${data.group ?? data.workspace ?? '?'}\n`);
|
|
56
56
|
process.stdout.write(` url: ${data.url ?? '?'}\n\n`);
|
|
57
57
|
process.stdout.write(' lifecycle: register → bootstrap → active → settled → adopted\n');
|
|
58
58
|
for (const s of stages) {
|
|
@@ -139,6 +139,7 @@ export function onboardCmd() {
|
|
|
139
139
|
ok: true,
|
|
140
140
|
uid: uid || '(unknown — no ONE_UID in env; re-run in a fresh dir to see it)',
|
|
141
141
|
workspace,
|
|
142
|
+
group: workspace, // the word a person reads; `workspace` stays for scripts
|
|
142
143
|
url: workspace ? `${base}/u/${workspace}` : base,
|
|
143
144
|
key: `${KEY_FILE} (0600)`,
|
|
144
145
|
stages,
|
package/dist/src/shop.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import { authHeaders, out, resolveBase } from './lib/client.js';
|
|
3
|
+
import { authHeaders, jsonMode, out, resolveBase } from './lib/client.js';
|
|
4
4
|
import { askPath } from './lib/api-path.js';
|
|
5
5
|
import { parseFacts, shopInit } from './lib/shop-init.js';
|
|
6
|
+
import { SALE_CHANNEL_IDS, SALE_KIND_IDS, SALE_RAIL_IDS, drawSale, saleChannelOf, saleJson, saleKindOf, saleRailOf, } from './lib/sale-card.js';
|
|
6
7
|
const DEFAULT_API = resolveBase({}, 'https://one.ie');
|
|
7
8
|
/**
|
|
8
9
|
* `one shop init` — twelve draft pages, and the seller's own facts written into
|
|
@@ -69,5 +70,41 @@ export function shopCmd() {
|
|
|
69
70
|
if (r.fillRequested && !r.filled)
|
|
70
71
|
process.exitCode = 1;
|
|
71
72
|
});
|
|
73
|
+
// A picture of the sale, drawn locally: no key, no network, nothing charged. The drawing lives in
|
|
74
|
+
// lib/sale-card.ts so it is tested without a terminal.
|
|
75
|
+
cmd
|
|
76
|
+
.command('card')
|
|
77
|
+
.description('Draw how your agent sells: the pay card, alone or inside a WhatsApp, SMS or email thread')
|
|
78
|
+
.option('--kind <kind>', `What is sold: ${SALE_KIND_IDS.join('|')}`, 'course')
|
|
79
|
+
.option('--rail <rail>', `How they pay: ${SALE_RAIL_IDS.join('|')}`, 'card')
|
|
80
|
+
.option('--channel <id>', `Where it is sold: ${SALE_CHANNEL_IDS.join('|')}`)
|
|
81
|
+
.option('--all', 'All four offers')
|
|
82
|
+
.option('--paid', 'Draw the card after the tap')
|
|
83
|
+
.action((opts, c) => {
|
|
84
|
+
const kind = saleKindOf(opts.kind);
|
|
85
|
+
const rail = saleRailOf(opts.rail);
|
|
86
|
+
const channel = opts.channel === undefined ? undefined : saleChannelOf(opts.channel);
|
|
87
|
+
// An unknown word is refused, never drawn as the default: a wrong picture reads as a right one.
|
|
88
|
+
if (!kind) {
|
|
89
|
+
out(c, { ok: false, error: `unknown kind "${opts.kind}" — ${SALE_KIND_IDS.join(', ')}` });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (!rail) {
|
|
93
|
+
out(c, { ok: false, error: `unknown rail "${opts.rail}" — ${SALE_RAIL_IDS.join(', ')}` });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (channel === null) {
|
|
97
|
+
out(c, { ok: false, error: `unknown channel "${opts.channel}" — ${SALE_CHANNEL_IDS.join(', ')}` });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const kinds = opts.all ? SALE_KIND_IDS : [kind];
|
|
101
|
+
const draw = { rail, channel, phase: opts.paid ? 'paid' : 'idle' };
|
|
102
|
+
if (jsonMode(c)) {
|
|
103
|
+
out(c, saleJson(kinds, draw));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const ascii = !process.stdout.isTTY || 'NO_COLOR' in process.env;
|
|
107
|
+
process.stdout.write(drawSale(kinds, { ...draw, ascii }));
|
|
108
|
+
});
|
|
72
109
|
return cmd;
|
|
73
110
|
}
|
package/dist/src/staff.js
CHANGED
|
@@ -88,6 +88,16 @@ export function staffCmd() {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
const result = json.result ?? json;
|
|
91
|
+
// The ask door answers a refusal INSIDE result (`{outcome:"failure", result:{error,reason}}`)
|
|
92
|
+
// with HTTP 200 — read it, or a forbidden prints `aid=undefined key=undefined` as ok.
|
|
93
|
+
if (result.error) {
|
|
94
|
+
out(cmd, { ok: false, error: result.reason ?? result.error });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!result.aid || !result.key) {
|
|
98
|
+
out(cmd, { ok: false, error: 'door answered without aid/key' });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
91
101
|
out(cmd, { ok: true, name, role, aid: result.aid, key: result.key });
|
|
92
102
|
});
|
|
93
103
|
return cmd;
|
package/dist/src/start.js
CHANGED
|
@@ -19,7 +19,8 @@ import { agentType } from './lib/agent-env.js';
|
|
|
19
19
|
import { provisionLocalWallet } from './init.js';
|
|
20
20
|
import { promptSecret, registerSealedWallet } from './wallet.js';
|
|
21
21
|
import { parseProductSpec, runJourney, } from './lib/journey.js';
|
|
22
|
-
import { journeyIntro, journeyResume, journeyWords } from './lib/journey-words.js';
|
|
22
|
+
import { asciiOf, haveNow, journeyIntro, journeyResume, journeyWords } from './lib/journey-words.js';
|
|
23
|
+
import { learnNetwork } from './lib/network.js';
|
|
23
24
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
|
|
24
25
|
/** The flags bare `npx oneie --email …` hands to `start` — the journey's own, nothing else. */
|
|
25
26
|
export const START_FLAGS = new Set(['--name', '--email', '--product', '--currency', '--wait', '--api']);
|
|
@@ -149,7 +150,7 @@ function deps(dir, api, say) {
|
|
|
149
150
|
export function startCmd() {
|
|
150
151
|
const cmd = new Command('start')
|
|
151
152
|
.description('Walk the whole path in this folder: your key, a product, a test sale, then one link that hands it over. Bare `npx oneie` runs it; run it again to pick up where you left off')
|
|
152
|
-
.option('--name <name>', '
|
|
153
|
+
.option('--name <name>', 'Group / agent display name', 'My Shop')
|
|
153
154
|
.option('--email <email>', "The new owner's email — the handover link is sent there as well as printed")
|
|
154
155
|
.option('--product <name=price>', 'A product in major units, e.g. "Mug=12.50" (repeatable; default one Test product at 1.00)', (v, acc) => [...acc, v], [])
|
|
155
156
|
.option('--currency <iso>', 'ISO 4217 for --product prices', 'usd')
|
|
@@ -172,11 +173,16 @@ export function startCmd() {
|
|
|
172
173
|
const api = opts.api.replace(/\/$/, '');
|
|
173
174
|
const json = jsonMode(sub);
|
|
174
175
|
const cli = cliPrefix();
|
|
176
|
+
// A pipe, a log or NO_COLOR gets plain ASCII: the same words, no box or glyph it cannot draw.
|
|
177
|
+
const plain = !process.stdout.isTTY || 'NO_COLOR' in process.env;
|
|
178
|
+
const fmt = (text) => (plain ? asciiOf(text) : text);
|
|
175
179
|
if (!json) {
|
|
176
180
|
const earlier = loadState(process.cwd());
|
|
177
|
-
process.stdout.write(earlier ? journeyResume(earlier.workspace) : journeyIntro(cli));
|
|
181
|
+
process.stdout.write(fmt(earlier ? journeyResume(earlier.workspace) : journeyIntro(cli)));
|
|
178
182
|
}
|
|
179
|
-
|
|
183
|
+
// The network shapes the words and `have.network`; asked now, in parallel with the walk, never blocking it.
|
|
184
|
+
const netP = learnNetwork(api);
|
|
185
|
+
const say = json ? () => { } : (line) => process.stderr.write(` ${fmt(line)}\n`);
|
|
180
186
|
const report = await runJourney(deps(process.cwd(), api, say), {
|
|
181
187
|
api,
|
|
182
188
|
name: opts.name,
|
|
@@ -184,10 +190,12 @@ export function startCmd() {
|
|
|
184
190
|
products,
|
|
185
191
|
...(opts.wait !== undefined ? { waitSeconds: Math.max(0, Number(opts.wait) || 0) } : {}),
|
|
186
192
|
});
|
|
193
|
+
const net = await netP;
|
|
194
|
+
// `have` is additive: every fact the panel prints, in full, beside the report's own keys.
|
|
187
195
|
if (json)
|
|
188
|
-
process.stdout.write(JSON.stringify(report) + '\n');
|
|
196
|
+
process.stdout.write(JSON.stringify({ ...report, have: haveNow(report, cli, { net }) }) + '\n');
|
|
189
197
|
else
|
|
190
|
-
process.stdout.write('\n' + journeyWords(report, cli, { agent: agentType() }));
|
|
198
|
+
process.stdout.write(fmt('\n' + journeyWords(report, cli, { agent: agentType(), net })));
|
|
191
199
|
if (!report.ok)
|
|
192
200
|
process.exitCode = 1;
|
|
193
201
|
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wallet-money.ts — the loaded wallet's money, one command away:
|
|
3
|
+
*
|
|
4
|
+
* one wallet balances [--net mainnet|testnet] every chain, wallet:get first, chains for the rest
|
|
5
|
+
* one wallet receive --chain base one address, one QR, never ambiguous
|
|
6
|
+
* one wallet send 1 USDC@base 0x… DRY: exactly what would be signed, fees, the chain
|
|
7
|
+
* one wallet send 0.0004 ETH@ethereum 0x… --live --dir ~/.one/tony
|
|
8
|
+
* one wallet request 25 USD a wallet:invoice payment link
|
|
9
|
+
* one wallet request 5 USDC --wait a link the owner opens and signs with Touch ID
|
|
10
|
+
*
|
|
11
|
+
* THE SERVER SIGNS NOTHING (R19). A --live send opens the sealed vault in --dir on THIS
|
|
12
|
+
* machine (Touch ID or a typed passphrase), signs here, broadcasts to a public node, and
|
|
13
|
+
* drops the key. Before the key opens: the gate (an agent shell signs only with its OWN
|
|
14
|
+
* vault and --yes), and the client check (R16) — the transaction is rebuilt from the
|
|
15
|
+
* person's own words and compared, never trusted from an echo.
|
|
16
|
+
*
|
|
17
|
+
* `balances` is the dev session's command (src/balances.ts, kept byte-identical so the two
|
|
18
|
+
* merge cleanly); `upgradeBalances` adds --net and the wallet:get fan-out to it in place.
|
|
19
|
+
*/
|
|
20
|
+
import { Command } from 'commander';
|
|
21
|
+
import { type Fetch } from './balances.js';
|
|
22
|
+
import { type SuiSendReq, type SuiSendDone } from './lib/sui-grpc-send.js';
|
|
23
|
+
import { type Net, type Obj, type SendPlan, type SendAsset, type SendChain } from './lib/wallet-money.js';
|
|
24
|
+
type Ask = (receiver: string, data: Obj) => Promise<Obj>;
|
|
25
|
+
type VaultKey = {
|
|
26
|
+
chain: string;
|
|
27
|
+
address: string;
|
|
28
|
+
privateKeyHex: string;
|
|
29
|
+
};
|
|
30
|
+
export interface MoneyIO {
|
|
31
|
+
/** One receiver call for this command's --api/--key; throws on a refusal. */
|
|
32
|
+
ask: (opts: {
|
|
33
|
+
api: string;
|
|
34
|
+
key?: string;
|
|
35
|
+
}, receiver: string, data: Obj) => Promise<Obj>;
|
|
36
|
+
workspace: (explicit: string | undefined) => string;
|
|
37
|
+
/** Who this command's key acts as, and where it came from (`machine` = the global login, null when it is the same key). */
|
|
38
|
+
identity?: (opts: {
|
|
39
|
+
api: string;
|
|
40
|
+
key?: string;
|
|
41
|
+
}, which: 'resolved' | 'machine') => Promise<{
|
|
42
|
+
actor?: string;
|
|
43
|
+
from: string;
|
|
44
|
+
local: boolean;
|
|
45
|
+
} | null>;
|
|
46
|
+
unlock: (dir: string) => Promise<{
|
|
47
|
+
keys: VaultKey[];
|
|
48
|
+
} | {
|
|
49
|
+
error: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** The pre-signed relay (`send <to> --payment-tx`) — the form `wallet send` had before. */
|
|
52
|
+
relay: (c: Command, to: string, opts: Obj) => Promise<void>;
|
|
53
|
+
defaultApi: string;
|
|
54
|
+
fetch?: Fetch;
|
|
55
|
+
sleep?: (ms: number) => Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/** fetch with a deadline: a node that hangs is a failed read, not a hung CLI. */
|
|
58
|
+
export declare const deadlineFetch: (ms?: number) => Fetch;
|
|
59
|
+
/** A word safe to paste into a shell: plain words as they are, anything else single-quoted. */
|
|
60
|
+
export declare const shq: (w: string) => string;
|
|
61
|
+
export interface GateArgs {
|
|
62
|
+
env: NodeJS.ProcessEnv;
|
|
63
|
+
yes: boolean;
|
|
64
|
+
interactive: boolean;
|
|
65
|
+
dir: string;
|
|
66
|
+
plan: SendPlan;
|
|
67
|
+
/** `--to-address`: the person's own copy of a resolved recipient. */
|
|
68
|
+
toAddress?: string;
|
|
69
|
+
/** `--workspace`: where the caller's wallet row lives (an agent's: its owner's workspace). */
|
|
70
|
+
workspace?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface GateDeps {
|
|
73
|
+
ask: Ask;
|
|
74
|
+
/** The vault's Sui address from its public authPub — no unlock, no Touch ID. */
|
|
75
|
+
vaultSuiAddress: (dir: string) => string | null;
|
|
76
|
+
confirm: (prompt: string) => Promise<boolean>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Before any key opens. `--yes` skips the prompt ONLY for a vault proven to be an agent's
|
|
80
|
+
* own (agentOwnVault) — never on an env marker alone, which a shell can simply not set, and
|
|
81
|
+
* never for a person's vault: the Keychain read behind "Touch ID" is `security -w`, which
|
|
82
|
+
* the OS may answer silently. A person's vault is opened only after a y/N typed at a terminal,
|
|
83
|
+
* every time. A shell an agent drives never opens anything but its own vault. A recipient
|
|
84
|
+
* found by name must be pinned with --to-address whenever nobody reads it at a prompt.
|
|
85
|
+
*/
|
|
86
|
+
export declare function liveGate(a: GateArgs, d: GateDeps): Promise<{
|
|
87
|
+
ok: true;
|
|
88
|
+
} | {
|
|
89
|
+
ok: false;
|
|
90
|
+
error: string;
|
|
91
|
+
message: string;
|
|
92
|
+
}>;
|
|
93
|
+
export interface EvmSigner {
|
|
94
|
+
signEip1559: (tx: NonNullable<SendPlan['tx']>, key: Uint8Array) => string;
|
|
95
|
+
evmAddressFromKey: (key: Uint8Array) => string;
|
|
96
|
+
evmTxHash: (raw: string) => string;
|
|
97
|
+
hexToBytes: (h: string) => Uint8Array;
|
|
98
|
+
}
|
|
99
|
+
export type { SuiSendReq, SuiSendDone };
|
|
100
|
+
export interface LiveDeps {
|
|
101
|
+
fetch: Fetch;
|
|
102
|
+
unlock: () => Promise<{
|
|
103
|
+
keys: VaultKey[];
|
|
104
|
+
} | {
|
|
105
|
+
error: string;
|
|
106
|
+
}>;
|
|
107
|
+
loadEvm?: () => Promise<EvmSigner>;
|
|
108
|
+
/** A string is a digest alone (the older shape); SuiSendDone carries the gas and the time to finality too. */
|
|
109
|
+
suiSend?: (r: SuiSendReq) => Promise<SuiSendDone | string>;
|
|
110
|
+
sleep?: (ms: number) => Promise<void>;
|
|
111
|
+
/** Receipt polls after an EVM broadcast (each `sleep(5000)` apart). */
|
|
112
|
+
polls?: number;
|
|
113
|
+
}
|
|
114
|
+
export declare const suiSendDefault: (r: SuiSendReq) => Promise<SuiSendDone>;
|
|
115
|
+
/**
|
|
116
|
+
* Sign and broadcast ONE plan. The client check runs first, against the person's own
|
|
117
|
+
* words; then the vault opens; then its key must derive `from`. One broadcast, never
|
|
118
|
+
* re-sent: on a failure after signing the locally computed hash is returned so the
|
|
119
|
+
* person can look before trying again.
|
|
120
|
+
*/
|
|
121
|
+
export declare function executeSend(plan: SendPlan, own: {
|
|
122
|
+
amount: string;
|
|
123
|
+
asset: SendAsset;
|
|
124
|
+
chain: SendChain;
|
|
125
|
+
to: string;
|
|
126
|
+
net: Net;
|
|
127
|
+
suiRpc?: string;
|
|
128
|
+
}, d: LiveDeps): Promise<Obj>;
|
|
129
|
+
export type Who = {
|
|
130
|
+
actor?: string;
|
|
131
|
+
from: string;
|
|
132
|
+
local: boolean;
|
|
133
|
+
};
|
|
134
|
+
export declare const actingLine: (w: Who | null | undefined) => string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* `no_from_address` from a folder-local key that is NOT the global login is the folder changing the
|
|
137
|
+
* answer: name both, and the way out. Any other refusal keeps its own words.
|
|
138
|
+
*/
|
|
139
|
+
export declare function noFromCause(io: MoneyIO, o: {
|
|
140
|
+
api: string;
|
|
141
|
+
key?: string;
|
|
142
|
+
}, me: Who | null | undefined, family: string, workspace: string): Promise<string | undefined>;
|
|
143
|
+
/**
|
|
144
|
+
* Give the dev session's `balances` (src/balances.ts) the network word and the server
|
|
145
|
+
* fan-out. Its explicit-address form on mainnet is left to its own reader, unchanged.
|
|
146
|
+
*/
|
|
147
|
+
export declare function upgradeBalances(balances: Command, io: MoneyIO): void;
|
|
148
|
+
export declare function receiveCmd(io: MoneyIO): Command;
|
|
149
|
+
export declare function requestCmd(io: MoneyIO): Command;
|
|
150
|
+
export declare function sendCmd(io: MoneyIO): Command;
|
|
151
|
+
/** The vault's Sui address from its PUBLIC authPub — read without opening it. */
|
|
152
|
+
export declare function vaultSuiAddressOf(dir: string): string | null;
|