oneie 5.7.4 → 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 +15 -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 +4 -0
- 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/swap-core.d.ts +163 -0
- package/dist/src/lib/swap-core.js +405 -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/swap.d.ts +93 -0
- package/dist/src/swap.js +622 -0
- 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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `one swap` and `one hl` — swap any coin to any coin, or send it into Hyperliquid
|
|
3
|
+
* (text/swap-plan.md § CLI (A)).
|
|
4
|
+
*
|
|
5
|
+
* one swap 0.01 BTC hl dry price (default — R11)
|
|
6
|
+
* one swap 10 USDC@base to hl --live a real deposit address, checked with 1Click
|
|
7
|
+
* one swap status <depositAddress> where is it; --watch polls until it lands
|
|
8
|
+
* one swap assets every alias, chain, decimals and signer
|
|
9
|
+
* one hl balance [0x…] a Hyperliquid account: perps and spot, never summed
|
|
10
|
+
*
|
|
11
|
+
* THIS COMMAND NEVER SIGNS AND HOLDS NO KEY. The server only quotes and reads status. On
|
|
12
|
+
* --live, nothing printed as a send instruction comes from the ONE server unchecked: the CLI
|
|
13
|
+
* reads the quote back from 1Click DIRECTLY (a plain fetch to a fixed host) and runs the client
|
|
14
|
+
* check (R16) against its OWN values — asset ids from its own table, the amount from its own
|
|
15
|
+
* parseUnits, its own slippage — then builds the send line and the wallet URI itself from
|
|
16
|
+
* 1Click's record. A mismatch prints `quote_mismatch` and no send line.
|
|
17
|
+
*
|
|
18
|
+
* Everything goes over ask() — no new @oneie/sdk import (R2). Every exit closes with
|
|
19
|
+
* out(cmd, data): one JSON line under --json, an `error <name>` + the reason otherwise, exit 1
|
|
20
|
+
* on ok:false; `status --watch` exits 2 when it stops at its poll cap.
|
|
21
|
+
*/
|
|
22
|
+
import { Command } from 'commander';
|
|
23
|
+
import { type SwapRow } from './lib/swap-core.js';
|
|
24
|
+
type Obj = Record<string, unknown>;
|
|
25
|
+
/** `--watch` polls every 5 s and stops after 360 polls (30 min) — then exits 2, still not final. */
|
|
26
|
+
export declare const WATCH_INTERVAL_MS = 5000;
|
|
27
|
+
export declare const WATCH_MAX_POLLS = 360;
|
|
28
|
+
export interface SwapDeps {
|
|
29
|
+
/** One receiver through the ask door; returns the resolver's own answer, or a named HTTP refusal. */
|
|
30
|
+
ask(receiver: string, data: Obj, opts?: {
|
|
31
|
+
anonymous?: boolean;
|
|
32
|
+
}): Promise<Obj>;
|
|
33
|
+
/** GET 1Click's own status record, directly — never through ONE. */
|
|
34
|
+
oneClick(url: string): Promise<{
|
|
35
|
+
ok: true;
|
|
36
|
+
body: unknown;
|
|
37
|
+
} | {
|
|
38
|
+
ok: false;
|
|
39
|
+
error: string;
|
|
40
|
+
status?: number;
|
|
41
|
+
}>;
|
|
42
|
+
now(): Date;
|
|
43
|
+
sleep(ms: number): Promise<void>;
|
|
44
|
+
/** A person at a TTY, not --json, not an agent shell: only then is a [y/N] asked. */
|
|
45
|
+
interactive: boolean;
|
|
46
|
+
confirm(question: string): Promise<boolean>;
|
|
47
|
+
/** Human lines (suppressed under --json by the caller). */
|
|
48
|
+
say(lines: string[]): void;
|
|
49
|
+
}
|
|
50
|
+
export interface Result {
|
|
51
|
+
data: Obj;
|
|
52
|
+
exitCode?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface SwapArgs {
|
|
55
|
+
words: string[];
|
|
56
|
+
live?: boolean;
|
|
57
|
+
sendTo?: string;
|
|
58
|
+
exactOut?: boolean;
|
|
59
|
+
slippage?: string;
|
|
60
|
+
mine?: string;
|
|
61
|
+
}
|
|
62
|
+
export declare function runSwap(args: SwapArgs, deps: SwapDeps): Promise<Result>;
|
|
63
|
+
/** The --mine entries shaped like an address on this chain (several = the person must pick). */
|
|
64
|
+
export declare function mineOn(mine: readonly string[], chain: SwapRow['chain']): string[];
|
|
65
|
+
export interface StatusArgs {
|
|
66
|
+
depositAddress: string;
|
|
67
|
+
tx?: string;
|
|
68
|
+
watch?: boolean;
|
|
69
|
+
mine?: string;
|
|
70
|
+
/** The slippage you asked for when the address was minted (default 100); the record must match. */
|
|
71
|
+
slippage?: string;
|
|
72
|
+
/** The amount you asked to swap, in the from asset. The record must match it, or no send line (R18). */
|
|
73
|
+
amount?: string;
|
|
74
|
+
maxPolls?: number;
|
|
75
|
+
}
|
|
76
|
+
export declare function runStatus(args: StatusArgs, deps: SwapDeps): Promise<Result>;
|
|
77
|
+
/** The server's whole table, read from an `unknown_asset` refusal (R2 — no assets receiver). */
|
|
78
|
+
export declare function runAssets(deps: SwapDeps): Promise<Result>;
|
|
79
|
+
export interface HlArgs {
|
|
80
|
+
address?: string;
|
|
81
|
+
testnet?: boolean;
|
|
82
|
+
actor?: string;
|
|
83
|
+
}
|
|
84
|
+
export declare function runHlBalance(args: HlArgs, deps: SwapDeps): Promise<Result>;
|
|
85
|
+
/** Close the loop: out() for --json and the error head, the reason lines on stderr, the exit code last. */
|
|
86
|
+
export declare function emit(cmd: Command, res: Result): void;
|
|
87
|
+
interface Common {
|
|
88
|
+
api?: string;
|
|
89
|
+
key?: string;
|
|
90
|
+
}
|
|
91
|
+
export declare function swapCmd(deps?: (cmd: Command, o: Common) => SwapDeps): Command;
|
|
92
|
+
export declare function hlCmd(deps?: (cmd: Command, o: Common) => SwapDeps): Command;
|
|
93
|
+
export {};
|