@anywalletkit/protocol-swap2-relay 0.1.2 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anywalletkit/protocol-swap2-relay",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Relay (relay.link) for the swap2 engine, with the whole order verified on the device before anything is signed: the order id recomputed from the order (EIP-712 hashStruct), the solver's signature recovered to a pinned signer, recipient / chain / token / minimum / refunds held to the user's request, and the deposit built here for the pinned RelayDepository. EVM to EVM, exact input, native coin and ERC-20.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.anywallet.tech",
@@ -66,7 +66,7 @@
66
66
  "dependencies": {
67
67
  "@noble/curves": "^2.4.0",
68
68
  "viem": "^2.57.2",
69
- "@anywalletkit/protocol-swap2-core": "0.12.0",
69
+ "@anywalletkit/protocol-swap2-core": "0.14.0",
70
70
  "@anywalletkit/swap2-assets": "0.3.0"
71
71
  },
72
72
  "peerDependencies": {
@@ -75,8 +75,8 @@
75
75
  "devDependencies": {
76
76
  "@types/node": "^22",
77
77
  "vitest": "^5.1.0",
78
- "@anywalletkit/conformance": "0.5.1",
79
- "@anywalletkit/protocol-swap2-router": "0.6.0",
78
+ "@anywalletkit/conformance": "0.6.0",
79
+ "@anywalletkit/protocol-swap2-router": "0.6.2",
80
80
  "@anywalletkit/core": "0.8.0"
81
81
  },
82
82
  "keywords": [
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import {anySignal, redactUrls, timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentState, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {httpRefusal, refusal, refusalOf, type Swap2RefusalInfo, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\nimport {describeRelayActivity} from \"./activity.js\";\nimport {RELAY_API, relay as relayCfg, relayChain} from \"./config.js\";\nimport {RelayRefusal} from \"./order.js\";\nimport {RELAY_DEFAULT_SLIPPAGE_BPS, RELAY_GAS_CAP as GAS_CAP, RELAY_GAS_FLOOR_ERC20 as GAS_FLOOR_ERC20, RELAY_GAS_FLOOR_NATIVE as GAS_FLOOR_NATIVE, checkRelayQuote, relayClearOrder, relayRequestOf, verifyRelayOrder, type RelayRequest} from \"./verify.js\";\n\n/**\n * Relay (relay.link) — a solver network. ONE source transaction: a deposit into the chain's RelayDepository that names\n * an order by its hash; Relay's solver then pays the recipient on the destination chain, or the deposit is refunded.\n *\n * - Quote = `POST /quote/v2` with `includeProtocolData: true`, which returns the order itself next to the deposit.\n * The answer is only an input to `verify.ts`: the order is parsed, hashed and attributed on the device, compared\n * with the request, and the deposit this module builds from its own pins must be byte-for-byte the one offered.\n * What a quote carries afterwards is that own-built call; the amounts it shows are the order's (`expectedAmount`\n * as the estimate, `minimumAmount` as the enforced minimum).\n * - The API's `approve` step is never used: an ERC-20 input sets `approvalAddress` to the pinned depository and the\n * engine approves exactly the input amount.\n * - `baseUrl` may be the app's own proxy that adds the API key. It cannot get a deposit signed for another\n * recipient, chain, token, minimum or refund address than the request's. It CAN make the quote worse: the solver\n * signs whatever request reaches Relay, so a proxy that adds an app fee or a gas top-up gets a genuine order with\n * a lower expected amount. The response's own account of such extras is refused (`app-fee`, `gas-topup`), but a\n * proxy can strip that too — the amounts shown are always the order's, and what bounds the price is the caller's\n * `minAmountOut` or the other quotes of the router, not this module.\n * - Routes Relay serves by first swapping on the source chain call a router, not the depository, and are refused\n * by name (`tx-target`); so are non-EVM chains and any chain without a pin.\n * - Status: `GET /intents/status/v3?requestId=` — display only, nothing is signed on its word.\n */\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\nconst QUOTE_TIMEOUT_MS = 20_000;\nconst STATUS_TIMEOUT_MS = 12_000;\nconst INTENT_PREFIX = \"relay:\";\nconst REQUEST_ID = /^0x[0-9a-f]{64}$/;\nconst MAX_BODY = 512 * 1024;\nconst MAX_REMEMBERED = 256;\n\nexport interface RelayProviderConfig {\n enabled?: boolean;\n /**\n * Relay's API (default https://api.relay.link) or the app's own proxy in front of it. Untrusted either way:\n * every answer is verified on the device.\n */\n baseUrl?: string;\n /** Sent as `x-api-key` when set. Prefer a proxy that adds it — a key shipped in an app is public. */\n apiKey?: string;\n /** Local lifetime of a quote (default 60 s, at most 5 min). The order itself is refused once older than 10 min. */\n quoteTtlMs?: number;\n /** Injectable for tests and for runtimes that bring their own. */\n fetchImpl?: typeof fetch;\n /**\n * Where cleared order ids are also kept, so that \"one deposit per order\" survives an app restart (the built-in\n * record lives in memory). `has` is asked and `add` awaited right before a signature; either throwing refuses.\n */\n clearedStore?: RelayClearedStore;\n}\n\n/** A durable record of order ids a deposit was cleared for. `expiresAtMs` is when an entry may be dropped. */\nexport interface RelayClearedStore {\n has(orderId: string): boolean | Promise<boolean>;\n add(orderId: string, expiresAtMs: number): void | Promise<void>;\n}\n\ninterface RelayStep {id?: unknown; requestId?: unknown; items?: unknown}\ninterface RelayQuoteBody {\n steps?: unknown;\n fees?: {relayer?: {currency?: {address?: unknown}; amount?: unknown; amountUsd?: unknown}; app?: {amount?: unknown}};\n details?: {timeEstimate?: unknown; currencyGasTopup?: {amount?: unknown}};\n protocol?: {v2?: unknown};\n message?: unknown;\n errorCode?: unknown;\n}\n\n/** Relay's request states → swap2 states. `failure` is read together with `refundFailReason` (see `trackIntent`). */\nexport const RELAY_STATUS_MAP: Readonly<Record<string, IntentState>> = Object.freeze({\n waiting: \"pending\", depositing: \"pending\", pending: \"pending\", submitted: \"pending\", delayed: \"pending\", unknown: \"pending\",\n success: \"completed\", refund: \"refunded\", refunded: \"refunded\", failure: \"refund-pending\",\n});\n\n/**\n * Relay's error codes that say why there is no quote (`errorCode` of a non-2xx answer, as docs.relay.link lists them\n * under \"handling errors\"). They win over the HTTP status except a 429, which keeps its Retry-After; a code not\n * listed here is read from the status, and failing that a JSON refusal is `no_route`.\n */\nconst RELAY_ERROR_REASONS: Readonly<Record<string, Swap2RefusalReason>> = Object.freeze(Object.assign(Object.create(null) as Record<string, Swap2RefusalReason>, {\n AMOUNT_TOO_LOW: \"amount_too_small\",\n AMOUNT_TOO_HIGH: \"amount_too_large\",\n INSUFFICIENT_LIQUIDITY: \"insufficient_liquidity\",\n NO_QUOTES: \"no_route\",\n NO_SWAP_ROUTES_FOUND: \"no_route\",\n NO_INTERNAL_SWAP_ROUTES_FOUND: \"no_route\",\n // Relay's own failures: a third-party pricing failure, and the transient codes it says to retry with backoff.\n SWAP_QUOTE_FAILED: \"upstream_unavailable\",\n REQUEST_TIMED_OUT: \"upstream_unavailable\",\n RPC_HTTP_ERROR: \"upstream_unavailable\",\n PRICE_FETCH_FAILED: \"upstream_unavailable\",\n SERVICE_UNAVAILABLE: \"upstream_unavailable\",\n // The recipient resolves to a token contract, which cannot receive.\n INVALID_RECIPIENT: \"recipient_mismatch\",\n UNSUPPORTED_CHAIN: \"unsupported_pair\",\n UNSUPPORTED_CURRENCY: \"unsupported_pair\",\n UNSUPPORTED_ROUTE: \"unsupported_pair\",\n UNSUPPORTED_EXECUTION_TYPE: \"unsupported_pair\",\n INVALID_INPUT_CURRENCY: \"unsupported_pair\",\n INVALID_OUTPUT_CURRENCY: \"unsupported_pair\",\n CHAIN_DISABLED: \"chain_halted\",\n ROUTE_TEMPORARILY_RESTRICTED: \"chain_halted\",\n SWAP_IMPACT_TOO_HIGH: \"price_check_failed\",\n UNAUTHORIZED: \"key_rejected\",\n UNAUTHORIZED_QUOTE: \"key_rejected\",\n FORBIDDEN: \"key_rejected\",\n}));\n\n/**\n * Why a non-2xx quote answer refused: a 429 first (its wait), then Relay's own code, then the status, then the body's\n * shape. `aborted`: the caller's own signal fired, so a body that could not be read is not Relay's failure.\n */\nfunction quoteHttpRefusal(res: Response, parsed: unknown, aborted: boolean): Swap2RefusalInfo | undefined {\n const code = (parsed as RelayQuoteBody | null)?.errorCode;\n const byCode = typeof code === \"string\" && Object.prototype.hasOwnProperty.call(RELAY_ERROR_REASONS, code) ? RELAY_ERROR_REASONS[code] : undefined;\n const byStatus = httpRefusal(res.status, res.headers?.get?.(\"retry-after\"));\n if (byStatus?.reason === \"rate_limited\") return byStatus;\n if (byCode) {\n if (byStatus?.reason === byCode) return byStatus;\n // The reasons that carry the status keep it whatever the status was.\n return byCode === \"upstream_unavailable\" || byCode === \"key_rejected\" ? {reason: byCode, httpStatus: res.status} : {reason: byCode};\n }\n if (byStatus) return byStatus;\n // A JSON refusal Relay did not name is a quote it does not have; anything else is an answer of another shape.\n if (parsed !== null && typeof parsed === \"object\") return {reason: \"no_route\"};\n return aborted ? undefined : {reason: \"upstream_unavailable\", httpStatus: res.status};\n}\n\nfunction clip(text: string, max = 240): string {\n const t = redactUrls(text).replace(/\\s+/g, \" \").trim();\n return t.length > max ? `${t.slice(0, max)}…` : t;\n}\n\n/** The single deposit step of a quote response; an `approve` step is ignored, anything else refuses the quote. */\nfunction depositStep(body: RelayQuoteBody): {requestId: string; tx: {to?: unknown; data?: unknown; value?: unknown; chainId?: unknown; gas?: unknown}} {\n const steps = body.steps;\n if (!Array.isArray(steps) || steps.length === 0 || steps.length > 8) throw new RelayRefusal(\"quote-steps\", \"the quote has no steps\", \"upstream_unavailable\");\n let found: RelayStep | null = null;\n for (const s of steps as RelayStep[]) {\n if (s === null || typeof s !== \"object\") throw new RelayRefusal(\"quote-steps\", \"the quote has a malformed step\", \"upstream_unavailable\");\n if (s.id === \"approve\") continue; // never used: the approval is built here, for the exact amount, to the pinned depository\n if (s.id !== \"deposit\") throw new RelayRefusal(\"quote-steps\", `the quote needs a \"${clip(String(s.id), 40)}\" step, only a single deposit is signed`, \"unsupported_pair\");\n if (found) throw new RelayRefusal(\"quote-steps\", \"the quote has more than one deposit step\", \"unsupported_pair\");\n found = s;\n }\n if (!found) throw new RelayRefusal(\"quote-steps\", \"the quote has no deposit step\", \"upstream_unavailable\");\n const items = found.items;\n if (!Array.isArray(items) || items.length !== 1) throw new RelayRefusal(\"quote-steps\", \"the deposit step is not a single transaction\", \"unsupported_pair\");\n const data = (items[0] as {data?: unknown} | null)?.data;\n if (data === null || typeof data !== \"object\") throw new RelayRefusal(\"quote-steps\", \"the deposit step has no transaction\", \"upstream_unavailable\");\n const requestId = typeof found.requestId === \"string\" ? found.requestId.toLowerCase() : \"\";\n if (!REQUEST_ID.test(requestId)) throw new RelayRefusal(\"quote-steps\", \"the quote has no request id to track the deposit by\", \"upstream_unavailable\");\n return {requestId, tx: data as never};\n}\n\nexport function relayProvider(config: RelayProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const base = (config.baseUrl ?? RELAY_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(base)) throw new Error(\"relay: baseUrl must use http or https\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"relay: quoteTtlMs must be an integer between 1 and 300000\");\n if (config.apiKey !== undefined && (typeof config.apiKey !== \"string\" || !/^[\\x21-\\x7e]{1,256}$/.test(config.apiKey))) throw new Error(\"relay: apiKey must be a printable string\");\n const doFetch: typeof fetch = (input, init) => (config.fetchImpl ?? fetch)(input, init);\n const headers = (json: boolean): Record<string, string> => ({\n accept: \"application/json\",\n ...(json ? {\"content-type\": \"application/json\"} : {}),\n ...(config.apiKey ? {\"x-api-key\": config.apiKey} : {}),\n });\n\n // The request each live quote answered, kept on this side: a deposit is checked against what was asked here, not\n // against what the quote object says was asked.\n const issued = new Map<string, RelayRequest>();\n const remember = <K, V>(m: Map<K, V>, k: K, v: V): void => {\n m.delete(k);\n m.set(k, v);\n if (m.size > MAX_REMEMBERED) m.delete(m.keys().next().value as K);\n };\n\n /** The request a quote is checked against before a build or a signature. */\n function requestOf(quote: Quote): RelayRequest {\n const pd = quote.providerData ?? {};\n const sealed: RelayRequest = {\n sourceChain: pd.sourceChain ?? \"\", destChain: pd.destChain ?? \"\", sourceToken: pd.sourceToken ?? \"\", destToken: pd.destToken ?? \"\",\n amount: /^[1-9]\\d{0,77}$/.test(pd.amount ?? \"\") ? BigInt(pd.amount!) : 0n,\n depositor: pd.depositor ?? \"\", recipient: pd.recipient ?? \"\",\n ...(/^\\d{1,78}$/.test(pd.minAmountOut ?? \"\") ? {minAmountOut: BigInt(pd.minAmountOut!)} : {}),\n ...(/^\\d{1,5}$/.test(pd.slippageBps ?? \"\") ? {slippageBps: Number(pd.slippageBps)} : {}),\n };\n // The pricing placeholder is never a party to a deposit, whatever flags the quote object carries.\n if (sealed.depositor.toLowerCase() === EVM_PLACEHOLDER.toLowerCase() || sealed.recipient.toLowerCase() === EVM_PLACEHOLDER.toLowerCase()) {\n throw new RelayRefusal(\"request-invalid\", \"a quote priced without the real addresses is never built or signed — quote again with them\", \"policy_refused\");\n }\n const mine = issued.get(quote.intentId);\n if (!mine) return sealed;\n const same = mine.sourceChain === sealed.sourceChain && mine.destChain === sealed.destChain && mine.amount === sealed.amount\n && mine.sourceToken.toLowerCase() === sealed.sourceToken.toLowerCase() && mine.destToken.toLowerCase() === sealed.destToken.toLowerCase()\n && mine.depositor.toLowerCase() === sealed.depositor.toLowerCase() && mine.recipient.toLowerCase() === sealed.recipient.toLowerCase();\n if (!same) throw new RelayRefusal(\"request-invalid\", \"the quote no longer says what was asked when it was issued — quote again\", \"policy_refused\");\n return mine;\n }\n\n async function readJson(res: Response): Promise<unknown> {\n const text = await res.text();\n if (text.length > MAX_BODY) throw new Error(\"relay: response too large\");\n return JSON.parse(text) as unknown;\n }\n\n return {\n name: \"relay\",\n describeActivity: describeRelayActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => relayCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => relayCfg.supports(from, to),\n supportsRoute: (from: Asset, to: Asset) => relayCfg.supports(from.chain, to.chain),\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n const refuse = (reason: string, info?: Swap2RefusalInfo) => { params.onRefusal?.(reason, info); return null; };\n const dry = params.dry !== false;\n // Only a quote priced with the placeholder is unbuildable; one asked with real addresses is a real order.\n const placeholder = dry && (!params.destAddress || !params.refundAddress);\n let request: RelayRequest;\n try {\n // The placeholder prices a dry quote; a live one without addresses is refused.\n request = relayRequestOf(params, dry ? {placeholder: EVM_PLACEHOLDER} : {});\n } catch (err) {\n if (err instanceof RelayRefusal) return refuse(err.message, refusalOf(err));\n throw err;\n }\n const src = relayChain(request.sourceChain)!;\n const dst = relayChain(request.destChain)!;\n let body: RelayQuoteBody;\n try {\n const res = await doFetch(`${base}/quote/v2`, {\n method: \"POST\",\n headers: headers(true),\n body: JSON.stringify({\n user: request.depositor,\n recipient: request.recipient,\n refundTo: request.depositor,\n originChainId: src.chainId,\n destinationChainId: dst.chainId,\n originCurrency: request.sourceToken.toLowerCase(),\n destinationCurrency: request.destToken.toLowerCase(),\n amount: request.amount.toString(10),\n tradeType: \"EXACT_INPUT\",\n includeProtocolData: true,\n // Always named: Relay's \"auto\" would leave the distance between expected and minimum to the answering side.\n slippageTolerance: String(request.slippageBps ?? RELAY_DEFAULT_SLIPPAGE_BPS),\n }),\n signal: signal ? anySignal([signal, timeoutSignal(QUOTE_TIMEOUT_MS)]) : timeoutSignal(QUOTE_TIMEOUT_MS),\n });\n let parsed: unknown;\n try { parsed = await readJson(res); } catch { parsed = null; }\n if (!res.ok) {\n const e = (parsed ?? {}) as RelayQuoteBody;\n const why = typeof e.message === \"string\" ? clip(e.message) : `HTTP ${res.status}`;\n return refuse(`relay: no quote — ${typeof e.errorCode === \"string\" ? `${clip(e.errorCode, 60)}: ` : \"\"}${why}`, quoteHttpRefusal(res, parsed, signal?.aborted === true));\n }\n // A body cut off by the caller's own abort is not Relay's failure.\n if (parsed === null || typeof parsed !== \"object\") return refuse(\"relay: the quote response is not JSON\", signal?.aborted ? undefined : {reason: \"upstream_unavailable\"});\n body = parsed as RelayQuoteBody;\n } catch (err) {\n // The network, or this module's own timeout; the caller's own abort is not Relay's failure.\n const info = refusalOf(err) ?? (signal?.aborted ? undefined : {reason: \"upstream_unavailable\" as const});\n return refuse(`relay: quote request failed — ${clip(err instanceof Error ? err.message : String(err))}`, info);\n }\n\n try {\n const step = depositStep(body);\n const proto = (body.protocol?.v2 ?? null) as Record<string, unknown> | null;\n const v = verifyRelayOrder(request, proto, step.tx);\n // Extras this module never asks for. Each lowers the output inside a genuine order; the response's own account\n // of them is only a hint (an answering side that adds one can also hide it), so this refuses the honest case.\n const extra = (x: unknown): boolean => x !== undefined && x !== null && x !== \"0\" && x !== 0;\n if (extra(body.fees?.app?.amount)) throw new RelayRefusal(\"app-fee\", \"the quote charges an app fee this module did not ask for\", \"policy_refused\");\n if (extra(body.details?.currencyGasTopup?.amount)) throw new RelayRefusal(\"gas-topup\", \"the quote converts part of the output into a gas top-up this module did not ask for\", \"policy_refused\");\n const native = v.deposit.approvalAddress === undefined;\n const floor = native ? GAS_FLOOR_NATIVE : GAS_FLOOR_ERC20;\n const apiGas = typeof step.tx.gas === \"string\" && /^[1-9]\\d{0,9}$/.test(step.tx.gas) ? BigInt(step.tx.gas) * 2n : 0n;\n const gasLimit = apiGas > GAS_CAP ? GAS_CAP : apiGas > floor ? apiGas : floor;\n\n // Fees are Relay's own account of the quote: shown, never used in a check. They are already inside the output.\n const relayer = body.fees?.relayer;\n const usd = typeof relayer?.amountUsd === \"string\" && /^\\d{1,12}(?:\\.\\d{1,18})?$/.test(relayer.amountUsd) ? parseFloat(relayer.amountUsd) : 0;\n const feeToken = relayer?.currency?.address;\n const fees = typeof relayer?.amount === \"string\" && /^[1-9]\\d{0,77}$/.test(relayer.amount) && typeof feeToken === \"string\" && /^0x[0-9a-fA-F]{40}$/.test(feeToken)\n ? [{type: \"protocol\" as const, amount: relayer.amount, token: feeToken.toLowerCase(), included: true, description: \"Relay fee\"}]\n : [];\n const eta = body.details?.timeEstimate;\n const etaSeconds = typeof eta === \"number\" && Number.isFinite(eta) && eta > 0 ? Math.min(Math.ceil(eta), 86_400) : 60;\n\n const intentId = `${INTENT_PREFIX}${step.requestId}`;\n if (!placeholder) remember(issued, intentId, request);\n return {\n provider: \"relay\",\n intentId,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {\n to: v.deposit.to,\n data: v.deposit.data,\n value: v.deposit.value,\n chainId: v.deposit.chainId,\n gasLimit: gasLimit.toString(10),\n ...(v.deposit.approvalAddress ? {approvalAddress: v.deposit.approvalAddress} : {}),\n },\n sourceAmount: request.amount.toString(10),\n destAmount: v.expectedAmount.toString(10),\n minDestAmount: v.minimumAmount.toString(10),\n feeUsd: usd,\n fees,\n etaSeconds,\n reliability: 0.97,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n requestId: step.requestId,\n orderId: v.id,\n hubType: \"onchain\",\n // The order as received, re-read by the same parser before a build and before a signature.\n orderData: JSON.stringify(proto!.orderData),\n orderSignature: String(proto!.orderSignature).toLowerCase(),\n paymentDetails: JSON.stringify(proto!.paymentDetails),\n sourceChain: request.sourceChain,\n destChain: request.destChain,\n sourceToken: request.sourceToken.toLowerCase(),\n destToken: request.destToken.toLowerCase(),\n amount: request.amount.toString(10),\n depositor: request.depositor.toLowerCase(),\n recipient: request.recipient.toLowerCase(),\n ...(request.minAmountOut !== undefined ? {minAmountOut: request.minAmountOut.toString(10)} : {}),\n ...(request.slippageBps !== undefined ? {slippageBps: String(request.slippageBps)} : {}),\n ...(placeholder ? {placeholder: \"1\"} : {}),\n },\n };\n } catch (err) {\n if (err instanceof RelayRefusal) return refuse(err.message, refusalOf(err));\n return refuse(`relay: unreadable quote — ${clip(err instanceof Error ? err.message : String(err))}`, refusalOf(err) ?? {reason: \"upstream_unavailable\"});\n }\n },\n\n /** The quote's own transaction — after the order it carries has been verified once more. */\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n if (!tx || !quote.intentId.startsWith(INTENT_PREFIX)) throw refusal(\"policy_refused\", \"swap2: Relay quote has no transaction request\");\n if (quote.providerData?.placeholder === \"1\") throw new RelayRefusal(\"request-invalid\", \"a quote priced without the real addresses is never built — quote again with them\", \"policy_refused\");\n const request = requestOf(quote);\n const v = checkRelayQuote(request, quote);\n return {\n chain: request.sourceChain,\n to: v.deposit.to,\n value: v.deposit.value,\n data: v.deposit.data,\n chainId: v.deposit.chainId,\n ...(tx.gasLimit ? {gasLimit: tx.gasLimit} : {}),\n ...(v.deposit.approvalAddress ? {approvalAddress: v.deposit.approvalAddress} : {}),\n };\n },\n\n /**\n * Right before signing: the whole verification again, against the request this instance issued the quote for\n * and the exact transaction about to be signed — and each order is cleared for one deposit only.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n if (quote.providerData?.placeholder === \"1\") throw new RelayRefusal(\"request-invalid\", \"a quote priced without the real addresses is never signed\", \"policy_refused\");\n const request = requestOf(quote);\n if (tx.chain !== request.sourceChain) throw new RelayRefusal(\"tx-chain\", `the deposit is for ${tx.chain}, not ${request.sourceChain}`, \"vault_mismatch\");\n if (tx.serializedTx !== undefined || tx.memo !== undefined || tx.typedData !== undefined || tx.bodyBoc !== undefined) {\n throw new RelayRefusal(\"quote-shape\", \"a Relay deposit is one EVM call\", \"policy_refused\");\n }\n const v = checkRelayQuote(request, quote, tx);\n const store = config.clearedStore;\n if (store && await store.has(v.id)) throw new RelayRefusal(\"order-reused\", `order ${v.id} was already cleared for a deposit — quote again`, \"policy_refused\");\n relayClearOrder(v.id, \"sign\");\n // Kept until the order's own deadline: a deposit for it is never signed twice, restart or not.\n if (store) await store.add(v.id, v.order.output.deadline * 1000);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (typeof ref.intentId !== \"string\" || !ref.intentId.startsWith(INTENT_PREFIX)) return {state: \"failed\"};\n const requestId = ref.intentId.slice(INTENT_PREFIX.length);\n if (!REQUEST_ID.test(requestId)) return {state: \"failed\"};\n // Nothing was sent yet: Relay answers \"waiting\" for a request it has seen no deposit for.\n if (!ref.sourceTxHash) return {state: \"pending\"};\n try {\n const res = await doFetch(`${base}/intents/status/v3?requestId=${requestId}`, {headers: headers(false), signal: timeoutSignal(STATUS_TIMEOUT_MS)});\n if (!res.ok) return {state: \"pending\"};\n const s = (await readJson(res)) as {status?: unknown; txHashes?: unknown; refundFailReason?: unknown} | null;\n const status = typeof s?.status === \"string\" ? s.status.toLowerCase() : \"\";\n const state = Object.prototype.hasOwnProperty.call(RELAY_STATUS_MAP, status) ? RELAY_STATUS_MAP[status]! : \"pending\";\n const seen = status !== \"waiting\" && status !== \"unknown\" && status !== \"\";\n if (state === \"completed\") {\n const hashes = Array.isArray(s?.txHashes) ? s.txHashes.filter((h): h is string => typeof h === \"string\" && /^0x[0-9a-fA-F]{64}$/.test(h)) : [];\n const dest = hashes[hashes.length - 1] ?? ref.destTxHash ?? undefined;\n return {state, depositReceived: true, ...(dest ? {destTxHash: dest} : {})};\n }\n if (status === \"failure\") {\n // A failed fill is refunded by Relay on its own. Only when the refund itself failed is there nothing\n // more coming without Relay's support.\n const why = typeof s?.refundFailReason === \"string\" ? s.refundFailReason.trim() : \"\";\n return {state: why !== \"\" && why.toUpperCase() !== \"N/A\" ? \"failed\" : \"refund-pending\", depositReceived: true};\n }\n return {state, ...(seen ? {depositReceived: true} : {})};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQ,WAAW,YAAY,qBAAoB;AAEnD,SAAQ,aAAa,SAAS,iBAAgE;AA4B9F,IAAM,kBAAkB;AACxB,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AACtB,IAAM,aAAa;AACnB,IAAM,WAAW,MAAM;AACvB,IAAM,iBAAiB;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