@qntx/wallet-engine 0.12.0 → 0.14.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 (81) hide show
  1. package/README.md +1057 -20
  2. package/dist/apps-fiat24.d.mts +202 -0
  3. package/dist/apps-fiat24.mjs +1378 -0
  4. package/dist/apps-fiat24.mjs.map +1 -0
  5. package/dist/apps-hyperliquid.d.mts +549 -0
  6. package/dist/apps-hyperliquid.mjs +2742 -0
  7. package/dist/apps-hyperliquid.mjs.map +1 -0
  8. package/dist/apps-polymarket.d.mts +729 -0
  9. package/dist/apps-polymarket.mjs +3786 -0
  10. package/dist/apps-polymarket.mjs.map +1 -0
  11. package/dist/apps.d.mts +136 -0
  12. package/dist/apps.mjs +535 -0
  13. package/dist/apps.mjs.map +1 -0
  14. package/dist/connect-BY1C5ZRI.mjs +210 -0
  15. package/dist/connect-BY1C5ZRI.mjs.map +1 -0
  16. package/dist/connect.d.mts +17 -9
  17. package/dist/connect.mjs +3 -185
  18. package/dist/controller-DpNVHVsj.d.mts +2295 -0
  19. package/dist/controller-rMnaxKAH.mjs +46 -0
  20. package/dist/controller-rMnaxKAH.mjs.map +1 -0
  21. package/dist/decimal-COJ4g8qy.mjs +38 -0
  22. package/dist/decimal-COJ4g8qy.mjs.map +1 -0
  23. package/dist/eligibility-BfM9ybYZ.mjs +48 -0
  24. package/dist/eligibility-BfM9ybYZ.mjs.map +1 -0
  25. package/dist/engine-Dic_kkEr.d.mts +1829 -0
  26. package/dist/errors-B8W-hoYW.d.mts +7 -0
  27. package/dist/errors-horUy5k1.mjs +24 -0
  28. package/dist/errors-horUy5k1.mjs.map +1 -0
  29. package/dist/gateway-contract.d.mts +3 -362
  30. package/dist/gateway-contract.mjs +1531 -81
  31. package/dist/gateway-contract.mjs.map +1 -1
  32. package/dist/idb.d.mts +5 -0
  33. package/dist/idb.mjs +122 -46
  34. package/dist/idb.mjs.map +1 -1
  35. package/dist/index-vBgfOFIh.d.mts +2227 -0
  36. package/dist/index.d.mts +58 -515
  37. package/dist/index.mjs +22314 -4901
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/json-BDwV38cj.mjs +15 -0
  40. package/dist/json-BDwV38cj.mjs.map +1 -0
  41. package/dist/link-Ceq8Dggp.mjs +139 -0
  42. package/dist/link-Ceq8Dggp.mjs.map +1 -0
  43. package/dist/primitives-DbSHLZKq.mjs +31 -0
  44. package/dist/primitives-DbSHLZKq.mjs.map +1 -0
  45. package/dist/push-message-AQuzoNFY.d.mts +84 -0
  46. package/dist/push-message-kbnH1A5w.mjs +142 -0
  47. package/dist/push-message-kbnH1A5w.mjs.map +1 -0
  48. package/dist/push.d.mts +13 -0
  49. package/dist/push.mjs +70 -0
  50. package/dist/push.mjs.map +1 -0
  51. package/dist/qr.d.mts +292 -0
  52. package/dist/qr.mjs +1725 -0
  53. package/dist/qr.mjs.map +1 -0
  54. package/dist/registry-CbtwcxkX.mjs +374 -0
  55. package/dist/registry-CbtwcxkX.mjs.map +1 -0
  56. package/dist/risk-DyABgg4W.mjs +757 -0
  57. package/dist/risk-DyABgg4W.mjs.map +1 -0
  58. package/dist/session-CNJFLarP.mjs +18 -0
  59. package/dist/session-CNJFLarP.mjs.map +1 -0
  60. package/dist/socket-ChG9JRT_.mjs +110 -0
  61. package/dist/socket-ChG9JRT_.mjs.map +1 -0
  62. package/dist/spi-BrTw5s98.d.mts +3 -0
  63. package/dist/timer-Cdk5rGM2.mjs +43 -0
  64. package/dist/timer-Cdk5rGM2.mjs.map +1 -0
  65. package/dist/types-BpvioFGo.d.mts +258 -0
  66. package/dist/types-DbftVZ3I.mjs +90 -0
  67. package/dist/types-DbftVZ3I.mjs.map +1 -0
  68. package/dist/walletconnect.d.mts +86 -0
  69. package/dist/walletconnect.mjs +1507 -0
  70. package/dist/walletconnect.mjs.map +1 -0
  71. package/dist/webln-BgrtPXpG.mjs +2593 -0
  72. package/dist/webln-BgrtPXpG.mjs.map +1 -0
  73. package/dist/webln-Bllk_xJ2.d.mts +666 -0
  74. package/package.json +94 -19
  75. package/dist/connect.mjs.map +0 -1
  76. package/dist/errors-DpkJneDe.d.mts +0 -1696
  77. package/dist/registry-Deo5WQe1.d.mts +0 -25
  78. package/dist/registry-wYrcuFNc.mjs +0 -99
  79. package/dist/registry-wYrcuFNc.mjs.map +0 -1
  80. package/dist/webln-DzsI7jVb.mjs +0 -3629
  81. package/dist/webln-DzsI7jVb.mjs.map +0 -1
