oneie 5.8.0 → 5.8.1
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/dist/package.json +7 -8
- package/dist/src/age-yefbe8pe.js +1 -0
- package/dist/src/evm-tx-ee2q0e3w.js +1 -0
- package/dist/src/hl-run-tgrkrk69.js +1 -0
- package/dist/src/index-0rj9wdk9.js +4 -0
- package/dist/src/index-91y484c2.js +2052 -0
- package/dist/src/index-940y3rnv.js +12 -0
- package/dist/src/index.js +1047 -134
- package/dist/src/message-key-db1xjdkw.js +1 -0
- package/dist/src/message-lock-5vr8079x.js +5 -0
- package/dist/src/sweep-order-c2p6rk8c.js +1 -0
- package/dist/src/sweep-runner-t68xe7vx.js +1 -0
- package/package.json +7 -8
- package/dist/src/agent.d.ts +0 -75
- package/dist/src/agent.js +0 -1334
- package/dist/src/agentverse.d.ts +0 -26
- package/dist/src/agentverse.js +0 -171
- package/dist/src/args.d.ts +0 -9
- package/dist/src/args.js +0 -61
- package/dist/src/auth.d.ts +0 -6
- package/dist/src/auth.js +0 -121
- package/dist/src/balances.d.ts +0 -89
- package/dist/src/balances.js +0 -202
- package/dist/src/banner.d.ts +0 -1
- package/dist/src/banner.js +0 -17
- package/dist/src/broadcast.d.ts +0 -8
- package/dist/src/broadcast.js +0 -175
- package/dist/src/catalog.d.ts +0 -12
- package/dist/src/catalog.js +0 -76
- package/dist/src/ceiling.d.ts +0 -36
- package/dist/src/ceiling.js +0 -189
- package/dist/src/chat.d.ts +0 -2
- package/dist/src/chat.js +0 -92
- package/dist/src/check.d.ts +0 -11
- package/dist/src/check.js +0 -53
- package/dist/src/client.d.ts +0 -5
- package/dist/src/client.js +0 -157
- package/dist/src/compiler.d.ts +0 -36
- package/dist/src/compiler.js +0 -366
- package/dist/src/config.d.ts +0 -24
- package/dist/src/config.js +0 -70
- package/dist/src/connect.d.ts +0 -2
- package/dist/src/connect.js +0 -64
- package/dist/src/coordinate.d.ts +0 -3
- package/dist/src/coordinate.js +0 -58
- package/dist/src/create.d.ts +0 -2
- package/dist/src/create.js +0 -113
- package/dist/src/credits.d.ts +0 -29
- package/dist/src/credits.js +0 -88
- package/dist/src/deploy.d.ts +0 -2
- package/dist/src/deploy.js +0 -19
- package/dist/src/dev.d.ts +0 -2
- package/dist/src/dev.js +0 -75
- package/dist/src/device-flow.d.ts +0 -57
- package/dist/src/device-flow.js +0 -173
- package/dist/src/doctor.d.ts +0 -26
- package/dist/src/doctor.js +0 -146
- package/dist/src/draw.d.ts +0 -18
- package/dist/src/draw.js +0 -156
- package/dist/src/endpoint.d.ts +0 -2
- package/dist/src/endpoint.js +0 -250
- package/dist/src/env.d.ts +0 -3
- package/dist/src/env.js +0 -37
- package/dist/src/eval.d.ts +0 -2
- package/dist/src/eval.js +0 -43
- package/dist/src/fn.d.ts +0 -2
- package/dist/src/fn.js +0 -70
- package/dist/src/group.d.ts +0 -2
- package/dist/src/group.js +0 -117
- package/dist/src/hl-run.d.ts +0 -119
- package/dist/src/hl-run.js +0 -480
- package/dist/src/hl.d.ts +0 -17
- package/dist/src/hl.js +0 -148
- package/dist/src/index.d.ts +0 -2
- package/dist/src/init.d.ts +0 -76
- package/dist/src/init.js +0 -278
- package/dist/src/join.d.ts +0 -11
- package/dist/src/join.js +0 -297
- package/dist/src/key-publish.d.ts +0 -40
- package/dist/src/key-publish.js +0 -232
- package/dist/src/key-seal.d.ts +0 -21
- package/dist/src/key-seal.js +0 -142
- package/dist/src/key-sweep.d.ts +0 -93
- package/dist/src/key-sweep.js +0 -270
- package/dist/src/key.d.ts +0 -26
- package/dist/src/key.js +0 -338
- package/dist/src/lib/age-plugin.d.ts +0 -51
- package/dist/src/lib/age-plugin.js +0 -130
- package/dist/src/lib/agent-env.d.ts +0 -12
- package/dist/src/lib/agent-env.js +0 -48
- package/dist/src/lib/api-path.d.ts +0 -2
- package/dist/src/lib/api-path.js +0 -40
- package/dist/src/lib/asker.d.ts +0 -34
- package/dist/src/lib/asker.js +0 -126
- package/dist/src/lib/check-words.d.ts +0 -57
- package/dist/src/lib/check-words.js +0 -144
- package/dist/src/lib/client.d.ts +0 -20
- package/dist/src/lib/client.js +0 -71
- package/dist/src/lib/env-sealed.d.ts +0 -53
- package/dist/src/lib/env-sealed.js +0 -184
- package/dist/src/lib/flow-tag.d.ts +0 -86
- package/dist/src/lib/flow-tag.js +0 -230
- package/dist/src/lib/hl-core/actions.d.ts +0 -99
- package/dist/src/lib/hl-core/actions.js +0 -69
- package/dist/src/lib/hl-core/eip712.d.ts +0 -33
- package/dist/src/lib/hl-core/eip712.js +0 -107
- package/dist/src/lib/hl-core/errors.d.ts +0 -10
- package/dist/src/lib/hl-core/errors.js +0 -15
- package/dist/src/lib/hl-core/exchange.d.ts +0 -24
- package/dist/src/lib/hl-core/exchange.js +0 -47
- package/dist/src/lib/hl-core/index.d.ts +0 -13
- package/dist/src/lib/hl-core/index.js +0 -14
- package/dist/src/lib/hl-core/meta.d.ts +0 -57
- package/dist/src/lib/hl-core/meta.js +0 -110
- package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
- package/dist/src/lib/hl-core/msgpack.js +0 -136
- package/dist/src/lib/hl-core/net.d.ts +0 -2
- package/dist/src/lib/hl-core/net.js +0 -7
- package/dist/src/lib/hl-core/signing.d.ts +0 -103
- package/dist/src/lib/hl-core/signing.js +0 -295
- package/dist/src/lib/hl-core/wire.d.ts +0 -34
- package/dist/src/lib/hl-core/wire.js +0 -81
- package/dist/src/lib/invoked-as.d.ts +0 -2
- package/dist/src/lib/invoked-as.js +0 -24
- package/dist/src/lib/journey-words.d.ts +0 -84
- package/dist/src/lib/journey-words.js +0 -363
- package/dist/src/lib/journey.d.ts +0 -150
- package/dist/src/lib/journey.js +0 -264
- package/dist/src/lib/key-receipt.d.ts +0 -48
- package/dist/src/lib/key-receipt.js +0 -116
- package/dist/src/lib/key-source.d.ts +0 -9
- package/dist/src/lib/key-source.js +0 -33
- package/dist/src/lib/keyfile.d.ts +0 -136
- package/dist/src/lib/keyfile.js +0 -397
- package/dist/src/lib/launch-claude.d.ts +0 -5
- package/dist/src/lib/launch-claude.js +0 -45
- package/dist/src/lib/lock-lookup.d.ts +0 -40
- package/dist/src/lib/lock-lookup.js +0 -92
- package/dist/src/lib/message-seal.d.ts +0 -63
- package/dist/src/lib/message-seal.js +0 -150
- package/dist/src/lib/net-choice.d.ts +0 -28
- package/dist/src/lib/net-choice.js +0 -72
- package/dist/src/lib/network.d.ts +0 -22
- package/dist/src/lib/network.js +0 -50
- package/dist/src/lib/next-words.d.ts +0 -105
- package/dist/src/lib/next-words.js +0 -298
- package/dist/src/lib/paths.d.ts +0 -41
- package/dist/src/lib/paths.js +0 -91
- package/dist/src/lib/plan-draw.d.ts +0 -56
- package/dist/src/lib/plan-draw.js +0 -219
- package/dist/src/lib/plan-live.d.ts +0 -20
- package/dist/src/lib/plan-live.js +0 -192
- package/dist/src/lib/qr.d.ts +0 -21
- package/dist/src/lib/qr.js +0 -402
- package/dist/src/lib/roster.d.ts +0 -20
- package/dist/src/lib/roster.js +0 -79
- package/dist/src/lib/sale-card.d.ts +0 -117
- package/dist/src/lib/sale-card.js +0 -261
- package/dist/src/lib/shop-init.d.ts +0 -62
- package/dist/src/lib/shop-init.js +0 -63
- package/dist/src/lib/sui-grpc-send.d.ts +0 -90
- package/dist/src/lib/sui-grpc-send.js +0 -128
- package/dist/src/lib/swap-core.d.ts +0 -163
- package/dist/src/lib/swap-core.js +0 -405
- package/dist/src/lib/tasks-digest.d.ts +0 -66
- package/dist/src/lib/tasks-digest.js +0 -200
- package/dist/src/lib/tasks-graph.d.ts +0 -79
- package/dist/src/lib/tasks-graph.js +0 -463
- package/dist/src/lib/tasks-lens.d.ts +0 -31
- package/dist/src/lib/tasks-lens.js +0 -47
- package/dist/src/lib/tasks-next.d.ts +0 -25
- package/dist/src/lib/tasks-next.js +0 -103
- package/dist/src/lib/tasks-prove.d.ts +0 -15
- package/dist/src/lib/tasks-prove.js +0 -68
- package/dist/src/lib/tasks-route.d.ts +0 -29
- package/dist/src/lib/tasks-route.js +0 -151
- package/dist/src/lib/tasks-score.d.ts +0 -36
- package/dist/src/lib/tasks-score.js +0 -152
- package/dist/src/lib/tasks-workspace.d.ts +0 -18
- package/dist/src/lib/tasks-workspace.js +0 -73
- package/dist/src/lib/timed-fetch.d.ts +0 -33
- package/dist/src/lib/timed-fetch.js +0 -59
- package/dist/src/lib/vault-read.d.ts +0 -24
- package/dist/src/lib/vault-read.js +0 -77
- package/dist/src/lib/vaultfile.d.ts +0 -103
- package/dist/src/lib/vaultfile.js +0 -249
- package/dist/src/lib/wallet-money.d.ts +0 -222
- package/dist/src/lib/wallet-money.js +0 -578
- package/dist/src/lib/wallet-request.d.ts +0 -50
- package/dist/src/lib/wallet-request.js +0 -86
- package/dist/src/links.d.ts +0 -5
- package/dist/src/links.js +0 -45
- package/dist/src/media.d.ts +0 -29
- package/dist/src/media.js +0 -487
- package/dist/src/message-receipt.d.ts +0 -25
- package/dist/src/message-receipt.js +0 -71
- package/dist/src/message.d.ts +0 -13
- package/dist/src/message.js +0 -92
- package/dist/src/move.d.ts +0 -36
- package/dist/src/move.js +0 -152
- package/dist/src/network-cmd.d.ts +0 -17
- package/dist/src/network-cmd.js +0 -74
- package/dist/src/next.d.ts +0 -12
- package/dist/src/next.js +0 -67
- package/dist/src/onboard.d.ts +0 -16
- package/dist/src/onboard.js +0 -149
- package/dist/src/plugin.d.ts +0 -2
- package/dist/src/plugin.js +0 -193
- package/dist/src/push.d.ts +0 -2
- package/dist/src/push.js +0 -115
- package/dist/src/render.d.ts +0 -21
- package/dist/src/render.js +0 -32
- package/dist/src/secrets-device.d.ts +0 -32
- package/dist/src/secrets-device.js +0 -127
- package/dist/src/secrets-give.d.ts +0 -125
- package/dist/src/secrets-give.js +0 -236
- package/dist/src/secrets-list.d.ts +0 -27
- package/dist/src/secrets-list.js +0 -84
- package/dist/src/secrets-run.d.ts +0 -31
- package/dist/src/secrets-run.js +0 -182
- package/dist/src/secrets.d.ts +0 -33
- package/dist/src/secrets.js +0 -200
- package/dist/src/setup.d.ts +0 -6
- package/dist/src/setup.js +0 -127
- package/dist/src/ship.d.ts +0 -2
- package/dist/src/ship.js +0 -18
- package/dist/src/shop-buy.d.ts +0 -16
- package/dist/src/shop-buy.js +0 -101
- package/dist/src/shop.d.ts +0 -10
- package/dist/src/shop.js +0 -112
- package/dist/src/skill-parser.d.ts +0 -14
- package/dist/src/skill-parser.js +0 -113
- package/dist/src/skill.d.ts +0 -2
- package/dist/src/skill.js +0 -493
- package/dist/src/slug.d.ts +0 -2
- package/dist/src/slug.js +0 -6
- package/dist/src/social.d.ts +0 -2
- package/dist/src/social.js +0 -106
- package/dist/src/staff.d.ts +0 -2
- package/dist/src/staff.js +0 -104
- package/dist/src/start.d.ts +0 -27
- package/dist/src/start.js +0 -225
- package/dist/src/status.d.ts +0 -2
- package/dist/src/status.js +0 -52
- package/dist/src/substrate.d.ts +0 -2
- package/dist/src/substrate.js +0 -258
- package/dist/src/swap.d.ts +0 -93
- package/dist/src/swap.js +0 -622
- package/dist/src/tasks.d.ts +0 -2
- package/dist/src/tasks.js +0 -743
- package/dist/src/templates.d.ts +0 -1
- package/dist/src/templates.js +0 -213
- package/dist/src/thread.d.ts +0 -2
- package/dist/src/thread.js +0 -52
- package/dist/src/trade.d.ts +0 -2
- package/dist/src/trade.js +0 -91
- package/dist/src/trail.d.ts +0 -2
- package/dist/src/trail.js +0 -41
- package/dist/src/validate.d.ts +0 -13
- package/dist/src/validate.js +0 -35
- package/dist/src/wallet-money.d.ts +0 -158
- package/dist/src/wallet-money.js +0 -664
- package/dist/src/wallet.d.ts +0 -169
- package/dist/src/wallet.js +0 -973
- package/dist/src/workflow.d.ts +0 -2
- package/dist/src/workflow.js +0 -169
- package/dist/src/write.d.ts +0 -43
- package/dist/src/write.js +0 -180
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vault-read.ts — what the owner's vault says about a sealed file (text/secrets-plan.md
|
|
3
|
-
* Interface Contract #7). `one run` asks it one question: "which sha256 of `.env.sealed`
|
|
4
|
-
* do you know?" — the `sealed_hash` the owner set with `set_sealed_hash` (C14).
|
|
5
|
-
*
|
|
6
|
-
* `vaultLoaders.read` is the seam, swapped in tests like message-seal.ts's `loaders`.
|
|
7
|
-
* The default reads:
|
|
8
|
-
* • ONE_SECRETS_VAULT_FIXTURE — a JSON file `{ "<vaultId>": { "sealedHash": "<64 hex>" } }`
|
|
9
|
-
* (the vault contract is not on testnet yet), else
|
|
10
|
-
* • Sui JSON-RPC `sui_getObject` (showContent) on ONE_SUI_RPC, 10 s deadline, reading the
|
|
11
|
-
* vault's `sealed_hash` (vector<u8>, 32 bytes) as lowercase hex.
|
|
12
|
-
*
|
|
13
|
-
* A vault that has no hash set is `{ sealedHash: null }`; a read that fails, times out or
|
|
14
|
-
* returns something that is not 32 bytes is a Fail. The caller refuses on both.
|
|
15
|
-
*/
|
|
16
|
-
import { readFileSync } from 'node:fs';
|
|
17
|
-
const DEFAULT_RPC = 'https://fullnode.testnet.sui.io:443';
|
|
18
|
-
const DEADLINE_MS = 10_000;
|
|
19
|
-
const HEX64 = /^[0-9a-f]{64}$/;
|
|
20
|
-
const cannotVerify = (error) => ({ ok: false, error, code: 'cannot_verify' });
|
|
21
|
-
function fromFixture(path, id) {
|
|
22
|
-
let doc;
|
|
23
|
-
try {
|
|
24
|
-
doc = JSON.parse(readFileSync(path, 'utf8'));
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return cannotVerify(`cannot read the vault fixture ${path}`);
|
|
28
|
-
}
|
|
29
|
-
const row = doc && typeof doc === 'object' ? doc[id] : undefined;
|
|
30
|
-
const h = row && typeof row === 'object' ? row.sealedHash : undefined;
|
|
31
|
-
if (h === undefined || h === null || h === '')
|
|
32
|
-
return { sealedHash: null };
|
|
33
|
-
if (typeof h !== 'string' || !HEX64.test(h.toLowerCase()))
|
|
34
|
-
return cannotVerify('the vault fixture sealedHash is not 64 hex characters');
|
|
35
|
-
return { sealedHash: h.toLowerCase() };
|
|
36
|
-
}
|
|
37
|
-
async function fromSui(id) {
|
|
38
|
-
if (!/^0x[0-9a-fA-F]{1,64}$/.test(id))
|
|
39
|
-
return cannotVerify('the vault id in the file header is not a Sui object id (0x…)');
|
|
40
|
-
const rpc = process.env.ONE_SUI_RPC?.trim() || DEFAULT_RPC;
|
|
41
|
-
const ctl = new AbortController();
|
|
42
|
-
const timer = setTimeout(() => ctl.abort(), DEADLINE_MS);
|
|
43
|
-
try {
|
|
44
|
-
const res = await fetch(rpc, {
|
|
45
|
-
method: 'POST',
|
|
46
|
-
headers: { 'content-type': 'application/json' },
|
|
47
|
-
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'sui_getObject', params: [id, { showContent: true }] }),
|
|
48
|
-
signal: ctl.signal,
|
|
49
|
-
});
|
|
50
|
-
if (!res.ok)
|
|
51
|
-
return cannotVerify(`the Sui node answered ${res.status}`);
|
|
52
|
-
const body = (await res.json());
|
|
53
|
-
const raw = body.result?.data?.content?.fields?.sealed_hash;
|
|
54
|
-
if (raw === undefined || raw === null)
|
|
55
|
-
return cannotVerify('that object has no sealed_hash field — it is not a vault');
|
|
56
|
-
if (!Array.isArray(raw))
|
|
57
|
-
return cannotVerify('the vault sealed_hash is not a byte vector');
|
|
58
|
-
if (raw.length === 0)
|
|
59
|
-
return { sealedHash: null }; // the owner has not set one
|
|
60
|
-
if (raw.length !== 32 || !raw.every((b) => Number.isInteger(b) && b >= 0 && b <= 255))
|
|
61
|
-
return cannotVerify('the vault sealed_hash is not 32 bytes');
|
|
62
|
-
return { sealedHash: Buffer.from(raw).toString('hex') };
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
return cannotVerify(e?.name === 'AbortError' ? 'the vault read timed out' : 'the vault read failed');
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
clearTimeout(timer);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async function defaultRead(id) {
|
|
72
|
-
const fixture = process.env.ONE_SECRETS_VAULT_FIXTURE?.trim();
|
|
73
|
-
return fixture ? fromFixture(fixture, id) : fromSui(id);
|
|
74
|
-
}
|
|
75
|
-
/** Swappable in tests; the default is the fixture file or the Sui node. */
|
|
76
|
-
export const vaultLoaders = { read: defaultRead };
|
|
77
|
-
export const readVault = (id) => vaultLoaders.read(id);
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The sealed envelope, as far as THIS module is concerned.
|
|
3
|
-
*
|
|
4
|
-
* Deliberately a local structural type rather than an import of
|
|
5
|
-
* `@oneie/sdk/vault-file`'s `VaultBlob`. Nothing here seals or opens anything —
|
|
6
|
-
* it moves an opaque JSON object on and off disk and reads exactly three fields
|
|
7
|
-
* of it. Importing the crypto module to borrow a type would drag Argon2id into
|
|
8
|
-
* the dependency graph of a file that never derives a key, and would couple the
|
|
9
|
-
* CLI's two-runtime-dep budget to a subpath that has to be linked before it
|
|
10
|
-
* resolves. The full type lives with the code that actually uses it.
|
|
11
|
-
*/
|
|
12
|
-
export interface SealedVault {
|
|
13
|
-
v: 1;
|
|
14
|
-
wrap: 'passphrase' | 'keychain';
|
|
15
|
-
authPub?: string;
|
|
16
|
-
[k: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
export declare const VAULT_FILE_NAME = "wallet.json";
|
|
19
|
-
export interface VaultWriteResult {
|
|
20
|
-
ok: boolean;
|
|
21
|
-
path?: string;
|
|
22
|
-
error?: string;
|
|
23
|
-
}
|
|
24
|
-
/** Where a project's vault lives. */
|
|
25
|
-
export declare function vaultPath(dir: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Write the sealed vault. Ignore entry FIRST — same order, same reason as the
|
|
28
|
-
* API key: a secret written before it is ignored is exposed for the width of the
|
|
29
|
-
* gap, and the gap is where `git add -A` lives. Refuses rather than writing an
|
|
30
|
-
* unignorable credential.
|
|
31
|
-
*/
|
|
32
|
-
export declare function writeVaultFolder(dir: string, blob: SealedVault): VaultWriteResult;
|
|
33
|
-
/** Read a sealed vault, or null when the folder has none. Never throws. */
|
|
34
|
-
export declare function readVaultFolder(dir: string): SealedVault | null;
|
|
35
|
-
/**
|
|
36
|
-
* The Keychain service name a vault's wrapping secret is stored under.
|
|
37
|
-
*
|
|
38
|
-
* Scoped by the vault's public identity rather than a constant, so two projects
|
|
39
|
-
* on one machine do not fight over one entry — and so deleting one wallet's
|
|
40
|
-
* secret cannot silently unlock another's.
|
|
41
|
-
*/
|
|
42
|
-
export declare function keychainService(authPub: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* The vault's passphrase sealed to a Secure Enclave key (`age-plugin-se`, access control
|
|
45
|
-
* `current-biometry`), and that key's identity file. Both sit BESIDE wallet.json, which is
|
|
46
|
-
* never rewritten: `wrap` is bound into the vault's AAD, so the vault keeps saying
|
|
47
|
-
* `keychain` and only the holder of its passphrase changes. When the sealed file exists,
|
|
48
|
-
* unlock opens it through the enclave and never reads Keychain.
|
|
49
|
-
*
|
|
50
|
-
* Why: a `security add-generic-password` item opened with no prompt for any process
|
|
51
|
-
* running as the user (measured 2026-11-12, task:01a1cd90d9ec7b99cb18fd33). An enclave key
|
|
52
|
-
* with a biometry rule cannot be used without the finger — the chip refuses, not a policy.
|
|
53
|
-
*/
|
|
54
|
-
export declare function seSealPath(dir: string): string;
|
|
55
|
-
export declare function seIdentityPath(dir: string): string;
|
|
56
|
-
/** Delete the vault's Keychain copy. Absent already counts as deleted. */
|
|
57
|
-
export declare function keychainDelete(authPub: string): KeychainResult;
|
|
58
|
-
export type KeychainResult = {
|
|
59
|
-
ok: true;
|
|
60
|
-
value?: string;
|
|
61
|
-
} | {
|
|
62
|
-
ok: false;
|
|
63
|
-
error: string;
|
|
64
|
-
};
|
|
65
|
-
/** macOS only — every other platform gets a clear refusal, never a silent no-op. */
|
|
66
|
-
export declare function keychainAvailable(): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Store the wrapping secret in Apple Keychain, gated by the user's login
|
|
69
|
-
* keychain ACL.
|
|
70
|
-
*
|
|
71
|
-
* `-w` takes the secret on argv, which is normally the thing to avoid — argv is
|
|
72
|
-
* world-readable in `ps`. It is accepted HERE because `security` offers no stdin
|
|
73
|
-
* form for add-generic-password, and the exposure is a race against a local
|
|
74
|
-
* process that could read the unlocked vault anyway. The mnemonic itself never
|
|
75
|
-
* appears on argv; only this random wrapper does, and it is useless without the
|
|
76
|
-
* file.
|
|
77
|
-
*/
|
|
78
|
-
export declare function keychainStore(authPub: string, secret: string): KeychainResult;
|
|
79
|
-
/** Read the wrapping secret back. This is the call that prompts for Touch ID. */
|
|
80
|
-
export declare function keychainRead(authPub: string): KeychainResult;
|
|
81
|
-
/**
|
|
82
|
-
* The 24 words laid out for transcription, numbered.
|
|
83
|
-
*
|
|
84
|
-
* Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
|
|
85
|
-
* words is trivially copied out of sequence — a wallet that restores to the
|
|
86
|
-
* wrong addresses with no error. Pure, so it is testable without a wallet.
|
|
87
|
-
*
|
|
88
|
-
* The derivation is printed, and named in the restore command, because the words
|
|
89
|
-
* carry no marker of their own: `wallet new --recover` with no `--derivation`
|
|
90
|
-
* recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
|
|
91
|
-
* `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
|
|
92
|
-
* different, empty wallet with no error. The paper alone must carry what restore
|
|
93
|
-
* needs, so the derivation is required here, not defaulted.
|
|
94
|
-
*
|
|
95
|
-
* `cli` is how the restore command is spelled (`one` or `npx oneie`, see
|
|
96
|
-
* invoked-as.ts) so the line runs as printed. The restore line itself is a bare
|
|
97
|
-
* command — nothing trailing — so it can be copied, and parsed by the test that
|
|
98
|
-
* follows it back to the same addresses (tests/paper-restore.test.ts).
|
|
99
|
-
*/
|
|
100
|
-
export declare function paperSheet(mnemonic: string, addresses: Record<string, string>, restore: {
|
|
101
|
-
derivation: 'v1' | 'v2';
|
|
102
|
-
cli: string;
|
|
103
|
-
}): string;
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vaultfile.ts — the encrypted wallet folder, and the three ways out of it.
|
|
3
|
-
*
|
|
4
|
-
* `.one/wallet.json` is a sealed 24-word mnemonic. From it `recoverWallet()`
|
|
5
|
-
* derives all four chain keys offline, so the file IS the wallet: lose it and
|
|
6
|
-
* the phrase and the money is gone; copy it and the copy is equally the wallet.
|
|
7
|
-
* That is the property the three export paths below exist to serve.
|
|
8
|
-
*
|
|
9
|
-
* THE KEYS NEVER LEAVE THIS MACHINE unless the human deliberately moves them,
|
|
10
|
-
* and there are exactly three doors:
|
|
11
|
-
* · PAPER — the 24 words, printed once, offline forever.
|
|
12
|
-
* · KEYCHAIN — Apple Keychain (or any OS keystore) holds the WRAPPING secret,
|
|
13
|
-
* released by biometrics. The vault stays on disk.
|
|
14
|
-
* · ADDRESSES — public only. `wallet register` uploads these to be paid at;
|
|
15
|
-
* they are not key material and never were.
|
|
16
|
-
* Nothing else is an export. In particular nothing here ever posts a mnemonic,
|
|
17
|
-
* a private key, or a passphrase to a server — there is no code path for it.
|
|
18
|
-
*
|
|
19
|
-
* WHAT THE SECURE ENCLAVE ACTUALLY DOES, because the difference matters and is
|
|
20
|
-
* easy to oversell: the SE holds NIST P-256 keys ONLY. It cannot hold the
|
|
21
|
-
* ed25519 (Sui, Solana) or secp256k1 (EVM, BTC) keys this wallet is made of. So
|
|
22
|
-
* "open and close it with your biometrics" is TRUE — Touch ID releases the
|
|
23
|
-
* wrapping secret that decrypts the vault — while "your keys live in the Secure
|
|
24
|
-
* Enclave" is FALSE. Once unlocked, the chain keys are in this process's memory
|
|
25
|
-
* like any other program's. That is a real and useful boundary; it is not a
|
|
26
|
-
* hardware signer, and the code says so where a reader will meet it.
|
|
27
|
-
*
|
|
28
|
-
* The write ceremony is `keyfile.ts`'s, reused rather than re-derived: ignore
|
|
29
|
-
* entry before the file, 0700 directory, O_NOFOLLOW writes, symlink refusal.
|
|
30
|
-
* A second implementation of that is a second thing to get wrong.
|
|
31
|
-
*/
|
|
32
|
-
import { existsSync, readFileSync, lstatSync } from 'node:fs';
|
|
33
|
-
import { dirname, join } from 'node:path';
|
|
34
|
-
import { spawnSync } from 'node:child_process';
|
|
35
|
-
import { ensureIgnored, KEY_DIR_NAME, LEGACY_KEY_DIR_NAME, writeSecret, canonicalDir } from './keyfile.js';
|
|
36
|
-
export const VAULT_FILE_NAME = 'wallet.json';
|
|
37
|
-
/** Where a project's vault lives. */
|
|
38
|
-
export function vaultPath(dir) {
|
|
39
|
-
const root = canonicalDir(dir);
|
|
40
|
-
const current = join(root, KEY_DIR_NAME, VAULT_FILE_NAME);
|
|
41
|
-
if (existsSync(current))
|
|
42
|
-
return current;
|
|
43
|
-
const legacy = join(root, LEGACY_KEY_DIR_NAME, VAULT_FILE_NAME);
|
|
44
|
-
// A vault minted before the rename still opens. New ones are always written
|
|
45
|
-
// to the current directory — vaultPath is used for BOTH, so the fallback only
|
|
46
|
-
// wins when a legacy file is actually there.
|
|
47
|
-
return existsSync(legacy) ? legacy : current;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Write the sealed vault. Ignore entry FIRST — same order, same reason as the
|
|
51
|
-
* API key: a secret written before it is ignored is exposed for the width of the
|
|
52
|
-
* gap, and the gap is where `git add -A` lives. Refuses rather than writing an
|
|
53
|
-
* unignorable credential.
|
|
54
|
-
*/
|
|
55
|
-
export function writeVaultFolder(dir, blob) {
|
|
56
|
-
const root = canonicalDir(dir);
|
|
57
|
-
if (!existsSync(root))
|
|
58
|
-
return { ok: false, error: `no such directory: ${root}` };
|
|
59
|
-
if (!ensureIgnored(root)) {
|
|
60
|
-
return { ok: false, error: 'could not write .gitignore — refusing to write a wallet git can see' };
|
|
61
|
-
}
|
|
62
|
-
const path = vaultPath(root);
|
|
63
|
-
if (existsSync(path)) {
|
|
64
|
-
// Overwriting a vault destroys a wallet. There is no undo and no backup,
|
|
65
|
-
// so this refuses and makes the operator move the old one by hand.
|
|
66
|
-
return { ok: false, error: `${path} already exists — move it aside first; overwriting destroys the wallet it holds` };
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
writeSecret(path, JSON.stringify(blob, null, 2) + '\n');
|
|
70
|
-
return { ok: true, path };
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
return { ok: false, error: `write failed: ${err.message}` };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/** Read a sealed vault, or null when the folder has none. Never throws. */
|
|
77
|
-
export function readVaultFolder(dir) {
|
|
78
|
-
const path = vaultPath(dir);
|
|
79
|
-
if (!existsSync(path))
|
|
80
|
-
return null;
|
|
81
|
-
try {
|
|
82
|
-
// lstat, not stat: a symlinked vault is refused rather than followed to a
|
|
83
|
-
// file whose mode looks fine.
|
|
84
|
-
const st = lstatSync(path);
|
|
85
|
-
if (st.isSymbolicLink())
|
|
86
|
-
return null;
|
|
87
|
-
if ((st.mode & 0o077) !== 0)
|
|
88
|
-
return null;
|
|
89
|
-
const blob = JSON.parse(readFileSync(path, 'utf8'));
|
|
90
|
-
return blob?.v === 1 ? blob : null;
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// ─── Keychain ────────────────────────────────────────────────────────────────
|
|
97
|
-
/**
|
|
98
|
-
* The Keychain service name a vault's wrapping secret is stored under.
|
|
99
|
-
*
|
|
100
|
-
* Scoped by the vault's public identity rather than a constant, so two projects
|
|
101
|
-
* on one machine do not fight over one entry — and so deleting one wallet's
|
|
102
|
-
* secret cannot silently unlock another's.
|
|
103
|
-
*/
|
|
104
|
-
export function keychainService(authPub) {
|
|
105
|
-
return `one.ie.wallet.${authPub}`;
|
|
106
|
-
}
|
|
107
|
-
// ─── Secure Enclave wrap (2026-11-12) ───────────────────────────────────────
|
|
108
|
-
/**
|
|
109
|
-
* The vault's passphrase sealed to a Secure Enclave key (`age-plugin-se`, access control
|
|
110
|
-
* `current-biometry`), and that key's identity file. Both sit BESIDE wallet.json, which is
|
|
111
|
-
* never rewritten: `wrap` is bound into the vault's AAD, so the vault keeps saying
|
|
112
|
-
* `keychain` and only the holder of its passphrase changes. When the sealed file exists,
|
|
113
|
-
* unlock opens it through the enclave and never reads Keychain.
|
|
114
|
-
*
|
|
115
|
-
* Why: a `security add-generic-password` item opened with no prompt for any process
|
|
116
|
-
* running as the user (measured 2026-11-12, task:01a1cd90d9ec7b99cb18fd33). An enclave key
|
|
117
|
-
* with a biometry rule cannot be used without the finger — the chip refuses, not a policy.
|
|
118
|
-
*/
|
|
119
|
-
export function seSealPath(dir) {
|
|
120
|
-
return join(dirname(vaultPath(dir)), 'passphrase.se.age');
|
|
121
|
-
}
|
|
122
|
-
export function seIdentityPath(dir) {
|
|
123
|
-
return join(dirname(vaultPath(dir)), 'se-identity.txt');
|
|
124
|
-
}
|
|
125
|
-
/** Delete the vault's Keychain copy. Absent already counts as deleted. */
|
|
126
|
-
export function keychainDelete(authPub) {
|
|
127
|
-
if (!keychainAvailable())
|
|
128
|
-
return { ok: false, error: 'Keychain is macOS-only' };
|
|
129
|
-
const r = spawnSync('security', ['delete-generic-password', '-a', process.env.USER ?? 'one', '-s', keychainService(authPub)], { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
130
|
-
if (r.status === 0 || r.status === 44)
|
|
131
|
-
return { ok: true };
|
|
132
|
-
return { ok: false, error: 'security delete-generic-password failed' };
|
|
133
|
-
}
|
|
134
|
-
/** macOS only — every other platform gets a clear refusal, never a silent no-op. */
|
|
135
|
-
export function keychainAvailable() {
|
|
136
|
-
return process.platform === 'darwin' && spawnSync('which', ['security']).status === 0;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Store the wrapping secret in Apple Keychain, gated by the user's login
|
|
140
|
-
* keychain ACL.
|
|
141
|
-
*
|
|
142
|
-
* `-w` takes the secret on argv, which is normally the thing to avoid — argv is
|
|
143
|
-
* world-readable in `ps`. It is accepted HERE because `security` offers no stdin
|
|
144
|
-
* form for add-generic-password, and the exposure is a race against a local
|
|
145
|
-
* process that could read the unlocked vault anyway. The mnemonic itself never
|
|
146
|
-
* appears on argv; only this random wrapper does, and it is useless without the
|
|
147
|
-
* file.
|
|
148
|
-
*/
|
|
149
|
-
export function keychainStore(authPub, secret) {
|
|
150
|
-
if (!keychainAvailable())
|
|
151
|
-
return { ok: false, error: 'Keychain is macOS-only' };
|
|
152
|
-
const r = spawnSync('security', [
|
|
153
|
-
'add-generic-password',
|
|
154
|
-
'-a', process.env.USER ?? 'one',
|
|
155
|
-
'-s', keychainService(authPub),
|
|
156
|
-
'-w', secret,
|
|
157
|
-
'-U',
|
|
158
|
-
'-T', '', // no app is pre-trusted: every read prompts, which is the biometric gate
|
|
159
|
-
]);
|
|
160
|
-
if (r.status !== 0) {
|
|
161
|
-
return { ok: false, error: (r.stderr?.toString() || 'security add-generic-password failed').trim() };
|
|
162
|
-
}
|
|
163
|
-
return { ok: true };
|
|
164
|
-
}
|
|
165
|
-
/** Read the wrapping secret back. This is the call that prompts for Touch ID. */
|
|
166
|
-
export function keychainRead(authPub) {
|
|
167
|
-
if (!keychainAvailable())
|
|
168
|
-
return { ok: false, error: 'Keychain is macOS-only' };
|
|
169
|
-
const r = spawnSync('security', [
|
|
170
|
-
'find-generic-password',
|
|
171
|
-
'-a', process.env.USER ?? 'one',
|
|
172
|
-
'-s', keychainService(authPub),
|
|
173
|
-
'-w',
|
|
174
|
-
]);
|
|
175
|
-
if (r.status !== 0) {
|
|
176
|
-
return { ok: false, error: 'no Keychain entry for this wallet (or access was denied)' };
|
|
177
|
-
}
|
|
178
|
-
return { ok: true, value: r.stdout.toString().trim() };
|
|
179
|
-
}
|
|
180
|
-
// ─── Paper ───────────────────────────────────────────────────────────────────
|
|
181
|
-
/**
|
|
182
|
-
* Where else the words open. Only v2 is BIP-39 at the standard paths, so only a v2
|
|
183
|
-
* sheet may name other wallets — v1 is ONE's own scheme and opens an empty account
|
|
184
|
-
* anywhere else. The wallet list is pinned against independent derivations at those
|
|
185
|
-
* paths in one.ie/web/tests/unit/wallet/sheet-other-wallets.test.ts.
|
|
186
|
-
*/
|
|
187
|
-
function otherWallets(restore) {
|
|
188
|
-
if (restore.derivation === 'v2') {
|
|
189
|
-
return [
|
|
190
|
-
'These words also open in: MetaMask (Ethereum), Phantom (Solana), Sui Wallet / Slush (Sui),',
|
|
191
|
-
' Sparrow or BlueWallet (Bitcoin, native SegWit), ASI Alliance Wallet (ASI).',
|
|
192
|
-
' The first account in each is the address above.',
|
|
193
|
-
];
|
|
194
|
-
}
|
|
195
|
-
return [
|
|
196
|
-
`These words recover only with ONE tools (\`${restore.cli} wallet new --recover --derivation v1\``,
|
|
197
|
-
' or `npx @oneie/recover --derivation v1`) — not in other wallets.',
|
|
198
|
-
];
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* The 24 words laid out for transcription, numbered.
|
|
202
|
-
*
|
|
203
|
-
* Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
|
|
204
|
-
* words is trivially copied out of sequence — a wallet that restores to the
|
|
205
|
-
* wrong addresses with no error. Pure, so it is testable without a wallet.
|
|
206
|
-
*
|
|
207
|
-
* The derivation is printed, and named in the restore command, because the words
|
|
208
|
-
* carry no marker of their own: `wallet new --recover` with no `--derivation`
|
|
209
|
-
* recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
|
|
210
|
-
* `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
|
|
211
|
-
* different, empty wallet with no error. The paper alone must carry what restore
|
|
212
|
-
* needs, so the derivation is required here, not defaulted.
|
|
213
|
-
*
|
|
214
|
-
* `cli` is how the restore command is spelled (`one` or `npx oneie`, see
|
|
215
|
-
* invoked-as.ts) so the line runs as printed. The restore line itself is a bare
|
|
216
|
-
* command — nothing trailing — so it can be copied, and parsed by the test that
|
|
217
|
-
* follows it back to the same addresses (tests/paper-restore.test.ts).
|
|
218
|
-
*/
|
|
219
|
-
export function paperSheet(mnemonic, addresses, restore) {
|
|
220
|
-
const words = mnemonic.trim().split(/\s+/);
|
|
221
|
-
const rows = [];
|
|
222
|
-
const half = Math.ceil(words.length / 2);
|
|
223
|
-
for (let i = 0; i < half; i++) {
|
|
224
|
-
const l = `${String(i + 1).padStart(2, ' ')}. ${(words[i] ?? '').padEnd(10)}`;
|
|
225
|
-
const j = i + half;
|
|
226
|
-
const r = j < words.length ? `${String(j + 1).padStart(2, ' ')}. ${words[j]}` : '';
|
|
227
|
-
rows.push(` ${l} ${r}`.trimEnd());
|
|
228
|
-
}
|
|
229
|
-
return [
|
|
230
|
-
'ONE — wallet recovery sheet',
|
|
231
|
-
'',
|
|
232
|
-
'These 24 words ARE the wallet. Anyone who reads them owns it.',
|
|
233
|
-
'Write them down in this order. Store the paper offline.',
|
|
234
|
-
'',
|
|
235
|
-
...rows,
|
|
236
|
-
'',
|
|
237
|
-
'Receiving addresses (public — safe to share, this is how you get paid):',
|
|
238
|
-
...Object.entries(addresses).map(([chain, addr]) => ` ${chain.padEnd(5)} ${addr}`),
|
|
239
|
-
'',
|
|
240
|
-
`Derivation: ${restore.derivation} (restore MUST name it — without it the same words open a different, empty wallet)`,
|
|
241
|
-
...otherWallets(restore),
|
|
242
|
-
'',
|
|
243
|
-
`Restore with: ${restore.cli} wallet new --recover --derivation ${restore.derivation}`,
|
|
244
|
-
' The words go in ONE_WALLET_MNEMONIC, set without echo first:',
|
|
245
|
-
' read -rs ONE_WALLET_MNEMONIC && export ONE_WALLET_MNEMONIC',
|
|
246
|
-
' Never on the command line — argv lands in shell history and in `ps`.',
|
|
247
|
-
`Offline, no ONE server: npx @oneie/recover --derivation ${restore.derivation}`,
|
|
248
|
-
].join('\n');
|
|
249
|
-
}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* wallet-money.ts — the pure half of `one wallet balances | receive | send | request`:
|
|
3
|
-
* the chain table, the words a person types, the reads, which chain a bare `USDC`
|
|
4
|
-
* means, the plan a send would sign, and the client check (R16) run before it does.
|
|
5
|
-
*
|
|
6
|
-
* Every chain read takes `Fetch` as an argument (tests hand in a fake; the command
|
|
7
|
-
* hands in a fetch with a deadline). A read that fails is null, never 0.
|
|
8
|
-
* Nothing here opens a vault or holds a key.
|
|
9
|
-
*/
|
|
10
|
-
import { type BalanceRow, type Fetch, type HlRead } from '../balances.js';
|
|
11
|
-
export type Net = 'mainnet' | 'testnet';
|
|
12
|
-
export type EvmChain = 'ethereum' | 'base' | 'arbitrum';
|
|
13
|
-
export type SendChain = EvmChain | 'sui';
|
|
14
|
-
export type SendAsset = 'ETH' | 'USDC' | 'SUI';
|
|
15
|
-
export type Obj = Record<string, unknown>;
|
|
16
|
-
export interface EvmNet {
|
|
17
|
-
chainId: number;
|
|
18
|
-
rpc: string;
|
|
19
|
-
usdc: string;
|
|
20
|
-
explorer: string;
|
|
21
|
-
label: string;
|
|
22
|
-
}
|
|
23
|
-
/** The three EVM chains on each network. Testnet USDC contracts read back `symbol() = USDC` (2026-11-09). */
|
|
24
|
-
export declare const EVM: Record<EvmChain, Record<Net, EvmNet>>;
|
|
25
|
-
export declare const EVM_CHAIN_NAMES: readonly EvmChain[];
|
|
26
|
-
/** Sui's public JSON-RPC answers "deprecated" on mainnet and testnet (measured 2026-11-09); GraphQL is the public read. */
|
|
27
|
-
export declare const SUI: Record<Net, {
|
|
28
|
-
graphql: string;
|
|
29
|
-
usdc: string;
|
|
30
|
-
explorer: string;
|
|
31
|
-
label: string;
|
|
32
|
-
}>;
|
|
33
|
-
export declare const SUI_NATIVE = "0x2::sui::SUI";
|
|
34
|
-
export declare const DECIMALS: Record<SendAsset, number>;
|
|
35
|
-
export declare function parseNet(v: unknown): Net | null;
|
|
36
|
-
/** "0.5" → base units; anything that is not a plain positive decimal within `decimals` places → null. */
|
|
37
|
-
export declare function parseAmount(input: string, decimals: number): bigint | null;
|
|
38
|
-
export type AssetWord = {
|
|
39
|
-
ok: true;
|
|
40
|
-
asset: SendAsset;
|
|
41
|
-
chain?: SendChain;
|
|
42
|
-
} | {
|
|
43
|
-
ok: false;
|
|
44
|
-
error: string;
|
|
45
|
-
message: string;
|
|
46
|
-
};
|
|
47
|
-
/** `ETH` · `USDC@base` · `SUI` — the asset and, when named, the chain. */
|
|
48
|
-
export declare function parseAssetWord(word: string): AssetWord;
|
|
49
|
-
/** The chains a bare asset could mean, in a fixed order. */
|
|
50
|
-
export declare function candidateChains(asset: SendAsset): SendChain[];
|
|
51
|
-
export declare const familyOf: (chain: SendChain) => "evm" | "sui";
|
|
52
|
-
export declare const chainLabel: (chain: SendChain, net: Net) => string;
|
|
53
|
-
export declare function addressShape(addr: string): 'evm' | 'sui' | null;
|
|
54
|
-
export declare function evmRpc(f: Fetch, rpc: string, method: string, params: unknown[]): Promise<string>;
|
|
55
|
-
export declare function readEvmAsset(f: Fetch, chain: EvmChain, net: Net, asset: 'ETH' | 'USDC', address: string): Promise<bigint | null>;
|
|
56
|
-
/** A coin balance on Sui via GraphQL; an address that never held the coin answers a null balance — a real zero. */
|
|
57
|
-
export declare function readSuiCoin(f: Fetch, net: Net, address: string, coinType: string): Promise<bigint | null>;
|
|
58
|
-
export declare function readAsset(f: Fetch, asset: SendAsset, chain: SendChain, net: Net, address: string): Promise<bigint | null>;
|
|
59
|
-
/** SOL in lamports from a public Solana node (testnet = devnet, where ONE's test money lives). */
|
|
60
|
-
export declare const SOL_RPC: Record<Net, string>;
|
|
61
|
-
export declare function readSol(f: Fetch, net: Net, address: string): Promise<bigint | null>;
|
|
62
|
-
/** BTC in satoshis from mempool.space: confirmed + unconfirmed, funded minus spent. */
|
|
63
|
-
export declare const BTC_API: Record<Net, string>;
|
|
64
|
-
export declare function readBtc(f: Fetch, net: Net, address: string): Promise<bigint | null>;
|
|
65
|
-
export interface Addresses {
|
|
66
|
-
evm?: string;
|
|
67
|
-
sui?: string;
|
|
68
|
-
solana?: string;
|
|
69
|
-
btc?: string;
|
|
70
|
-
}
|
|
71
|
-
export type MoneyRow = BalanceRow & {
|
|
72
|
-
source: 'wallet:get' | 'chain';
|
|
73
|
-
};
|
|
74
|
-
export interface MoneyBalances {
|
|
75
|
-
ok: true;
|
|
76
|
-
network: Net;
|
|
77
|
-
addresses: Addresses;
|
|
78
|
-
rows: MoneyRow[];
|
|
79
|
-
hyperliquid?: HlRead;
|
|
80
|
-
note: string;
|
|
81
|
-
}
|
|
82
|
-
/** What a server-given address must look like before it is used, printed or pasted anywhere. */
|
|
83
|
-
export declare const ADDRESS_SHAPE: Record<'evm' | 'sui' | 'solana' | 'btc', RegExp>;
|
|
84
|
-
/** wallet:get's rows for one actor → the addresses it holds. A row whose address is not its chain's shape is dropped. */
|
|
85
|
-
export declare function addressesFor(walletGet: Obj, actor: string): Addresses;
|
|
86
|
-
/**
|
|
87
|
-
* Every balance of one actor on ONE network. A wallet:get row is used only when it says
|
|
88
|
-
* it was read on the network asked (a server that ignores `net` answers the deploy's —
|
|
89
|
-
* production's is testnet — and such a row is dropped, never shown under the wrong label).
|
|
90
|
-
* What wallet:get does not read — USDC everywhere, ETH on Base and Arbitrum, USDT on
|
|
91
|
-
* mainnet, and SOL/BTC when the server gave no row — is read from the chains here.
|
|
92
|
-
*/
|
|
93
|
-
export declare function moneyBalances(args: {
|
|
94
|
-
walletGet: Obj | null;
|
|
95
|
-
actor: string;
|
|
96
|
-
addresses: Addresses;
|
|
97
|
-
net: Net;
|
|
98
|
-
}, f: Fetch, hlRead?: (address: string) => Promise<HlRead>): Promise<MoneyBalances>;
|
|
99
|
-
export declare function moneyLines(r: MoneyBalances): string[];
|
|
100
|
-
export type ReceiveChain = EvmChain | 'sui' | 'solana' | 'bitcoin';
|
|
101
|
-
export type ReceivePlan = {
|
|
102
|
-
ok: true;
|
|
103
|
-
chain: ReceiveChain;
|
|
104
|
-
network: Net;
|
|
105
|
-
address: string;
|
|
106
|
-
uri: string;
|
|
107
|
-
label: string;
|
|
108
|
-
accepts: string;
|
|
109
|
-
warning: string;
|
|
110
|
-
} | {
|
|
111
|
-
ok: false;
|
|
112
|
-
error: string;
|
|
113
|
-
message: string;
|
|
114
|
-
options?: string[];
|
|
115
|
-
};
|
|
116
|
-
/** Which chains these addresses can receive on — the list a refusal names. */
|
|
117
|
-
export declare function receivableChains(a: Addresses): ReceiveChain[];
|
|
118
|
-
/** One chain, one address, one QR payload. No chain = refused: one 0x address is three chains. */
|
|
119
|
-
export declare function receivePlan(chainWord: string | undefined, a: Addresses, net: Net): ReceivePlan;
|
|
120
|
-
/** wallet:invoice takes cents: USD or USDC, at most 2 decimals. Anything else is refused by name. */
|
|
121
|
-
export declare function invoiceCents(amount: string, asset: string): {
|
|
122
|
-
ok: true;
|
|
123
|
-
cents: number;
|
|
124
|
-
} | {
|
|
125
|
-
ok: false;
|
|
126
|
-
error: string;
|
|
127
|
-
message: string;
|
|
128
|
-
};
|
|
129
|
-
export interface EvmTxFields {
|
|
130
|
-
chainId: number;
|
|
131
|
-
nonce: bigint;
|
|
132
|
-
maxPriorityFeePerGas: bigint;
|
|
133
|
-
maxFeePerGas: bigint;
|
|
134
|
-
gasLimit: bigint;
|
|
135
|
-
to: string;
|
|
136
|
-
value: bigint;
|
|
137
|
-
data: string;
|
|
138
|
-
}
|
|
139
|
-
export interface SendPlan {
|
|
140
|
-
network: Net;
|
|
141
|
-
chain: SendChain;
|
|
142
|
-
chainLabel: string;
|
|
143
|
-
asset: SendAsset;
|
|
144
|
-
amount: string;
|
|
145
|
-
amountUnits: bigint;
|
|
146
|
-
from: string;
|
|
147
|
-
to: string;
|
|
148
|
-
/** How `to` was found: typed (an address in argv), or resolved from a name. */
|
|
149
|
-
toSource: 'typed' | 'wallet:get' | 'identity:address';
|
|
150
|
-
/** Why this chain — named, or the only one holding it. */
|
|
151
|
-
choice: string;
|
|
152
|
-
balanceUnits: bigint;
|
|
153
|
-
/** EVM: the transaction exactly as it would be signed. */
|
|
154
|
-
tx?: EvmTxFields;
|
|
155
|
-
/** EVM: gasLimit × maxFeePerGas — the most the fee can be, in wei. */
|
|
156
|
-
feeMaxUnits?: bigint;
|
|
157
|
-
/** Sui: the coin type moved. */
|
|
158
|
-
coinType?: string;
|
|
159
|
-
explorer: string;
|
|
160
|
-
}
|
|
161
|
-
export interface PlanDeps {
|
|
162
|
-
fetch: Fetch;
|
|
163
|
-
/** The sender's registered addresses (wallet:get), read once. */
|
|
164
|
-
from: Addresses;
|
|
165
|
-
/** Resolves a name (slug or agent id) to an address of `family`; null = none. */
|
|
166
|
-
resolve: (name: string, family: 'evm' | 'sui') => Promise<{
|
|
167
|
-
address: string;
|
|
168
|
-
source: 'wallet:get' | 'identity:address';
|
|
169
|
-
} | null>;
|
|
170
|
-
}
|
|
171
|
-
export type PlanResult = {
|
|
172
|
-
ok: true;
|
|
173
|
-
plan: SendPlan;
|
|
174
|
-
} | {
|
|
175
|
-
ok: false;
|
|
176
|
-
error: string;
|
|
177
|
-
message: string;
|
|
178
|
-
options?: Obj[];
|
|
179
|
-
};
|
|
180
|
-
/** A bare asset → the one chain that holds it. Two → refused with the list; a failed read → refused (it might be a second). */
|
|
181
|
-
export declare function pickChain(asset: SendAsset, from: Addresses, net: Net, f: Fetch): Promise<{
|
|
182
|
-
ok: true;
|
|
183
|
-
chain: SendChain;
|
|
184
|
-
choice: string;
|
|
185
|
-
} | {
|
|
186
|
-
ok: false;
|
|
187
|
-
error: string;
|
|
188
|
-
message: string;
|
|
189
|
-
options: Obj[];
|
|
190
|
-
}>;
|
|
191
|
-
/** Everything a send would sign, read and checked — nothing signed, nothing sent. */
|
|
192
|
-
export declare function planSend(intent: {
|
|
193
|
-
amount: string;
|
|
194
|
-
asset: string;
|
|
195
|
-
to: string;
|
|
196
|
-
net: Net;
|
|
197
|
-
}, deps: PlanDeps): Promise<PlanResult>;
|
|
198
|
-
/** ERC-20 transfer(address,uint256) — the same bytes as @oneie/sdk/evm-tx encodeErc20Transfer, kept here so a dry run needs no SDK upgrade. */
|
|
199
|
-
export declare function erc20TransferData(to: string, amount: bigint): string;
|
|
200
|
-
/**
|
|
201
|
-
* R16 — before a key signs, rebuild what the transaction MUST be from the person's own inputs
|
|
202
|
-
* (argv, and the address they confirmed), never from a server answer or the plan's echo, and
|
|
203
|
-
* compare. Any difference refuses.
|
|
204
|
-
*/
|
|
205
|
-
export declare function clientCheck(plan: SendPlan, own: {
|
|
206
|
-
amount: string;
|
|
207
|
-
asset: SendAsset;
|
|
208
|
-
chain: SendChain;
|
|
209
|
-
to: string;
|
|
210
|
-
net: Net;
|
|
211
|
-
}): {
|
|
212
|
-
ok: true;
|
|
213
|
-
} | {
|
|
214
|
-
ok: false;
|
|
215
|
-
field: string;
|
|
216
|
-
};
|
|
217
|
-
/** What a person reads before anything is signed. */
|
|
218
|
-
export declare function planLines(p: SendPlan): string[];
|
|
219
|
-
/** A plan as JSON-safe values (bigints as decimal strings). */
|
|
220
|
-
export declare function planJson(p: SendPlan): Obj;
|
|
221
|
-
/** The `wallet send … --payment-tx` line that records a broadcast transfer in ONE's ledger. */
|
|
222
|
-
export declare function recordLine(p: SendPlan, hash: string, cli: string): string;
|