@qntx/wallet-engine 0.11.0 → 0.13.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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- import { $ as PrepareZapContext, A as PayInput, At as EngineCollection, B as SignLogEntry, C as ConnectionOrigin, Ct as NetworkController, Dt as AddressBookEntry, E as ConnectionState, Et as AddressBookState, F as RequestControllerState, Ft as createEventBus, G as RiskFinding, H as BrowserOrigin, I as RequestInput, It as Controller, J as PHISHING_REFRESH_MS, K as TransactionController, L as RequestStage, Lt as ControllerOptions, M as REQUEST_TTL_MS, Mt as PublicStore, N as RESIMULATE_AFTER_MS, Nt as EngineLogger, O as PendingConnection, Ot as AddressBookRecord, P as RequestController, Pt as EventBus, Q as PhishingStatus, R as SparkDepositInput, S as ConnectionController, St as RequestCheckCode, T as ConnectionSession, Tt as AddressBookController, U as RequestMethod, V as SignLogOutcome, W as RequestOrigin, X as PhishingControllerOptions, Y as PhishingController, Z as PhishingState, _t as SparkControllerOptions, at as WithdrawLnurlParams, b as BitcoinWalletHandler, bt as PaymentNote, ct as PaymentParse, dt as PreparedSparkAction, et as PrepareZapParams, f as Eip1193Event, ft as SparkDisplay, gt as SparkController, ht as SparkClientFactory, it as PayParams, j as PendingRequest, jt as EngineStore, k as EvmSignInput, kt as AddressFamily, l as SolanaWalletHandler, lt as PaymentRequest, m as Eip1193Request, mt as SparkAccountState, n as WeblnHandler, nt as ZapRecipient, ot as ParseOptions, p as Eip1193Handler, pt as SparkResult, q as SignatureResult, rt as prepareZap, st as PaymentOption, t as ProviderError, tt as PreparedZap, u as Nip07Handler, ut as parsePayment, vt as SparkControllerState, w as ConnectionScope, wt as Esplora, x as AccountGroup$1, xt as SparkActivity, yt as sparkStore, z as SparkExitInput } from "./errors-Bglz0VYn.mjs";
2
- import { BackupHeader, BackupInfo, InitialFactor, UnlockFactor, Wallet, WalletInfo } from "@qntx/wallet";
1
+ import { $ as PHISHING_REFRESH_MS, A as PayInput, At as AddressBookController, B as SignLogEntry, Bt as createEventBus, C as ConnectionOrigin, Ct as SparkControllerState, Dt as RequestCheckCode, E as ConnectionState, Et as SparkActivity, F as RequestControllerState, Ft as EngineCollection, G as RiskFinding, H as BrowserOrigin, Ht as ControllerOptions, I as RequestInput, It as EngineStore, J as DelegationStatus, K as TransactionController, L as RequestStage, Lt as PublicStore, M as REQUEST_TTL_MS, Mt as AddressBookEntry, N as RESIMULATE_AFTER_MS, Nt as AddressBookRecord, O as PendingConnection, Ot as NetworkController, P as RequestController, Pt as AddressFamily, Q as AcrossBridgeStatus, R as SparkDepositInput, Rt as EngineLogger, S as ConnectionController, St as SparkControllerOptions, T as ConnectionSession, Tt as PaymentNote, U as RequestMethod, V as SignLogOutcome, Vt as Controller, W as RequestOrigin, X as SwapQuote, Y as SignatureResult, Z as AcrossBridgeQuote, _t as SparkDisplay, at as PrepareZapParams, b as BitcoinWalletHandler, bt as SparkClientFactory, ct as prepareZap, dt as ParseOptions, et as PhishingController, f as Eip1193Event, ft as PaymentOption, gt as PreparedSparkAction, ht as parsePayment, it as PrepareZapContext, j as PendingRequest, jt as AddressBookState, k as EvmSignInput, kt as Esplora, l as SolanaWalletHandler, lt as PayParams, m as Eip1193Request, mt as PaymentRequest, n as WeblnHandler, nt as PhishingState, ot as PreparedZap, p as Eip1193Handler, pt as PaymentParse, q as AccountRef, rt as PhishingStatus, st as ZapRecipient, t as ProviderError, tt as PhishingControllerOptions, u as Nip07Handler, ut as WithdrawLnurlParams, vt as SparkResult, w as ConnectionScope, wt as sparkStore, x as AccountGroup$1, xt as SparkController, yt as SparkAccountState, z as SparkExitInput, zt as EventBus } from "./errors-CQnlTc1i.mjs";
2
+ import { BackupHeader, BackupInfo, InitialFactor, KeyInfo, KeysApi, UnlockFactor, Wallet, WalletInfo } from "@qntx/wallet";
3
3
  import { LightningInvoice, SparkExitChain, SparkNetwork } from "@qntx/spark";
