oneie 5.7.5 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +19 -0
  2. package/dist/package.json +5 -2
  3. package/dist/src/balances.d.ts +89 -0
  4. package/dist/src/balances.js +202 -0
  5. package/dist/src/ceiling.d.ts +36 -0
  6. package/dist/src/ceiling.js +189 -0
  7. package/dist/src/check.d.ts +11 -0
  8. package/dist/src/check.js +53 -0
  9. package/dist/src/credits.d.ts +29 -0
  10. package/dist/src/credits.js +88 -0
  11. package/dist/src/hl-run.d.ts +119 -0
  12. package/dist/src/hl-run.js +480 -0
  13. package/dist/src/hl.d.ts +17 -0
  14. package/dist/src/hl.js +148 -0
  15. package/dist/src/index.js +15 -1
  16. package/dist/src/join.js +4 -0
  17. package/dist/src/key-sweep.d.ts +19 -3
  18. package/dist/src/key-sweep.js +70 -20
  19. package/dist/src/lib/check-words.d.ts +57 -0
  20. package/dist/src/lib/check-words.js +144 -0
  21. package/dist/src/lib/hl-core/actions.d.ts +99 -0
  22. package/dist/src/lib/hl-core/actions.js +69 -0
  23. package/dist/src/lib/hl-core/eip712.d.ts +33 -0
  24. package/dist/src/lib/hl-core/eip712.js +107 -0
  25. package/dist/src/lib/hl-core/errors.d.ts +10 -0
  26. package/dist/src/lib/hl-core/errors.js +15 -0
  27. package/dist/src/lib/hl-core/exchange.d.ts +24 -0
  28. package/dist/src/lib/hl-core/exchange.js +47 -0
  29. package/dist/src/lib/hl-core/index.d.ts +13 -0
  30. package/dist/src/lib/hl-core/index.js +14 -0
  31. package/dist/src/lib/hl-core/meta.d.ts +57 -0
  32. package/dist/src/lib/hl-core/meta.js +110 -0
  33. package/dist/src/lib/hl-core/msgpack.d.ts +18 -0
  34. package/dist/src/lib/hl-core/msgpack.js +136 -0
  35. package/dist/src/lib/hl-core/net.d.ts +2 -0
  36. package/dist/src/lib/hl-core/net.js +7 -0
  37. package/dist/src/lib/hl-core/signing.d.ts +103 -0
  38. package/dist/src/lib/hl-core/signing.js +295 -0
  39. package/dist/src/lib/hl-core/wire.d.ts +34 -0
  40. package/dist/src/lib/hl-core/wire.js +81 -0
  41. package/dist/src/lib/journey-words.d.ts +54 -3
  42. package/dist/src/lib/journey-words.js +162 -20
  43. package/dist/src/lib/journey.d.ts +2 -0
  44. package/dist/src/lib/journey.js +21 -2
  45. package/dist/src/lib/key-source.d.ts +9 -0
  46. package/dist/src/lib/key-source.js +33 -0
  47. package/dist/src/lib/net-choice.d.ts +28 -0
  48. package/dist/src/lib/net-choice.js +72 -0
  49. package/dist/src/lib/network.d.ts +22 -0
  50. package/dist/src/lib/network.js +50 -0
  51. package/dist/src/lib/next-words.d.ts +105 -0
  52. package/dist/src/lib/next-words.js +298 -0
  53. package/dist/src/lib/qr.d.ts +21 -0
  54. package/dist/src/lib/qr.js +402 -0
  55. package/dist/src/lib/sale-card.d.ts +117 -0
  56. package/dist/src/lib/sale-card.js +261 -0
  57. package/dist/src/lib/sui-grpc-send.d.ts +90 -0
  58. package/dist/src/lib/sui-grpc-send.js +128 -0
  59. package/dist/src/lib/timed-fetch.d.ts +33 -0
  60. package/dist/src/lib/timed-fetch.js +59 -0
  61. package/dist/src/lib/vaultfile.d.ts +15 -0
  62. package/dist/src/lib/vaultfile.js +28 -1
  63. package/dist/src/lib/wallet-money.d.ts +222 -0
  64. package/dist/src/lib/wallet-money.js +578 -0
  65. package/dist/src/lib/wallet-request.d.ts +50 -0
  66. package/dist/src/lib/wallet-request.js +86 -0
  67. package/dist/src/move.d.ts +36 -0
  68. package/dist/src/move.js +152 -0
  69. package/dist/src/network-cmd.d.ts +17 -0
  70. package/dist/src/network-cmd.js +74 -0
  71. package/dist/src/next.d.ts +12 -0
  72. package/dist/src/next.js +67 -0
  73. package/dist/src/onboard.js +4 -3
  74. package/dist/src/shop-buy.d.ts +16 -0
  75. package/dist/src/shop-buy.js +101 -0
  76. package/dist/src/shop.js +40 -1
  77. package/dist/src/staff.js +10 -0
  78. package/dist/src/start.d.ts +12 -0
  79. package/dist/src/start.js +51 -21
  80. package/dist/src/thread.d.ts +2 -0
  81. package/dist/src/thread.js +52 -0
  82. package/dist/src/wallet-money.d.ts +158 -0
  83. package/dist/src/wallet-money.js +664 -0
  84. package/dist/src/wallet.d.ts +2 -0
  85. package/dist/src/wallet.js +290 -27
  86. package/dist/src/workflow.js +4 -1
  87. package/package.json +5 -2
@@ -0,0 +1,222 @@
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;