@@ -0,0 +1,1829 @@
1
+ import { An as Controller, At as PhishingController, B as AccountRef, Bt as WithdrawLnurlParams, Cn as PublicStore, Fn as Esplora, Ft as PrepareZapParams, H as ChainApis, In as SetTimer, It as PreparedZap, Mn as TronApi, On as GatewayConfig, Q as TrackedTransaction, Qt as SparkControllerOptions, R as TransactionController, Rn as EngineLogger, Sn as EngineStore, U as ChainRequestInput, Ut as PaymentParse, W as DelegationStatus, Zt as SparkController, _ as RequestController, at as AcrossBridgeQuote, gn as AddressBookRecord, ot as AcrossBridgeStatus, p as PendingRequest, pn as AddressBookController, q as PrepareParams, rt as SwapQuote, sn as RequestCheckCode, vn as NetworkController } from "./controller-DpNVHVsj.mjs";
2
+ import { I as NftDetail, W as NftStandard, l as PushFamily, u as PushPlatform, zt as FiatCurrency } from "./index-vBgfOFIh.mjs";
3
+ import { l as PushEventKind } from "./push-message-AQuzoNFY.mjs";
4
+ import { D as ConnectionController, T as BitcoinWalletHandler, c as TronWalletHandler, h as Nip07Handler, m as SolanaWalletHandler, t as WeblnHandler, v as Eip1193Handler } from "./webln-Bllk_xJ2.mjs";
5
+ import { StoreApi } from "zustand/vanilla";
6
+ import { DisplayExcerpt } from "@qntx/wallet-chains";
7
+ import "@scure/btc-signer";
8
+ import { BitcoinAccountTemplate } from "@qntx/wallet-chains/bitcoin";
9
+ import { readContract } from "viem/actions";
10
+ import { LightningInvoice, SparkNetwork } from "@qntx/spark";
11
+ import { BackupFactorInput, BackupHeader, BackupInfo, HardwareDevice, InitialFactor, KeyInfo, KeysApi, VerifyFactor, Wallet, WalletInfo } from "@qntx/wallet";
12
+ import { Event, Filter } from "@qntx/nostr";
13
+ import { WalletSyncSigner } from "@qntx/wallet/nostr";
14
+ import { getEnsAddress } from "viem/ens";
15
+ import { CardStep } from "@qntx/wallet/card";
16
+ import { ChainsApi } from "@qntx/wallet/chains";
17
+ import { DeviceIo, HardwareStep } from "@qntx/wallet/hardware";
18
+ import { ChainAccount, ChainAccountsParams, ChainTemplate, SessionInfo, SparkNetwork as SparkNetwork$1 } from "@qntx/wallet/protocol";
19
+ type BitcoinSourceKey = BitcoinAccountTemplate | "address";
20
+ type BitcoinTotals = {
21
+ readonly native: string;
22
+ readonly unconfirmed: string;
23
+ readonly protected: string;
24
+ };
25
+ type BitcoinUtxoView = {
26
+ readonly txid: string;
27
+ readonly vout: number;
28
+ readonly value: number;
29
+ readonly address: string;
30
+ readonly height: number;
31
+ readonly source: BitcoinSourceKey;
32
+ readonly protected: boolean;
33
+ };
34
+ /**
35
+ * Display-time spam heuristics for tokens the chain offers no trust signal for. A reason is only
36
+ * ever computed for unverified tokens — a verified entry (built-in table, or a list token whose
37
+ * on-chain decimals match) returns an empty array. Reasons are reported in the type's fixed order
38
+ * so the same token always flags the same way.
39
+ */
40
+ type SpamReason = "impersonation" | "suspicious-symbol" | "link-in-name" | "permanent-delegate" | "non-transferable";
41
+ /** The stake-resource view the account screen shows for a TRON account. */
42
+ type TronAccountView = {
43
+ /** TRX staked per resource, in sun. */
44
+ readonly frozen: {
45
+ readonly bandwidth: string;
46
+ readonly energy: string;
47
+ };
48
+ readonly unfreezing: ReadonlyArray<{
49
+ readonly resource: "bandwidth" | "energy";
50
+ readonly amount: string;
51
+ readonly expiresAt: number;
52
+ }>;
53
+ /** This account's delegations out (delegated_frozenV2 fields) and in (acquired_*). */
54
+ readonly delegatedOut: {
55
+ readonly bandwidth: string;
56
+ readonly energy: string;
57
+ };
58
+ readonly delegatedIn: {
59
+ readonly bandwidth: string;
60
+ readonly energy: string;
61
+ };
62
+ readonly votes: ReadonlyArray<{
63
+ readonly witness: string;
64
+ readonly count: string;
65
+ }>;
66
+ /** Withdrawable voting reward, in sun. */
67
+ readonly reward: string;
68
+ readonly bandwidth: {
69
+ readonly free: {
70
+ readonly limit: string;
71
+ readonly used: string;
72
+ };
73
+ readonly staked: {
74
+ readonly limit: string;
75
+ readonly used: string;
76
+ };
77
+ };
78
+ readonly energy: {
79
+ readonly limit: string;
80
+ readonly used: string;
81
+ };
82
+ readonly tronPower: {
83
+ readonly limit: string;
84
+ readonly used: string;
85
+ };
86
+ };
87
+ type TokenBalance = {
88
+ readonly address: string;
89
+ readonly symbol: string;
90
+ readonly name?: string;
91
+ readonly decimals: number;
92
+ readonly balance: string;
93
+ /** Solana only, present when non-zero — a frozen token account cannot be moved until thawed. */
94
+ readonly frozen?: string;
95
+ /** Built-in table entry, or a list token whose on-chain decimals match the list's. */
96
+ readonly verified: boolean;
97
+ /** Display-time spam verdict; always empty on a verified token. */
98
+ readonly spam: ReadonlyArray<SpamReason>;
99
+ /** Hidden by the user, or flagged spam without an explicit keep. */
100
+ readonly hidden: boolean;
101
+ };
102
+ type AccountBalances = {
103
+ readonly native: string;
104
+ readonly tokens: ReadonlyArray<TokenBalance>;
105
+ /** Bitcoin only — confirmed + own unconfirmed change; protected (inscription) UTXOs apart. */
106
+ readonly unconfirmed?: string;
107
+ /**
108
+ * Bitcoin only — outputs protected as possible inscription or rune carriers, counted apart from
109
+ * `native`. User freezes (`transactions.frozenUtxos`) are a separate list: a user-frozen coin
110
+ * still counts in `native`/`unconfirmed`.
111
+ */
112
+ readonly protected?: string;
113
+ /** Bitcoin only — the same totals split by the source they were read from. */
114
+ readonly sources?: Readonly<Partial<Record<BitcoinSourceKey, BitcoinTotals>>>;
115
+ /** Bitcoin only — every UTXO seen, with the source that produced it and its spend protection. */
116
+ readonly utxos?: ReadonlyArray<BitcoinUtxoView>;
117
+ /** TRON only — the stake/resource view of the account. */
118
+ readonly tron?: TronAccountView;
119
+ };
120
+ type AssetsControllerState = {
121
+ readonly balances: Record<string, AccountBalances>;
122
+ };
123
+ type Options = {
124
+ readonly networks: NetworkController;
125
+ readonly chains: Pick<ChainsApi, "account">;
126
+ /**
127
+ * The txids of bitcoin transactions this wallet built — whose height-0 outputs count as own
128
+ * unconfirmed change.
129
+ */
130
+ readonly ownBitcoinTxids: () => ReadonlySet<string>;
131
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
132
+ readonly openStore: () => Promise<EngineStore>;
133
+ readonly setTimer: (ms: number, fn: () => unknown) => () => void;
134
+ readonly logger: EngineLogger;
135
+ readonly gateway: GatewayConfig | undefined;
136
+ readonly fetch: typeof globalThis.fetch;
137
+ readonly now: () => number;
138
+ };
139
+ declare class AssetsController extends Controller<AssetsControllerState> {
140
+ private readonly options;
141
+ private readonly lists;
142
+ private engineStore;
143
+ private visible;
144
+ private cancelPoll;
145
+ private readonly customTokens;
146
+ private readonly visibility;
147
+ /**
148
+ * Chain-read ERC-20 metadata per `network:lowercase-address` for this unlock; entries without
149
+ * readable decimals are never cached so a later read can succeed.
150
+ */
151
+ private readonly meta;
152
+ /** Mint facts per `network:mint` for this unlock — each mint is inspected at most once. */
153
+ private readonly mints;
154
+ private readonly tronMeta;
155
+ /** Bitcoin templates verified unused within the discovery window — skipped on warm refreshes. */
156
+ private readonly btcDiscovery;
157
+ /** State key → the held list tokens found on the last discovery scan, and when it ran. */
158
+ private readonly discovered;
159
+ /** State key → the read that produced it, so a poll re-runs whichever entry was written. */
160
+ private readonly tracked;
161
+ /** Bumped on lock: a read that resolved across it records nothing into the next session. */
162
+ private generation;
163
+ constructor(options: Options);
164
+ init(): Promise<void>;
165
+ lock(): void;
166
+ destroy(): Promise<void>;
167
+ setVisible(visible: boolean): void;
168
+ private armPoll;
169
+ private refreshAll;
170
+ /**
171
+ * Writes `balances` under `stateKey` and remembers the read that produced it — unless the lock
172
+ * generation moved since the read started, in which case the result is returned unwritten: a read
173
+ * landing after `lock()` must not repopulate balances or re-arm its reread.
174
+ */
175
+ private record;
176
+ /**
177
+ * TRON: liquid TRX plus TRC-20/TRC-10 rows and the stake-resource view. TRC-20 reads are
178
+ * per-contract `triggerconstantcontract`s (no canonical Multicall — see assets/tron.ts);
179
+ * discovery comes from the TronGrid indexer path and only exists when the gateway serves the
180
+ * network, since the route is the only indexer source.
181
+ */
182
+ private refreshTron;
183
+ /**
184
+ * The visibility verdict of one token: explicit `hidden` wins, explicit `shown` keeps even a
185
+ * flagged token, and anything else hides exactly when it carries a spam reason.
186
+ */
187
+ private hiddenFor;
188
+ /** Reads the address's balances and returns exactly what it wrote under its state key. */
189
+ refresh(address: string, network: string): Promise<AccountBalances>;
190
+ /**
191
+ * The network's eligible list tokens keyed by canonical (lowercase) address: list entries whose
192
+ * symbol does not impersonate a built-in table token at a different address — an impersonator is
193
+ * never a verified entry, however it got on the list.
194
+ */
195
+ private eligibleEvmList;
196
+ /**
197
+ * The shown EVM tokens: table rows in table order, custom rows in add order, then discovered list
198
+ * tokens by address. Discovery — reading every list token's balance — runs on the first poll of
199
+ * an unlock and every {@link DISCOVERY_MS} after, and only when the network has a Multicall3;
200
+ * between scans only the discovered (still held) list tokens are read. Decimals come from the
201
+ * per-unlock cache, filled in one aggregate3 for the tokens still missing one.
202
+ */
203
+ private evmTokens;
204
+ /** Fills the per-unlock metadata cache for `wants` in one batched read; failures stay uncached. */
205
+ private loadEvmMetadata;
206
+ /** SOL via getBalance; SPL holdings summed per mint over both token programs. */
207
+ private refreshSolana;
208
+ /** Whether `address` is in the built-in token table of `network` or among the custom tokens. */
209
+ isTracked(network: string, address: string): boolean;
210
+ /** The token's own `symbol` and `decimals`; throws when either read fails. */
211
+ tokenMetadata(network: string, address: string): Promise<{
212
+ readonly symbol: string;
213
+ readonly decimals: number;
214
+ }>;
215
+ /**
216
+ * Persists the visibility verdict of one token — EVM addresses must be hex, Solana mints base58 —
217
+ * and re-derives `hidden` on that network's state rows without touching the chain. The same
218
+ * verdict applies on the next refresh: a flag stays hidden until explicitly shown.
219
+ */
220
+ setTokenHidden(network: string, address: string, hidden: boolean): Promise<void>;
221
+ private persistVisibility;
222
+ /** Reads the mint on-chain, marks unverified, persists; throws when the read fails. */
223
+ addToken(network: string, address: string): Promise<void>;
224
+ private persistToken;
225
+ /** A watched Bitcoin address's balance, keyed `${network}:${address}` like the other families. */
226
+ private refreshBitcoinAddress;
227
+ /**
228
+ * BTC balance of an account group = confirmed spendable + own unconfirmed change across every
229
+ * account template's xpub; protected (inscription) UTXOs shown separately.
230
+ */
231
+ refreshBitcoinGroup(group: {
232
+ readonly walletId: string;
233
+ readonly groupIndex: number;
234
+ }, network: string): Promise<AccountBalances>;
235
+ }
236
+ /** The authority forms a row can take, by chain. */
237
+ type ApprovalKind = "erc20" | "permit2" | "operator" | "nft" | "delegation" | "spl-delegate" | "spl-close-authority" | "spl-mint-authority" | "stake-authority" | "trc20" | "tron-permission";
238
+ /** What makes a row dangerous to leave standing. */
239
+ type ApprovalRisk =
240
+ /** The grantee may take the full balance, now and as it grows. */
241
+ "unlimited" |
242
+ /** The spender key is an externally owned account, not a contract. */
243
+ "eoa-spender" |
244
+ /** The spender address holds no code and has never transacted — a dead or unborn grantee. */
245
+ "spender-no-code" |
246
+ /** The grantee shares its first and last characters with a known address — a lookalike. */
247
+ "address-poisoning" |
248
+ /** The account's 7702 delegation points at a contract that is not this wallet's delegator. */
249
+ "foreign-delegation";
250
+ /** Where the candidate key that produced a row came from. `chain`: the chain enumerated it. */
251
+ type ApprovalSource = "gateway" | "local" | "chain";
252
+ /** A token a row names; display metadata only, resolved best-effort and never trusted. */
253
+ type TokenRef = {
254
+ readonly address: string;
255
+ readonly symbol?: string;
256
+ readonly decimals?: number;
257
+ };
258
+ type RowBase = {
259
+ /** Stable id inside its view — e.g. `erc20:<token>:<spender>` (lowercase EVM addresses). */
260
+ readonly id: string;
261
+ readonly network: string;
262
+ /** Every applicable risk flag. */
263
+ readonly risk: ReadonlyArray<ApprovalRisk>;
264
+ /**
265
+ * True only when the corroborating upstream agreed with the primary read (or no second upstream
266
+ * was needed). An unverified row is shown but marked.
267
+ */
268
+ readonly verified: boolean;
269
+ /** The sources whose candidate produced this row; `chain` when the chain enumerates the kind. */
270
+ readonly sources: ReadonlyArray<ApprovalSource>;
271
+ /**
272
+ * How the row can be revoked from this wallet: `single` — one transaction per row; `batchable` —
273
+ * alone or inside a multicall batch; `none` — not revocable here.
274
+ */
275
+ readonly revoke: "single" | "batchable" | "none";
276
+ };
277
+ /**
278
+ * One standing authority. `amount`/`exposure` are base-unit decimal strings read at the view's
279
+ * height; `exposure` is what the grantee can take right now (allowance bounded by balance and, for
280
+ * Permit2, by the token's allowance to Permit2 itself).
281
+ */
282
+ type ApprovalRow = RowBase & ({
283
+ readonly kind: "erc20" | "trc20";
284
+ readonly token: TokenRef;
285
+ readonly spender: string;
286
+ readonly amount: string;
287
+ readonly unlimited: boolean;
288
+ readonly exposure?: string;
289
+ } | {
290
+ readonly kind: "permit2";
291
+ readonly token: TokenRef;
292
+ readonly spender: string;
293
+ readonly amount: string;
294
+ /** Unix seconds; Permit2 allowances always carry one. */
295
+ readonly expiration: number;
296
+ readonly unlimited: boolean;
297
+ readonly exposure?: string;
298
+ } | {
299
+ /** ERC-721/1155 `setApprovalForAll`: `operator` may move every token of `contract`. */
300
+ readonly kind: "operator";
301
+ readonly contract: string;
302
+ readonly operator: string;
303
+ } | {
304
+ /** ERC-721 `approve`: `spender` (the chain's answer, not the candidate's) holds `tokenId`. */
305
+ readonly kind: "nft";
306
+ readonly contract: string;
307
+ readonly tokenId: string;
308
+ readonly spender: string;
309
+ } | {
310
+ /** EIP-7702: `address` runs as the account's code; `ours` names this wallet's delegator. */
311
+ readonly kind: "delegation";
312
+ readonly address: string;
313
+ readonly ours: boolean;
314
+ } | {
315
+ /** An SPL token account's delegate and its remaining allowance. */
316
+ readonly kind: "spl-delegate";
317
+ readonly tokenAccount: string;
318
+ /** The mint the token account holds. */
319
+ readonly token: TokenRef;
320
+ readonly delegate: string;
321
+ readonly amount: string;
322
+ readonly exposure?: string;
323
+ readonly program: "token" | "token-2022";
324
+ } | {
325
+ /** A close authority on the token account other than the owner. */
326
+ readonly kind: "spl-close-authority";
327
+ readonly tokenAccount: string;
328
+ readonly mint: string;
329
+ readonly authority: string;
330
+ } | {
331
+ /** A mint's freeze authority, or a Token-2022 permanent delegate. */
332
+ readonly kind: "spl-mint-authority";
333
+ readonly mint: string;
334
+ readonly role: "freeze" | "permanent-delegate";
335
+ readonly authority: string;
336
+ } | {
337
+ /** A stake account role held by a key other than the owner. */
338
+ readonly kind: "stake-authority";
339
+ readonly stakeAccount: string;
340
+ readonly role: "staker" | "withdrawer";
341
+ readonly authority: string;
342
+ } | {
343
+ /** A TRON account permission containing a key other than the owner's. */
344
+ readonly kind: "tron-permission";
345
+ readonly permission: "owner" | "active" | "witness";
346
+ readonly name: string;
347
+ /** Threshold and weights as decimal strings. */
348
+ readonly threshold: string;
349
+ readonly keys: ReadonlyArray<{
350
+ readonly address: string;
351
+ readonly weight: string;
352
+ }>;
353
+ });
354
+ /** How one candidate source fared during the last refresh. */
355
+ type ApprovalSourceState = {
356
+ readonly source: "gateway" | "local";
357
+ /**
358
+ * `ok`: answered; `truncated`: answered but could not carry every candidate; `failed`: error or
359
+ * malformed; `unsupported`: the gateway has no coverage here; `unavailable`: no gateway or no
360
+ * gateway-first indexer path exists.
361
+ */
362
+ readonly status: "ok" | "truncated" | "failed" | "unsupported" | "unavailable";
363
+ /** Unix ms of the last successful answer. */
364
+ readonly at?: number;
365
+ /** The block head the gateway scanned to (EVM only). */
366
+ readonly toBlock?: string;
367
+ };
368
+ /**
369
+ * A kernel session key signing for this view's owner — linked, never duplicated: it is revoked
370
+ * through the app that owns the scheme, not through this list.
371
+ */
372
+ type SessionLink = Pick<SessionInfo, "address" | "scheme" | "name" | "validUntil" | "supported">;
373
+ /**
374
+ * One account's approvals on one network. `rows` holds every standing authority found; the counters
375
+ * say how the refresh went for what is not in `rows`: `dropped` — candidates the chain proved
376
+ * inactive; `disputed` — primary and corroborator disagreed (never shown); `unread` — candidates
377
+ * that could not be read; `unverified` — rows shown without a corroborating read.
378
+ */
379
+ type ApprovalsView = {
380
+ readonly key: string;
381
+ readonly network: string;
382
+ readonly owner: string;
383
+ readonly status: "loading" | "ready" | "failed";
384
+ /** The height every row was read at: an EVM block, a Solana slot, a TRON head. */
385
+ readonly at?: {
386
+ readonly height: string;
387
+ readonly time?: number;
388
+ };
389
+ readonly rows: ReadonlyArray<ApprovalRow>;
390
+ /**
391
+ * The kinds the chain enumerates for this view (EVM delegation; the SPL account reads; TRON
392
+ * permissions) — for every other kind the list is "known approvals" only.
393
+ */
394
+ readonly exhaustive: ReadonlyArray<ApprovalKind>;
395
+ readonly sources: ReadonlyArray<ApprovalSourceState>;
396
+ readonly dropped: number;
397
+ readonly disputed: number;
398
+ readonly unread: number;
399
+ readonly unverified: number;
400
+ /** Kernel session keys signing for this owner — link targets, not rows. */
401
+ readonly sessions: ReadonlyArray<SessionLink>;
402
+ readonly updatedAt?: number;
403
+ readonly error?: string;
404
+ };
405
+ type ApprovalsState = {
406
+ readonly views: Readonly<Record<string, ApprovalsView>>;
407
+ };
408
+ declare const APPROVALS_POLL_MS = 600000;
409
+ type ApprovalsControllerOptions = {
410
+ readonly networks: Pick<NetworkController, "client" | "independentClient" | "solanaRpc" | "independentSolanaRpc" | "tronApi" | "independentTronApi" | "gatewayFirst">;
411
+ readonly transactions: Pick<TransactionController, "getState" | "store">;
412
+ readonly gateway: GatewayConfig | undefined;
413
+ readonly fetch: typeof globalThis.fetch;
414
+ /** The session EngineStore — opened once per unlock, closed on lock. */
415
+ readonly openStore: () => Promise<EngineStore>;
416
+ readonly setTimer: SetTimer;
417
+ readonly now: () => number;
418
+ readonly logger: EngineLogger;
419
+ /** Resolves a send-account ref to its address on `network` (HD or imported; family-checked). */
420
+ readonly addressOf: (account: AccountRef, network: string) => Promise<string>;
421
+ /** The engine's known addresses per family — address book + paid recipients. */
422
+ readonly known: (family: "evm" | "solana" | "tron") => ReadonlyArray<string>;
423
+ /** Token display metadata for one contract/mint — host read, may throw. */
424
+ readonly tokenMetadata: (network: string, address: string) => Promise<{
425
+ readonly symbol: string;
426
+ readonly decimals: number;
427
+ }>;
428
+ /** Kernel session keys signing for `owner` — engine root filters; [] + warn on failure. */
429
+ readonly sessions: (owner: string) => Promise<ReadonlyArray<SessionLink>>;
430
+ /** Prepares a wallet-internal chain request — the engine root passes `requests.prepare`. */
431
+ readonly prepare: (input: ChainRequestInput) => Promise<PendingRequest>;
432
+ };
433
+ declare class ApprovalsController extends Controller<ApprovalsState> {
434
+ private readonly options;
435
+ private readonly fetchGateway;
436
+ private engineStore;
437
+ private active;
438
+ private visible;
439
+ private epoch;
440
+ private cancelPoll;
441
+ private unsubscribeTxs;
442
+ private readonly inflight;
443
+ /** The account each loaded view was opened with — feeds `revoke`/`revokeBatch`. */
444
+ private readonly accounts;
445
+ private readonly rerun;
446
+ /** Lowest chain height the next refresh of a key may read at — set by confirmed sends. */
447
+ private readonly floors;
448
+ private readonly aborts;
449
+ /** Token metadata cached per session — a failed read is cached too (never retried in-session). */
450
+ private readonly tokens;
451
+ constructor(options: ApprovalsControllerOptions);
452
+ init(): Promise<void>;
453
+ lock(): void;
454
+ destroy(): Promise<void>;
455
+ /** Visible: poll every {@link APPROVALS_POLL_MS}. Hidden: stop. */
456
+ setVisible(visible: boolean): void;
457
+ /**
458
+ * Loads (or returns) the view for `account` on `network`, then refreshes it. The key is
459
+ * `${network}|${owner}` — the address the view's rows grant over.
460
+ */
461
+ load(account: AccountRef, network: string): Promise<string>;
462
+ /** Removes a view; an in-flight refresh's answer is discarded via the state check. */
463
+ unload(key: string): void;
464
+ /**
465
+ * Builds one wallet-internal revocation request for a row — `none` rows and unknown ids throw
466
+ * `invalid-request`. The row is never removed optimistically: the confirmed-transaction
467
+ * subscription re-reads the view after inclusion, so it stays while the chain still shows the
468
+ * approval. One request per call — nonces are reserved at commit, so several prepared at once
469
+ * would make all but the first stale.
470
+ */
471
+ revoke(key: string, rowId: string, fee?: PrepareParams["fee"]): Promise<PendingRequest>;
472
+ /**
473
+ * Builds one wallet-internal revocation request covering several rows — at least two distinct,
474
+ * all `batchable`, all one family: EVM approvals (≤ {@link EVM_BATCH_LIMIT}) become one
475
+ * `evm-revoke`, SPL delegates (≤ {@link SOLANA_REVOKE_MAX}) one `solana-revoke`. Same nonce
476
+ * caveat as {@link revoke}: one request per call.
477
+ */
478
+ revokeBatch(key: string, rowIds: ReadonlyArray<string>, fee?: PrepareParams["fee"]): Promise<PendingRequest>;
479
+ /** The loaded view, its row and the account it was opened with — all three or a throw. */
480
+ private rowFor;
481
+ /** Re-reads a view: single-flight per key, a concurrent ask reruns once after. */
482
+ refresh(key: string): Promise<void>;
483
+ /**
484
+ * `refresh` with a lowest chain height the next read may answer at — the confirmed-transaction
485
+ * subscription sets it to the send's block so a lagging head cannot hide what the send changed.
486
+ */
487
+ private refreshAt;
488
+ private armPoll;
489
+ private token;
490
+ private tryTokenMetadata;
491
+ /** The persisted candidate keys for one view; a malformed record is ignored with a warning. */
492
+ private stored;
493
+ /** Persists the candidates the refresh proved live or could not rule out. */
494
+ private persist;
495
+ private refreshOnce;
496
+ }
497
+ declare const PRICES_POLL_MS = 60000;
498
+ type PriceQuoteState = {
499
+ readonly price: string;
500
+ readonly change24h: string | null;
501
+ readonly updatedAt: number;
502
+ };
503
+ /** Why the last fetch failed: no gateway configured, it failed or refused, or it answered junk. */
504
+ type PricesFailure = "no-gateway" | "unavailable" | "rate-limited" | "invalid-response";
505
+ type PricesState = {
506
+ readonly currency: FiatCurrency;
507
+ /** Asset id → its latest quote; only assets still held are kept. */
508
+ readonly quotes: Readonly<Record<string, PriceQuoteState>>;
509
+ /** Per-asset errors: `unpriced` when no provider had a price, `unsupported` when none maps it. */
510
+ readonly errors: Readonly<Record<string, "unpriced" | "unsupported">>;
511
+ readonly failure: PricesFailure | null;
512
+ /** The last successful fetch, Unix ms. */
513
+ readonly fetchedAt: number | null;
514
+ };
515
+ type PricesControllerOptions = {
516
+ readonly gateway: GatewayConfig | undefined;
517
+ readonly fetch: typeof globalThis.fetch;
518
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
519
+ readonly openStore: () => Promise<EngineStore>;
520
+ readonly setTimer: SetTimer;
521
+ readonly now: () => number;
522
+ readonly logger: EngineLogger;
523
+ /** Every priceable asset id the engine holds a balance of now. */
524
+ readonly held: () => ReadonlyArray<string>;
525
+ /** Calls `listener` whenever `held` may have changed; returns the unsubscribe. */
526
+ readonly onHeldChange: (listener: () => void) => () => void;
527
+ };
528
+ declare class PricesController extends Controller<PricesState> {
529
+ private readonly options;
530
+ private readonly fetchGateway;
531
+ private engineStore;
532
+ private active;
533
+ private visible;
534
+ private epoch;
535
+ private cancelPoll;
536
+ private unsubscribe;
537
+ private inflight;
538
+ private rerun;
539
+ /** Assets some request of this unlock already named — a newly held asset is one not in here. */
540
+ private readonly asked;
541
+ private readonly aborts;
542
+ constructor(options: PricesControllerOptions);
543
+ init(): Promise<void>;
544
+ lock(): void;
545
+ destroy(): Promise<void>;
546
+ /** Visible: refresh now, then every {@link PRICES_POLL_MS}. Hidden: stop polling. */
547
+ setVisible(visible: boolean): void;
548
+ /** Switches the quote currency: drops every quote, persists the choice, refetches. */
549
+ setCurrency(currency: FiatCurrency): Promise<void>;
550
+ /** Fetches quotes for every held asset; resolves once the state reflects the answer. */
551
+ refresh(): Promise<void>;
552
+ private refreshIfNewlyHeld;
553
+ private armPoll;
554
+ private fetchOnce;
555
+ private request;
556
+ private persist;
557
+ }
558
+ type Holding = {
559
+ /** The state key the balance came from: an assets-state key, or `spark:<spark account key>`. */
560
+ readonly key: string;
561
+ readonly network: string;
562
+ /** CAIP-19 id — `undefined` on a network without prices (every testnet). */
563
+ readonly asset: string | undefined;
564
+ readonly symbol: string;
565
+ readonly decimals: number;
566
+ /** Base units. */
567
+ readonly amount: bigint;
568
+ };
569
+ /** A quote older than this (by the provider's own `updatedAt`) is shown as stale. */
570
+ declare const PRICE_STALE_MS: number;
571
+ type PriceView = {
572
+ readonly price: string;
573
+ readonly change24h: string | null;
574
+ readonly updatedAt: number;
575
+ readonly stale: boolean;
576
+ };
577
+ type ValuedHolding = Holding & {
578
+ /** Absent when the asset has no quote: a network without prices, unpriced, or not fetched yet. */
579
+ readonly price?: PriceView;
580
+ /** `amount` at `price`, a decimal string in the state's currency. */
581
+ readonly value?: string;
582
+ };
583
+ type Valuation = {
584
+ readonly currency: FiatCurrency;
585
+ /** The exact sum of every priced holding's value. */
586
+ readonly total: string;
587
+ /** Whether a stale quote contributed to the total. */
588
+ readonly stale: boolean;
589
+ /** How many holdings have no price and are left out of the total. */
590
+ readonly unpriced: number;
591
+ readonly holdings: ReadonlyArray<ValuedHolding>;
592
+ };
593
+ /** Wallet-facing activity entry: one transaction per chain or provider source, merged per group. */
594
+ type HistoryStatus = "pending" | "confirmed" | "failed" | "dropped" | "replaced";
595
+ type HistoryFlag = "zero-value-transfer" | "token-impersonation" | "suspicious-token-symbol" | "lookalike-counterparty" | "chain-mismatch" |
596
+ /** The outcome is genuinely unknown and no evidence can still arrive — user-archived. */
597
+ "unresolved";
598
+ type HistoryChange = {
599
+ readonly direction: "in" | "out";
600
+ /** EVM "native" | checksummed token; Solana "lamports" | mint; Bitcoin/Spark "sats". */
601
+ readonly asset: string;
602
+ /** Non-negative base units; zero is kept — a poisoning transfer stays visible, flagged. */
603
+ readonly amount: string;
604
+ readonly decimals?: number;
605
+ readonly symbol?: string;
606
+ readonly tokenId?: string;
607
+ /** Native or in the built-in token table: symbol and decimals are trusted. */
608
+ readonly listed: boolean;
609
+ };
610
+ type HistoryEntry = {
611
+ /** `${network}:${hash}` */
612
+ readonly id: string;
613
+ readonly family: "evm" | "solana" | "bitcoin" | "tron" | "spark";
614
+ /** CAIP-2; Spark uses `spark:${SparkNetwork}`. */
615
+ readonly network: string;
616
+ /** Tx hash / signature / txid / Spark transfer id. */
617
+ readonly hash: string;
618
+ /** All changes in / all out / none / both. */
619
+ readonly direction: "in" | "out" | "self" | "mixed";
620
+ /** Never the group's own addresses. */
621
+ readonly counterparties: ReadonlyArray<string>;
622
+ readonly changes: ReadonlyArray<HistoryChange>;
623
+ /** Native base units this wallet paid. */
624
+ readonly fee?: string;
625
+ readonly status: HistoryStatus;
626
+ /** Milliseconds since the epoch. */
627
+ readonly timestamp?: number;
628
+ /** Block / slot / height. */
629
+ readonly block?: number;
630
+ /** Read from the ledger itself, or a provider claim confirmed against it. */
631
+ readonly verified: boolean;
632
+ readonly origin: "chain" | "provider" | "local";
633
+ readonly flags: ReadonlyArray<HistoryFlag>;
634
+ /** The TransactionController id when this wallet sent it. */
635
+ readonly localTxId?: string;
636
+ };
637
+ type NftMedia = {
638
+ readonly scheme: "https" | "ipfs" | "ar" | "data";
639
+ readonly url: string;
640
+ /**
641
+ * The type the source declared (data URIs: their own); a hint — remote content is unknown until
642
+ * fetched.
643
+ */
644
+ readonly mime?: string;
645
+ /** May run script when rendered as a document: SVG, HTML, or an animation of unknown type. */
646
+ readonly active: boolean;
647
+ };
648
+ /** How the standard lets the wallet move the item: programmable rules or no token account at all. */
649
+ type NftTransferSupport = "supported" | "programmable" | "compressed";
650
+ /** One sanitised gateway item, before spam/visibility. */
651
+ type NftItemFacts = {
652
+ readonly id: string;
653
+ readonly network: string;
654
+ readonly contract: string;
655
+ readonly tokenId?: string;
656
+ readonly standard: NftStandard;
657
+ readonly balance: string;
658
+ readonly name?: string;
659
+ readonly image?: NftMedia;
660
+ readonly animation?: NftMedia;
661
+ readonly collection?: {
662
+ readonly id?: string;
663
+ readonly name?: string;
664
+ readonly verified: boolean;
665
+ };
666
+ readonly gatewaySpam: boolean;
667
+ /** The item or collection name carried hidden characters or markup and was dropped. */
668
+ readonly deceptive: boolean;
669
+ readonly transfer: NftTransferSupport;
670
+ };
671
+ type NftCollectionView = {
672
+ readonly id: string;
673
+ readonly name?: string;
674
+ readonly symbol?: string;
675
+ readonly description?: DisplayExcerpt;
676
+ readonly image?: NftMedia;
677
+ readonly totalSupply?: string;
678
+ readonly standard?: NftStandard;
679
+ readonly spam: boolean;
680
+ readonly verified: boolean;
681
+ };
682
+ /** A gateway detail as sanitised facts plus its long-form fields. */
683
+ declare function sanitizeDetail(network: string, detail: NftDetail): {
684
+ readonly facts: NftItemFacts;
685
+ readonly description?: DisplayExcerpt;
686
+ readonly attributes: ReadonlyArray<{
687
+ readonly trait: string;
688
+ readonly value: string;
689
+ }>;
690
+ readonly externalUrl?: string;
691
+ };
692
+ type NftSpamReason = "gateway" | "airdrop" | "lookalike" | "link-in-name" | "deceptive-text";
693
+ /** How the item got into the wallet, as far as its own activity can tell. */
694
+ type NftAcquisition = "airdrop" | "interacted" | "unknown";
695
+ /** Poll cadence while the inventory is on screen — a refresh can walk 20 pages of 100 CU each. */
696
+ declare const NFT_POLL_MS = 300000;
697
+ /** The most pages `loadMore` walks before calling the inventory truncated. */
698
+ declare const NFT_INVENTORY_MAX_PAGES = 20;
699
+ /** Why a gateway answer did not produce data. */
700
+ type NftFailure = "no-gateway" | "unavailable" | "rate-limited" | "unsupported" | "not-found" | "invalid-response";
701
+ /** An item as displayed: sanitised facts plus the controller's spam verdict and visibility. */
702
+ type NftView = Omit<NftItemFacts, "gatewaySpam" | "deceptive"> & {
703
+ readonly spam: ReadonlyArray<NftSpamReason>;
704
+ readonly hidden: boolean;
705
+ };
706
+ /** A detail answer: the item's display view plus its long-form fields. */
707
+ type NftDetailView = {
708
+ readonly item: NftView;
709
+ readonly description?: ReturnType<typeof sanitizeDetail>["description"];
710
+ readonly attributes: ReadonlyArray<{
711
+ readonly trait: string;
712
+ readonly value: string;
713
+ }>;
714
+ readonly externalUrl?: string;
715
+ };
716
+ /** One marketplace's floor as displayed. */
717
+ type NftFloorView = {
718
+ readonly marketplace: "opensea" | "looksrare";
719
+ readonly amount: string;
720
+ readonly currency: string;
721
+ readonly retrievedAt: number | null;
722
+ };
723
+ /** One inventory's worth of gateway state for `${network}:${owner}`. */
724
+ type NftInventory = {
725
+ readonly network: string;
726
+ readonly owner: string;
727
+ readonly items: ReadonlyArray<NftView>;
728
+ /** The cursor of the next page; `null` at the last page or when truncated. */
729
+ readonly cursor: string | null;
730
+ /** The number of pages fetched so far. */
731
+ readonly pages: number;
732
+ /** True when 20 pages were fetched and the cursor still names a next page. */
733
+ readonly truncated: boolean;
734
+ readonly loading: boolean;
735
+ readonly failure: NftFailure | null;
736
+ readonly updatedAt: number | null;
737
+ };
738
+ type NftState = {
739
+ readonly inventories: Readonly<Record<string, NftInventory>>;
740
+ };
741
+ type NftResult<A> = {
742
+ readonly ok: true;
743
+ readonly value: A;
744
+ } | {
745
+ readonly ok: false;
746
+ readonly failure: NftFailure;
747
+ };
748
+ type NftControllerOptions = {
749
+ readonly gateway: GatewayConfig | undefined;
750
+ readonly fetch: typeof globalThis.fetch;
751
+ readonly openStore: () => Promise<EngineStore>;
752
+ readonly setTimer: SetTimer;
753
+ readonly now: () => number;
754
+ readonly logger: EngineLogger;
755
+ readonly networks: Pick<NetworkController, "info" | "client" | "solanaRpc">;
756
+ readonly balances: () => Readonly<Record<string, AccountBalances>>;
757
+ readonly activity: () => {
758
+ readonly entries: ReadonlyArray<HistoryEntry>;
759
+ readonly txs: ReadonlyArray<TrackedTransaction>;
760
+ };
761
+ readonly onActivityChange: (listener: () => void) => () => void;
762
+ readonly onConfirmed: (listener: (tx: TrackedTransaction) => void) => () => void;
763
+ };
764
+ declare class NftController extends Controller<NftState> {
765
+ private readonly options;
766
+ private readonly fetchGateway;
767
+ private engineStore;
768
+ private active;
769
+ private visible;
770
+ private epoch;
771
+ private cancelPoll;
772
+ private unsubscribes;
773
+ private readonly inflight;
774
+ private readonly aborts;
775
+ /** Sanitised facts behind every view — the inventory keeps views, the controller keeps these. */
776
+ private readonly facts;
777
+ private visibility;
778
+ constructor(options: NftControllerOptions);
779
+ init(): Promise<void>;
780
+ lock(): void;
781
+ destroy(): Promise<void>;
782
+ /** Visible: refresh every loaded inventory now, then every {@link NFT_POLL_MS}. */
783
+ setVisible(visible: boolean): void;
784
+ /** Fetches page 1 of `owner`'s inventory on `network`, replacing it. */
785
+ load(owner: string, network: string): Promise<NftInventory>;
786
+ /** Fetches the inventory's next page and appends its new items. */
787
+ loadMore(owner: string, network: string): Promise<NftInventory>;
788
+ /**
789
+ * Refetches pages 1..`pages` of every inventory `owner` has on `network`, replacing its items
790
+ * only when every page answers. A failed page keeps the items already shown.
791
+ */
792
+ refresh(owner: string, network: string): Promise<NftInventory>;
793
+ /**
794
+ * The item's full gateway record — description, attributes, external URL — sanitised the same way
795
+ * inventory items are. The answer must name the asked contract and tokenId.
796
+ */
797
+ detail(network: string, contract: string, tokenId?: string): Promise<NftResult<NftDetailView>>;
798
+ /** The collection's gateway descriptor, sanitised. */
799
+ collection(network: string, id: string): Promise<NftResult<NftCollectionView>>;
800
+ /** Marketplace floor quotes for a collection — schema only, no fit rule exists for floors. */
801
+ floor(network: string, id: string): Promise<NftResult<ReadonlyArray<NftFloorView>>>;
802
+ /**
803
+ * `hidden` hides the item, `shown` pins it over its spam verdicts, `undefined` clears the
804
+ * override. The whole override map persists under one row per unlock.
805
+ */
806
+ setHidden(network: string, id: string, verdict: "hidden" | "shown" | undefined): Promise<void>;
807
+ /**
808
+ * Read-only view of the UTXOs the spend path already protects; no new read. `network` must be a
809
+ * Bitcoin network — inscription-bearing UTXOs exist only there.
810
+ */
811
+ inscriptions(group: {
812
+ readonly walletId: string;
813
+ readonly groupIndex: number;
814
+ }, network: string): ReadonlyArray<BitcoinUtxoView>;
815
+ private address;
816
+ private request;
817
+ private requestPage;
818
+ /** One in-flight fetch per inventory key — a second caller joins the same answer. */
819
+ private singleFlight;
820
+ private sanitised;
821
+ private viewOf;
822
+ private views;
823
+ private apply;
824
+ /**
825
+ * A failed read keeps the whole inventory as it was — items, cursor, pages, truncated, updatedAt
826
+ * — and only records the failure and clears `loading`, so `loadMore` still resumes.
827
+ */
828
+ private fail;
829
+ /** Rebuilds every view from its facts — activity and visibility verdicts change outside fetch. */
830
+ private rebuild;
831
+ private must;
832
+ private refreshAll;
833
+ private armPoll;
834
+ /**
835
+ * The post-inclusion re-read: a confirmed send's named items are re-read on chain and a zero
836
+ * balance drops the item. A failed read keeps it — a display-only item is cheaper than a lost
837
+ * record — and logs. The gateway is never consulted here.
838
+ */
839
+ private reRead;
840
+ private applyReRead;
841
+ /** One item's balance on chain: ERC-721's ownerOf / ERC-1155's balanceOf, or the Solana read. */
842
+ private chainBalance;
843
+ private persist;
844
+ }
845
+ type EnsResolution = {
846
+ readonly name: string;
847
+ readonly address: string;
848
+ readonly checks: ReadonlyArray<RequestCheckCode>;
849
+ };
850
+ type LidoWithdrawalRequest = {
851
+ readonly id: bigint;
852
+ readonly amountOfStETH: bigint;
853
+ readonly timestamp: number;
854
+ readonly status: "pending" | "claimable" | "claimed";
855
+ readonly claimableEther?: bigint;
856
+ };
857
+ type LidoPosition = {
858
+ readonly stETH: bigint;
859
+ readonly requests: ReadonlyArray<LidoWithdrawalRequest>;
860
+ };
861
+ type StakePosition = {
862
+ readonly address: string;
863
+ readonly seed: string;
864
+ readonly lamports: bigint;
865
+ /**
866
+ * Display approximation of the activation state — warmup and cooldown are rate-limited, so an
867
+ * "active" account can still be partially activating and a "deactivating" one partly liquid.
868
+ */
869
+ readonly state: "initialized" | "activating" | "active" | "deactivating" | "inactive";
870
+ /** Stake/withdraw authorities — absent when the account's parse carried none. */
871
+ readonly staker?: string;
872
+ readonly withdrawer?: string;
873
+ readonly validator?: string;
874
+ readonly activationEpoch?: bigint;
875
+ readonly deactivationEpoch?: bigint;
876
+ };
877
+ type StakeValidator = {
878
+ readonly vote: string;
879
+ readonly node: string;
880
+ readonly commission: number;
881
+ readonly activatedStake: bigint;
882
+ };
883
+ /**
884
+ * A watch-only account: an address the wallet tracks but can never sign for. Kept out of
885
+ * `AccountRef` deliberately — a watch account can never reach a signing/request input.
886
+ */
887
+ type WatchAccount = {
888
+ readonly id: string;
889
+ readonly family: "evm" | "solana" | "bitcoin" | "tron";
890
+ readonly address: string;
891
+ readonly name?: string;
892
+ /**
893
+ * The phone this watch account signs through: its master fingerprint, the signing key's path and
894
+ * — Bitcoin only — the account xpub. A qr-linked watch account signs only through the phone's
895
+ * frames; it still never reaches `AccountRef`.
896
+ */
897
+ readonly qr?: {
898
+ readonly fingerprint: string;
899
+ readonly path: string;
900
+ readonly xpub?: string;
901
+ };
902
+ readonly createdAt: number;
903
+ };
904
+ /**
905
+ * Wallet metadata document — the plaintext exchanged over kind-30078 events between this wallet's
906
+ * own devices. One document per wallet; entry-level last-writer-wins on `updatedAt`.
907
+ */
908
+ type MetaDocWallet = {
909
+ readonly name?: string;
910
+ readonly updatedAt: number;
911
+ };
912
+ type MetaDocGroup = {
913
+ readonly index: number;
914
+ readonly name?: string;
915
+ readonly hidden: boolean;
916
+ readonly boundPubkey?: string;
917
+ readonly updatedAt: number;
918
+ };
919
+ /** The per-wallet part of the document: this wallet's name and account groups. */
920
+ type MetaDocTree = {
921
+ readonly wallet: MetaDocWallet;
922
+ readonly groups: ReadonlyArray<MetaDocGroup>;
923
+ };
924
+ /** Every wallet's document also carries the whole address book, which is shared across wallets. */
925
+ type MetaDoc = MetaDocTree & {
926
+ readonly v: 2;
927
+ readonly contacts: ReadonlyArray<AddressBookRecord>;
928
+ };
929
+ type AccountGroup = {
930
+ readonly walletId: string;
931
+ readonly index: number;
932
+ /** `discoverGroups` result — family key → used; a family error lives under `errors`. */
933
+ readonly used?: Readonly<Record<string, boolean>>;
934
+ readonly errors?: Readonly<Record<string, string>>;
935
+ /** Families only the external signer can answer — no material is cached for them. */
936
+ readonly signer?: Readonly<Record<string, "device-required">>;
937
+ readonly name?: string;
938
+ readonly hidden: boolean;
939
+ /** A social identity (64 lowercase hex) bound to this group; one identity binds one group. */
940
+ readonly boundPubkey?: string;
941
+ /** Last local edit time (ms); reconcile- and discovery-created entries start at 0. */
942
+ readonly updatedAt: number;
943
+ };
944
+ type AccountTreeState = {
945
+ readonly status: "locked" | "ready";
946
+ readonly wallets: ReadonlyArray<{
947
+ readonly walletId: string;
948
+ readonly name?: string;
949
+ readonly updatedAt: number;
950
+ readonly custody: WalletInfo["custody"];
951
+ /** `incomplete` — a card wallet still waiting on a member card — holds no groups. */
952
+ readonly state: "ready" | "incomplete";
953
+ }>;
954
+ readonly groups: Readonly<Record<string, ReadonlyArray<AccountGroup>>>;
955
+ readonly selected: {
956
+ readonly walletId: string;
957
+ readonly groupIndex: number;
958
+ } | null;
959
+ readonly totals: Readonly<Record<string, number>>;
960
+ };
961
+ type DiscoveryNetworks = {
962
+ readonly client: (network: string) => {
963
+ readonly getTransactionCount: (p: {
964
+ readonly address: `0x${string}`;
965
+ readonly blockTag: "latest";
966
+ }) => Promise<number>;
967
+ readonly getBalance: (p: {
968
+ readonly address: `0x${string}`;
969
+ }) => Promise<bigint>;
970
+ };
971
+ readonly solanaRpc: (network: string) => {
972
+ readonly call: (method: string, params: unknown[]) => Promise<unknown>;
973
+ };
974
+ readonly esplora: (network: string) => Esplora;
975
+ readonly tronApi: (network: string) => TronApi;
976
+ readonly enabled: (family: "evm" | "solana" | "bitcoin" | "tron") => ReadonlyArray<string>;
977
+ };
978
+ type AccountTreeControllerOptions = {
979
+ readonly wallet: Wallet;
980
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
981
+ readonly spark: SparkController;
982
+ readonly sparkNetwork: SparkNetwork;
983
+ readonly networks?: DiscoveryNetworks;
984
+ readonly chains: {
985
+ readonly account: (params: ChainAccountsParams) => Promise<{
986
+ readonly address: string;
987
+ } | {
988
+ readonly xpub: string;
989
+ readonly changeMark: number;
990
+ }>;
991
+ };
992
+ readonly logger: EngineLogger;
993
+ readonly now: () => number;
994
+ };
995
+ declare class AccountTreeController extends Controller<AccountTreeState> {
996
+ private readonly options;
997
+ private col;
998
+ private sparkUnsubscribe;
999
+ private cancelTotals;
1000
+ private persistChain;
1001
+ /** Every imported private key in the vault — a separate list, never a group member. */
1002
+ imported: () => Promise<ReadonlyArray<KeyInfo>>;
1003
+ constructor(options: AccountTreeControllerOptions);
1004
+ setStore(store: EngineStore | undefined): void;
1005
+ /** Load persisted state, reconcile with the snapshot, start driving Spark. */
1006
+ init(): Promise<void>;
1007
+ destroy(): Promise<void>;
1008
+ /** Locked: stop every Spark client, flush pending persists, then drop to the empty state. */
1009
+ lock(): Promise<void>;
1010
+ /** Reconcile groups/names/selected with `wallet.getSnapshot().wallets`; persists on change. */
1011
+ reconcile(): void;
1012
+ addGroup(walletId: string): number;
1013
+ addGroups(walletId: string, indices: ReadonlyArray<number>): void;
1014
+ renameWallet(walletId: string, name: string): void;
1015
+ renameGroup(walletId: string, index: number, name: string): void;
1016
+ setHidden(walletId: string, index: number, hidden: boolean): void;
1017
+ select(walletId: string, index: number): void;
1018
+ /**
1019
+ * Binds a social identity to one group. The identity is unique across the whole tree — every
1020
+ * group in every wallet carrying it loses the binding (each entry re-stamped).
1021
+ */
1022
+ bind(walletId: string, index: number, pubkey: string): void;
1023
+ unbind(walletId: string, index: number): void;
1024
+ /**
1025
+ * Which group currently holds a pubkey — merges can leave the same identity on groups in two
1026
+ * wallets; the newest `updatedAt` wins, ties resolve by snapshot wallet order then lower index.
1027
+ */
1028
+ bindingOf(pubkey: string): {
1029
+ walletId: string;
1030
+ groupIndex: number;
1031
+ } | undefined;
1032
+ /** The wallet's metadata document — every group, hidden included. */
1033
+ exportMeta(walletId: string): MetaDocTree;
1034
+ /**
1035
+ * Entry-level last-writer-wins merge: a newer remote `updatedAt` replaces the local entry, a tie
1036
+ * keeps local; remote-only groups are added. `selected`/hidden rules are re-validated — if the
1037
+ * merge hides the selected group it is re-selected, and a merge may never leave every group
1038
+ * hidden (the selected one stays visible and is re-stamped so the fix propagates).
1039
+ */
1040
+ mergeMeta(walletId: string, doc: MetaDocTree): {
1041
+ changed: boolean;
1042
+ localNewer: boolean;
1043
+ };
1044
+ /** Sequential inspect from 0 upward; index 0 always included; stop after 2 consecutive unused. */
1045
+ discoverSpark(walletId: string): Promise<number[]>;
1046
+ /**
1047
+ * The five family check runnables for one group — shared by `discoverGroups` (which runs all of
1048
+ * them) and `recheckFamily` (which re-runs one after the signer fetched new material).
1049
+ */
1050
+ private familyChecks;
1051
+ /**
1052
+ * Per-group chain-family discovery — same stop rule as `discoverSpark`: group 0 always, stop
1053
+ * after two consecutive fully-unused groups. A family error is reported on the group and does NOT
1054
+ * count as unused (the group stays in `found` — it can't be proven empty).
1055
+ */
1056
+ discoverGroups(walletId: string): Promise<number[]>;
1057
+ /**
1058
+ * Re-runs one family's check for one group after the signer fetched new material — clears the
1059
+ * `signer` mark when the family now answers, records a fresh `device-required` when it still
1060
+ * cannot.
1061
+ */
1062
+ recheckFamily(walletId: string, groupIndex: number, family: string): Promise<void>;
1063
+ /** Refresh `totals` for every other visible group; per-group failures are logged and skipped. */
1064
+ refreshTotals(): Promise<void>;
1065
+ private onSparkState;
1066
+ private setTotal;
1067
+ private driveSpark;
1068
+ /**
1069
+ * Only a vault wallet holds the seed spark/nostr derive from; anything else must never drive
1070
+ * them.
1071
+ */
1072
+ private isVault;
1073
+ private visibleGroups;
1074
+ private validSelection;
1075
+ private selectFallback;
1076
+ private mutateGroups;
1077
+ /** A card wallet still waiting on a member card holds no groups — nothing can be added or found. */
1078
+ private mustReady;
1079
+ private mustWallet;
1080
+ private mustGroup;
1081
+ private checkedName;
1082
+ private load;
1083
+ /** Queues a store write behind the previous one — the last queued write always lands last. */
1084
+ private persist;
1085
+ private scheduleTotalsPersist;
1086
+ private flushTotals;
1087
+ }
1088
+ /** BackupController error categories — never carry file contents, digests or secrets. */
1089
+ type BackupErrorCategory = "cloud" | "conflict" | "unavailable" | "weak-password" | "quota" | "auth-required";
1090
+ declare class BackupControllerError extends Error {
1091
+ readonly category: BackupErrorCategory;
1092
+ constructor(category: BackupErrorCategory, message: string);
1093
+ }
1094
+ /**
1095
+ * Cloud-file storage port (design/backup.mdx "存储"): the cloud is an opaque key-value namespace —
1096
+ * names are file names (`qntx-wallet-backup-<id>-<digest>.json`), contents are envelope texts. The
1097
+ * kernel never sees it; only the engine transports ciphertext across it.
1098
+ *
1099
+ * Semantics every implementation honours:
1100
+ *
1101
+ * - S1 names matching /^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/ only — ≤ 255 chars, CloudKit's recordName
1102
+ * limit; violations reject `invalid` before any I/O (the rule keeps Drive's `name = '…'` query
1103
+ * escape-free).
1104
+ * - S2 texts hold at most CLOUD_TEXT_MAX_BYTES UTF-8 bytes with no lone surrogate; non-ASCII
1105
+ * round-trips byte-exact.
1106
+ * - S3 a write lands atomically: a read sees the old text or the new text, never a prefix.
1107
+ * - S4 a read returns the complete text or undefined; truncation surfaces as an error.
1108
+ * - S5 a write is readable by the same instance immediately (read-your-own-write).
1109
+ * - S6 list pages fully and dedupes; it is eventually consistent but never invents names.
1110
+ * - S7 deleting a missing name succeeds; a deleted name reads undefined.
1111
+ * - S8 same-name concurrent writes converge to one of the texts, listed exactly once.
1112
+ * - S9 every failure is a CloudStoreError carrying a CloudStoreErrorCode.
1113
+ */
1114
+ type CloudStore = {
1115
+ /** Every file name in the namespace. */
1116
+ readonly list: () => Promise<ReadonlyArray<string>>;
1117
+ /** File contents, or undefined when the name does not exist. */
1118
+ readonly read: (name: string) => Promise<string | undefined>;
1119
+ /** Overwrites the whole file atomically from the caller's perspective. */
1120
+ readonly write: (name: string, text: string) => Promise<void>;
1121
+ /** Deleting a missing file succeeds. */
1122
+ readonly delete: (name: string) => Promise<void>;
1123
+ };
1124
+ type CloudStoreErrorCode = "unavailable" | "auth-required" | "quota" | "invalid" | "failed";
1125
+ declare class CloudStoreError extends Error {
1126
+ readonly code: CloudStoreErrorCode;
1127
+ constructor(code: CloudStoreErrorCode, message: string);
1128
+ }
1129
+ declare const CLOUD_TEXT_MAX_BYTES = 4000000;
1130
+ declare function checkCloudName(name: string): void;
1131
+ declare function checkCloudText(text: string): void;
1132
+ type BackupControllerState = {
1133
+ readonly status: "locked" | "unavailable" | "off" | "syncing" | "synced" | "conflict" | "error";
1134
+ /** The retained backup key's public summary from the wallet snapshot. */
1135
+ readonly backup: BackupInfo | null;
1136
+ readonly uploadedAt: number | undefined;
1137
+ readonly unprotected: {
1138
+ readonly walletIds: ReadonlyArray<string>;
1139
+ };
1140
+ readonly error: BackupErrorCategory | undefined;
1141
+ };
1142
+ type BackupControllerOptions = {
1143
+ readonly wallet: Wallet;
1144
+ readonly cloud: CloudStore | undefined;
1145
+ readonly now: () => number;
1146
+ readonly logger: EngineLogger;
1147
+ };
1148
+ declare class BackupController extends Controller<BackupControllerState> {
1149
+ private readonly wallet;
1150
+ private readonly cloud;
1151
+ private readonly now;
1152
+ private readonly logger;
1153
+ private engineStore;
1154
+ private generation;
1155
+ private current;
1156
+ private rerun;
1157
+ /**
1158
+ * Header coverage by file name — a versioned name binds its content, so entries never need
1159
+ * invalidation; the map is cleared on lock() with the rest of the session state.
1160
+ */
1161
+ private readonly remoteCoverage;
1162
+ /** Foreign names already seen to hold garbage — never read again this session. */
1163
+ private readonly remoteInvalid;
1164
+ /** Set by restore() before the kernel call — applied by the first pass that sees the record. */
1165
+ private pendingAdoption;
1166
+ constructor(options: BackupControllerOptions);
1167
+ init(): Promise<void>;
1168
+ destroy(): Promise<void>;
1169
+ /** The engine hands over the store on unlock and takes it back on lock. */
1170
+ setStore(store: EngineStore | undefined): void;
1171
+ /** Bumps the generation: an in-flight reconcile writes nothing after this point. */
1172
+ lock(): void;
1173
+ trigger(): void;
1174
+ private triggerAsync;
1175
+ /** Explicit sync — awaits the run so callers see its outcome. */
1176
+ sync(): Promise<void>;
1177
+ enable(options: {
1178
+ readonly verify: VerifyFactor;
1179
+ readonly factors: ReadonlyArray<BackupFactorInput>;
1180
+ }): Promise<void>;
1181
+ disable(verify: VerifyFactor): Promise<void>;
1182
+ /** Every versioned file with a verified digest and a parseable header. */
1183
+ list(): Promise<ReadonlyArray<{
1184
+ readonly name: string;
1185
+ readonly id: string;
1186
+ readonly header: BackupHeader;
1187
+ }>>;
1188
+ /**
1189
+ * Merges a cloud backup into the vault. Wallets with a BIP-39 passphrase restore only when
1190
+ * `passphrases` carries theirs; the rest come back in `passphraseRequired`.
1191
+ */
1192
+ restore(options: {
1193
+ readonly name: string;
1194
+ readonly backupFactor: BackupFactorInput;
1195
+ readonly passphrases?: ReadonlyArray<{
1196
+ readonly walletId: string;
1197
+ readonly passphrase: string;
1198
+ }>;
1199
+ readonly factor?: InitialFactor;
1200
+ }): Promise<{
1201
+ readonly wallets: ReadonlyArray<WalletInfo>;
1202
+ readonly passphraseRequired: ReadonlyArray<string>;
1203
+ }>;
1204
+ private reconcileOrThrow;
1205
+ private readRecord;
1206
+ private writeRecord;
1207
+ private deleteRecord;
1208
+ private snapshot;
1209
+ private coverage;
1210
+ private unprotected;
1211
+ private setStatus;
1212
+ /** Maps a thrown cloud call: `unavailable` stands alone, every other failure is `error`. */
1213
+ private setCloudError;
1214
+ /**
1215
+ * Single-flight: a trigger during a run flags exactly one rerun inside the same promise, so
1216
+ * `sync()`/`enable()` await real convergence instead of a mid-run snapshot.
1217
+ */
1218
+ private reconcile;
1219
+ private pass;
1220
+ /**
1221
+ * The header coverage of a foreign version — cached by name either way: the name binds the
1222
+ * content, so garbage stays garbage and is never re-read. Read failures propagate for the pass to
1223
+ * map them; only a verified-but-corrupt payload resolves undefined.
1224
+ */
1225
+ private remoteCoverageOf;
1226
+ /** Backup off: delete every recorded file, then the record itself; failures retry next pass. */
1227
+ private passOff;
1228
+ }
1229
+ type HistoryGroup = {
1230
+ readonly walletId: string;
1231
+ readonly groupIndex: number;
1232
+ };
1233
+ type GroupHistory = {
1234
+ readonly status: "loading" | "ready";
1235
+ readonly entries: ReadonlyArray<HistoryEntry>;
1236
+ readonly hasMore: boolean;
1237
+ /** Shown from the persisted cache; fresh load pending. */
1238
+ readonly stale: boolean;
1239
+ /** Source id → error message; the other sources still list their entries. */
1240
+ readonly errors: Readonly<Record<string, string>>;
1241
+ /** Networks whose provider omitted entries it could not page — the list has gaps there. */
1242
+ readonly truncated: ReadonlyArray<string>;
1243
+ /** Networks the gateway has no history for — the entry list is complete for the others. */
1244
+ readonly unsupported: ReadonlyArray<string>;
1245
+ };
1246
+ type HistoryState = {
1247
+ readonly groups: Readonly<Record<string, GroupHistory>>;
1248
+ };
1249
+ type HistoryControllerOptions = {
1250
+ readonly networks: Pick<NetworkController, "enabled" | "client" | "gatewayFirst" | "independentClient" | "independentSolanaRpc" | "independentEsplora" | "independentTronApi" | "solanaRpc" | "tronApi" | "esplora">;
1251
+ readonly chains: {
1252
+ readonly account: (params: {
1253
+ readonly walletId: string;
1254
+ readonly groupIndex: number;
1255
+ readonly template: ChainTemplate;
1256
+ readonly network: string;
1257
+ }) => Promise<{
1258
+ readonly address: string;
1259
+ readonly confirmed: boolean;
1260
+ } | {
1261
+ readonly xpub: string;
1262
+ readonly changeMark: number;
1263
+ readonly confirmed: boolean;
1264
+ }>;
1265
+ };
1266
+ readonly spark: Pick<SparkController, "history" | "store">;
1267
+ readonly sparkNetwork: SparkNetwork$1;
1268
+ readonly transactions: Pick<TransactionController, "store">;
1269
+ readonly addressBook: Pick<AddressBookController, "store">;
1270
+ readonly gateway: {
1271
+ readonly url: string;
1272
+ readonly fetch: typeof globalThis.fetch;
1273
+ } | undefined;
1274
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
1275
+ readonly openStore: () => Promise<EngineStore>;
1276
+ readonly setTimer: SetTimer;
1277
+ readonly now: () => number;
1278
+ readonly logger: EngineLogger;
1279
+ };
1280
+ /**
1281
+ * Per-account-group activity: every enabled chain family plus local tracked sends, merged
1282
+ * newest-first, persisted bounded. The controller holds no chain or secret access itself — all I/O
1283
+ * is injected, and the only state it ever writes is its own store and the history collection.
1284
+ */
1285
+ declare class HistoryController extends Controller<HistoryState> {
1286
+ private readonly options;
1287
+ private engineStore;
1288
+ private generation;
1289
+ private readonly runtimes;
1290
+ private unsubscribes;
1291
+ constructor(options: HistoryControllerOptions);
1292
+ init(): Promise<void>;
1293
+ lock(): void;
1294
+ destroy(): Promise<void>;
1295
+ private runtime;
1296
+ /** Serialized per group; the queue survives a rejected task. */
1297
+ private enqueue;
1298
+ private writeGroup;
1299
+ private locals;
1300
+ /** Book entries + recipients of live tracked sends + the group's own addresses — never history. */
1301
+ private known;
1302
+ private entries;
1303
+ /** Re-derive every loaded group's view — local sends and the known set move under it. */
1304
+ private recomposeAll;
1305
+ private readPersisted;
1306
+ /** The newest PERSIST_MAX non-local entries — local sends are reconstructed, not stored. */
1307
+ private persist;
1308
+ /** The group's own addresses on every family — the sender side of every source and local match. */
1309
+ private resolveOwn;
1310
+ private streams;
1311
+ load(group: HistoryGroup): Promise<void>;
1312
+ loadMore(group: HistoryGroup): Promise<void>;
1313
+ }
1314
+ /** Meta-sync error categories — messages never carry event or document content. */
1315
+ type MetaSyncErrorCategory = "network" | "internal" | "unsupported" | "corrupt";
1316
+ declare class MetaSyncError extends Error {
1317
+ readonly category: MetaSyncErrorCategory;
1318
+ constructor(category: MetaSyncErrorCategory, message: string, cause?: unknown);
1319
+ }
1320
+ type MetaSyncRelayPort = {
1321
+ readonly fetch: (filter: Filter) => Promise<ReadonlyArray<Event>>;
1322
+ readonly publish: (event: Event) => Promise<void>;
1323
+ };
1324
+ type MetaSyncConfig = {
1325
+ /** The `d` tag that names this wallet's metadata document. */
1326
+ readonly tag: string;
1327
+ readonly relays: MetaSyncRelayPort;
1328
+ };
1329
+ type MetaSyncWalletStatus = {
1330
+ readonly status: "syncing" | "synced" | "error";
1331
+ readonly error?: MetaSyncErrorCategory;
1332
+ };
1333
+ type MetaSyncState = {
1334
+ readonly wallets: Readonly<Record<string, MetaSyncWalletStatus>>;
1335
+ };
1336
+ /** What the sync needs from the address book: its records, a merge, and a change subscription. */
1337
+ type AddressBookSync = {
1338
+ readonly syncEntries: () => ReadonlyArray<AddressBookRecord>;
1339
+ readonly merge: (remote: ReadonlyArray<AddressBookRecord>) => Promise<{
1340
+ readonly changed: boolean;
1341
+ readonly localNewer: boolean;
1342
+ }>;
1343
+ readonly store: {
1344
+ readonly subscribe: (listener: () => void) => () => void;
1345
+ };
1346
+ };
1347
+ type MetaSyncControllerOptions = {
1348
+ readonly wallet: Wallet;
1349
+ readonly accounts: AccountTreeController;
1350
+ readonly addressBook: AddressBookSync;
1351
+ /** `nostr(wallet).syncSigner` — each wallet signs metadata with its dedicated sync key. */
1352
+ readonly nostr: {
1353
+ readonly syncSigner: (walletId: string) => WalletSyncSigner;
1354
+ };
1355
+ readonly metaSync: MetaSyncConfig | undefined;
1356
+ readonly logger: EngineLogger;
1357
+ readonly now: () => number;
1358
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
1359
+ readonly verifyEvent: (event: Event) => boolean;
1360
+ };
1361
+ /**
1362
+ * Wallet-metadata sync over kind-30078 addressable events: one NIP-44-encrypted document per
1363
+ * wallet, authored by its dedicated sync key (WD-070). Pull always precedes publish in an unlock
1364
+ * session — replaceable events would otherwise let a stale local tree overwrite a newer remote
1365
+ * document. Debounced publishes are per wallet; a generation counter cancels in-flight write-backs
1366
+ * on lock.
1367
+ */
1368
+ declare class MetaSyncController extends Controller<MetaSyncState> {
1369
+ private readonly options;
1370
+ private generation;
1371
+ private readonly pulled;
1372
+ private readonly lastRemoteCreatedAt;
1373
+ private readonly lastExported;
1374
+ private readonly timers;
1375
+ private readonly inflight;
1376
+ private accountsUnsubscribe;
1377
+ private addressBookUnsubscribe;
1378
+ constructor(options: MetaSyncControllerOptions);
1379
+ /** Unlocked: pull every wallet whose group-0 identity exists, then watch the tree. */
1380
+ init(): Promise<void>;
1381
+ destroy(): Promise<void>;
1382
+ /** Locked: cancel debounces and in-flight write-backs, forget the pull/publish bookkeeping. */
1383
+ lock(): Promise<void>;
1384
+ /** Snapshot changed while unlocked: pull newly-seen wallets, drop removed ones. */
1385
+ reconcile(): void;
1386
+ /** Manual re-pull of every wallet that can sync. */
1387
+ sync(): Promise<void>;
1388
+ private pullAll;
1389
+ private setStatus;
1390
+ /** Metadata sync signs with the wallet's nostr sync key — only a vault wallet has one. */
1391
+ private isVault;
1392
+ private pullOne;
1393
+ /** The wallet's tree plus the shared address book — every wallet's document carries both. */
1394
+ private exportDoc;
1395
+ private filterFor;
1396
+ private acceptableEvent;
1397
+ /** Snapshot the wallet's exported doc — the debounce publishes only on a real change. */
1398
+ private rememberExport;
1399
+ private onTreeChange;
1400
+ private publishNow;
1401
+ }
1402
+ /**
1403
+ * Host port: where the payload keys live for the notification extension (iOS App Group keychain,
1404
+ * Android app storage). Keyed by subscription id — the token and the secret stay engine-side.
1405
+ */
1406
+ type PushKeyStore = {
1407
+ readonly put: (id: string, key: Uint8Array) => Promise<void>;
1408
+ readonly delete: (id: string) => Promise<void>;
1409
+ /**
1410
+ * Every stored key id. The controller sweeps ids with no live subscription row at init — after a
1411
+ * vault reset or a crash between the subscription row write and the key export, an orphaned key
1412
+ * would let the extension keep opening an erased wallet's activity.
1413
+ */
1414
+ readonly ids: () => Promise<ReadonlyArray<string>>;
1415
+ };
1416
+ /**
1417
+ * The display hint one opened delivery produces. It exists to refresh the UI; the activity list
1418
+ * changes only by re-reading history, never by trusting the hint.
1419
+ */
1420
+ type NotificationEvent = {
1421
+ readonly walletId: string;
1422
+ readonly family: PushFamily;
1423
+ readonly kind: PushEventKind;
1424
+ readonly network: string;
1425
+ readonly hash: string;
1426
+ readonly address: string;
1427
+ readonly observedAt: number;
1428
+ readonly transfer?: {
1429
+ readonly amount: string;
1430
+ readonly decimals?: number;
1431
+ readonly symbol?: string;
1432
+ readonly contract?: string;
1433
+ };
1434
+ };
1435
+ type NotificationStatus = "active" | "pending" | "failed" | "device-required";
1436
+ type NotificationsState = {
1437
+ readonly status: "locked" | "ready";
1438
+ /** The token's platform; the token value itself never enters state. */
1439
+ readonly platform: PushPlatform | undefined;
1440
+ readonly capabilities: {
1441
+ readonly platforms: ReadonlyArray<PushPlatform>;
1442
+ readonly families: ReadonlyArray<PushFamily>;
1443
+ } | undefined;
1444
+ /** Opted-in wallets only. */
1445
+ readonly wallets: Readonly<Record<string, {
1446
+ readonly families: Readonly<Partial<Record<PushFamily, NotificationStatus>>>;
1447
+ }>>;
1448
+ };
1449
+ type NotificationsControllerOptions = {
1450
+ /** `gatewayFetch`-wrapped fetch: per-family client ids are attached by the scope already. */
1451
+ readonly gateway: {
1452
+ readonly url: string;
1453
+ readonly fetch: typeof globalThis.fetch;
1454
+ } | undefined;
1455
+ readonly openStore: () => Promise<EngineStore>;
1456
+ readonly random: (length: number) => Uint8Array;
1457
+ readonly now: () => number;
1458
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
1459
+ readonly logger: EngineLogger;
1460
+ /** Absent → the extension cannot decrypt and shows the generic text; in-app `receive` works. */
1461
+ readonly keys: PushKeyStore | undefined;
1462
+ readonly accounts: Pick<AccountTreeController, "getState" | "store">;
1463
+ readonly networks: Pick<NetworkController, "enabled" | "store">;
1464
+ readonly transactions: Pick<TransactionController, "store">;
1465
+ readonly addresses: (walletId: string, family: PushFamily) => Promise<ReadonlyArray<string>>;
1466
+ /** Best-effort refresh of whatever the hint touches — history reloads, an assets refresh. */
1467
+ readonly reconcile: (event: NotificationEvent) => Promise<void>;
1468
+ };
1469
+ declare class NotificationsController extends Controller<NotificationsState> {
1470
+ private readonly options;
1471
+ private engineStore;
1472
+ private collection;
1473
+ private generation;
1474
+ private token;
1475
+ private readonly optedIn;
1476
+ private readonly subs;
1477
+ /** Tx ids already POSTed this session — the gateway is idempotent, one attempt per tx. */
1478
+ private readonly watched;
1479
+ private readonly statusBySub;
1480
+ private unsubscribes;
1481
+ private reconcileTimer;
1482
+ private running;
1483
+ private queued;
1484
+ constructor(options: NotificationsControllerOptions);
1485
+ init(): Promise<void>;
1486
+ lock(): void;
1487
+ destroy(): Promise<void>;
1488
+ private requireUnlocked;
1489
+ setToken(platform: PushPlatform, token: string): Promise<void>;
1490
+ enable(walletId: string): Promise<void>;
1491
+ disable(walletId: string): Promise<void>;
1492
+ /**
1493
+ * Opens a provider-delivered message with the device's subscription keys. `undefined` — locked,
1494
+ * unreadable, or addressed to a network/address the subscription does not cover — means the host
1495
+ * falls back to its generic copy.
1496
+ */
1497
+ receive(message: unknown): Promise<NotificationEvent | undefined>;
1498
+ /** Coalesces reconcile triggers onto a zero-delay timer. */
1499
+ private trigger;
1500
+ private reconcileLoop;
1501
+ private url;
1502
+ private enabledDigest;
1503
+ private walletStatuses;
1504
+ private reconcile;
1505
+ private fetchCapabilities;
1506
+ private putSubscription;
1507
+ private removeSub;
1508
+ private deleteSubscription;
1509
+ /** POSTs a watch for every submitted/pending tracked transaction of an opted-in wallet. */
1510
+ private scanOutgoing;
1511
+ private postWatch;
1512
+ }
1513
+ /**
1514
+ * What the host shows while a device operation runs: which wallet, which custody, which operation,
1515
+ * and the facade's latest step — card steps pass through wholesale, hardware publishes the device
1516
+ * exchanges (`done` never needs a widget: the result resolves instead).
1517
+ */
1518
+ type SignerActivity = {
1519
+ readonly id: string;
1520
+ readonly walletId: string;
1521
+ readonly custody: "card" | "hardware";
1522
+ readonly operation: "sign" | "accounts" | "verify-address";
1523
+ readonly step: {
1524
+ readonly kind: "starting";
1525
+ } | {
1526
+ readonly kind: "card";
1527
+ readonly step: CardStep;
1528
+ } | {
1529
+ readonly kind: "device";
1530
+ readonly step: Extract<HardwareStep, {
1531
+ kind: "exchange";
1532
+ }>;
1533
+ };
1534
+ };
1535
+ type SignersState = {
1536
+ readonly active: SignerActivity | null;
1537
+ };
1538
+ type SignerFamily = "evm" | "solana" | "bitcoin" | "tron";
1539
+ type SignersControllerOptions = {
1540
+ readonly wallet: Wallet;
1541
+ /**
1542
+ * The host's transport for a paired device (Ledger APDUs, a Keystone QR channel, …). Absent →
1543
+ * hardware wallets cannot sign, verify or fetch accounts here.
1544
+ */
1545
+ readonly deviceIo?: ((device: HardwareDevice) => DeviceIo) | undefined;
1546
+ /** Re-runs one family's discovery check for a group after fetched material lands. */
1547
+ readonly recheck: (walletId: string, groupIndex: number, family: SignerFamily) => Promise<void>;
1548
+ /** Enabled networks per family — fetchAccounts needs one derivation network per coin type. */
1549
+ readonly networks?: {
1550
+ readonly enabled: (family: SignerFamily) => ReadonlyArray<string>;
1551
+ };
1552
+ readonly random: (length: number) => Uint8Array;
1553
+ readonly logger: EngineLogger;
1554
+ };
1555
+ /**
1556
+ * The engine's external-signer orchestration: at most one device operation at a time, its progress
1557
+ * in `active`, and the single signing path (`apis`) every engine component signs through — the
1558
+ * custody of the request's wallet decides whether the vault signs directly or a card/hardware op
1559
+ * runs first.
1560
+ */
1561
+ declare class SignersController extends Controller<SignersState> {
1562
+ private readonly options;
1563
+ private activeTask;
1564
+ constructor(options: SignersControllerOptions);
1565
+ /** The one signing path: vault material signs directly; card and hardware wallets run an op. */
1566
+ readonly apis: ChainApis;
1567
+ init(): Promise<void>;
1568
+ destroy(): Promise<void>;
1569
+ /** Lock hook — the engine calls this as the vault locks; the task's result still rejects. */
1570
+ lock(): void;
1571
+ /** Cancel the running device operation; a no-op when nothing is active. */
1572
+ cancel(): Promise<void>;
1573
+ /** Verify one derived address on the device's screen — hardware only; a card has no screen. */
1574
+ verifyAddress(params: {
1575
+ readonly walletId: string;
1576
+ readonly groupIndex: number;
1577
+ readonly template: ChainTemplate;
1578
+ readonly network: string;
1579
+ readonly index?: number;
1580
+ }): Promise<{
1581
+ readonly address: string;
1582
+ readonly method: string;
1583
+ }>;
1584
+ /**
1585
+ * Fetch one family's pinned accounts from the signer, then re-run that family's discovery check
1586
+ * for the group. Bitcoin derives per network (coin types differ); the other families derive once
1587
+ * on their first enabled network.
1588
+ */
1589
+ fetchAccounts(params: {
1590
+ readonly walletId: string;
1591
+ readonly groupIndex: number;
1592
+ readonly family: SignerFamily;
1593
+ /** Keys the pin does not serve need a verification — the kernel asks approval-required else. */
1594
+ readonly verify?: VerifyFactor;
1595
+ }): Promise<ReadonlyArray<ChainAccount>>;
1596
+ private cardSign;
1597
+ private deviceSign;
1598
+ private mustWallet;
1599
+ private deviceIo;
1600
+ private begin;
1601
+ private setStep;
1602
+ private end;
1603
+ private trackCard;
1604
+ private trackDevice;
1605
+ private runCard;
1606
+ private runDevice;
1607
+ }
1608
+ type EngineOptions = {
1609
+ readonly wallet: Wallet;
1610
+ /**
1611
+ * Verifies events the engine checks itself (external-signer zap requests, relay metadata
1612
+ * documents). Required, with no default: `@qntx/nostr`'s own `verifyEvent` is bound to the
1613
+ * pure-JS noble backend — pass the host's native verifier, the same one given to the wallet.
1614
+ */
1615
+ readonly verifyEvent: (event: Event) => boolean;
1616
+ /** Every Spark account the engine touches lives on this network. */
1617
+ readonly sparkNetwork: SparkNetwork;
1618
+ readonly fetch: typeof globalThis.fetch;
1619
+ readonly random: (length: number) => Uint8Array;
1620
+ readonly now: () => number;
1621
+ /** The WebLN node's display alias — `getInfo` never exposes a pubkey. */
1622
+ readonly weblnAlias: string;
1623
+ /** The host's lightning fee cap for WebLN sends — validated to a non-negative safe integer. */
1624
+ readonly lightningMaxFee: (amountSats: number) => number;
1625
+ readonly logger: EngineLogger;
1626
+ readonly openStore: () => Promise<EngineStore>;
1627
+ /** The host surfaces a call bundle's status page — `wallet_showCallsStatus` triggers it. */
1628
+ readonly showCallsStatus: (request: {
1629
+ readonly origin: string;
1630
+ readonly txIds: ReadonlyArray<string>;
1631
+ }) => void;
1632
+ /**
1633
+ * Non-secret device data (the phishing list, the origins the user trusts), available while the
1634
+ * wallet is locked: a page can be opened before the first unlock.
1635
+ */
1636
+ readonly publicStore: PublicStore;
1637
+ /** Cloud file transport for the backup controller; absent → `unavailable`. */
1638
+ readonly cloud?: CloudStore;
1639
+ /**
1640
+ * Host endpoints per network (CAIP-2), ordered by preference, per family: EVM and Solana JSON-RPC
1641
+ * URLs, the Esplora base URL for Bitcoin, full-node HTTP base URLs for TRON.
1642
+ */
1643
+ readonly rpc?: Readonly<Record<string, ReadonlyArray<string>>>;
1644
+ /**
1645
+ * The wallet gateway: tried first for the networks it serves (read at each unlock) unless a
1646
+ * network has custom endpoints. The engine draws per-session, per-scope client ids — sent only to
1647
+ * the gateway's origin — so requests cannot be joined across families or installs.
1648
+ */
1649
+ readonly gateway?: {
1650
+ readonly url: string;
1651
+ };
1652
+ /** Development builds: also accept `http://localhost` as a dApp origin. */
1653
+ readonly allowLocalhostOrigins?: boolean;
1654
+ /**
1655
+ * Injected one-shot timer with `setTimeout` semantics (each call runs `fn` at most once); polling
1656
+ * loops re-arm it after every run. Defaults to setTimeout.
1657
+ */
1658
+ readonly setTimer?: (ms: number, fn: () => void) => () => void;
1659
+ /** Kind-30078 wallet-metadata sync; absent → no wallet metadata is synced. */
1660
+ readonly metaSync?: MetaSyncConfig;
1661
+ /**
1662
+ * Where the notification extension reads payload keys (iOS App Group keychain, Android app
1663
+ * storage). Absent → the extension cannot decrypt and shows the generic text; in-app
1664
+ * `notifications.receive` still works.
1665
+ */
1666
+ readonly pushKeys?: PushKeyStore;
1667
+ /** Test seam — defaults to the wallet's real spark proxy. */
1668
+ readonly sparkApis?: SparkControllerOptions["spark"];
1669
+ /**
1670
+ * The host's transport for a paired hardware device (Ledger APDUs, a Keystone QR channel). Absent
1671
+ * → hardware wallets cannot sign, verify addresses or fetch accounts here.
1672
+ */
1673
+ readonly deviceIo?: (device: HardwareDevice) => DeviceIo;
1674
+ };
1675
+ /** A controller's store without `setState`: hosts read and subscribe, only the engine writes. */
1676
+ type ReadonlyStore<S> = Pick<StoreApi<S>, "getState" | "getInitialState" | "subscribe">;
1677
+ /**
1678
+ * Read-only view all the way down: primitives and functions pass through, `Uint8Array` and the
1679
+ * other ArrayBuffer views stay as-is (they are runtime-frozen only as objects, and their contents
1680
+ * are engine inputs anyway — the runtime freeze cannot cover them), arrays become ReadonlyArray,
1681
+ * Map/Set their readonly twins, and every other object is mapped readonly recursively.
1682
+ */
1683
+ type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends Uint8Array | Uint8ClampedArray | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Float16Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | DataView ? T : T extends ReadonlyArray<infer E> ? ReadonlyArray<DeepReadonly<E>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlySet<infer E> ? ReadonlySet<DeepReadonly<E>> : T extends Record<PropertyKey, unknown> ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
1684
+ /**
1685
+ * A controller as hosts hold it: its state, deeply read-only, and the methods named in `K`.
1686
+ * Lifecycle and the wiring between controllers stay with the engine, and a method added to a
1687
+ * controller is not host API until it is listed here.
1688
+ */
1689
+ type HostController<C extends Controller<Record<string, unknown>>, K extends Exclude<keyof C, "store">> = Pick<C, Exclude<K, "getState">> & {
1690
+ readonly getState: () => DeepReadonly<ReturnType<C["getState"]>>;
1691
+ readonly store: ReadonlyStore<DeepReadonly<ReturnType<C["getState"]>>>;
1692
+ };
1693
+ type WalletEngine = {
1694
+ readonly networks: HostController<NetworkController, "endpoints" | "info" | "enabled" | "client" | "independentClient" | "solanaRpc" | "esplora" | "addRpc">;
1695
+ readonly assets: HostController<AssetsController, "setVisible" | "refresh" | "refreshBitcoinGroup" | "isTracked" | "tokenMetadata" | "addToken" | "setTokenHidden">;
1696
+ /** Spot prices of the held assets — display-only; nothing that builds or signs reads them. */
1697
+ readonly prices: HostController<PricesController, "setVisible" | "setCurrency" | "refresh">;
1698
+ /**
1699
+ * Fiat valuation of the balances already in state, at the current quotes — exact decimals,
1700
+ * display-only. `group` covers the group's EVM and Solana addresses on every enabled network, its
1701
+ * Bitcoin accounts and its Spark balance; it reads no chain.
1702
+ */
1703
+ readonly portfolio: {
1704
+ readonly group: (group: {
1705
+ readonly walletId: string;
1706
+ readonly groupIndex: number;
1707
+ }) => Promise<Valuation>;
1708
+ };
1709
+ /** Tracked transactions and coin control; every send, replacement and dApp signature is a request. */
1710
+ readonly transactions: HostController<TransactionController, "txById" | "nextReceiveAddress" | "setUtxosFrozen" | "frozenUtxos">;
1711
+ readonly requests: HostController<RequestController, "prepare" | "approve" | "reject" | "outcome" | "signLog" | "clearSignLog">;
1712
+ /**
1713
+ * External signers: at most one card/hardware operation at a time, its progress in `active`.
1714
+ * Every engine signature runs through its `apis` — the request's wallet custody decides whether
1715
+ * the vault signs directly or the signer runs first.
1716
+ */
1717
+ readonly signers: HostController<SignersController, "apis" | "cancel" | "verifyAddress" | "fetchAccounts">;
1718
+ readonly addressBook: HostController<AddressBookController, "add" | "rename" | "setNote" | "remove">;
1719
+ readonly history: HostController<HistoryController, "load" | "loadMore">;
1720
+ /**
1721
+ * The approvals inventory: loaded per account+network, every row corroborated on chain.
1722
+ * `exposure(key)` values the rows' exposure at current quotes — display-only.
1723
+ */
1724
+ readonly approvals: HostController<ApprovalsController, "load" | "unload" | "refresh" | "setVisible" | "revoke" | "revokeBatch"> & {
1725
+ readonly exposure: (key: string) => Valuation;
1726
+ };
1727
+ /** NFT inventory — display-only gateway data; transfers go through requests. */
1728
+ readonly nfts: HostController<NftController, "setVisible" | "load" | "loadMore" | "refresh" | "detail" | "collection" | "floor" | "setHidden" | "inscriptions">;
1729
+ readonly notifications: HostController<NotificationsController, "setToken" | "enable" | "disable" | "receive">;
1730
+ /** DApp sessions; `checkOrigin` and `invalidateOrigin` are what `createBrowserBridge` needs. */
1731
+ readonly connections: HostController<ConnectionController, "checkOrigin" | "invalidateOrigin" | "session" | "pending" | "sessionAccounts" | "previewAccounts" | "nostrIdentity" | "isEnabled" | "approveConnection" | "rejectConnection" | "revoke" | "setCurrentNetwork" | "setTronNetwork" | "activeIdentity" | "setActiveIdentity" | "nostrPolicy" | "lightningPolicy" | "establishWalletConnect" | "authorize" | "touch">;
1732
+ readonly eip1193: Pick<Eip1193Handler, "handle" | "subscribe">;
1733
+ readonly nip07: Pick<Nip07Handler, "handle">;
1734
+ readonly webln: Pick<WeblnHandler, "handle">;
1735
+ readonly solanaWallet: Pick<SolanaWalletHandler, "handle" | "subscribe">;
1736
+ readonly bitcoinWallet: Pick<BitcoinWalletHandler, "handle" | "subscribe">;
1737
+ readonly tronWallet: Pick<TronWalletHandler, "handle" | "subscribe">;
1738
+ /** The phishing list: lifecycle is independent of the lock state. */
1739
+ readonly phishing: HostController<PhishingController, "check" | "sync" | "trust" | "untrust">;
1740
+ /** Read and receive surface; every payment goes through `requests`. */
1741
+ readonly spark: HostController<SparkController, "history" | "accountBalance" | "archivePayment" | "receiveAddress" | "createInvoice" | "newDepositAddress" | "paymentStatus" | "quoteExit" | "registerLightningAddress" | "unregisterLightningAddress">;
1742
+ readonly accounts: HostController<AccountTreeController, "imported" | "addGroup" | "addGroups" | "renameWallet" | "renameGroup" | "setHidden" | "select" | "bind" | "unbind" | "bindingOf" | "discoverSpark" | "discoverGroups" | "refreshTotals">;
1743
+ readonly watch: {
1744
+ readonly add: (input: {
1745
+ readonly family: "evm" | "solana" | "bitcoin" | "tron";
1746
+ readonly address: string;
1747
+ readonly name?: string;
1748
+ readonly qr?: {
1749
+ readonly fingerprint: string;
1750
+ readonly path: string;
1751
+ readonly xpub?: string;
1752
+ };
1753
+ }) => Promise<WatchAccount>;
1754
+ readonly rename: (id: string, name: string) => Promise<void>;
1755
+ readonly remove: (id: string) => Promise<void>;
1756
+ readonly list: () => ReadonlyArray<WatchAccount>;
1757
+ readonly assets: (id: string, network: string) => Promise<AccountBalances>;
1758
+ };
1759
+ readonly metaSync: HostController<MetaSyncController, "sync">;
1760
+ readonly backup: HostController<BackupController, "enable" | "disable" | "sync" | "list" | "restore">;
1761
+ readonly zaps: {
1762
+ readonly prepare: (params: PrepareZapParams) => Promise<PreparedZap>;
1763
+ };
1764
+ readonly names: {
1765
+ /** Forward-resolves an ENS name for a send on `network`; throws when it cannot resolve. */
1766
+ readonly resolve: (name: string, network: string) => Promise<EnsResolution>;
1767
+ };
1768
+ /** The account's EIP-7702 delegation state on `network`. */
1769
+ readonly delegation: (account: AccountRef, network: string) => Promise<DelegationStatus>;
1770
+ /**
1771
+ * A gateway Across bridge quote — display-only; `undefined` when the route has no liquidity.
1772
+ * `status` reads the Across deposit-status API; neither affects signing.
1773
+ */
1774
+ readonly bridges: {
1775
+ readonly quote: (params: {
1776
+ readonly account: AccountRef;
1777
+ readonly network: string;
1778
+ readonly destinationNetwork: string;
1779
+ readonly inputToken: string;
1780
+ readonly outputToken: string;
1781
+ readonly amount: bigint;
1782
+ /** Highest relay fee accepted, in basis points of the input amount. */
1783
+ readonly maxFeeBps: number;
1784
+ }) => Promise<AcrossBridgeQuote | undefined>;
1785
+ readonly status: (params: {
1786
+ readonly network: string;
1787
+ readonly txHash: string;
1788
+ }) => Promise<AcrossBridgeStatus>;
1789
+ };
1790
+ /** Imported single private keys held in the vault — passthrough to `wallet.keys`. */
1791
+ readonly keys: KeysApi;
1792
+ /**
1793
+ * A gateway swap quote (0x on EVM, Jupiter on Solana) bound to the request's tokens, amount and
1794
+ * slippage; `undefined` when the quote has no liquidity.
1795
+ */
1796
+ readonly swaps: {
1797
+ readonly quote: (params: {
1798
+ readonly account: AccountRef;
1799
+ readonly network: string;
1800
+ readonly sell: string;
1801
+ readonly buy: string;
1802
+ readonly amount: bigint;
1803
+ readonly slippageBps: number;
1804
+ }) => Promise<SwapQuote | undefined>;
1805
+ };
1806
+ /** Lido liquid staking on Ethereum mainnet — stETH balance and withdrawal requests. */
1807
+ readonly lido: {
1808
+ readonly position: (account: AccountRef) => Promise<LidoPosition>;
1809
+ };
1810
+ /** Solana staking reads — the account's stake positions and the current validator set. */
1811
+ readonly staking: {
1812
+ readonly positions: (account: AccountRef, network: string) => Promise<ReadonlyArray<StakePosition>>;
1813
+ readonly validators: (network: string) => Promise<ReadonlyArray<StakeValidator>>;
1814
+ };
1815
+ readonly payments: {
1816
+ readonly parse: (input: string, network: SparkNetwork) => PaymentParse;
1817
+ readonly resolve: (input: string, network: SparkNetwork) => Promise<PaymentParse>;
1818
+ /** Receives funds from an LNURL-withdraw service; needs no verification factor. */
1819
+ readonly withdrawLnurl: (params: WithdrawLnurlParams) => Promise<{
1820
+ readonly kind: "lnurl-withdraw";
1821
+ readonly invoice: LightningInvoice;
1822
+ }>;
1823
+ };
1824
+ /** Stops listening to the wallet and stops the phishing list refresh. */
1825
+ readonly unsubscribe: () => void;
1826
+ };
1827
+ declare function createWalletEngine(options: EngineOptions): WalletEngine;
1828
+ export { NFT_POLL_MS as $, BackupControllerState as A, APPROVALS_POLL_MS as At, AccountTreeController as B, SessionLink as Bt, MetaSyncErrorCategory as C, Holding as Ct, HistoryState as D, PricesControllerOptions as Dt, HistoryControllerOptions as E, PricesController as Et, checkCloudName as F, ApprovalRow as Ft, MetaDocWallet as G, TokenBalance as Gt, MetaDoc as H, AccountBalances as Ht, checkCloudText as I, ApprovalSource as It, StakeValidator as J, BitcoinSourceKey as Jt, WatchAccount as K, TronAccountView as Kt, BackupControllerError as L, ApprovalSourceState as Lt, CloudStore as M, ApprovalsControllerOptions as Mt, CloudStoreError as N, ApprovalKind as Nt, HistoryGroup as O, PricesFailure as Ot, CloudStoreErrorCode as P, ApprovalRisk as Pt, NFT_INVENTORY_MAX_PAGES as Q, BackupErrorCategory as R, ApprovalsState as Rt, MetaSyncError as S, ValuedHolding as St, HistoryController as T, PriceQuoteState as Tt, MetaDocGroup as U, AssetsController as Ut, AccountTreeState as V, TokenRef as Vt, MetaDocTree as W, AssetsControllerState as Wt, LidoWithdrawalRequest as X, BitcoinUtxoView as Xt, LidoPosition as Y, BitcoinTotals as Yt, EnsResolution as Z, MetaSyncConfig as _, HistoryFlag as _t, WalletEngine as a, NftInventory as at, MetaSyncState as b, PriceView as bt, SignerFamily as c, NftView as ct, NotificationEvent as d, NftCollectionView as dt, NftController as et, NotificationStatus as f, NftItemFacts as ft, PushKeyStore as g, HistoryEntry as gt, NotificationsState as h, HistoryChange as ht, ReadonlyStore as i, NftFloorView as it, CLOUD_TEXT_MAX_BYTES as j, ApprovalsController as jt, BackupController as k, PricesState as kt, SignersController as l, NftAcquisition as lt, NotificationsControllerOptions as m, NftTransferSupport as mt, EngineOptions as n, NftDetailView as nt, createWalletEngine as o, NftResult as ot, NotificationsController as p, NftMedia as pt, StakePosition as q, SpamReason as qt, HostController as r, NftFailure as rt, SignerActivity as s, NftState as st, DeepReadonly as t, NftControllerOptions as tt, SignersState as u, NftSpamReason as ut, MetaSyncController as v, HistoryStatus as vt, GroupHistory as w, PRICES_POLL_MS as wt, MetaSyncWalletStatus as x, Valuation as xt, MetaSyncRelayPort as y, PRICE_STALE_MS as yt, AccountGroup as z, ApprovalsView as zt };
1829
+ //# sourceMappingURL=engine-Dic_kkEr.d.mts.map