4
4
  import { Event, Filter } from "@qntx/nostr";
5
+ import { readContract } from "viem/actions";
5
6
  import { WalletSyncSigner } from "@qntx/wallet/nostr";
6
7
  import { getEnsAddress } from "viem/ens";
7
8
  type EngineErrorCode = "closed" | "integrity" | "invalid-input";
@@ -18,6 +19,65 @@ export declare function createMemoryEngineStore(backing?: {
18
19
  export declare function createMemoryPublicStore(backing?: {
19
20
  readonly values?: Map<string, Uint8Array>;
20
21
  }): PublicStore;
22
+ type TokenBalance = {
23
+ readonly address: string;
24
+ readonly symbol: string;
25
+ readonly decimals: number;
26
+ readonly balance: string;
27
+ /** False for user-added tokens until they appear in the built-in table. */
28
+ readonly verified: boolean;
29
+ };
30
+ type AccountBalances = {
31
+ readonly native: string;
32
+ readonly tokens: ReadonlyArray<TokenBalance>;
33
+ /** Bitcoin only — confirmed + own unconfirmed change; frozen 546/330-sat UTXOs shown apart. */
34
+ readonly unconfirmed?: string;
35
+ readonly frozen?: string;
36
+ };
37
+ type AssetsControllerState = {
38
+ readonly balances: Record<string, AccountBalances>;
39
+ };
40
+ type Options = {
41
+ readonly networks: NetworkController;
42
+ readonly openStore: () => Promise<EngineStore>;
43
+ readonly setTimer: (ms: number, fn: () => unknown) => () => void;
44
+ readonly logger: EngineLogger;
45
+ };
46
+ export declare class AssetsController extends Controller<AssetsControllerState> {
47
+ private readonly options;
48
+ private engineStore;
49
+ private readonly bitcoinUtxos;
50
+ private visible;
51
+ private cancelPoll;
52
+ private readonly customTokens;
53
+ constructor(options: Options);
54
+ init(): Promise<void>;
55
+ lock(): void;
56
+ destroy(): Promise<void>;
57
+ setVisible(visible: boolean): void;
58
+ private armPoll;
59
+ private refreshAll;
60
+ /** Reads the address's balances and returns exactly what it wrote under its state key. */
61
+ refresh(address: string, network: string): Promise<AccountBalances>;
62
+ /** SOL via getBalance; SPL via getTokenAccountsByOwner (jsonParsed) for known mints. */
63
+ private refreshSolana;
64
+ private readTokens;
65
+ private balanceOfBatch;
66
+ private balanceOf;
67
+ private callToken;
68
+ /** Whether `address` is in the built-in token table of `network` or among the custom tokens. */
69
+ isTracked(network: string, address: string): boolean;
70
+ /** The token's own `symbol` and `decimals` (EVM only); throws when either read fails. */
71
+ tokenMetadata(network: string, address: string): Promise<{
72
+ readonly symbol: string;
73
+ readonly decimals: number;
74
+ }>;
75
+ /** Reads symbol/decimals on-chain, marks unverified, persists; throws when the calls fail. */
76
+ addToken(network: string, address: string): Promise<void>;
77
+ private persistToken;
78
+ /** BTC balance = confirmed spendable + own unconfirmed change; frozen 546/330 shown separately. */
79
+ refreshBitcoin(xpub: string, network: string): Promise<AccountBalances>;
80
+ }
21
81
  type AddressBookErrorCategory = "invalid-input" | "duplicate" | "not-found" | "locked" | "limit";
22
82
  export declare class AddressBookError extends Error {
23
83
  readonly category: AddressBookErrorCategory;
@@ -119,6 +179,8 @@ export declare class AccountTreeController extends Controller<AccountTreeState>
119
179
  private sparkUnsubscribe;
120
180
  private cancelTotals;
121
181
  private persistChain;
182
+ /** Every imported private key in the vault — a separate list, never a group member. */
183
+ imported: () => Promise<ReadonlyArray<KeyInfo>>;
122
184
  constructor(options: AccountTreeControllerOptions);
123
185
  setStore(store: EngineStore | undefined): void;
124
186
  /** Load persisted state, reconcile with the snapshot, start driving Spark. */
@@ -193,64 +255,17 @@ export declare class AccountTreeController extends Controller<AccountTreeState>
193
255
  private scheduleTotalsPersist;
194
256
  private flushTotals;
195
257
  }
196
- type TokenBalance = {
258
+ /**
259
+ * A watch-only account: an address the wallet tracks but can never sign for. Kept out of
260
+ * `AccountRef` deliberately — a watch account can never reach a signing/request input.
261
+ */
262
+ type WatchAccount = {
263
+ readonly id: string;
264
+ readonly family: "evm" | "solana" | "bitcoin";
197
265
  readonly address: string;
198
- readonly symbol: string;
199
- readonly decimals: number;
200
- readonly balance: string;
201
- /** False for user-added tokens until they appear in the built-in table. */
202
- readonly verified: boolean;
203
- };
204
- type AccountBalances = {
205
- readonly native: string;
206
- readonly tokens: ReadonlyArray<TokenBalance>;
207
- /** Bitcoin only — confirmed + own unconfirmed change; frozen 546/330-sat UTXOs shown apart. */
208
- readonly unconfirmed?: string;
209
- readonly frozen?: string;
210
- };
211
- type AssetsControllerState = {
212
- readonly balances: Record<string, AccountBalances>;
213
- };
214
- type Options = {
215
- readonly networks: NetworkController;
216
- readonly openStore: () => Promise<EngineStore>;
217
- readonly setTimer: (ms: number, fn: () => unknown) => () => void;
218
- readonly logger: EngineLogger;
266
+ readonly name?: string;
267
+ readonly createdAt: number;
219
268
  };
220
- declare class AssetsController extends Controller<AssetsControllerState> {
221
- private readonly options;
222
- private engineStore;
223
- private readonly bitcoinUtxos;
224
- private visible;
225
- private cancelPoll;
226
- private readonly customTokens;
227
- constructor(options: Options);
228
- init(): Promise<void>;
229
- lock(): void;
230
- destroy(): Promise<void>;
231
- setVisible(visible: boolean): void;
232
- private armPoll;
233
- private refreshAll;
234
- refresh(address: string, network: string): Promise<void>;
235
- /** SOL via getBalance; SPL via getTokenAccountsByOwner (jsonParsed) for known mints. */
236
- private refreshSolana;
237
- private readTokens;
238
- private balanceOfBatch;
239
- private balanceOf;
240
- private callToken;
241
- /** Whether `address` is in the built-in token table of `network` or among the custom tokens. */
242
- isTracked(network: string, address: string): boolean;
243
- /** The token's own `symbol` and `decimals` (EVM only); throws when either read fails. */
244
- tokenMetadata(network: string, address: string): Promise<{
245
- readonly symbol: string;
246
- readonly decimals: number;
247
- }>;
248
- /** Reads symbol/decimals on-chain, marks unverified, persists; throws when the calls fail. */
249
- addToken(network: string, address: string): Promise<void>;
250
- private persistToken;
251
- /** BTC balance = confirmed spendable + own unconfirmed change; frozen 546/330 shown separately. */
252
- refreshBitcoin(xpub: string, network: string): Promise<void>;
253
- }
254
269
  /** BackupController error categories — never carry file contents, digests or secrets. */
255
270
  type BackupErrorCategory = "cloud" | "conflict" | "unavailable";
256
271
  export declare class BackupControllerError extends Error {
@@ -353,6 +368,17 @@ export declare class BackupController extends Controller<BackupControllerState>
353
368
  private reconcile;
354
369
  private pass;
355
370
  }
371
+ type LidoWithdrawalRequest = {
372
+ readonly id: bigint;
373
+ readonly amountOfStETH: bigint;
374
+ readonly timestamp: number;
375
+ readonly status: "pending" | "claimable" | "claimed";
376
+ readonly claimableEther?: bigint;
377
+ };
378
+ type LidoPosition = {
379
+ readonly stETH: bigint;
380
+ readonly requests: ReadonlyArray<LidoWithdrawalRequest>;
381
+ };
356
382
  /** Meta-sync error categories — messages never carry event or document content. */
357
383
  type MetaSyncErrorCategory = "network" | "internal" | "unsupported" | "corrupt";
358
384
  export declare class MetaSyncError extends Error {
@@ -444,6 +470,25 @@ type EnsResolution = {
444
470
  readonly address: string;
445
471
  readonly checks: ReadonlyArray<RequestCheckCode>;
446
472
  };
473
+ type StakePosition = {
474
+ readonly address: string;
475
+ readonly seed: string;
476
+ readonly lamports: bigint;
477
+ /**
478
+ * Display approximation of the activation state — warmup and cooldown are rate-limited, so an
479
+ * "active" account can still be partially activating and a "deactivating" one partly liquid.
480
+ */
481
+ readonly state: "initialized" | "activating" | "active" | "deactivating" | "inactive";
482
+ readonly validator?: string;
483
+ readonly activationEpoch?: bigint;
484
+ readonly deactivationEpoch?: bigint;
485
+ };
486
+ type StakeValidator = {
487
+ readonly vote: string;
488
+ readonly node: string;
489
+ readonly commission: number;
490
+ readonly activatedStake: bigint;
491
+ };
447
492
  type EngineOptions = {
448
493
  readonly wallet: Wallet;
449
494
  /**
@@ -463,6 +508,11 @@ type EngineOptions = {
463
508
  readonly lightningMaxFee: (amountSats: number) => number;
464
509
  readonly logger: EngineLogger;
465
510
  readonly openStore: () => Promise<EngineStore>;
511
+ /** The host surfaces a call bundle's status page — `wallet_showCallsStatus` triggers it. */
512
+ readonly showCallsStatus: (request: {
513
+ readonly origin: string;
514
+ readonly txIds: ReadonlyArray<string>;
515
+ }) => void;
466
516
  /**
467
517
  * Non-secret device data (the phishing list, the origins the user trusts), available while the
468
518
  * wallet is locked: a page can be opened before the first unlock.
@@ -509,6 +559,17 @@ type WalletEngine = {
509
559
  /** Read and receive surface; every payment goes through `requests`. */
510
560
  readonly spark: Omit<SparkController, "send" | "payInvoice" | "paySparkInvoice" | "withdraw">;
511
561
  readonly accounts: AccountTreeController;
562
+ readonly watch: {
563
+ readonly add: (input: {
564
+ readonly family: "evm" | "solana" | "bitcoin";
565
+ readonly address: string;
566
+ readonly name?: string;
567
+ }) => Promise<WatchAccount>;
568
+ readonly rename: (id: string, name: string) => Promise<void>;
569
+ readonly remove: (id: string) => Promise<void>;
570
+ readonly list: () => ReadonlyArray<WatchAccount>;
571
+ readonly assets: (id: string, network: string) => Promise<AccountBalances>;
572
+ };
512
573
  readonly metaSync: MetaSyncController;
513
574
  readonly backup: BackupController;
514
575
  readonly zaps: {
@@ -518,6 +579,48 @@ type WalletEngine = {
518
579
  /** Forward-resolves an ENS name for a send on `network`; throws when it cannot resolve. */
519
580
  readonly resolve: (name: string, network: string) => Promise<EnsResolution>;
520
581
  };
582
+ /** The account's EIP-7702 delegation state on `network`. */
583
+ readonly delegation: (account: AccountRef, network: string) => Promise<DelegationStatus>;
584
+ /**
585
+ * A gateway Across bridge quote — display-only; `undefined` when the route has no liquidity.
586
+ * `status` reads the Across deposit-status API; neither affects signing.
587
+ */
588
+ readonly bridges: {
589
+ readonly quote: (params: {
590
+ readonly account: AccountRef;
591
+ readonly network: string;
592
+ readonly destinationNetwork: string;
593
+ readonly inputToken: string;
594
+ readonly outputToken: string;
595
+ readonly amount: bigint;
596
+ }) => Promise<AcrossBridgeQuote | undefined>;
597
+ readonly status: (params: {
598
+ readonly network: string;
599
+ readonly txHash: string;
600
+ }) => Promise<AcrossBridgeStatus>;
601
+ };
602
+ /** A gateway 0x swap quote — display-only; `undefined` when the quote has no liquidity. */
603
+ /** Imported single private keys held in the vault — passthrough to `wallet.keys`. */
604
+ readonly keys: KeysApi;
605
+ readonly swaps: {
606
+ readonly quote: (params: {
607
+ readonly account: AccountRef;
608
+ readonly network: string;
609
+ readonly sell: string;
610
+ readonly buy: string;
611
+ readonly amount: bigint;
612
+ readonly slippageBps: number;
613
+ }) => Promise<SwapQuote | undefined>;
614
+ };
615
+ /** Lido liquid staking on Ethereum mainnet — stETH balance and withdrawal requests. */
616
+ readonly lido: {
617
+ readonly position: (account: AccountRef) => Promise<LidoPosition>;
618
+ };
619
+ /** Solana staking reads — the account's stake positions and the current validator set. */
620
+ readonly staking: {
621
+ readonly positions: (account: AccountRef, network: string) => Promise<ReadonlyArray<StakePosition>>;
622
+ readonly validators: (network: string) => Promise<ReadonlyArray<StakeValidator>>;
623
+ };
521
624
  readonly payments: {
522
625
  readonly parse: (input: string, network: SparkNetwork) => PaymentParse;
523
626
  readonly resolve: (input: string, network: SparkNetwork) => Promise<PaymentParse>;
@@ -562,5 +665,5 @@ type ResolveOptions = ParseOptions & {
562
665
  export declare function resolvePayment(input: string, options: ResolveOptions): Promise<PaymentParse>;
563
666
  export declare function encodeExitChain(chain: SparkExitChain): Uint8Array;
564
667
  export declare function decodeExitChain(bytes: Uint8Array): SparkExitChain;
565
- export { type AccountGroup, type AccountTreeState, AddressBookController, type AddressBookEntry, type AddressBookErrorCategory, type AddressBookState, type AddressFamily, type BackupControllerState, type BackupErrorCategory, type BrowserOrigin, type CloudStore, type AccountGroup$1 as ConnectionAccountGroup, ConnectionController, type ConnectionOrigin, type ConnectionScope, type ConnectionSession, type ConnectionState, Controller, type ControllerOptions, type Eip1193Event, Eip1193Handler, type Eip1193Request, type EngineCollection, type EngineErrorCode, type EngineLogger, type EngineOptions, type EngineStore, type EventBus, type EvmSignInput, type MetaDoc, type MetaDocGroup, type MetaDocTree, type MetaDocWallet, type MetaSyncConfig, type MetaSyncRelayPort, type MetaSyncState, type MetaSyncWalletStatus, PHISHING_REFRESH_MS, type PayInput, type PayParams, type PaymentNote, type PaymentOption, type PaymentParse, type PaymentRequest, type PendingConnection, type PendingRequest, PhishingController, type PhishingControllerOptions, type PhishingState, type PhishingStatus, type PrepareZapContext, type PrepareZapParams, type PreparedSparkAction, type PreparedZap, ProviderError, type PublicStore, REQUEST_TTL_MS, RESIMULATE_AFTER_MS, type RequestCheckCode, RequestController, type RequestControllerState, type RequestInput, type RequestMethod, type RequestOrigin, type RequestStage, type RiskFinding, type SignLogEntry, type SignLogOutcome, type SignatureResult, type SparkAccountState, type SparkActivity, type SparkClientFactory, SparkController, type SparkControllerOptions, type SparkControllerState, type SparkDepositInput, type SparkDisplay, type SparkErrorCategory, type SparkExitInput, type SparkResult, type WalletEngine, type WithdrawLnurlParams, type ZapRecipient, createEventBus, parsePayment, prepareZap, sparkStore };
668
+ export { type AccountBalances, type AccountGroup, type AccountTreeState, AddressBookController, type AddressBookEntry, type AddressBookErrorCategory, type AddressBookState, type AddressFamily, type BackupControllerState, type BackupErrorCategory, type BrowserOrigin, type CloudStore, type AccountGroup$1 as ConnectionAccountGroup, ConnectionController, type ConnectionOrigin, type ConnectionScope, type ConnectionSession, type ConnectionState, Controller, type ControllerOptions, type Eip1193Event, Eip1193Handler, type Eip1193Request, type EngineCollection, type EngineErrorCode, type EngineLogger, type EngineOptions, type EngineStore, type EventBus, type EvmSignInput, type MetaDoc, type MetaDocGroup, type MetaDocTree, type MetaDocWallet, type MetaSyncConfig, type MetaSyncRelayPort, type MetaSyncState, type MetaSyncWalletStatus, PHISHING_REFRESH_MS, type PayInput, type PayParams, type PaymentNote, type PaymentOption, type PaymentParse, type PaymentRequest, type PendingConnection, type PendingRequest, PhishingController, type PhishingControllerOptions, type PhishingState, type PhishingStatus, type PrepareZapContext, type PrepareZapParams, type PreparedSparkAction, type PreparedZap, ProviderError, type PublicStore, REQUEST_TTL_MS, RESIMULATE_AFTER_MS, type RequestCheckCode, RequestController, type RequestControllerState, type RequestInput, type RequestMethod, type RequestOrigin, type RequestStage, type RiskFinding, type SignLogEntry, type SignLogOutcome, type SignatureResult, type SparkAccountState, type SparkActivity, type SparkClientFactory, SparkController, type SparkControllerOptions, type SparkControllerState, type SparkDepositInput, type SparkDisplay, type SparkErrorCategory, type SparkExitInput, type SparkResult, type TokenBalance, type WalletEngine, type WithdrawLnurlParams, type ZapRecipient, createEventBus, parsePayment, prepareZap, sparkStore };
566
669
  //# sourceMappingURL=index.d.mts.map