@qntx/wallet-engine 0.12.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/connect.d.mts +1 -1
- package/dist/connect.mjs +1 -1
- package/dist/{errors-DpkJneDe.d.mts → errors-CQnlTc1i.d.mts} +274 -10
- package/dist/gateway-contract.d.mts +247 -1
- package/dist/gateway-contract.mjs +146 -2
- package/dist/gateway-contract.mjs.map +1 -1
- package/dist/index.d.mts +162 -59
- package/dist/index.mjs +5899 -3613
- package/dist/index.mjs.map +1 -1
- package/dist/{registry-Deo5WQe1.d.mts → registry-DwguKWvt.d.mts} +3 -1
- package/dist/{registry-wYrcuFNc.mjs → registry-oorLoGtz.mjs} +23 -2
- package/dist/registry-oorLoGtz.mjs.map +1 -0
- package/dist/{webln-DzsI7jVb.mjs → webln-DKqCnqx1.mjs} +58 -10
- package/dist/webln-DKqCnqx1.mjs.map +1 -0
- package/package.json +8 -6
- package/dist/registry-wYrcuFNc.mjs.map +0 -1
- package/dist/webln-DzsI7jVb.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as networkById, n as NETWORKS, r as SOLANA_NETWORKS, t as BITCOIN_NETWORKS } from "./registry-
|
|
1
|
+
import { i as networkById, n as NETWORKS, r as SOLANA_NETWORKS, t as BITCOIN_NETWORKS } from "./registry-oorLoGtz.mjs";
|
|
2
2
|
import { utf8ToBytes } from "@noble/hashes/utils.js";
|
|
3
3
|
import * as z from "zod/mini";
|
|
4
4
|
import { base64 } from "@scure/base";
|
|
@@ -389,6 +389,150 @@ const union = (a, b) => merge(a, b, () => true);
|
|
|
389
389
|
const difference = (a, b) => merge(a, b, (inA, inB) => inA && !inB);
|
|
390
390
|
/** `(list − remove) ∪ add`. */
|
|
391
391
|
const applyDiff = (list, add, remove) => union(difference(list, remove), add);
|
|
392
|
-
|
|
392
|
+
// src/gateway/contract/quotes.ts
|
|
393
|
+
/** The native-token sentinel 0x uses for sell and buy tokens. */
|
|
394
|
+
const ZEROX_NATIVE_TOKEN = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
395
|
+
/** `0x` + 40 hex — an EVM address, the 0x native sentinel `0xEeee…` among them. */
|
|
396
|
+
const evmAddress = z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/));
|
|
397
|
+
/** A decimal string of a non-negative integer (`"0"` allowed for gas nulls). */
|
|
398
|
+
const decimal = z.string().check(z.regex(/^[0-9]+$/));
|
|
399
|
+
/** The `swapQuote` request: which exact-in sell on which chain, for which taker, at what slippage. */
|
|
400
|
+
const swapQuoteRequest = z.object({
|
|
401
|
+
/** `eip155:<n>` — the only namespace a 0x swap supports. */
|
|
402
|
+
network: caip2.check(z.regex(/^eip155:[0-9]+$/)),
|
|
403
|
+
/** The token sold — an ERC-20 address, or `0xEeeee…` for native. */
|
|
404
|
+
sellToken: evmAddress,
|
|
405
|
+
/** The token bought — an ERC-20 address, or `0xEeeee…` for native. */
|
|
406
|
+
buyToken: evmAddress,
|
|
407
|
+
/** Exact base-unit sell amount, a positive integer as decimal. */
|
|
408
|
+
sellAmount: z.string().check(z.regex(/^[1-9][0-9]*$/)),
|
|
409
|
+
/** The address the settlement contract pays out for. */
|
|
410
|
+
taker: evmAddress,
|
|
411
|
+
/** Worst-case slippage in basis points, 1–5000 (a query string, coerced). */
|
|
412
|
+
slippageBps: z.coerce.number().check(z.int(), z.minimum(1), z.maximum(5e3))
|
|
413
|
+
});
|
|
414
|
+
const fee = z.object({
|
|
415
|
+
/** The token the fee is charged in (sell or buy token). */
|
|
416
|
+
token: evmAddress,
|
|
417
|
+
/** The fee amount in base units. */
|
|
418
|
+
amount: decimal
|
|
419
|
+
});
|
|
420
|
+
/** A quote with liquidity: the AllowanceHolder `exec` calldata to sign and the terms it must keep. */
|
|
421
|
+
const quoteFilled = z.object({
|
|
422
|
+
liquidity: z.literal(true),
|
|
423
|
+
provider: z.literal("0x"),
|
|
424
|
+
sellToken: evmAddress,
|
|
425
|
+
buyToken: evmAddress,
|
|
426
|
+
sellAmount: decimal,
|
|
427
|
+
buyAmount: decimal,
|
|
428
|
+
minBuyAmount: decimal,
|
|
429
|
+
/** The spender `exec` approves — `null` for a native sell. */
|
|
430
|
+
allowanceTarget: z.union([evmAddress, z.null()]),
|
|
431
|
+
transaction: z.object({
|
|
432
|
+
to: evmAddress,
|
|
433
|
+
data: z.string().check(z.regex(/^0x[0-9a-fA-F]*$/)),
|
|
434
|
+
value: decimal,
|
|
435
|
+
gas: z.union([decimal, z.null()])
|
|
436
|
+
}),
|
|
437
|
+
fees: z.object({
|
|
438
|
+
integrator: z.union([fee, z.null()]),
|
|
439
|
+
zeroEx: z.union([fee, z.null()])
|
|
440
|
+
}),
|
|
441
|
+
/** The block the quote was priced at — staleness is measured against this. */
|
|
442
|
+
blockNumber: decimal
|
|
443
|
+
});
|
|
444
|
+
/** No route found: the response carries only the liquidity flag. */
|
|
445
|
+
const quoteEmpty = z.object({ liquidity: z.literal(false) });
|
|
446
|
+
const swapQuoteResponse = z.union([quoteFilled, quoteEmpty]);
|
|
447
|
+
const swapQuote = endpoint("GET", "/v1/quotes/swap", swapQuoteRequest, swapQuoteResponse);
|
|
448
|
+
/** Base58 public key — Solana mints, program ids, takers and accounts are all 32-byte keys. */
|
|
449
|
+
const base58$1 = z.string().check(z.regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/));
|
|
450
|
+
/** Jupiter is mainnet-only — every other Solana CAIP-2 id is a client error. */
|
|
451
|
+
const SOLANA_MAINNET = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
452
|
+
/** The `swapQuoteSolana` request: an exact-in mint pair for a taker on Solana mainnet. */
|
|
453
|
+
const swapQuoteSolanaRequest = z.object({
|
|
454
|
+
network: z.literal(SOLANA_MAINNET),
|
|
455
|
+
/** The mint sold — `So111…112` for wrapped SOL. */
|
|
456
|
+
inputMint: base58$1,
|
|
457
|
+
/** The mint bought — `So111…112` for wrapped SOL. */
|
|
458
|
+
outputMint: base58$1,
|
|
459
|
+
/** Exact base-unit sell amount, a positive integer as decimal. */
|
|
460
|
+
amount: z.string().check(z.regex(/^[1-9][0-9]*$/)),
|
|
461
|
+
/** The account the swap settles for. */
|
|
462
|
+
taker: base58$1,
|
|
463
|
+
/** Worst-case slippage in basis points, 1–5000 (a query string, coerced). */
|
|
464
|
+
slippageBps: z.coerce.number().check(z.int(), z.minimum(1), z.maximum(5e3))
|
|
465
|
+
});
|
|
466
|
+
/** One Solana instruction as the wire carries it — base64 data, plain account flags. */
|
|
467
|
+
const solanaInstruction = z.object({
|
|
468
|
+
programId: base58$1,
|
|
469
|
+
accounts: z.array(z.object({
|
|
470
|
+
address: base58$1,
|
|
471
|
+
signer: z.boolean(),
|
|
472
|
+
writable: z.boolean()
|
|
473
|
+
})),
|
|
474
|
+
data: z.string().check(z.regex(/^[A-Za-z0-9+/]*={0,2}$/))
|
|
475
|
+
});
|
|
476
|
+
/**
|
|
477
|
+
* A Jupiter `/build` relay: the instructions that assemble the versioned transaction — the engine
|
|
478
|
+
* replaces the compute budget with its own and reads the named lookup tables from chain.
|
|
479
|
+
*/
|
|
480
|
+
const solanaQuoteFilled = z.object({
|
|
481
|
+
liquidity: z.literal(true),
|
|
482
|
+
provider: z.literal("jupiter"),
|
|
483
|
+
inputMint: base58$1,
|
|
484
|
+
outputMint: base58$1,
|
|
485
|
+
inAmount: decimal,
|
|
486
|
+
outAmount: decimal,
|
|
487
|
+
otherAmountThreshold: decimal,
|
|
488
|
+
slippageBps: z.coerce.number().check(z.int()),
|
|
489
|
+
setup: z.array(solanaInstruction),
|
|
490
|
+
swap: solanaInstruction,
|
|
491
|
+
cleanup: z.union([solanaInstruction, z.null()]),
|
|
492
|
+
/** The address lookup tables the message compresses against — contents never come over the wire. */
|
|
493
|
+
lookupTables: z.array(base58$1)
|
|
494
|
+
});
|
|
495
|
+
const swapQuoteSolanaResponse = z.union([solanaQuoteFilled, quoteEmpty]);
|
|
496
|
+
const swapQuoteSolana = endpoint("GET", "/v1/quotes/swap/solana", swapQuoteSolanaRequest, swapQuoteSolanaResponse);
|
|
497
|
+
/** The `bridgeQuote` request: an exact-in token transfer from an origin chain to a destination. */
|
|
498
|
+
const bridgeQuoteRequest = z.object({
|
|
499
|
+
/** `eip155:<n>` — the origin chain. */
|
|
500
|
+
network: caip2.check(z.regex(/^eip155:[0-9]+$/)),
|
|
501
|
+
/** `eip155:<n>` — the destination chain. */
|
|
502
|
+
destinationNetwork: caip2.check(z.regex(/^eip155:[0-9]+$/)),
|
|
503
|
+
/** The token deposited on the origin chain — the chain's wrapped native for a native send. */
|
|
504
|
+
inputToken: evmAddress,
|
|
505
|
+
/** The token received on the destination chain. */
|
|
506
|
+
outputToken: evmAddress,
|
|
507
|
+
/** Exact base-unit input amount, a positive integer as decimal. */
|
|
508
|
+
amount: z.string().check(z.regex(/^[1-9][0-9]*$/)),
|
|
509
|
+
/** The account the deposit settles for. */
|
|
510
|
+
taker: evmAddress
|
|
511
|
+
});
|
|
512
|
+
/**
|
|
513
|
+
* An Across `/suggested-fees` relay: the deposit terms the engine must verify on-chain — output and
|
|
514
|
+
* deadline verbatim, the spoke pool address so a stale or spoofed build is refused.
|
|
515
|
+
*/
|
|
516
|
+
const bridgeQuoteFilled = z.object({
|
|
517
|
+
liquidity: z.literal(true),
|
|
518
|
+
provider: z.literal("across"),
|
|
519
|
+
inputToken: evmAddress,
|
|
520
|
+
outputToken: evmAddress,
|
|
521
|
+
inputAmount: decimal,
|
|
522
|
+
outputAmount: decimal,
|
|
523
|
+
destinationNetwork: caip2.check(z.regex(/^eip155:[0-9]+$/)),
|
|
524
|
+
quoteTimestamp: z.coerce.number().check(z.int()),
|
|
525
|
+
fillDeadline: z.coerce.number().check(z.int()),
|
|
526
|
+
exclusiveRelayer: evmAddress,
|
|
527
|
+
exclusivityParameter: z.coerce.number().check(z.int()),
|
|
528
|
+
spokePool: evmAddress,
|
|
529
|
+
limits: z.object({
|
|
530
|
+
minDeposit: decimal,
|
|
531
|
+
maxDeposit: decimal
|
|
532
|
+
})
|
|
533
|
+
});
|
|
534
|
+
const bridgeQuoteResponse = z.union([bridgeQuoteFilled, quoteEmpty]);
|
|
535
|
+
const bridgeQuote = endpoint("GET", "/v1/quotes/bridge", bridgeQuoteRequest, bridgeQuoteResponse);
|
|
536
|
+
export { BITCOIN_NETWORKS, ESPLORA_ROUTES, EVM_RPC_METHODS, GATEWAY_ERRORS, INSTALL_ID_HEADER, NETWORKS, PHISHING_HASH_BYTES, PHISHING_MAX_PATH_SEGMENTS, PROVIDERS_HEADER, RPC_BATCH_MAX, SOLANA_MAINNET, SOLANA_NETWORKS, SOLANA_RPC_METHODS, ZEROX_NATIVE_TOKEN, accepts, applyDiff, bridgeQuote, bridgeQuoteRequest, bridgeQuoteResponse, caip2, contains, decodeHashList, difference, encodeHashList, endpoint, esploraBasePath, esploraGet, esploraPathAllowed, esploraPost, evmRpcRequest, gatewayError, hashCount, hashList, health, healthRequest, healthResponse, installId, jsonRpcId, jsonRpcResponse, networkById, networksPath, parseWith, phishingCandidates, phishingHash, phishingKey, phishingList, phishingListPath, phishingListRequest, phishingListResponse, rpc, rpcPath, rpcRequest, rpcResponse, servedNetworks, servedNetworksRequest, servedNetworksResponse, solanaInstruction, solanaRpcRequest, swapQuote, swapQuoteRequest, swapQuoteResponse, swapQuoteSolana, swapQuoteSolanaRequest, swapQuoteSolanaResponse, union };
|
|
393
537
|
|
|
394
538
|
//# sourceMappingURL=gateway-contract.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-contract.mjs","names":[],"sources":["../src/gateway/contract/endpoint.ts","../src/gateway/contract/rpc.ts","../src/gateway/contract/primitives.ts","../src/gateway/contract/health.ts","../src/gateway/contract/esplora.ts","../src/gateway/contract/served.ts","../src/gateway/contract/risk.ts","../src/gateway/contract/hash-list.ts"],"sourcesContent":["import * as z from \"zod/mini\";\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"DELETE\";\n\nexport type Endpoint<Req extends z.ZodMiniType, Res extends z.ZodMiniType> = {\n readonly method: HttpMethod;\n readonly path: string;\n readonly request: Req;\n readonly response: Res;\n};\n\n/** One gateway route: its verb, versioned path template, and request/response schemas. */\nexport function endpoint<Req extends z.ZodMiniType, Res extends z.ZodMiniType>(\n method: HttpMethod,\n path: `/v1/${string}`,\n request: Req,\n response: Res,\n): Endpoint<Req, Res> {\n return { method, path, request, response };\n}\n\n/** `value` typed by `schema`, or `undefined` when it does not satisfy it. */\nexport function parseWith<S extends z.ZodMiniType>(\n schema: S,\n value: unknown,\n): z.output<S> | undefined {\n const result = z.safeParse(schema, value);\n return result.success ? result.data : undefined;\n}\n\n/** Whether `value` satisfies `schema` — lets consumers validate without importing zod. */\nexport function accepts(schema: z.ZodMiniType, value: unknown): boolean {\n return z.safeParse(schema, value).success;\n}\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\n/** One JSON-RPC call plus nothing else: batches may carry at most this many entries. */\nexport const RPC_BATCH_MAX = 20;\n\n/** Read-only EVM methods plus `eth_sendRawTransaction`. Anything not listed is rejected. */\nexport const EVM_RPC_METHODS = [\n \"eth_blobBaseFee\",\n \"eth_blockNumber\",\n \"eth_call\",\n \"eth_chainId\",\n \"eth_createAccessList\",\n \"eth_estimateGas\",\n \"eth_feeHistory\",\n \"eth_gasPrice\",\n \"eth_getBalance\",\n \"eth_getBlockByHash\",\n \"eth_getBlockByNumber\",\n \"eth_getBlockReceipts\",\n \"eth_getBlockTransactionCountByHash\",\n \"eth_getBlockTransactionCountByNumber\",\n \"eth_getCode\",\n \"eth_getProof\",\n \"eth_getStorageAt\",\n \"eth_getTransactionByBlockHashAndIndex\",\n \"eth_getTransactionByBlockNumberAndIndex\",\n \"eth_getTransactionByHash\",\n \"eth_getTransactionCount\",\n \"eth_getTransactionReceipt\",\n \"eth_maxPriorityFeePerGas\",\n \"eth_sendRawTransaction\",\n \"eth_simulateV1\",\n \"net_version\",\n \"web3_clientVersion\",\n] as const;\n\n/** Read-only Solana methods plus `sendTransaction`. Anything not listed is rejected. */\nexport const SOLANA_RPC_METHODS = [\n \"getAccountInfo\",\n \"getBalance\",\n \"getBlock\",\n \"getBlockHeight\",\n \"getBlockTime\",\n \"getEpochInfo\",\n \"getFeeForMessage\",\n \"getGenesisHash\",\n \"getLatestBlockhash\",\n \"getMinimumBalanceForRentExemption\",\n \"getMultipleAccounts\",\n \"getRecentPrioritizationFees\",\n \"getSignatureStatuses\",\n \"getSignaturesForAddress\",\n \"getSlot\",\n \"getTokenAccountBalance\",\n \"getTokenAccountsByOwner\",\n \"getTokenSupply\",\n \"getTransaction\",\n \"getVersion\",\n \"isBlockhashValid\",\n \"sendTransaction\",\n \"simulateTransaction\",\n] as const;\n\nexport type EvmRpcMethod = (typeof EVM_RPC_METHODS)[number];\nexport type SolanaRpcMethod = (typeof SOLANA_RPC_METHODS)[number];\n\nexport const jsonRpcId = z.union([z.string(), z.number(), z.null()]);\n\nconst jsonRpcParams = z.optional(\n z.union([z.array(z.unknown()), z.record(z.string(), z.unknown())]),\n);\n\nconst callSchema = <M extends z.ZodMiniType<string>>(method: M) =>\n z.object({ jsonrpc: z.literal(\"2.0\"), id: jsonRpcId, method, params: jsonRpcParams });\n\nconst bodySchema = <C extends z.ZodMiniType>(call: C) =>\n z.union([call, z.array(call).check(z.minLength(1), z.maxLength(RPC_BATCH_MAX))]);\n\n/** Method-agnostic wire shape of a call or batch (the gateway narrows by family). */\nexport const rpcRequest = bodySchema(callSchema(z.string()));\n\nexport const evmRpcRequest = bodySchema(callSchema(z.enum(EVM_RPC_METHODS)));\nexport const solanaRpcRequest = bodySchema(callSchema(z.enum(SOLANA_RPC_METHODS)));\n\nconst successResponse = z.object({\n jsonrpc: z.literal(\"2.0\"),\n id: jsonRpcId,\n result: z.unknown(),\n});\nconst errorResponse = z.object({\n jsonrpc: z.literal(\"2.0\"),\n id: jsonRpcId,\n error: z.object({ code: z.int(), message: z.string(), data: z.optional(z.unknown()) }),\n});\n\nexport const jsonRpcResponse = z.union([successResponse, errorResponse]);\nexport const rpcResponse = z.union([jsonRpcResponse, z.array(jsonRpcResponse)]);\n\nexport const rpc = endpoint(\"POST\", \"/v1/rpc/:caip2\", rpcRequest, rpcResponse);\n\n/** The JSON-RPC URL path for one network. */\nexport const rpcPath = (caip2: string): string => rpc.path.replace(\":caip2\", caip2);\n","import * as z from \"zod/mini\";\n\nexport const INSTALL_ID_HEADER = \"x-install-id\";\nexport const PROVIDERS_HEADER = \"x-gateway-providers\";\n\n/** 128 random bits as lowercase hex — generated once per install, unrelated to wallet secrets. */\nexport const installId = z.string().check(z.regex(/^[0-9a-f]{32}$/));\n\n/** CAIP-2 chain id: `namespace:reference`. */\nexport const caip2 = z.string().check(z.regex(/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/));\n\nexport type Caip2 = z.infer<typeof caip2>;\nexport type InstallId = z.infer<typeof installId>;\n\nexport const GATEWAY_ERRORS = [\n \"invalid-request\",\n \"unknown-network\",\n \"not-found\",\n \"rate-limited\",\n \"unavailable\",\n \"internal\",\n] as const;\n\nexport const gatewayError = z.object({ error: z.enum(GATEWAY_ERRORS) });\n\nexport type GatewayErrorCode = (typeof GATEWAY_ERRORS)[number];\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nexport const healthRequest = z.undefined();\nexport const healthResponse = z.object({ status: z.literal(\"ok\") });\n\nexport const health = endpoint(\"GET\", \"/v1/health\", healthRequest, healthResponse);\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nconst HEX64 = \"[0-9a-f]{64}\";\n\ntype EsploraRoute = { readonly method: \"GET\" | \"POST\"; readonly pattern: RegExp };\n\n/** The Esplora surface the engine uses; every other path is rejected. */\nexport const ESPLORA_ROUTES: ReadonlyArray<EsploraRoute> = [\n { method: \"GET\", pattern: /^\\/block-height\\/\\d{1,10}$/ },\n { method: \"GET\", pattern: /^\\/fee-estimates$/ },\n { method: \"GET\", pattern: new RegExp(`^/scripthash/${HEX64}/txs$`) },\n { method: \"GET\", pattern: new RegExp(`^/scripthash/${HEX64}/utxo$`) },\n { method: \"GET\", pattern: new RegExp(`^/tx/${HEX64}/hex$`) },\n { method: \"GET\", pattern: new RegExp(`^/tx/${HEX64}/status$`) },\n { method: \"POST\", pattern: /^\\/tx$/ },\n];\n\n/** `path` is the Esplora path after `/v1/esplora/:caip2`, with a leading slash and no query. */\nexport const esploraPathAllowed = (method: string, path: string): boolean =>\n ESPLORA_ROUTES.some((route) => route.method === method && route.pattern.test(path));\n\nexport const esploraGet = endpoint(\"GET\", \"/v1/esplora/:caip2/*\", z.undefined(), z.unknown());\n\n/** The Esplora base path for one network; allow-listed paths are appended to it. */\nexport const esploraBasePath = (caip2: string): string =>\n esploraGet.path.replace(\":caip2\", caip2).replace(/\\/\\*$/, \"\");\nexport const esploraPost = endpoint(\"POST\", \"/v1/esplora/:caip2/tx\", z.string(), z.string());\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\nimport { caip2 } from \"./primitives.ts\";\n\nexport const servedNetworksRequest = z.undefined();\n/** The networks the gateway actually serves, in its configured order. */\nexport const servedNetworksResponse = z.object({ networks: z.array(caip2) });\n\nexport const servedNetworks = endpoint(\n \"GET\",\n \"/v1/networks\",\n servedNetworksRequest,\n servedNetworksResponse,\n);\n\nexport const networksPath: string = servedNetworks.path;\n","import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { utf8ToBytes } from \"@noble/hashes/utils.js\";\nimport * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nexport const PHISHING_HASH_BYTES = 8;\nexport const PHISHING_MAX_PATH_SEGMENTS = 8;\n\nconst MAX_HOST_LENGTH = 253;\nconst MIN_HOST_LABELS = 2;\nconst FORBIDDEN_ENTRY = /:\\/\\/|[?#@\\\\\\s]/;\nconst IPV4 = /^\\d{1,3}(?:\\.\\d{1,3}){3}$/;\n/** Lowercase ASCII labels ending in a non-numeric label: `new URL` returns such a host unchanged. */\nconst PLAIN_HOST = /^(?:[a-z0-9_-]+\\.)+[a-z][a-z0-9_-]*\\.?$/;\n\nconst trimTrailingDot = (host: string): string => (host.endsWith(\".\") ? host.slice(0, -1) : host);\n\nconst pathSegments = (pathname: string): ReadonlyArray<string> =>\n pathname.split(\"/\").filter((segment) => segment !== \"\");\n\n/** One list entry as its lookup key, or `undefined` when the entry is not a usable host or path. */\nexport function phishingKey(entry: string): string | undefined {\n if (PLAIN_HOST.test(entry) && !entry.includes(\"xn--\")) {\n const host = trimTrailingDot(entry);\n return host.length > MAX_HOST_LENGTH ? undefined : host;\n }\n let raw = entry.trim();\n if (raw.startsWith(\"*.\")) {\n raw = raw.slice(2);\n }\n if (raw === \"\" || FORBIDDEN_ENTRY.test(raw)) {\n return undefined;\n }\n let url: URL;\n try {\n url = new URL(`https://${raw}`);\n } catch {\n return undefined;\n }\n if ((raw.split(\"/\")[0] ?? \"\").includes(\":\")) {\n return undefined;\n }\n const host = trimTrailingDot(url.hostname.toLowerCase());\n const labels = host.split(\".\");\n if (\n host.length > MAX_HOST_LENGTH ||\n labels.length < MIN_HOST_LABELS ||\n labels.some((label) => label === \"\")\n ) {\n return undefined;\n }\n const segments = pathSegments(url.pathname);\n if (segments.length === 0) {\n return host;\n }\n if (segments.length > PHISHING_MAX_PATH_SEGMENTS) {\n return undefined;\n }\n return `${host}/${segments.join(\"/\")}`;\n}\n\n/** The first 8 bytes of SHA-256 over the UTF-8 key. */\nexport function phishingHash(key: string): Uint8Array {\n return sha256(utf8ToBytes(key)).slice(0, PHISHING_HASH_BYTES);\n}\n\n/** Lookup keys for a page URL, most specific first; empty for anything but http(s). */\nexport function phishingCandidates(url: string): ReadonlyArray<string> {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return [];\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return [];\n }\n const host = trimTrailingDot(parsed.hostname);\n if (host === \"\") {\n return [];\n }\n if (host.startsWith(\"[\") || IPV4.test(host)) {\n return [host];\n }\n const segments = pathSegments(parsed.pathname).slice(0, PHISHING_MAX_PATH_SEGMENTS);\n const candidates: string[] = [];\n for (let depth = segments.length; depth > 0; depth -= 1) {\n candidates.push(`${host}/${segments.slice(0, depth).join(\"/\")}`);\n }\n const labels = host.split(\".\");\n for (let start = 0; labels.length - start >= MIN_HOST_LABELS; start += 1) {\n candidates.push(labels.slice(start).join(\".\"));\n }\n return candidates;\n}\n\nconst version = z.number().check(z.int(), z.nonnegative());\n\n/** Concatenated sorted 8-byte hashes, standard-alphabet base64; the empty string is an empty set. */\nconst hashes = z\n .string()\n .check(z.regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/));\n\nconst delta = z.object({ add: hashes, remove: hashes });\n\nexport const phishingListRequest = z.object({\n since: z.optional(z.string().check(z.regex(/^\\d{1,15}$/))),\n});\n\nexport const phishingListResponse = z.discriminatedUnion(\"kind\", [\n z.object({ kind: z.literal(\"current\"), version }),\n z.object({\n kind: z.literal(\"diff\"),\n from: version,\n version,\n deny: delta,\n allow: delta,\n }),\n z.object({ kind: z.literal(\"snapshot\"), version, deny: hashes, allow: hashes }),\n]);\n\nexport type PhishingListResponse = z.infer<typeof phishingListResponse>;\n\nexport const phishingList = endpoint(\n \"GET\",\n \"/v1/risk/lists/phishing\",\n phishingListRequest,\n phishingListResponse,\n);\n\nexport const phishingListPath: string = phishingList.path;\n","import { base64 } from \"@scure/base\";\n\nimport { PHISHING_HASH_BYTES } from \"./risk.ts\";\n\n/** Strictly ascending 8-byte hashes, concatenated: a sorted set. */\nexport type HashList = Uint8Array;\n\nconst WIDTH = PHISHING_HASH_BYTES;\n\nfunction compareAt(a: Uint8Array, ai: number, b: Uint8Array, bi: number): number {\n for (let k = 0; k < WIDTH; k += 1) {\n const delta = (a[ai * WIDTH + k] ?? 0) - (b[bi * WIDTH + k] ?? 0);\n if (delta !== 0) {\n return delta;\n }\n }\n return 0;\n}\n\nconst size = (list: HashList): number => list.length / WIDTH;\n\nexport const hashCount = size;\n\nconst isStrictlyAscending = (list: HashList): boolean => {\n for (let i = 1; i < size(list); i += 1) {\n if (compareAt(list, i - 1, list, i) >= 0) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * A base64 hash list, or `undefined` when it is not whole 8-byte hashes in strictly ascending\n * order.\n */\nexport function decodeHashList(encoded: string): HashList | undefined {\n let bytes: Uint8Array;\n try {\n bytes = base64.decode(encoded);\n } catch {\n return undefined;\n }\n return bytes.length % WIDTH === 0 && isStrictlyAscending(bytes) ? bytes : undefined;\n}\n\nconst RADIX = 256;\n\n/** Indices of the `count` hashes in `flat`, ascending: an LSD radix sort, one pass per byte. */\nfunction sortedOrder(flat: Uint8Array, count: number): Uint32Array {\n let order = new Uint32Array(count);\n let scratch = new Uint32Array(count);\n for (let i = 0; i < count; i += 1) {\n order[i] = i;\n }\n const offsets = new Uint32Array(RADIX + 1);\n for (let byte = WIDTH - 1; byte >= 0; byte -= 1) {\n offsets.fill(0);\n for (let i = 0; i < count; i += 1) {\n const slot = (flat[i * WIDTH + byte] ?? 0) + 1;\n offsets[slot] = (offsets[slot] ?? 0) + 1;\n }\n for (let bucket = 0; bucket < RADIX; bucket += 1) {\n offsets[bucket + 1] = (offsets[bucket + 1] ?? 0) + (offsets[bucket] ?? 0);\n }\n for (let i = 0; i < count; i += 1) {\n const index = order[i] ?? 0;\n const bucket = flat[index * WIDTH + byte] ?? 0;\n scratch[offsets[bucket] ?? 0] = index;\n offsets[bucket] = (offsets[bucket] ?? 0) + 1;\n }\n [order, scratch] = [scratch, order];\n }\n return order;\n}\n\n/** The sorted set of `hashes`, duplicates removed. */\nexport function hashList(hashes: Iterable<Uint8Array>): HashList {\n let flat = new Uint8Array(1024 * WIDTH);\n let count = 0;\n for (const hash of hashes) {\n if ((count + 1) * WIDTH > flat.length) {\n const grown = new Uint8Array(flat.length * 2);\n grown.set(flat);\n flat = grown;\n }\n flat.set(hash.subarray(0, WIDTH), count * WIDTH);\n count += 1;\n }\n const order = sortedOrder(flat, count);\n const out = new Uint8Array(count * WIDTH);\n let written = 0;\n for (let i = 0; i < count; i += 1) {\n const at = (order[i] ?? 0) * WIDTH;\n if (written === 0 || compareAt(out, written / WIDTH - 1, flat, at / WIDTH) !== 0) {\n out.set(flat.subarray(at, at + WIDTH), written);\n written += WIDTH;\n }\n }\n return out.slice(0, written);\n}\n\nexport const encodeHashList = (list: HashList): string => base64.encode(list);\n\nexport function contains(list: HashList, hash: Uint8Array): boolean {\n let low = 0;\n let high = size(list) - 1;\n while (low <= high) {\n const middle = Math.floor((low + high) / 2);\n const order = compareAt(list, middle, hash, 0);\n if (order === 0) {\n return true;\n }\n if (order < 0) {\n low = middle + 1;\n } else {\n high = middle - 1;\n }\n }\n return false;\n}\n\nfunction merge(a: HashList, b: HashList, keep: (inA: boolean, inB: boolean) => boolean): HashList {\n const out = new Uint8Array(a.length + b.length);\n let written = 0;\n const take = (source: Uint8Array, index: number): void => {\n out.set(source.subarray(index * WIDTH, (index + 1) * WIDTH), written);\n written += WIDTH;\n };\n let i = 0;\n let j = 0;\n while (i < size(a) || j < size(b)) {\n const order = i >= size(a) ? 1 : j >= size(b) ? -1 : compareAt(a, i, b, j);\n if (order < 0) {\n if (keep(true, false)) {\n take(a, i);\n }\n i += 1;\n } else if (order > 0) {\n if (keep(false, true)) {\n take(b, j);\n }\n j += 1;\n } else {\n if (keep(true, true)) {\n take(a, i);\n }\n i += 1;\n j += 1;\n }\n }\n return out.slice(0, written);\n}\n\nexport const union = (a: HashList, b: HashList): HashList => merge(a, b, () => true);\n\n/** The hashes of `a` that are not in `b`. */\nexport const difference = (a: HashList, b: HashList): HashList =>\n merge(a, b, (inA, inB) => inA && !inB);\n\n/** `(list − remove) ∪ add`. */\nexport const applyDiff = (list: HashList, add: HashList, remove: HashList): HashList =>\n union(difference(list, remove), add);\n"],"mappings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AC7C,IAAI,UAAU,GACZ,OAAO;EAET,IAAI,QAAQ,GACV,MAAM,SAAS;OAEf,OAAO,SAAS;CAEpB;CACA,OAAO;AACT;AAEA,SAAS,MAAM,GAAa,GAAa,MAAyD;CAChG,MAAM,MAAM,IAAI,WAAW,EAAE,SAAS,EAAE,MAAM;CAC9C,IAAI,UAAU;CACd,MAAM,QAAQ,QAAoB,UAAwB;EACxD,IAAI,IAAI,OAAO,SAAS,QAAQ,QAAQ,QAAQ,KAAK,KAAK,GAAG,OAAO;EACpE,WAAW;CACb;CACA,IAAI,IAAI;CACR,IAAI,IAAI;CACR,OAAO,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG;EACjC,MAAM,QAAQ,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,GAAG,GAAG,GAAG,CAAC;EACzE,IAAI,QAAQ,GAAG;GACb,IAAI,KAAK,MAAM,KAAK,GAClB,KAAK,GAAG,CAAC;GAEX,KAAK;EACP,OAAO,IAAI,QAAQ,GAAG;GACpB,IAAI,KAAK,OAAO,IAAI,GAClB,KAAK,GAAG,CAAC;GAEX,KAAK;EACP,OAAO;GACL,IAAI,KAAK,MAAM,IAAI,GACjB,KAAK,GAAG,CAAC;GAEX,KAAK;GACL,KAAK;EACP;CACF;CACA,OAAO,IAAI,MAAM,GAAG,OAAO;AAC7B;AAEA,MAAa,SAAS,GAAa,MAA0B,MAAM,GAAG,SAAS,IAAI;;AAGnF,MAAa,cAAc,GAAa,MACtC,MAAM,GAAG,IAAI,KAAK,QAAQ,OAAO,CAAC,GAAG;;AAGvC,MAAa,aAAa,MAAgB,KAAe,WACvD,MAAM,WAAW,MAAM,MAAM,GAAG,GAAG"}
|
|
1
|
+
{"version":3,"file":"gateway-contract.mjs","names":["base58"],"sources":["../src/gateway/contract/endpoint.ts","../src/gateway/contract/rpc.ts","../src/gateway/contract/primitives.ts","../src/gateway/contract/health.ts","../src/gateway/contract/esplora.ts","../src/gateway/contract/served.ts","../src/gateway/contract/risk.ts","../src/gateway/contract/hash-list.ts","../src/gateway/contract/quotes.ts"],"sourcesContent":["import * as z from \"zod/mini\";\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"DELETE\";\n\nexport type Endpoint<Req extends z.ZodMiniType, Res extends z.ZodMiniType> = {\n readonly method: HttpMethod;\n readonly path: string;\n readonly request: Req;\n readonly response: Res;\n};\n\n/** One gateway route: its verb, versioned path template, and request/response schemas. */\nexport function endpoint<Req extends z.ZodMiniType, Res extends z.ZodMiniType>(\n method: HttpMethod,\n path: `/v1/${string}`,\n request: Req,\n response: Res,\n): Endpoint<Req, Res> {\n return { method, path, request, response };\n}\n\n/** `value` typed by `schema`, or `undefined` when it does not satisfy it. */\nexport function parseWith<S extends z.ZodMiniType>(\n schema: S,\n value: unknown,\n): z.output<S> | undefined {\n const result = z.safeParse(schema, value);\n return result.success ? result.data : undefined;\n}\n\n/** Whether `value` satisfies `schema` — lets consumers validate without importing zod. */\nexport function accepts(schema: z.ZodMiniType, value: unknown): boolean {\n return z.safeParse(schema, value).success;\n}\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\n/** One JSON-RPC call plus nothing else: batches may carry at most this many entries. */\nexport const RPC_BATCH_MAX = 20;\n\n/** Read-only EVM methods plus `eth_sendRawTransaction`. Anything not listed is rejected. */\nexport const EVM_RPC_METHODS = [\n \"eth_blobBaseFee\",\n \"eth_blockNumber\",\n \"eth_call\",\n \"eth_chainId\",\n \"eth_createAccessList\",\n \"eth_estimateGas\",\n \"eth_feeHistory\",\n \"eth_gasPrice\",\n \"eth_getBalance\",\n \"eth_getBlockByHash\",\n \"eth_getBlockByNumber\",\n \"eth_getBlockReceipts\",\n \"eth_getBlockTransactionCountByHash\",\n \"eth_getBlockTransactionCountByNumber\",\n \"eth_getCode\",\n \"eth_getProof\",\n \"eth_getStorageAt\",\n \"eth_getTransactionByBlockHashAndIndex\",\n \"eth_getTransactionByBlockNumberAndIndex\",\n \"eth_getTransactionByHash\",\n \"eth_getTransactionCount\",\n \"eth_getTransactionReceipt\",\n \"eth_maxPriorityFeePerGas\",\n \"eth_sendRawTransaction\",\n \"eth_simulateV1\",\n \"net_version\",\n \"web3_clientVersion\",\n] as const;\n\n/** Read-only Solana methods plus `sendTransaction`. Anything not listed is rejected. */\nexport const SOLANA_RPC_METHODS = [\n \"getAccountInfo\",\n \"getBalance\",\n \"getBlock\",\n \"getBlockHeight\",\n \"getBlockTime\",\n \"getEpochInfo\",\n \"getFeeForMessage\",\n \"getGenesisHash\",\n \"getLatestBlockhash\",\n \"getMinimumBalanceForRentExemption\",\n \"getMultipleAccounts\",\n \"getRecentPrioritizationFees\",\n \"getSignatureStatuses\",\n \"getSignaturesForAddress\",\n \"getSlot\",\n \"getTokenAccountBalance\",\n \"getTokenAccountsByOwner\",\n \"getTokenSupply\",\n \"getTransaction\",\n \"getVersion\",\n \"isBlockhashValid\",\n \"sendTransaction\",\n \"simulateTransaction\",\n] as const;\n\nexport type EvmRpcMethod = (typeof EVM_RPC_METHODS)[number];\nexport type SolanaRpcMethod = (typeof SOLANA_RPC_METHODS)[number];\n\nexport const jsonRpcId = z.union([z.string(), z.number(), z.null()]);\n\nconst jsonRpcParams = z.optional(\n z.union([z.array(z.unknown()), z.record(z.string(), z.unknown())]),\n);\n\nconst callSchema = <M extends z.ZodMiniType<string>>(method: M) =>\n z.object({ jsonrpc: z.literal(\"2.0\"), id: jsonRpcId, method, params: jsonRpcParams });\n\nconst bodySchema = <C extends z.ZodMiniType>(call: C) =>\n z.union([call, z.array(call).check(z.minLength(1), z.maxLength(RPC_BATCH_MAX))]);\n\n/** Method-agnostic wire shape of a call or batch (the gateway narrows by family). */\nexport const rpcRequest = bodySchema(callSchema(z.string()));\n\nexport const evmRpcRequest = bodySchema(callSchema(z.enum(EVM_RPC_METHODS)));\nexport const solanaRpcRequest = bodySchema(callSchema(z.enum(SOLANA_RPC_METHODS)));\n\nconst successResponse = z.object({\n jsonrpc: z.literal(\"2.0\"),\n id: jsonRpcId,\n result: z.unknown(),\n});\nconst errorResponse = z.object({\n jsonrpc: z.literal(\"2.0\"),\n id: jsonRpcId,\n error: z.object({ code: z.int(), message: z.string(), data: z.optional(z.unknown()) }),\n});\n\nexport const jsonRpcResponse = z.union([successResponse, errorResponse]);\nexport const rpcResponse = z.union([jsonRpcResponse, z.array(jsonRpcResponse)]);\n\nexport const rpc = endpoint(\"POST\", \"/v1/rpc/:caip2\", rpcRequest, rpcResponse);\n\n/** The JSON-RPC URL path for one network. */\nexport const rpcPath = (caip2: string): string => rpc.path.replace(\":caip2\", caip2);\n","import * as z from \"zod/mini\";\n\nexport const INSTALL_ID_HEADER = \"x-install-id\";\nexport const PROVIDERS_HEADER = \"x-gateway-providers\";\n\n/** 128 random bits as lowercase hex — generated once per install, unrelated to wallet secrets. */\nexport const installId = z.string().check(z.regex(/^[0-9a-f]{32}$/));\n\n/** CAIP-2 chain id: `namespace:reference`. */\nexport const caip2 = z.string().check(z.regex(/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/));\n\nexport type Caip2 = z.infer<typeof caip2>;\nexport type InstallId = z.infer<typeof installId>;\n\nexport const GATEWAY_ERRORS = [\n \"invalid-request\",\n \"unknown-network\",\n \"not-found\",\n \"rate-limited\",\n \"unavailable\",\n \"internal\",\n] as const;\n\nexport const gatewayError = z.object({ error: z.enum(GATEWAY_ERRORS) });\n\nexport type GatewayErrorCode = (typeof GATEWAY_ERRORS)[number];\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nexport const healthRequest = z.undefined();\nexport const healthResponse = z.object({ status: z.literal(\"ok\") });\n\nexport const health = endpoint(\"GET\", \"/v1/health\", healthRequest, healthResponse);\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nconst HEX64 = \"[0-9a-f]{64}\";\n\ntype EsploraRoute = { readonly method: \"GET\" | \"POST\"; readonly pattern: RegExp };\n\n/** The Esplora surface the engine uses; every other path is rejected. */\nexport const ESPLORA_ROUTES: ReadonlyArray<EsploraRoute> = [\n { method: \"GET\", pattern: /^\\/block-height\\/\\d{1,10}$/ },\n { method: \"GET\", pattern: /^\\/fee-estimates$/ },\n { method: \"GET\", pattern: new RegExp(`^/scripthash/${HEX64}/txs$`) },\n { method: \"GET\", pattern: new RegExp(`^/scripthash/${HEX64}/utxo$`) },\n { method: \"GET\", pattern: new RegExp(`^/tx/${HEX64}/hex$`) },\n { method: \"GET\", pattern: new RegExp(`^/tx/${HEX64}/status$`) },\n { method: \"POST\", pattern: /^\\/tx$/ },\n];\n\n/** `path` is the Esplora path after `/v1/esplora/:caip2`, with a leading slash and no query. */\nexport const esploraPathAllowed = (method: string, path: string): boolean =>\n ESPLORA_ROUTES.some((route) => route.method === method && route.pattern.test(path));\n\nexport const esploraGet = endpoint(\"GET\", \"/v1/esplora/:caip2/*\", z.undefined(), z.unknown());\n\n/** The Esplora base path for one network; allow-listed paths are appended to it. */\nexport const esploraBasePath = (caip2: string): string =>\n esploraGet.path.replace(\":caip2\", caip2).replace(/\\/\\*$/, \"\");\nexport const esploraPost = endpoint(\"POST\", \"/v1/esplora/:caip2/tx\", z.string(), z.string());\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\nimport { caip2 } from \"./primitives.ts\";\n\nexport const servedNetworksRequest = z.undefined();\n/** The networks the gateway actually serves, in its configured order. */\nexport const servedNetworksResponse = z.object({ networks: z.array(caip2) });\n\nexport const servedNetworks = endpoint(\n \"GET\",\n \"/v1/networks\",\n servedNetworksRequest,\n servedNetworksResponse,\n);\n\nexport const networksPath: string = servedNetworks.path;\n","import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { utf8ToBytes } from \"@noble/hashes/utils.js\";\nimport * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nexport const PHISHING_HASH_BYTES = 8;\nexport const PHISHING_MAX_PATH_SEGMENTS = 8;\n\nconst MAX_HOST_LENGTH = 253;\nconst MIN_HOST_LABELS = 2;\nconst FORBIDDEN_ENTRY = /:\\/\\/|[?#@\\\\\\s]/;\nconst IPV4 = /^\\d{1,3}(?:\\.\\d{1,3}){3}$/;\n/** Lowercase ASCII labels ending in a non-numeric label: `new URL` returns such a host unchanged. */\nconst PLAIN_HOST = /^(?:[a-z0-9_-]+\\.)+[a-z][a-z0-9_-]*\\.?$/;\n\nconst trimTrailingDot = (host: string): string => (host.endsWith(\".\") ? host.slice(0, -1) : host);\n\nconst pathSegments = (pathname: string): ReadonlyArray<string> =>\n pathname.split(\"/\").filter((segment) => segment !== \"\");\n\n/** One list entry as its lookup key, or `undefined` when the entry is not a usable host or path. */\nexport function phishingKey(entry: string): string | undefined {\n if (PLAIN_HOST.test(entry) && !entry.includes(\"xn--\")) {\n const host = trimTrailingDot(entry);\n return host.length > MAX_HOST_LENGTH ? undefined : host;\n }\n let raw = entry.trim();\n if (raw.startsWith(\"*.\")) {\n raw = raw.slice(2);\n }\n if (raw === \"\" || FORBIDDEN_ENTRY.test(raw)) {\n return undefined;\n }\n let url: URL;\n try {\n url = new URL(`https://${raw}`);\n } catch {\n return undefined;\n }\n if ((raw.split(\"/\")[0] ?? \"\").includes(\":\")) {\n return undefined;\n }\n const host = trimTrailingDot(url.hostname.toLowerCase());\n const labels = host.split(\".\");\n if (\n host.length > MAX_HOST_LENGTH ||\n labels.length < MIN_HOST_LABELS ||\n labels.some((label) => label === \"\")\n ) {\n return undefined;\n }\n const segments = pathSegments(url.pathname);\n if (segments.length === 0) {\n return host;\n }\n if (segments.length > PHISHING_MAX_PATH_SEGMENTS) {\n return undefined;\n }\n return `${host}/${segments.join(\"/\")}`;\n}\n\n/** The first 8 bytes of SHA-256 over the UTF-8 key. */\nexport function phishingHash(key: string): Uint8Array {\n return sha256(utf8ToBytes(key)).slice(0, PHISHING_HASH_BYTES);\n}\n\n/** Lookup keys for a page URL, most specific first; empty for anything but http(s). */\nexport function phishingCandidates(url: string): ReadonlyArray<string> {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return [];\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return [];\n }\n const host = trimTrailingDot(parsed.hostname);\n if (host === \"\") {\n return [];\n }\n if (host.startsWith(\"[\") || IPV4.test(host)) {\n return [host];\n }\n const segments = pathSegments(parsed.pathname).slice(0, PHISHING_MAX_PATH_SEGMENTS);\n const candidates: string[] = [];\n for (let depth = segments.length; depth > 0; depth -= 1) {\n candidates.push(`${host}/${segments.slice(0, depth).join(\"/\")}`);\n }\n const labels = host.split(\".\");\n for (let start = 0; labels.length - start >= MIN_HOST_LABELS; start += 1) {\n candidates.push(labels.slice(start).join(\".\"));\n }\n return candidates;\n}\n\nconst version = z.number().check(z.int(), z.nonnegative());\n\n/** Concatenated sorted 8-byte hashes, standard-alphabet base64; the empty string is an empty set. */\nconst hashes = z\n .string()\n .check(z.regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/));\n\nconst delta = z.object({ add: hashes, remove: hashes });\n\nexport const phishingListRequest = z.object({\n since: z.optional(z.string().check(z.regex(/^\\d{1,15}$/))),\n});\n\nexport const phishingListResponse = z.discriminatedUnion(\"kind\", [\n z.object({ kind: z.literal(\"current\"), version }),\n z.object({\n kind: z.literal(\"diff\"),\n from: version,\n version,\n deny: delta,\n allow: delta,\n }),\n z.object({ kind: z.literal(\"snapshot\"), version, deny: hashes, allow: hashes }),\n]);\n\nexport type PhishingListResponse = z.infer<typeof phishingListResponse>;\n\nexport const phishingList = endpoint(\n \"GET\",\n \"/v1/risk/lists/phishing\",\n phishingListRequest,\n phishingListResponse,\n);\n\nexport const phishingListPath: string = phishingList.path;\n","import { base64 } from \"@scure/base\";\n\nimport { PHISHING_HASH_BYTES } from \"./risk.ts\";\n\n/** Strictly ascending 8-byte hashes, concatenated: a sorted set. */\nexport type HashList = Uint8Array;\n\nconst WIDTH = PHISHING_HASH_BYTES;\n\nfunction compareAt(a: Uint8Array, ai: number, b: Uint8Array, bi: number): number {\n for (let k = 0; k < WIDTH; k += 1) {\n const delta = (a[ai * WIDTH + k] ?? 0) - (b[bi * WIDTH + k] ?? 0);\n if (delta !== 0) {\n return delta;\n }\n }\n return 0;\n}\n\nconst size = (list: HashList): number => list.length / WIDTH;\n\nexport const hashCount = size;\n\nconst isStrictlyAscending = (list: HashList): boolean => {\n for (let i = 1; i < size(list); i += 1) {\n if (compareAt(list, i - 1, list, i) >= 0) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * A base64 hash list, or `undefined` when it is not whole 8-byte hashes in strictly ascending\n * order.\n */\nexport function decodeHashList(encoded: string): HashList | undefined {\n let bytes: Uint8Array;\n try {\n bytes = base64.decode(encoded);\n } catch {\n return undefined;\n }\n return bytes.length % WIDTH === 0 && isStrictlyAscending(bytes) ? bytes : undefined;\n}\n\nconst RADIX = 256;\n\n/** Indices of the `count` hashes in `flat`, ascending: an LSD radix sort, one pass per byte. */\nfunction sortedOrder(flat: Uint8Array, count: number): Uint32Array {\n let order = new Uint32Array(count);\n let scratch = new Uint32Array(count);\n for (let i = 0; i < count; i += 1) {\n order[i] = i;\n }\n const offsets = new Uint32Array(RADIX + 1);\n for (let byte = WIDTH - 1; byte >= 0; byte -= 1) {\n offsets.fill(0);\n for (let i = 0; i < count; i += 1) {\n const slot = (flat[i * WIDTH + byte] ?? 0) + 1;\n offsets[slot] = (offsets[slot] ?? 0) + 1;\n }\n for (let bucket = 0; bucket < RADIX; bucket += 1) {\n offsets[bucket + 1] = (offsets[bucket + 1] ?? 0) + (offsets[bucket] ?? 0);\n }\n for (let i = 0; i < count; i += 1) {\n const index = order[i] ?? 0;\n const bucket = flat[index * WIDTH + byte] ?? 0;\n scratch[offsets[bucket] ?? 0] = index;\n offsets[bucket] = (offsets[bucket] ?? 0) + 1;\n }\n [order, scratch] = [scratch, order];\n }\n return order;\n}\n\n/** The sorted set of `hashes`, duplicates removed. */\nexport function hashList(hashes: Iterable<Uint8Array>): HashList {\n let flat = new Uint8Array(1024 * WIDTH);\n let count = 0;\n for (const hash of hashes) {\n if ((count + 1) * WIDTH > flat.length) {\n const grown = new Uint8Array(flat.length * 2);\n grown.set(flat);\n flat = grown;\n }\n flat.set(hash.subarray(0, WIDTH), count * WIDTH);\n count += 1;\n }\n const order = sortedOrder(flat, count);\n const out = new Uint8Array(count * WIDTH);\n let written = 0;\n for (let i = 0; i < count; i += 1) {\n const at = (order[i] ?? 0) * WIDTH;\n if (written === 0 || compareAt(out, written / WIDTH - 1, flat, at / WIDTH) !== 0) {\n out.set(flat.subarray(at, at + WIDTH), written);\n written += WIDTH;\n }\n }\n return out.slice(0, written);\n}\n\nexport const encodeHashList = (list: HashList): string => base64.encode(list);\n\nexport function contains(list: HashList, hash: Uint8Array): boolean {\n let low = 0;\n let high = size(list) - 1;\n while (low <= high) {\n const middle = Math.floor((low + high) / 2);\n const order = compareAt(list, middle, hash, 0);\n if (order === 0) {\n return true;\n }\n if (order < 0) {\n low = middle + 1;\n } else {\n high = middle - 1;\n }\n }\n return false;\n}\n\nfunction merge(a: HashList, b: HashList, keep: (inA: boolean, inB: boolean) => boolean): HashList {\n const out = new Uint8Array(a.length + b.length);\n let written = 0;\n const take = (source: Uint8Array, index: number): void => {\n out.set(source.subarray(index * WIDTH, (index + 1) * WIDTH), written);\n written += WIDTH;\n };\n let i = 0;\n let j = 0;\n while (i < size(a) || j < size(b)) {\n const order = i >= size(a) ? 1 : j >= size(b) ? -1 : compareAt(a, i, b, j);\n if (order < 0) {\n if (keep(true, false)) {\n take(a, i);\n }\n i += 1;\n } else if (order > 0) {\n if (keep(false, true)) {\n take(b, j);\n }\n j += 1;\n } else {\n if (keep(true, true)) {\n take(a, i);\n }\n i += 1;\n j += 1;\n }\n }\n return out.slice(0, written);\n}\n\nexport const union = (a: HashList, b: HashList): HashList => merge(a, b, () => true);\n\n/** The hashes of `a` that are not in `b`. */\nexport const difference = (a: HashList, b: HashList): HashList =>\n merge(a, b, (inA, inB) => inA && !inB);\n\n/** `(list − remove) ∪ add`. */\nexport const applyDiff = (list: HashList, add: HashList, remove: HashList): HashList =>\n union(difference(list, remove), add);\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\nimport { caip2 } from \"./primitives.ts\";\n\n/** The native-token sentinel 0x uses for sell and buy tokens. */\nexport const ZEROX_NATIVE_TOKEN = \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\";\n\n/** `0x` + 40 hex — an EVM address, the 0x native sentinel `0xEeee…` among them. */\nconst evmAddress = z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/));\n\n/** A decimal string of a non-negative integer (`\"0\"` allowed for gas nulls). */\nconst decimal = z.string().check(z.regex(/^[0-9]+$/));\n\n/** The `swapQuote` request: which exact-in sell on which chain, for which taker, at what slippage. */\nexport const swapQuoteRequest = z.object({\n /** `eip155:<n>` — the only namespace a 0x swap supports. */\n network: caip2.check(z.regex(/^eip155:[0-9]+$/)),\n /** The token sold — an ERC-20 address, or `0xEeeee…` for native. */\n sellToken: evmAddress,\n /** The token bought — an ERC-20 address, or `0xEeeee…` for native. */\n buyToken: evmAddress,\n /** Exact base-unit sell amount, a positive integer as decimal. */\n sellAmount: z.string().check(z.regex(/^[1-9][0-9]*$/)),\n /** The address the settlement contract pays out for. */\n taker: evmAddress,\n /** Worst-case slippage in basis points, 1–5000 (a query string, coerced). */\n slippageBps: z.coerce.number().check(z.int(), z.minimum(1), z.maximum(5000)),\n});\n\nconst fee = z.object({\n /** The token the fee is charged in (sell or buy token). */\n token: evmAddress,\n /** The fee amount in base units. */\n amount: decimal,\n});\n\n/** A quote with liquidity: the AllowanceHolder `exec` calldata to sign and the terms it must keep. */\nconst quoteFilled = z.object({\n liquidity: z.literal(true),\n provider: z.literal(\"0x\"),\n sellToken: evmAddress,\n buyToken: evmAddress,\n sellAmount: decimal,\n buyAmount: decimal,\n minBuyAmount: decimal,\n /** The spender `exec` approves — `null` for a native sell. */\n allowanceTarget: z.union([evmAddress, z.null()]),\n transaction: z.object({\n to: evmAddress,\n data: z.string().check(z.regex(/^0x[0-9a-fA-F]*$/)),\n value: decimal,\n gas: z.union([decimal, z.null()]),\n }),\n fees: z.object({\n integrator: z.union([fee, z.null()]),\n zeroEx: z.union([fee, z.null()]),\n }),\n /** The block the quote was priced at — staleness is measured against this. */\n blockNumber: decimal,\n});\n\n/** No route found: the response carries only the liquidity flag. */\nconst quoteEmpty = z.object({ liquidity: z.literal(false) });\n\nexport const swapQuoteResponse = z.union([quoteFilled, quoteEmpty]);\n\nexport const swapQuote = endpoint(\"GET\", \"/v1/quotes/swap\", swapQuoteRequest, swapQuoteResponse);\n\nexport type SwapQuoteRequest = z.infer<typeof swapQuoteRequest>;\nexport type SwapQuoteResponse = z.infer<typeof swapQuoteResponse>;\n\n/** Base58 public key — Solana mints, program ids, takers and accounts are all 32-byte keys. */\nconst base58 = z.string().check(z.regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/));\n\n/** Jupiter is mainnet-only — every other Solana CAIP-2 id is a client error. */\nexport const SOLANA_MAINNET = \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\";\n\n/** The `swapQuoteSolana` request: an exact-in mint pair for a taker on Solana mainnet. */\nexport const swapQuoteSolanaRequest = z.object({\n network: z.literal(SOLANA_MAINNET),\n /** The mint sold — `So111…112` for wrapped SOL. */\n inputMint: base58,\n /** The mint bought — `So111…112` for wrapped SOL. */\n outputMint: base58,\n /** Exact base-unit sell amount, a positive integer as decimal. */\n amount: z.string().check(z.regex(/^[1-9][0-9]*$/)),\n /** The account the swap settles for. */\n taker: base58,\n /** Worst-case slippage in basis points, 1–5000 (a query string, coerced). */\n slippageBps: z.coerce.number().check(z.int(), z.minimum(1), z.maximum(5000)),\n});\n\n/** One Solana instruction as the wire carries it — base64 data, plain account flags. */\nexport const solanaInstruction = z.object({\n programId: base58,\n accounts: z.array(\n z.object({\n address: base58,\n signer: z.boolean(),\n writable: z.boolean(),\n }),\n ),\n data: z.string().check(z.regex(/^[A-Za-z0-9+/]*={0,2}$/)),\n});\n\n/**\n * A Jupiter `/build` relay: the instructions that assemble the versioned transaction — the engine\n * replaces the compute budget with its own and reads the named lookup tables from chain.\n */\nconst solanaQuoteFilled = z.object({\n liquidity: z.literal(true),\n provider: z.literal(\"jupiter\"),\n inputMint: base58,\n outputMint: base58,\n inAmount: decimal,\n outAmount: decimal,\n otherAmountThreshold: decimal,\n slippageBps: z.coerce.number().check(z.int()),\n setup: z.array(solanaInstruction),\n swap: solanaInstruction,\n cleanup: z.union([solanaInstruction, z.null()]),\n /** The address lookup tables the message compresses against — contents never come over the wire. */\n lookupTables: z.array(base58),\n});\n\nexport const swapQuoteSolanaResponse = z.union([solanaQuoteFilled, quoteEmpty]);\n\nexport const swapQuoteSolana = endpoint(\n \"GET\",\n \"/v1/quotes/swap/solana\",\n swapQuoteSolanaRequest,\n swapQuoteSolanaResponse,\n);\n\nexport type SwapQuoteSolanaRequest = z.infer<typeof swapQuoteSolanaRequest>;\nexport type SwapQuoteSolanaResponse = z.infer<typeof swapQuoteSolanaResponse>;\n\n/** The `bridgeQuote` request: an exact-in token transfer from an origin chain to a destination. */\nexport const bridgeQuoteRequest = z.object({\n /** `eip155:<n>` — the origin chain. */\n network: caip2.check(z.regex(/^eip155:[0-9]+$/)),\n /** `eip155:<n>` — the destination chain. */\n destinationNetwork: caip2.check(z.regex(/^eip155:[0-9]+$/)),\n /** The token deposited on the origin chain — the chain's wrapped native for a native send. */\n inputToken: evmAddress,\n /** The token received on the destination chain. */\n outputToken: evmAddress,\n /** Exact base-unit input amount, a positive integer as decimal. */\n amount: z.string().check(z.regex(/^[1-9][0-9]*$/)),\n /** The account the deposit settles for. */\n taker: evmAddress,\n});\n\n/**\n * An Across `/suggested-fees` relay: the deposit terms the engine must verify on-chain — output and\n * deadline verbatim, the spoke pool address so a stale or spoofed build is refused.\n */\nconst bridgeQuoteFilled = z.object({\n liquidity: z.literal(true),\n provider: z.literal(\"across\"),\n inputToken: evmAddress,\n outputToken: evmAddress,\n inputAmount: decimal,\n outputAmount: decimal,\n destinationNetwork: caip2.check(z.regex(/^eip155:[0-9]+$/)),\n quoteTimestamp: z.coerce.number().check(z.int()),\n fillDeadline: z.coerce.number().check(z.int()),\n exclusiveRelayer: evmAddress,\n exclusivityParameter: z.coerce.number().check(z.int()),\n spokePool: evmAddress,\n limits: z.object({ minDeposit: decimal, maxDeposit: decimal }),\n});\n\nexport const bridgeQuoteResponse = z.union([bridgeQuoteFilled, quoteEmpty]);\n\nexport const bridgeQuote = endpoint(\n \"GET\",\n \"/v1/quotes/bridge\",\n bridgeQuoteRequest,\n bridgeQuoteResponse,\n);\n\nexport type BridgeQuoteRequest = z.infer<typeof bridgeQuoteRequest>;\nexport type BridgeQuoteResponse = z.infer<typeof bridgeQuoteResponse>;\n"],"mappings":";;;;;;;AAYA,SAAgB,SACd,QACA,MACA,SACA,UACoB;CACpB,OAAO;EAAE;EAAQ;EAAM;EAAS;CAAS;AAC3C;;AAGA,SAAgB,UACd,QACA,OACyB;CACzB,MAAM,SAAS,EAAE,UAAU,QAAQ,KAAK;CACxC,OAAO,OAAO,UAAU,OAAO,OAAO,KAAA;AACxC;;AAGA,SAAgB,QAAQ,QAAuB,OAAyB;CACtE,OAAO,EAAE,UAAU,QAAQ,KAAK,CAAC,CAAC;AACpC;;;AC5BA,MAAa,gBAAgB;;AAG7B,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAKA,MAAa,YAAY,EAAE,MAAM;CAAC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AE,MAAM,CAAC,mBAAmB,UAAU,CAAC;AAE1E,MAAa,cAAc,SACzB,OACA,qBACA,oBACA,mBACF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { $ as
|
|
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
|
-
|
|
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
|
|
199
|
-
readonly
|
|
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
|