@anywalletkit/protocol-swap2-near-intents 0.2.1 → 0.3.1

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/README.md CHANGED
@@ -16,6 +16,33 @@ npm install @anywalletkit/protocol-swap2-near-intents @anywalletkit/core
16
16
 
17
17
  On npm: [@anywalletkit/protocol-swap2-near-intents](https://www.npmjs.com/package/@anywalletkit/protocol-swap2-near-intents), published from the [release workflow](https://github.com/ultratestbro/anywalletkit/blob/main/RELEASING.md) with provenance.
18
18
 
19
+ ## Credit a NEAR Intents (near.com) account
20
+
21
+ By default 1Click withdraws the output to `destAddress` on `destChain`. With `recipientType: "INTENTS"` it credits the
22
+ NEAR Intents account `destAddress` inside `intents.near` instead, the account a near.com user holds (`nearcom:0x…`
23
+ in near.com is the `0x…` account here). Nothing is withdrawn: the asset stays in that account as the intents token,
24
+ so `destChain` must be `near:mainnet` (another chain is refused, so a review never names a chain the output does not
25
+ reach) and `destToken` may be the token id itself, e.g. `nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near`
26
+ for Base USDC held in intents.
27
+
28
+ ```ts
29
+ const toNearCom = nearIntentsProvider({recipientType: "INTENTS"});
30
+ await toNearCom.getQuote({
31
+ sourceChain: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", sourceToken: "USDC",
32
+ destChain: "near:mainnet", destToken: "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1",
33
+ destAddress: "0x63428e70a8016d10e8e2f7da440c898063afa299", amountIn: "5000000", refundAddress, dry: false,
34
+ });
35
+ ```
36
+
37
+ near.com keeps user funds in the Confidential Intents balance. `recipientType: "CONFIDENTIAL_INTENTS"` credits that
38
+ balance directly (1Click settles it with a signed transfer intent). 1Click serves it to partners only, so the provider
39
+ requires `jwt` in this mode and throws at construction without it.
40
+
41
+ `destAddress` must be a NEAR Intents account id: a named account (`alice.near`), an implicit id (64 lowercase hex) or
42
+ an implicit `0x` id (40 lowercase hex); anything else, a top-level name or a chain address such as `bc1q…` included,
43
+ is refused before a request is sent. Because the output never reaches the destination chain, a corridor paused for that chain does not block an
44
+ intents token id.
45
+
19
46
  ## Behind `remoteProvider`
20
47
 
21
48
  When the provider runs on your server, spread its pins into the app's stub:
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-P4T4UJWT.js";
8
8
 
9
9
  // src/provider.ts
10
- import { timeoutSignal } from "@anywalletkit/protocol-swap2-core/util";
10
+ import { namespace, timeoutSignal } from "@anywalletkit/protocol-swap2-core/util";
11
11
  import { CC_DEST, ccAsset, ccAssetByToken, ccChain } from "@anywalletkit/swap2-assets";
12
12
  var ONE_CLICK_DEFAULT = "https://1click.chaindefuser.com/v0";
13
13
  var QUOTE_TTL_MS = 55e3;
@@ -76,6 +76,25 @@ function txHashOf(entry) {
76
76
  const h = entry.hash;
77
77
  return typeof h === "string" ? h : null;
78
78
  }
79
+ function unitsText(units, decimals) {
80
+ const digits = units.replace(/^0+(?=\d)/, "").padStart(decimals + 1, "0");
81
+ const whole = digits.slice(0, digits.length - decimals);
82
+ const frac = digits.slice(digits.length - decimals).replace(/0+$/, "");
83
+ return frac ? `${whole}.${frac}` : whole;
84
+ }
85
+ function minimumRefusal(message, origin) {
86
+ const usd = /minimum swap amount is \$([\d,.]+)/i.exec(message)?.[1]?.replace(/[.,]+$/, "");
87
+ if (usd && /\d/.test(usd)) return `near_intents: below the 1Click minimum ($${usd})`;
88
+ const units = /amount is too low for bridge, try at least (\d{1,78})\b/i.exec(message)?.[1];
89
+ if (units) return `near_intents: below the 1Click minimum (at least ${unitsText(units, origin.decimals)} ${origin.symbol})`;
90
+ return null;
91
+ }
92
+ var NEAR_ACCOUNT_ID = /^(?=.{2,64}$)(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/;
93
+ var INTENTS_TOKEN_ID = /^nep(141|245):\S+$/;
94
+ function intentsAccountId(id) {
95
+ if (!NEAR_ACCOUNT_ID.test(id)) return false;
96
+ return id.includes(".") || /^[0-9a-f]{64}$/.test(id) || /^0x[0-9a-f]{40}$/.test(id);
97
+ }
79
98
  function nearIntentsProvider(config = {}) {
80
99
  config = Object.freeze({ ...config });
81
100
  const parsedApiUrl = new URL(config.apiUrl ?? ONE_CLICK_DEFAULT);
@@ -83,6 +102,16 @@ function nearIntentsProvider(config = {}) {
83
102
  throw new Error("near-intents: apiUrl must use http or https");
84
103
  }
85
104
  const apiBase = parsedApiUrl.toString().replace(/\/$/, "");
105
+ const recipientType = config.recipientType ?? "DESTINATION_CHAIN";
106
+ if (recipientType !== "DESTINATION_CHAIN" && recipientType !== "INTENTS" && recipientType !== "CONFIDENTIAL_INTENTS") {
107
+ throw new Error("near-intents: recipientType must be DESTINATION_CHAIN, INTENTS or CONFIDENTIAL_INTENTS");
108
+ }
109
+ if (recipientType === "CONFIDENTIAL_INTENTS" && !config.jwt) {
110
+ throw new Error("near-intents: CONFIDENTIAL_INTENTS delivery is partner-only and needs a 1Click jwt");
111
+ }
112
+ const intents = recipientType !== "DESTINATION_CHAIN";
113
+ const intentsDestOk = (destChain) => !intents || namespace(destChain) === "near";
114
+ const destinationAsset = (destChain, destToken) => intents && INTENTS_TOKEN_ID.test(destToken) ? destToken : destAssetId(destChain, destToken);
86
115
  const hasRecipient = config.feeRecipient !== void 0;
87
116
  const hasBps = config.feeBps !== void 0;
88
117
  if (hasRecipient !== hasBps) throw new Error("near-intents: feeRecipient and feeBps must be configured together");
@@ -96,25 +125,30 @@ function nearIntentsProvider(config = {}) {
96
125
  // Capability discovery comes from the provider itself, so it can run alone
97
126
  // or inside the optional aggregator without a central capability table.
98
127
  supportsChain: (chain) => nearIntents.supportsChain(chain),
99
- supportsChainPair: (fromChain, toChain) => nearIntents.supports(fromChain, toChain),
128
+ supportsChainPair: (fromChain, toChain) => nearIntents.supports(fromChain, toChain) && intentsDestOk(toChain),
100
129
  supportsRoute(from, to) {
101
- if (!nearIntents.supports(from.chain, to.chain)) return false;
130
+ if (!nearIntents.supports(from.chain, to.chain) || !intentsDestOk(to.chain)) return false;
102
131
  const asset = ccAsset(from.chain, from.token);
103
- return !!ccChain(from.chain) && !!asset?.assetId && !!destAssetId(to.chain, to.token);
132
+ return !!ccChain(from.chain) && !!asset?.assetId && !!destinationAsset(to.chain, to.token);
104
133
  },
105
134
  async getQuote(params, signal) {
106
- const refuse = (reason) => {
135
+ const refuse = (reason, shown) => {
107
136
  const detail = `${reason} [dry=${params.dry !== false} ${params.sourceChain}->${params.destChain} amount=${params.amountIn}]`;
108
137
  console.warn(`near-intents: no quote \u2014 ${detail.replace(/[\u0000-\u001f\u007f]/g, " ")}`);
109
- params.onRefusal?.(detail);
138
+ params.onRefusal?.(shown ?? detail);
110
139
  return null;
111
140
  };
112
141
  const paused = config.suspendedChains ?? {};
113
- const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused) ?? nearIntentsChainRefusal(params.destChain, paused);
142
+ const rawIntentsDest = intents && INTENTS_TOKEN_ID.test(params.destToken);
143
+ const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused) ?? (rawIntentsDest ? null : nearIntentsChainRefusal(params.destChain, paused));
114
144
  if (chainRefusal) return refuse(chainRefusal);
145
+ if (!intentsDestOk(params.destChain)) return refuse(`${recipientType} credits intents.near: destChain must be a NEAR chain, not ${params.destChain}`);
146
+ if (intents && !intentsAccountId(params.destAddress)) {
147
+ return refuse(`${recipientType} recipient must be a NEAR Intents account id`);
148
+ }
115
149
  const origin = ccAsset(params.sourceChain, params.sourceToken);
116
150
  if (!origin?.assetId) return refuse(`1Click does not list ${params.sourceChain} ${params.sourceToken}`);
117
- const destination = destAssetId(params.destChain, params.destToken);
151
+ const destination = destinationAsset(params.destChain, params.destToken);
118
152
  if (!destination) return refuse(`1Click does not list ${params.destChain} ${params.destToken}`);
119
153
  const dry = params.dry !== false;
120
154
  const refund = params.refundAddress ?? (dry ? placeholderFor(params.sourceChain) : "");
@@ -134,7 +168,7 @@ function nearIntentsProvider(config = {}) {
134
168
  refundTo: dcfg.refundTo,
135
169
  refundType: dcfg.refundType,
136
170
  recipient: params.destAddress,
137
- recipientType: "DESTINATION_CHAIN",
171
+ recipientType,
138
172
  deadline: requestedDeadline
139
173
  };
140
174
  const fees = appFees(config.feeRecipient, config.feeBps);
@@ -160,7 +194,11 @@ function nearIntentsProvider(config = {}) {
160
194
  if (!flaky || attempt >= 2 || signal?.aborted) break;
161
195
  await new Promise((resolve) => setTimeout(resolve, 500 * (attempt + 1)));
162
196
  }
163
- if (!res?.ok) return refuse(`1Click ${res?.status ?? "network error"}: ${String(data.message ?? "").slice(0, 200)}`);
197
+ if (!res?.ok) {
198
+ const message = String(data.message ?? "").slice(0, 200);
199
+ const below = res?.status === 400 ? minimumRefusal(message, origin) : null;
200
+ return refuse(`1Click ${res?.status ?? "network error"}: ${message}`, below ?? void 0);
201
+ }
164
202
  const q = data.quote ?? {};
165
203
  const depositAddress = typeof q.depositAddress === "string" ? q.depositAddress : "";
166
204
  if (!dry && !depositAddress) return refuse("live quote came back without a deposit address");
@@ -247,4 +285,4 @@ function nearIntentsProvider(config = {}) {
247
285
  export {
248
286
  nearIntentsProvider
249
287
  };
250
- //# sourceMappingURL=chunk-ZCU6YSV4.js.map
288
+ //# sourceMappingURL=chunk-4GRRM3WT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import {nearIntents as cfg, nearIntentsChainRefusal, type NearIntentsSuspendedChains} from \"./config.js\";\nimport {describeNearIntentsActivity} from \"./activity.js\";\nimport {namespace, timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {CC_DEST, ccAsset, ccAssetByToken, ccChain} from \"@anywalletkit/swap2-assets\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * NEAR Intents (1Click) provider — the core route, broadest coverage:\n * dry quote → pricing preview; live quote → depositAddress the user funds\n * from any wallet; status polled by depositAddress.\n * Runs server-side, so the partner JWT stays here (no proxy needed). Defensive:\n * any API error yields a null quote so the provider drops out of that round.\n */\n\nconst ONE_CLICK_DEFAULT = \"https://1click.chaindefuser.com/v0\";\nconst QUOTE_TTL_MS = 55_000;\n\n/** intentId durably carries both status lookup keys (memo is quote-specific). */\nconst INTENT_PREFIX = \"near1click:\";\n\nfunction encodeIntent(depositAddress: string, depositMemo: string | null): string {\n return `${INTENT_PREFIX}${encodeURIComponent(depositAddress)}|${encodeURIComponent(depositMemo ?? \"\")}`;\n}\n\nfunction decodeIntent(intentId: string): {depositAddress: string; depositMemo?: string} {\n try {\n if (!intentId.startsWith(INTENT_PREFIX)) throw new Error(\"unsupported id version\");\n const raw = intentId.slice(INTENT_PREFIX.length);\n const parts = raw.split(\"|\");\n if (parts.length !== 2 || !parts[0]) throw new Error(\"invalid id shape\");\n const depositAddress = decodeURIComponent(parts[0]);\n const memo = decodeURIComponent(parts[1] ?? \"\");\n if (!depositAddress) throw new Error(\"empty deposit address\");\n return {depositAddress, ...(memo ? {depositMemo: memo} : {})};\n } catch {\n throw new Error(\"near-intents: malformed intent id\");\n }\n}\n\nfunction authHeaders(jwtOverride?: string): Record<string, string> {\n const h: Record<string, string> = {\"content-type\": \"application/json\", accept: \"application/json\"};\n const jwt = jwtOverride;\n if (jwt) h.authorization = `Bearer ${jwt}`;\n return h;\n}\n\n/** Our integrator fee, injected server-side when a recipient is configured. */\nfunction appFees(recipient?: string, bps?: number): {recipient: string; fee: number}[] | undefined {\n return recipient !== undefined && bps !== undefined ? [{recipient, fee: bps}] : undefined;\n}\n\n/**\n * Per-source deposit + refund config. Every live default keeps failed-swap\n * ownership on the caller's source-chain address.\n */\nfunction depositConfig(_sourceChain: string, refundAddress: string, _dry: boolean) {\n // Every source refunds to the caller's own source-chain address (Zcash\n // included — a t-address placeholder serves dry quotes since 2026-10-18).\n // Never redirect failed swaps to an integrator-owned NEAR account.\n return {depositType: \"ORIGIN_CHAIN\", refundType: \"ORIGIN_CHAIN\", refundTo: refundAddress};\n}\n\n/** Placeholder sender/recipient for dry quotes (1Click requires the fields). */\nconst PLACEHOLDER: Record<string, string> = {\n bitcoin: \"bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq\",\n ton: \"UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJKZ\",\n // NOT a token mint: with the USDC mint here, every dry quote whose ORIGIN\n // was Solana USDC answered 500 \"Internal server error\" (2026-10-09) — a\n // refund \"to the asset's own mint\" trips 1Click. The incinerator is a\n // plain, valid system address.\n solana: \"1nc1nerator11111111111111111111111111111111\",\n tron: \"TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9\",\n // NEAR refunds go to an account id; the registrar account always exists.\n near: \"near\",\n // A live transparent address (exchange hot wallet); dry quotes only.\n zcash: \"t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua\",\n eip155: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\",\n};\n\nfunction placeholderFor(chain: string): string {\n return PLACEHOLDER[chain.split(\":\")[0] ?? \"\"] ?? PLACEHOLDER.eip155!;\n}\n\nfunction deadlineIn(minutes: number): string {\n return new Date(Date.now() + minutes * 60_000).toISOString().replace(/\\.\\d{3}Z$/, \"Z\");\n}\n\n/**\n * dest asset id for ANY chain in the catalog (inbound → Ethereum, or the step-2\n * off-ramp → any supported chain). Falls back to the Ethereum omft pattern for\n * a mainnet ERC-20 that isn't in the curated catalog.\n */\nfunction destAssetId(destChain: string, destToken: string): string | null {\n const asset = ccAssetByToken(destChain, destToken);\n if (asset) return asset.assetId;\n if (destChain === CC_DEST.caip2 && /^0x[0-9a-fA-F]{40}$/.test(destToken)) {\n return `nep141:eth-${destToken.toLowerCase()}.omft.near`;\n }\n return null;\n}\n\ntype OneClickQuote = {\n quote?: Record<string, unknown>;\n correlationId?: string;\n error?: string;\n message?: string;\n};\n\n/** 1Click returns tx hashes either as strings or {hash, explorerUrl}. */\nfunction txHashOf(entry: unknown): string | null {\n if (!entry) return null;\n if (typeof entry === \"string\") return entry;\n const h = (entry as {hash?: string}).hash;\n return typeof h === \"string\" ? h : null;\n}\n\n/** `units / 10^decimals` as an exact decimal string (no float on the way, so no Hermes bigint trap). */\nfunction unitsText(units: string, decimals: number): string {\n const digits = units.replace(/^0+(?=\\d)/, \"\").padStart(decimals + 1, \"0\");\n const whole = digits.slice(0, digits.length - decimals);\n const frac = digits.slice(digits.length - decimals).replace(/0+$/, \"\");\n return frac ? `${whole}.${frac}` : whole;\n}\n\n/**\n * 1Click's amount floors, as a stable text an app can show the user. Two wordings, both HTTP 400:\n * - \"Temporary swap limits: minimum swap amount is $1,000\" — the USD floors 1Click announces in its\n * changelog (2026-09-09: $1,000 on BNB Chain and other chains; 2026-09-14: $100 from Tron), seen\n * live 2026-11-04 on Base USDC → BSC USDT and Tron USDT → Base USDC;\n * - \"Amount is too low for bridge, try at least 150000\" — a floor in the ORIGIN asset's base units\n * (live 2026-11-04: Base USDC → Arbitrum answers it below 150000 and quotes at exactly 150000).\n * Only digits are taken from 1Click's text; anything else is not a known floor and returns null.\n */\nfunction minimumRefusal(message: string, origin: {symbol: string; decimals: number}): string | null {\n const usd = /minimum swap amount is \\$([\\d,.]+)/i.exec(message)?.[1]?.replace(/[.,]+$/, \"\");\n if (usd && /\\d/.test(usd)) return `near_intents: below the 1Click minimum ($${usd})`;\n const units = /amount is too low for bridge, try at least (\\d{1,78})\\b/i.exec(message)?.[1];\n if (units) return `near_intents: below the 1Click minimum (at least ${unitsText(units, origin.decimals)} ${origin.symbol})`;\n return null;\n}\n\n/** Explicit constructor configuration; no deployment environment is read. */\nexport interface NearIntentsProviderConfig {\n enabled?: boolean;\n apiUrl?: string;\n jwt?: string;\n feeRecipient?: string;\n feeBps?: number;\n /** Corridors the app has paused (caip2 → reason): refused up front, by name, until the app lifts them. */\n suspendedChains?: NearIntentsSuspendedChains;\n /**\n * Where 1Click credits the output. `DESTINATION_CHAIN` (default) withdraws to\n * `destAddress` on `destChain`. `INTENTS` credits the NEAR Intents account\n * `destAddress` inside intents.near — the account a near.com user holds — with\n * no withdrawal: the asset stays there as the intents token. In this mode\n * `destChain` must be the NEAR chain (`near:mainnet`), and `destToken` may be\n * the intents token id itself (`nep141:…` / `nep245:…`).\n * `CONFIDENTIAL_INTENTS` credits the same account's Confidential Intents\n * balance (where near.com keeps funds); 1Click settles it with a signed\n * transfer intent and serves it to partners only, so it requires `jwt`.\n */\n recipientType?: \"DESTINATION_CHAIN\" | \"INTENTS\" | \"CONFIDENTIAL_INTENTS\";\n}\n\n/** NEAR account id rules (intents.near accounts include implicit hex and 0x ids). */\nconst NEAR_ACCOUNT_ID = /^(?=.{2,64}$)(([a-z\\d]+[-_])*[a-z\\d]+\\.)*([a-z\\d]+[-_])*[a-z\\d]+$/;\nconst INTENTS_TOKEN_ID = /^nep(141|245):\\S+$/;\n\n/**\n * An intents.near account someone can sign for: a named account (`alice.near`), an\n * implicit ed25519 id (64 hex) or an implicit EVM-style id (`0x` + 40 hex). Any other\n * dot-less id passes the NEAR syntax but is a pasted chain address (`bc1q…`, a padded\n * `0x…`), credited to an account no key controls.\n */\nfunction intentsAccountId(id: string): boolean {\n if (!NEAR_ACCOUNT_ID.test(id)) return false;\n return id.includes(\".\") || /^[0-9a-f]{64}$/.test(id) || /^0x[0-9a-f]{40}$/.test(id);\n}\n\nexport function nearIntentsProvider(config: NearIntentsProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const parsedApiUrl = new URL(config.apiUrl ?? ONE_CLICK_DEFAULT);\n if (parsedApiUrl.protocol !== \"https:\" && parsedApiUrl.protocol !== \"http:\") {\n throw new Error(\"near-intents: apiUrl must use http or https\");\n }\n const apiBase = parsedApiUrl.toString().replace(/\\/$/, \"\");\n const recipientType = config.recipientType ?? \"DESTINATION_CHAIN\";\n if (recipientType !== \"DESTINATION_CHAIN\" && recipientType !== \"INTENTS\" && recipientType !== \"CONFIDENTIAL_INTENTS\") {\n throw new Error(\"near-intents: recipientType must be DESTINATION_CHAIN, INTENTS or CONFIDENTIAL_INTENTS\");\n }\n if (recipientType === \"CONFIDENTIAL_INTENTS\" && !config.jwt) {\n throw new Error(\"near-intents: CONFIDENTIAL_INTENTS delivery is partner-only and needs a 1Click jwt\");\n }\n /** Output credited inside NEAR Intents (public or confidential), never withdrawn to a chain. */\n const intents = recipientType !== \"DESTINATION_CHAIN\";\n /**\n * An intents credit lands in the intents.near contract on NEAR, whatever token it is, so\n * only a NEAR destChain names it truthfully: a review of \"USDC on Base to 0x…\" must not\n * be a credit that never reaches Base.\n */\n const intentsDestOk = (destChain: string): boolean => !intents || namespace(destChain) === \"near\";\n /** The 1Click destination asset: an intents token id passes through in INTENTS mode. */\n const destinationAsset = (destChain: string, destToken: string): string | null =>\n intents && INTENTS_TOKEN_ID.test(destToken) ? destToken : destAssetId(destChain, destToken);\n const hasRecipient = config.feeRecipient !== undefined;\n const hasBps = config.feeBps !== undefined;\n if (hasRecipient !== hasBps) throw new Error(\"near-intents: feeRecipient and feeBps must be configured together\");\n if (hasRecipient && (!config.feeRecipient!.trim() || !Number.isInteger(config.feeBps) || config.feeBps! <= 0 || config.feeBps! > 10_000)) {\n throw new Error(\"near-intents: fee config requires a recipient and feeBps between 1 and 10000\");\n }\n return {\n name: \"near_intents\",\n describeActivity: describeNearIntentsActivity,\n enabled: () => config.enabled ?? true,\n\n // Capability discovery comes from the provider itself, so it can run alone\n // or inside the optional aggregator without a central capability table.\n supportsChain: (chain: string) => cfg.supportsChain(chain),\n supportsChainPair: (fromChain: string, toChain: string) => cfg.supports(fromChain, toChain) && intentsDestOk(toChain),\n supportsRoute(from: Asset, to: Asset): boolean {\n // Chain-level gate first (namespace, catalog listing, hand-suspended\n // corridors such as TON while the HOT bridge is dark) …\n if (!cfg.supports(from.chain, to.chain) || !intentsDestOk(to.chain)) return false;\n // … then only pairs present in the curated catalog are offered — and only\n // those with a 1Click asset id (LI.FI-only tokens carry an empty assetId).\n // Both ends: a destination 1Click doesn't list (Unichain, MegaETH, …)\n // answered \"unknown asset\" on every quote (589 of the 2026-10-10 matrix).\n const asset = ccAsset(from.chain, from.token);\n return !!ccChain(from.chain) && !!asset?.assetId && !!destinationAsset(to.chain, to.token);\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n // Every refusal below names itself: on the server these lines are the\n // only visibility into WHY a live quote returned null (the wire answer\n // is just `null`), and \"no route\" bugs hide in exactly that silence.\n // `shown`, when given, is the user-presentable text the caller hands on (a router rejection,\n // the server's {noQuote}); the log line keeps the debug suffix either way.\n const refuse = (reason: string, shown?: string): null => {\n const detail = `${reason} [dry=${params.dry !== false} ${params.sourceChain}->${params.destChain} amount=${params.amountIn}]`;\n // Caller fields and 1Click text are untrusted: no control characters in server logs.\n console.warn(`near-intents: no quote — ${detail.replace(/[\\u0000-\\u001f\\u007f]/g, \" \")}`);\n params.onRefusal?.(shown ?? detail);\n return null;\n };\n // Up-front, named refusals — no wire call for a corridor 1Click cannot\n // serve: a chain outside its list / suspended by hand, or a token the\n // catalog carries without a 1Click asset id (\"1Click does not list …\").\n const paused = config.suspendedChains ?? {};\n // An output credited inside intents.near never touches the destination\n // chain, so only the source corridor can be paused for it.\n const rawIntentsDest = intents && INTENTS_TOKEN_ID.test(params.destToken);\n const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused)\n ?? (rawIntentsDest ? null : nearIntentsChainRefusal(params.destChain, paused));\n if (chainRefusal) return refuse(chainRefusal);\n if (!intentsDestOk(params.destChain)) return refuse(`${recipientType} credits intents.near: destChain must be a NEAR chain, not ${params.destChain}`);\n if (intents && !intentsAccountId(params.destAddress)) {\n return refuse(`${recipientType} recipient must be a NEAR Intents account id`);\n }\n const origin = ccAsset(params.sourceChain, params.sourceToken);\n if (!origin?.assetId) return refuse(`1Click does not list ${params.sourceChain} ${params.sourceToken}`);\n const destination = destinationAsset(params.destChain, params.destToken);\n if (!destination) return refuse(`1Click does not list ${params.destChain} ${params.destToken}`);\n const dry = params.dry !== false;\n // A live quote derives the deposit address from the refund config —\n // never create one without a real refund destination.\n const refund = params.refundAddress ?? (dry ? placeholderFor(params.sourceChain) : \"\");\n const dcfg = depositConfig(params.sourceChain, refund, dry);\n if (!dry && !dcfg.refundTo) return refuse(\"live quote without a refund address\");\n\n const requestedDeadline = deadlineIn(60);\n const body: Record<string, unknown> = {\n dry,\n // FLEX_INPUT (exchange flow): the address accepts any amount; amountIn\n // is just the pricing notional. Verified against the live API.\n swapType: params.flex ? \"FLEX_INPUT\" : \"EXACT_INPUT\",\n slippageTolerance: params.slippageBps ?? 100,\n originAsset: origin.assetId,\n depositType: dcfg.depositType,\n destinationAsset: destination,\n amount: params.amountIn,\n refundTo: dcfg.refundTo,\n refundType: dcfg.refundType,\n recipient: params.destAddress,\n recipientType,\n deadline: requestedDeadline,\n };\n const fees = appFees(config.feeRecipient, config.feeBps);\n if (fees) body.appFees = fees;\n\n try {\n // 1Click's solver auction flaps: the same body can answer 400 \"No\n // liquidity available\" and 201 seconds apart (observed live on\n // TON USDT -> ETH). A transient flap on the EXECUTION quote would\n // surface as a terminal \"no route\" right after a successful display\n // quote, so ride through it: up to two retries on liquidity flaps,\n // 5xx and network errors. Real rejections (bad address, unknown\n // asset) still fail on the first answer.\n let res: Response | null = null;\n let data: OneClickQuote = {};\n for (let attempt = 0; ; attempt++) {\n try {\n res = await fetch(`${apiBase}/quote`, {\n method: \"POST\",\n headers: authHeaders(config.jwt),\n body: JSON.stringify(body),\n signal: signal ?? timeoutSignal(12_000),\n });\n data = (await res.json().catch(() => ({}))) as OneClickQuote;\n } catch (err) {\n if (attempt >= 2 || signal?.aborted) throw err;\n res = null;\n }\n if (res?.ok) break;\n const flaky =\n res === null ||\n res.status >= 500 ||\n (res.status === 400 && /no liquidity/i.test(String(data.message ?? \"\")));\n if (!flaky || attempt >= 2 || signal?.aborted) break;\n await new Promise((resolve) => setTimeout(resolve, 500 * (attempt + 1)));\n }\n if (!res?.ok) {\n const message = String(data.message ?? \"\").slice(0, 200);\n // A known amount floor goes out as a stable, presentable reason; any other answer keeps the raw text.\n const below = res?.status === 400 ? minimumRefusal(message, origin) : null;\n return refuse(`1Click ${res?.status ?? \"network error\"}: ${message}`, below ?? undefined);\n }\n const q = (data.quote ?? {}) as Record<string, unknown>;\n\n const depositAddress = typeof q.depositAddress === \"string\" ? q.depositAddress : \"\";\n if (!dry && !depositAddress) return refuse(\"live quote came back without a deposit address\");\n const inUsd = Number.parseFloat(String(q.amountInUsd ?? \"0\"));\n const outUsd = Number.parseFloat(String(q.amountOutUsd ?? \"0\"));\n const parsedDeadline = Date.parse(String(q.deadline ?? \"\"));\n if (!dry && (!Number.isFinite(parsedDeadline) || parsedDeadline <= Date.now())) return refuse(`unusable deadline ${String(q.deadline)}`);\n const deadline = Number.isFinite(parsedDeadline) && parsedDeadline > Date.now()\n ? Math.min(parsedDeadline, Date.now() + QUOTE_TTL_MS)\n : Date.now() + QUOTE_TTL_MS;\n\n if (q.amountIn !== undefined && String(q.amountIn) !== params.amountIn) return refuse(`amountIn mismatch (${String(q.amountIn)} vs ${params.amountIn})`);\n\n // amountOut is optimistic, not a guaranteed floor. Live execution must\n // not fabricate a minimum when the provider omits it.\n if (q.minAmountOut === undefined || q.minAmountOut === null) return refuse(\"quote has no minAmountOut\");\n const minDestAmount = String(q.minAmountOut);\n if (params.minAmountOut !== undefined && BigInt(minDestAmount) < BigInt(params.minAmountOut)) return refuse(`floor breach (min=${minDestAmount} < floor=${params.minAmountOut})`);\n const depositMemo =\n (typeof q.depositMemo === \"string\" && q.depositMemo) ||\n (typeof q.memo === \"string\" && q.memo) ||\n null;\n return {\n provider: \"near_intents\",\n intentId: depositAddress ? encodeIntent(depositAddress, depositMemo) : `dry:${crypto.randomUUID()}`,\n depositAddress,\n depositMemo,\n sourceAmount: params.amountIn,\n destAmount: String(q.amountOut ?? \"0\"),\n minDestAmount,\n feeUsd: Math.max(0, inUsd - outUsd),\n etaSeconds: Number(q.timeEstimate ?? 60),\n reliability: 0.95,\n validUntilMs: deadline,\n };\n } catch (err) {\n return refuse(`threw: ${err instanceof Error ? err.message.slice(0, 200) : String(err).slice(0, 200)}`);\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n return {\n chain: \"\",\n to: quote.depositAddress,\n value: quote.sourceAmount,\n ...(quote.depositMemo ? {memo: quote.depositMemo} : {}),\n };\n },\n\n async notifyDeposit(intentId: string, txHash: string): Promise<void> {\n const {depositAddress} = decodeIntent(intentId);\n const res = await fetch(`${apiBase}/deposit/submit`, {\n method: \"POST\",\n headers: authHeaders(config.jwt),\n body: JSON.stringify({depositAddress, txHash}),\n signal: timeoutSignal(12_000),\n });\n if (!res.ok) throw new Error(`near-intents: deposit notification failed (${res.status})`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const {depositAddress, depositMemo} = decodeIntent(ref.intentId);\n // Durable retry: BaseSwap2Protocol embeds the source hash in the swap2\n // id. If the post-broadcast notify failed, every status poll retries it.\n if (ref.sourceTxHash) {\n await this.notifyDeposit?.(ref.intentId, ref.sourceTxHash).catch(() => {});\n }\n try {\n const query = new URLSearchParams({depositAddress});\n if (depositMemo) query.set(\"depositMemo\", depositMemo);\n const res = await fetch(\n `${apiBase}/status?${query.toString()}`,\n {headers: authHeaders(config.jwt), signal: timeoutSignal(12_000)},\n );\n if (!res.ok) return {state: \"pending\"};\n const s = (await res.json()) as {\n status?: string;\n swapDetails?: {destinationChainTxHashes?: unknown[]};\n };\n const map: Record<string, IntentStatus[\"state\"]> = {\n PENDING_DEPOSIT: \"pending\",\n KNOWN_DEPOSIT_TX: \"pending\",\n INCOMPLETE_DEPOSIT: \"pending\",\n PROCESSING: \"pending\",\n SUCCESS: \"completed\",\n FAILED: \"failed\",\n REFUNDED: \"refunded\",\n };\n const state = map[s.status ?? \"PENDING_DEPOSIT\"] ?? \"pending\";\n // KNOWN_DEPOSIT_TX: 1Click has the deposit tx (submitted, not yet\n // credited). Counted as received so a caller with no source hash of\n // its own does not expire a swap that is already on its way.\n const depositReceived = s.status === \"KNOWN_DEPOSIT_TX\" || s.status === \"PROCESSING\" || s.status === \"INCOMPLETE_DEPOSIT\";\n const destTx = txHashOf(s.swapDetails?.destinationChainTxHashes?.[0]);\n return {state, depositReceived, ...(destTx ? {destTxHash: destTx} : {})};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;AAEA,SAAQ,WAAW,qBAAoB;AACvC,SAAQ,SAAS,SAAS,gBAAgB,eAAc;AAWxD,IAAM,oBAAoB;AAC1B,IAAM,eAAe;AAGrB,IAAM,gBAAgB;AAEtB,SAAS,aAAa,gBAAwB,aAAoC;AAChF,SAAO,GAAG,aAAa,GAAG,mBAAmB,cAAc,CAAC,IAAI,mBAAmB,eAAe,EAAE,CAAC;AACvG;AAEA,SAAS,aAAa,UAAkE;AACtF,MAAI;AACF,QAAI,CAAC,SAAS,WAAW,aAAa,EAAG,OAAM,IAAI,MAAM,wBAAwB;AACjF,UAAM,MAAM,SAAS,MAAM,cAAc,MAAM;AAC/C,UAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,QAAI,MAAM,WAAW,KAAK,CAAC,MAAM,CAAC,EAAG,OAAM,IAAI,MAAM,kBAAkB;AACvE,UAAM,iBAAiB,mBAAmB,MAAM,CAAC,CAAC;AAClD,UAAM,OAAO,mBAAmB,MAAM,CAAC,KAAK,EAAE;AAC9C,QAAI,CAAC,eAAgB,OAAM,IAAI,MAAM,uBAAuB;AAC5D,WAAO,EAAC,gBAAgB,GAAI,OAAO,EAAC,aAAa,KAAI,IAAI,CAAC,EAAE;AAAA,EAC9D,QAAQ;AACN,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AACF;AAEA,SAAS,YAAY,aAA8C;AACjE,QAAM,IAA4B,EAAC,gBAAgB,oBAAoB,QAAQ,mBAAkB;AACjG,QAAM,MAAM;AACZ,MAAI,IAAK,GAAE,gBA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AY,OAAO,GAAG,GAAG,QAAQ,cAAc,IAAM,EAAC;AAAA,QAClE;AACA,YAAI,CAAC,IAAI,GAAI,QAAO,EAAC,OAAO,UAAS;AACrC,cAAM,IAAK,MAAM,IAAI,KAAK;AAI1B,cAAM,MAA6C;AAAA,UACjD,iBAAiB;AAAA,UACjB,kBAAkB;AAAA,UAClB,oBAAoB;AAAA,UACpB,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,UAAU;AAAA,QACZ;AACA,cAAM,QAAQ,IAAI,EAAE,UAAU,iBAAiB,KAAK;AAIpD,cAAM,kBAAkB,EAAE,WAAW,sBAAsB,EAAE,WAAW,gBAAgB,EAAE,WAAW;AACrG,cAAM,SAAS,SAAS,EAAE,aAAa,2BAA2B,CAAC,CAAC;AACpE,eAAO,EAAC,OAAO,iBAAiB,GAAI,SAAS,EAAC,YAAY,OAAM,IAAI,CAAC,EAAE;AAAA,MACzE,QAAQ;AACN,eAAO,EAAC,OAAO,UAAS;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  nearIntentsProvider
3
- } from "./chunk-ZCU6YSV4.js";
3
+ } from "./chunk-4GRRM3WT.js";
4
4
  import {
5
5
  nearIntents
6
6
  } from "./chunk-DIFUONLL.js";
@@ -24,4 +24,4 @@ var NearIntentsSwap2Protocol = class extends SingleProviderSwap2 {
24
24
  export {
25
25
  NearIntentsSwap2Protocol
26
26
  };
27
- //# sourceMappingURL=chunk-BXDRS5SZ.js.map
27
+ //# sourceMappingURL=chunk-GE5KDZVH.js.map
package/dist/index.cjs CHANGED
@@ -172,6 +172,25 @@ function txHashOf(entry) {
172
172
  const h = entry.hash;
173
173
  return typeof h === "string" ? h : null;
174
174
  }
175
+ function unitsText(units, decimals) {
176
+ const digits = units.replace(/^0+(?=\d)/, "").padStart(decimals + 1, "0");
177
+ const whole = digits.slice(0, digits.length - decimals);
178
+ const frac = digits.slice(digits.length - decimals).replace(/0+$/, "");
179
+ return frac ? `${whole}.${frac}` : whole;
180
+ }
181
+ function minimumRefusal(message, origin) {
182
+ const usd = /minimum swap amount is \$([\d,.]+)/i.exec(message)?.[1]?.replace(/[.,]+$/, "");
183
+ if (usd && /\d/.test(usd)) return `near_intents: below the 1Click minimum ($${usd})`;
184
+ const units = /amount is too low for bridge, try at least (\d{1,78})\b/i.exec(message)?.[1];
185
+ if (units) return `near_intents: below the 1Click minimum (at least ${unitsText(units, origin.decimals)} ${origin.symbol})`;
186
+ return null;
187
+ }
188
+ var NEAR_ACCOUNT_ID = /^(?=.{2,64}$)(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/;
189
+ var INTENTS_TOKEN_ID = /^nep(141|245):\S+$/;
190
+ function intentsAccountId(id) {
191
+ if (!NEAR_ACCOUNT_ID.test(id)) return false;
192
+ return id.includes(".") || /^[0-9a-f]{64}$/.test(id) || /^0x[0-9a-f]{40}$/.test(id);
193
+ }
175
194
  function nearIntentsProvider(config = {}) {
176
195
  config = Object.freeze({ ...config });
177
196
  const parsedApiUrl = new URL(config.apiUrl ?? ONE_CLICK_DEFAULT);
@@ -179,6 +198,16 @@ function nearIntentsProvider(config = {}) {
179
198
  throw new Error("near-intents: apiUrl must use http or https");
180
199
  }
181
200
  const apiBase = parsedApiUrl.toString().replace(/\/$/, "");
201
+ const recipientType = config.recipientType ?? "DESTINATION_CHAIN";
202
+ if (recipientType !== "DESTINATION_CHAIN" && recipientType !== "INTENTS" && recipientType !== "CONFIDENTIAL_INTENTS") {
203
+ throw new Error("near-intents: recipientType must be DESTINATION_CHAIN, INTENTS or CONFIDENTIAL_INTENTS");
204
+ }
205
+ if (recipientType === "CONFIDENTIAL_INTENTS" && !config.jwt) {
206
+ throw new Error("near-intents: CONFIDENTIAL_INTENTS delivery is partner-only and needs a 1Click jwt");
207
+ }
208
+ const intents = recipientType !== "DESTINATION_CHAIN";
209
+ const intentsDestOk = (destChain) => !intents || (0, import_util2.namespace)(destChain) === "near";
210
+ const destinationAsset = (destChain, destToken) => intents && INTENTS_TOKEN_ID.test(destToken) ? destToken : destAssetId(destChain, destToken);
182
211
  const hasRecipient = config.feeRecipient !== void 0;
183
212
  const hasBps = config.feeBps !== void 0;
184
213
  if (hasRecipient !== hasBps) throw new Error("near-intents: feeRecipient and feeBps must be configured together");
@@ -192,25 +221,30 @@ function nearIntentsProvider(config = {}) {
192
221
  // Capability discovery comes from the provider itself, so it can run alone
193
222
  // or inside the optional aggregator without a central capability table.
194
223
  supportsChain: (chain) => nearIntents.supportsChain(chain),
195
- supportsChainPair: (fromChain, toChain) => nearIntents.supports(fromChain, toChain),
224
+ supportsChainPair: (fromChain, toChain) => nearIntents.supports(fromChain, toChain) && intentsDestOk(toChain),
196
225
  supportsRoute(from, to) {
197
- if (!nearIntents.supports(from.chain, to.chain)) return false;
226
+ if (!nearIntents.supports(from.chain, to.chain) || !intentsDestOk(to.chain)) return false;
198
227
  const asset = (0, import_swap2_assets2.ccAsset)(from.chain, from.token);
199
- return !!(0, import_swap2_assets2.ccChain)(from.chain) && !!asset?.assetId && !!destAssetId(to.chain, to.token);
228
+ return !!(0, import_swap2_assets2.ccChain)(from.chain) && !!asset?.assetId && !!destinationAsset(to.chain, to.token);
200
229
  },
201
230
  async getQuote(params, signal) {
202
- const refuse = (reason) => {
231
+ const refuse = (reason, shown) => {
203
232
  const detail = `${reason} [dry=${params.dry !== false} ${params.sourceChain}->${params.destChain} amount=${params.amountIn}]`;
204
233
  console.warn(`near-intents: no quote \u2014 ${detail.replace(/[\u0000-\u001f\u007f]/g, " ")}`);
205
- params.onRefusal?.(detail);
234
+ params.onRefusal?.(shown ?? detail);
206
235
  return null;
207
236
  };
208
237
  const paused = config.suspendedChains ?? {};
209
- const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused) ?? nearIntentsChainRefusal(params.destChain, paused);
238
+ const rawIntentsDest = intents && INTENTS_TOKEN_ID.test(params.destToken);
239
+ const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused) ?? (rawIntentsDest ? null : nearIntentsChainRefusal(params.destChain, paused));
210
240
  if (chainRefusal) return refuse(chainRefusal);
241
+ if (!intentsDestOk(params.destChain)) return refuse(`${recipientType} credits intents.near: destChain must be a NEAR chain, not ${params.destChain}`);
242
+ if (intents && !intentsAccountId(params.destAddress)) {
243
+ return refuse(`${recipientType} recipient must be a NEAR Intents account id`);
244
+ }
211
245
  const origin = (0, import_swap2_assets2.ccAsset)(params.sourceChain, params.sourceToken);
212
246
  if (!origin?.assetId) return refuse(`1Click does not list ${params.sourceChain} ${params.sourceToken}`);
213
- const destination = destAssetId(params.destChain, params.destToken);
247
+ const destination = destinationAsset(params.destChain, params.destToken);
214
248
  if (!destination) return refuse(`1Click does not list ${params.destChain} ${params.destToken}`);
215
249
  const dry = params.dry !== false;
216
250
  const refund = params.refundAddress ?? (dry ? placeholderFor(params.sourceChain) : "");
@@ -230,7 +264,7 @@ function nearIntentsProvider(config = {}) {
230
264
  refundTo: dcfg.refundTo,
231
265
  refundType: dcfg.refundType,
232
266
  recipient: params.destAddress,
233
- recipientType: "DESTINATION_CHAIN",
267
+ recipientType,
234
268
  deadline: requestedDeadline
235
269
  };
236
270
  const fees = appFees(config.feeRecipient, config.feeBps);
@@ -256,7 +290,11 @@ function nearIntentsProvider(config = {}) {
256
290
  if (!flaky || attempt >= 2 || signal?.aborted) break;
257
291
  await new Promise((resolve) => setTimeout(resolve, 500 * (attempt + 1)));
258
292
  }
259
- if (!res?.ok) return refuse(`1Click ${res?.status ?? "network error"}: ${String(data.message ?? "").slice(0, 200)}`);
293
+ if (!res?.ok) {
294
+ const message = String(data.message ?? "").slice(0, 200);
295
+ const below = res?.status === 400 ? minimumRefusal(message, origin) : null;
296
+ return refuse(`1Click ${res?.status ?? "network error"}: ${message}`, below ?? void 0);
297
+ }
260
298
  const q = data.quote ?? {};
261
299
  const depositAddress = typeof q.depositAddress === "string" ? q.depositAddress : "";
262
300
  if (!dry && !depositAddress) return refuse("live quote came back without a deposit address");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/activity.ts","../src/provider.ts","../src/protocol.ts"],"sourcesContent":["export * from \"./config.js\";\nexport * from \"./provider.js\";\nexport {NearIntentsSwap2Protocol} from \"./protocol.js\";\nexport {NearIntentsSwap2Protocol as default} from \"./protocol.js\";\nexport * from \"./activity.js\";\nexport type { NearIntentsSwap2Config } from \"./protocol.js\"\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {namespace} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {ccChain} from \"@anywalletkit/swap2-assets\";\n\n// ── NEAR Intents (1Click) — core, broadest coverage ─────────────────────────\nconst NEAR_INTENTS_NS = new Set([\n \"eip155\", \"solana\", \"tron\", \"bitcoin\", \"near\", \"sui\", \"ton\", \"zcash\",\n \"litecoin\", \"doge\", \"xrp\", \"bch\", \"cardano\", \"stellar\", \"aptos\",\n]);\n\n/**\n * Corridors the APP has paused (caip2 → why), passed in through the provider\n * config: a venue-side degradation (1Click's HOT omni-bridge assets answering\n * \"not available\" for days) is an operational switch, not SDK knowledge — the\n * wallet flips an env var and lifts it the same way when the venue recovers.\n */\nexport type NearIntentsSuspendedChains = Readonly<Record<string, string>>;\n\n/** Why a chain is refused up front, or null when 1Click can serve it. */\nexport function nearIntentsChainRefusal(chain: string, suspended: NearIntentsSuspendedChains = {}): string | null {\n if (!NEAR_INTENTS_NS.has(namespace(chain))) return `1Click does not serve ${chain}`;\n const why = suspended[chain];\n if (why) return `1Click corridor paused by the app: ${chain} — ${why}`;\n // A chain the catalog knows but carries no 1Click asset id for (World Chain,\n // Sei, Ink, Plume, X Layer, Unichain, MegaETH, Linea, Sonic, …) is LI.FI /\n // CCTP territory: the eip155 namespace alone used to claim it, and every\n // quote then died as \"unknown asset\" (2026-10-16 funded run).\n const listed = ccChain(chain)?.assets.some((a) => a.assetId.length > 0) ?? false;\n return listed ? null : `1Click does not list ${chain}`;\n}\n\nexport const nearIntents = {\n enabled: () => true,\n // Routes between any pair of 1Click-listed chains. 1Click is a NEAR-intents\n // solver network — it settles non-EVM↔non-EVM directly (BTC→Solana, Tron→\n // Base …), so this pre-filter must NOT require an EVM leg (the old \"vault\n // leg is always EVM\" assumption of the off-ramp flow silently blocked those\n // swap routes). A chain counts as listed when the shared catalog carries at\n // least one 1Click asset id for it and it is not suspended above; `getQuote`\n // is the real per-pair check and fail-closes (returns null, naming why) for\n // any pair 1Click can't actually route.\n // 2026-08 sweep: 1Click added LTC/DOGE/XRP/BCH/ADA/XLM/APT (+ the EVM\n // additions Avalanche/Scroll/Berachain, covered by the catalog ids).\n supportsChain(chain: string): boolean {\n return nearIntentsChainRefusal(chain) === null;\n },\n supports(from: string, to: string): boolean {\n return this.supportsChain(from) && this.supportsChain(to);\n },\n};\n\n/**\n * The app's side of a remote NEAR Intents stub: `remoteProvider({name: \"near_intents\", baseUrl, ...nearIntentsPins})`.\n * Every 1Click route is a send to a deposit address minted per quote, so nothing can be pinned ahead: the stub calls\n * no contract and approves no spender, and is opened to deposit-address routes (scan 2026-10-28, F9). The deposit\n * address is your backend's word — run the backend you trust.\n */\nexport const nearIntentsPins: RemotePins = Object.freeze({\n callTargets: (): readonly string[] => [],\n spenders: (): readonly string[] => [],\n depositAddressRoutes: true,\n});\n","/**\n * Activity recognition for NEAR Intents (1Click).\n *\n * The source leg on EVM / TON / Solana / Tron / BTC is a plain transfer to a\n * one-time 1Click deposit address, and the destination leg is a plain transfer\n * from a solver / bridge account that changes per swap — neither carries a\n * stable on-chain marker, so they are NOT recognizable offline. The kit's\n * intent journal (the `intentId` returned by `swap2()`) ties those legs back to\n * the swap; this hook only answers for the legs that do have a fixed\n * counterparty: on NEAR itself, deposits into and withdrawals out of the\n * `intents.near` verifier contract (NEP-141 `ft_transfer_call` / `ft_withdraw`).\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {describeSwapLike} from \"@anywalletkit/protocol-swap2-core/activity\";\n\nexport const NEAR_INTENTS_MODULE = \"@anywalletkit/protocol-swap2-near-intents\";\n\n/** The NEAR Intents verifier / settlement contract. */\nexport const NEAR_INTENTS_CONTRACT = \"intents.near\";\n\nexport function describeNearIntentsActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n if (!tx.chain.startsWith(\"near:\")) return null;\n const isOwn = (a: string) => ctx.own.has(a);\n const touches = tx.transfers.some((t) => (t.from === NEAR_INTENTS_CONTRACT && isOwn(t.to)) || (t.to === NEAR_INTENTS_CONTRACT && isOwn(t.from)));\n if (!touches) return null;\n return describeSwapLike(tx, ctx, {\n protocol: NEAR_INTENTS_MODULE,\n subtitle: \"NEAR Intents\",\n kind: \"bridge\",\n counterparty: NEAR_INTENTS_CONTRACT,\n inSuffix: \"via NEAR Intents\",\n });\n}\n","import {nearIntents as cfg, nearIntentsChainRefusal, type NearIntentsSuspendedChains} from \"./config.js\";\nimport {describeNearIntentsActivity} from \"./activity.js\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {CC_DEST, ccAsset, ccAssetByToken, ccChain} from \"@anywalletkit/swap2-assets\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * NEAR Intents (1Click) provider — the core route, broadest coverage. Ported\n * from a production 1Click integration:\n * dry quote → pricing preview; live quote → depositAddress the user funds\n * from any wallet; status polled by depositAddress.\n * Runs server-side, so the partner JWT stays here (no proxy needed). Defensive:\n * any API error yields a null quote so the provider drops out of that round.\n */\n\nconst ONE_CLICK_DEFAULT = \"https://1click.chaindefuser.com/v0\";\nconst QUOTE_TTL_MS = 55_000;\n\n/** intentId durably carries both status lookup keys (memo is quote-specific). */\nconst INTENT_PREFIX = \"near1click:\";\n\nfunction encodeIntent(depositAddress: string, depositMemo: string | null): string {\n return `${INTENT_PREFIX}${encodeURIComponent(depositAddress)}|${encodeURIComponent(depositMemo ?? \"\")}`;\n}\n\nfunction decodeIntent(intentId: string): {depositAddress: string; depositMemo?: string} {\n try {\n if (!intentId.startsWith(INTENT_PREFIX)) throw new Error(\"unsupported id version\");\n const raw = intentId.slice(INTENT_PREFIX.length);\n const parts = raw.split(\"|\");\n if (parts.length !== 2 || !parts[0]) throw new Error(\"invalid id shape\");\n const depositAddress = decodeURIComponent(parts[0]);\n const memo = decodeURIComponent(parts[1] ?? \"\");\n if (!depositAddress) throw new Error(\"empty deposit address\");\n return {depositAddress, ...(memo ? {depositMemo: memo} : {})};\n } catch {\n throw new Error(\"near-intents: malformed intent id\");\n }\n}\n\nfunction authHeaders(jwtOverride?: string): Record<string, string> {\n const h: Record<string, string> = {\"content-type\": \"application/json\", accept: \"application/json\"};\n const jwt = jwtOverride;\n if (jwt) h.authorization = `Bearer ${jwt}`;\n return h;\n}\n\n/** Our integrator fee, injected server-side when a recipient is configured. */\nfunction appFees(recipient?: string, bps?: number): {recipient: string; fee: number}[] | undefined {\n return recipient !== undefined && bps !== undefined ? [{recipient, fee: bps}] : undefined;\n}\n\n/**\n * Per-source deposit + refund config. Every live default keeps failed-swap\n * ownership on the caller's source-chain address.\n */\nfunction depositConfig(_sourceChain: string, refundAddress: string, _dry: boolean) {\n // Every source refunds to the caller's own source-chain address (Zcash\n // included — a t-address placeholder serves dry quotes since 2026-10-18).\n // Never redirect failed swaps to an integrator-owned NEAR account.\n return {depositType: \"ORIGIN_CHAIN\", refundType: \"ORIGIN_CHAIN\", refundTo: refundAddress};\n}\n\n/** Placeholder sender/recipient for dry quotes (1Click requires the fields). */\nconst PLACEHOLDER: Record<string, string> = {\n bitcoin: \"bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq\",\n ton: \"UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJKZ\",\n // NOT a token mint: with the USDC mint here, every dry quote whose ORIGIN\n // was Solana USDC answered 500 \"Internal server error\" (2026-10-09) — a\n // refund \"to the asset's own mint\" trips 1Click. The incinerator is a\n // plain, valid system address.\n solana: \"1nc1nerator11111111111111111111111111111111\",\n tron: \"TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9\",\n // NEAR refunds go to an account id; the registrar account always exists.\n near: \"near\",\n // A live transparent address (exchange hot wallet); dry quotes only.\n zcash: \"t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua\",\n eip155: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\",\n};\n\nfunction placeholderFor(chain: string): string {\n return PLACEHOLDER[chain.split(\":\")[0] ?? \"\"] ?? PLACEHOLDER.eip155!;\n}\n\nfunction deadlineIn(minutes: number): string {\n return new Date(Date.now() + minutes * 60_000).toISOString().replace(/\\.\\d{3}Z$/, \"Z\");\n}\n\n/**\n * dest asset id for ANY chain in the catalog (inbound → Ethereum, or the step-2\n * off-ramp → any supported chain). Falls back to the Ethereum omft pattern for\n * a mainnet ERC-20 that isn't in the curated catalog.\n */\nfunction destAssetId(destChain: string, destToken: string): string | null {\n const asset = ccAssetByToken(destChain, destToken);\n if (asset) return asset.assetId;\n if (destChain === CC_DEST.caip2 && /^0x[0-9a-fA-F]{40}$/.test(destToken)) {\n return `nep141:eth-${destToken.toLowerCase()}.omft.near`;\n }\n return null;\n}\n\ntype OneClickQuote = {\n quote?: Record<string, unknown>;\n correlationId?: string;\n error?: string;\n message?: string;\n};\n\n/** 1Click returns tx hashes either as strings or {hash, explorerUrl}. */\nfunction txHashOf(entry: unknown): string | null {\n if (!entry) return null;\n if (typeof entry === \"string\") return entry;\n const h = (entry as {hash?: string}).hash;\n return typeof h === \"string\" ? h : null;\n}\n\n/** Explicit constructor configuration; no deployment environment is read. */\nexport interface NearIntentsProviderConfig {\n enabled?: boolean;\n apiUrl?: string;\n jwt?: string;\n feeRecipient?: string;\n feeBps?: number;\n /** Corridors the app has paused (caip2 → reason): refused up front, by name, until the app lifts them. */\n suspendedChains?: NearIntentsSuspendedChains;\n}\n\nexport function nearIntentsProvider(config: NearIntentsProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const parsedApiUrl = new URL(config.apiUrl ?? ONE_CLICK_DEFAULT);\n if (parsedApiUrl.protocol !== \"https:\" && parsedApiUrl.protocol !== \"http:\") {\n throw new Error(\"near-intents: apiUrl must use http or https\");\n }\n const apiBase = parsedApiUrl.toString().replace(/\\/$/, \"\");\n const hasRecipient = config.feeRecipient !== undefined;\n const hasBps = config.feeBps !== undefined;\n if (hasRecipient !== hasBps) throw new Error(\"near-intents: feeRecipient and feeBps must be configured together\");\n if (hasRecipient && (!config.feeRecipient!.trim() || !Number.isInteger(config.feeBps) || config.feeBps! <= 0 || config.feeBps! > 10_000)) {\n throw new Error(\"near-intents: fee config requires a recipient and feeBps between 1 and 10000\");\n }\n return {\n name: \"near_intents\",\n describeActivity: describeNearIntentsActivity,\n enabled: () => config.enabled ?? true,\n\n // Capability discovery comes from the provider itself, so it can run alone\n // or inside the optional aggregator without a central capability table.\n supportsChain: (chain: string) => cfg.supportsChain(chain),\n supportsChainPair: (fromChain: string, toChain: string) => cfg.supports(fromChain, toChain),\n supportsRoute(from: Asset, to: Asset): boolean {\n // Chain-level gate first (namespace, catalog listing, hand-suspended\n // corridors such as TON while the HOT bridge is dark) …\n if (!cfg.supports(from.chain, to.chain)) return false;\n // … then only pairs present in the curated catalog are offered — and only\n // those with a 1Click asset id (LI.FI-only tokens carry an empty assetId).\n // Both ends: a destination 1Click doesn't list (Unichain, MegaETH, …)\n // answered \"unknown asset\" on every quote (589 of the 2026-10-10 matrix).\n const asset = ccAsset(from.chain, from.token);\n return !!ccChain(from.chain) && !!asset?.assetId && !!destAssetId(to.chain, to.token);\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n // Every refusal below names itself: on the server these lines are the\n // only visibility into WHY a live quote returned null (the wire answer\n // is just `null`), and \"no route\" bugs hide in exactly that silence.\n const refuse = (reason: string): null => {\n const detail = `${reason} [dry=${params.dry !== false} ${params.sourceChain}->${params.destChain} amount=${params.amountIn}]`;\n // Caller fields and 1Click text are untrusted: no control characters in server logs.\n console.warn(`near-intents: no quote — ${detail.replace(/[\\u0000-\\u001f\\u007f]/g, \" \")}`);\n params.onRefusal?.(detail);\n return null;\n };\n // Up-front, named refusals — no wire call for a corridor 1Click cannot\n // serve: a chain outside its list / suspended by hand, or a token the\n // catalog carries without a 1Click asset id (\"1Click does not list …\").\n const paused = config.suspendedChains ?? {};\n const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused) ?? nearIntentsChainRefusal(params.destChain, paused);\n if (chainRefusal) return refuse(chainRefusal);\n const origin = ccAsset(params.sourceChain, params.sourceToken);\n if (!origin?.assetId) return refuse(`1Click does not list ${params.sourceChain} ${params.sourceToken}`);\n const destination = destAssetId(params.destChain, params.destToken);\n if (!destination) return refuse(`1Click does not list ${params.destChain} ${params.destToken}`);\n const dry = params.dry !== false;\n // A live quote derives the deposit address from the refund config —\n // never create one without a real refund destination.\n const refund = params.refundAddress ?? (dry ? placeholderFor(params.sourceChain) : \"\");\n const dcfg = depositConfig(params.sourceChain, refund, dry);\n if (!dry && !dcfg.refundTo) return refuse(\"live quote without a refund address\");\n\n const requestedDeadline = deadlineIn(60);\n const body: Record<string, unknown> = {\n dry,\n // FLEX_INPUT (exchange flow): the address accepts any amount; amountIn\n // is just the pricing notional. Verified against the live API.\n swapType: params.flex ? \"FLEX_INPUT\" : \"EXACT_INPUT\",\n slippageTolerance: params.slippageBps ?? 100,\n originAsset: origin.assetId,\n depositType: dcfg.depositType,\n destinationAsset: destination,\n amount: params.amountIn,\n refundTo: dcfg.refundTo,\n refundType: dcfg.refundType,\n recipient: params.destAddress,\n recipientType: \"DESTINATION_CHAIN\",\n deadline: requestedDeadline,\n };\n const fees = appFees(config.feeRecipient, config.feeBps);\n if (fees) body.appFees = fees;\n\n try {\n // 1Click's solver auction flaps: the same body can answer 400 \"No\n // liquidity available\" and 201 seconds apart (observed live on\n // TON USDT -> ETH). A transient flap on the EXECUTION quote would\n // surface as a terminal \"no route\" right after a successful display\n // quote, so ride through it: up to two retries on liquidity flaps,\n // 5xx and network errors. Real rejections (bad address, unknown\n // asset) still fail on the first answer.\n let res: Response | null = null;\n let data: OneClickQuote = {};\n for (let attempt = 0; ; attempt++) {\n try {\n res = await fetch(`${apiBase}/quote`, {\n method: \"POST\",\n headers: authHeaders(config.jwt),\n body: JSON.stringify(body),\n signal: signal ?? timeoutSignal(12_000),\n });\n data = (await res.json().catch(() => ({}))) as OneClickQuote;\n } catch (err) {\n if (attempt >= 2 || signal?.aborted) throw err;\n res = null;\n }\n if (res?.ok) break;\n const flaky =\n res === null ||\n res.status >= 500 ||\n (res.status === 400 && /no liquidity/i.test(String(data.message ?? \"\")));\n if (!flaky || attempt >= 2 || signal?.aborted) break;\n await new Promise((resolve) => setTimeout(resolve, 500 * (attempt + 1)));\n }\n if (!res?.ok) return refuse(`1Click ${res?.status ?? \"network error\"}: ${String(data.message ?? \"\").slice(0, 200)}`);\n const q = (data.quote ?? {}) as Record<string, unknown>;\n\n const depositAddress = typeof q.depositAddress === \"string\" ? q.depositAddress : \"\";\n if (!dry && !depositAddress) return refuse(\"live quote came back without a deposit address\");\n const inUsd = Number.parseFloat(String(q.amountInUsd ?? \"0\"));\n const outUsd = Number.parseFloat(String(q.amountOutUsd ?? \"0\"));\n const parsedDeadline = Date.parse(String(q.deadline ?? \"\"));\n if (!dry && (!Number.isFinite(parsedDeadline) || parsedDeadline <= Date.now())) return refuse(`unusable deadline ${String(q.deadline)}`);\n const deadline = Number.isFinite(parsedDeadline) && parsedDeadline > Date.now()\n ? Math.min(parsedDeadline, Date.now() + QUOTE_TTL_MS)\n : Date.now() + QUOTE_TTL_MS;\n\n if (q.amountIn !== undefined && String(q.amountIn) !== params.amountIn) return refuse(`amountIn mismatch (${String(q.amountIn)} vs ${params.amountIn})`);\n\n // amountOut is optimistic, not a guaranteed floor. Live execution must\n // not fabricate a minimum when the provider omits it.\n if (q.minAmountOut === undefined || q.minAmountOut === null) return refuse(\"quote has no minAmountOut\");\n const minDestAmount = String(q.minAmountOut);\n if (params.minAmountOut !== undefined && BigInt(minDestAmount) < BigInt(params.minAmountOut)) return refuse(`floor breach (min=${minDestAmount} < floor=${params.minAmountOut})`);\n const depositMemo =\n (typeof q.depositMemo === \"string\" && q.depositMemo) ||\n (typeof q.memo === \"string\" && q.memo) ||\n null;\n return {\n provider: \"near_intents\",\n intentId: depositAddress ? encodeIntent(depositAddress, depositMemo) : `dry:${crypto.randomUUID()}`,\n depositAddress,\n depositMemo,\n sourceAmount: params.amountIn,\n destAmount: String(q.amountOut ?? \"0\"),\n minDestAmount,\n feeUsd: Math.max(0, inUsd - outUsd),\n etaSeconds: Number(q.timeEstimate ?? 60),\n reliability: 0.95,\n validUntilMs: deadline,\n };\n } catch (err) {\n return refuse(`threw: ${err instanceof Error ? err.message.slice(0, 200) : String(err).slice(0, 200)}`);\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n return {\n chain: \"\",\n to: quote.depositAddress,\n value: quote.sourceAmount,\n ...(quote.depositMemo ? {memo: quote.depositMemo} : {}),\n };\n },\n\n async notifyDeposit(intentId: string, txHash: string): Promise<void> {\n const {depositAddress} = decodeIntent(intentId);\n const res = await fetch(`${apiBase}/deposit/submit`, {\n method: \"POST\",\n headers: authHeaders(config.jwt),\n body: JSON.stringify({depositAddress, txHash}),\n signal: timeoutSignal(12_000),\n });\n if (!res.ok) throw new Error(`near-intents: deposit notification failed (${res.status})`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const {depositAddress, depositMemo} = decodeIntent(ref.intentId);\n // Durable retry: BaseSwap2Protocol embeds the source hash in the swap2\n // id. If the post-broadcast notify failed, every status poll retries it.\n if (ref.sourceTxHash) {\n await this.notifyDeposit?.(ref.intentId, ref.sourceTxHash).catch(() => {});\n }\n try {\n const query = new URLSearchParams({depositAddress});\n if (depositMemo) query.set(\"depositMemo\", depositMemo);\n const res = await fetch(\n `${apiBase}/status?${query.toString()}`,\n {headers: authHeaders(config.jwt), signal: timeoutSignal(12_000)},\n );\n if (!res.ok) return {state: \"pending\"};\n const s = (await res.json()) as {\n status?: string;\n swapDetails?: {destinationChainTxHashes?: unknown[]};\n };\n const map: Record<string, IntentStatus[\"state\"]> = {\n PENDING_DEPOSIT: \"pending\",\n KNOWN_DEPOSIT_TX: \"pending\",\n INCOMPLETE_DEPOSIT: \"pending\",\n PROCESSING: \"pending\",\n SUCCESS: \"completed\",\n FAILED: \"failed\",\n REFUNDED: \"refunded\",\n };\n const state = map[s.status ?? \"PENDING_DEPOSIT\"] ?? \"pending\";\n // KNOWN_DEPOSIT_TX: 1Click has the deposit tx (submitted, not yet\n // credited). Counted as received so a caller with no source hash of\n // its own does not expire a swap that is already on its way.\n const depositReceived = s.status === \"KNOWN_DEPOSIT_TX\" || s.status === \"PROCESSING\" || s.status === \"INCOMPLETE_DEPOSIT\";\n const destTx = txHashOf(s.swapDetails?.destinationChainTxHashes?.[0]);\n return {state, depositReceived, ...(destTx ? {destTxHash: destTx} : {})};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n","import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {nearIntents as nearIntentsCfg} from \"./config.js\";\nimport {nearIntentsProvider, type NearIntentsProviderConfig} from \"./provider.js\";\n\nexport interface NearIntentsSwap2Config extends Swap2EngineConfig, NearIntentsProviderConfig {}\n\nexport class NearIntentsSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: NearIntentsSwap2Config) {\n super(account, config);\n this.provider = nearIntentsProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return nearIntentsCfg.supports(caip2, \"eip155:1\") || nearIntentsCfg.supports(\"eip155:1\", caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n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AA,QACZ;AACA,cAAM,QAAQ,IAAI,EAAE,UAAU,iBAAiB,KAAK;AAIpD,cAAM,kBAAkB,EAAE,WAAW,sBAAsB,EAAE,WAAW,gBAAgB,EAAE,WAAW;AACrG,cAAM,SAAS,SAAS,EAAE,aAAa,2BAA2B,CAAC,CAAC;AACpE,eAAO,EAAC,OAAO,iBAAiB,GAAI,SAAS,EAAC,YAAY,OAAM,IAAI,CAAC,EAAE;AAAA,MACzE,QAAQ;AACN,eAAO,EAAC,OAAO,UAAS;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACF;;;ACvVA,oBAAkC;AAO3B,IAAM,2BAAN,cAAuC,kCAAoB;AAAA,EAC7C;AAAA,EACnB,YAAY,SAAmC,QAAgC;AAC7E,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,oBAAoB,MAAM;AAAA,EAC5C;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,YAAe,SAAS,OAAO,UAAU,KAAK,YAAe,SAAS,YAAY,KAAK;AAAA,EAChG;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,YAAe,SAAS,WAAW,OAAO;AAAA,EACnD;AACF;","names":["import_util","import_swap2_assets"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/activity.ts","../src/provider.ts","../src/protocol.ts"],"sourcesContent":["export * from \"./config.js\";\nexport * from \"./provider.js\";\nexport {NearIntentsSwap2Protocol} from \"./protocol.js\";\nexport {NearIntentsSwap2Protocol as default} from \"./protocol.js\";\nexport * from \"./activity.js\";\nexport type { NearIntentsSwap2Config } from \"./protocol.js\"\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {namespace} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {ccChain} from \"@anywalletkit/swap2-assets\";\n\n// ── NEAR Intents (1Click) — core, broadest coverage ─────────────────────────\nconst NEAR_INTENTS_NS = new Set([\n \"eip155\", \"solana\", \"tron\", \"bitcoin\", \"near\", \"sui\", \"ton\", \"zcash\",\n \"litecoin\", \"doge\", \"xrp\", \"bch\", \"cardano\", \"stellar\", \"aptos\",\n]);\n\n/**\n * Corridors the APP has paused (caip2 → why), passed in through the provider\n * config: a venue-side degradation (1Click's HOT omni-bridge assets answering\n * \"not available\" for days) is an operational switch, not SDK knowledge — the\n * wallet flips an env var and lifts it the same way when the venue recovers.\n */\nexport type NearIntentsSuspendedChains = Readonly<Record<string, string>>;\n\n/** Why a chain is refused up front, or null when 1Click can serve it. */\nexport function nearIntentsChainRefusal(chain: string, suspended: NearIntentsSuspendedChains = {}): string | null {\n if (!NEAR_INTENTS_NS.has(namespace(chain))) return `1Click does not serve ${chain}`;\n const why = suspended[chain];\n if (why) return `1Click corridor paused by the app: ${chain} — ${why}`;\n // A chain the catalog knows but carries no 1Click asset id for (World Chain,\n // Sei, Ink, Plume, X Layer, Unichain, MegaETH, Linea, Sonic, …) is LI.FI /\n // CCTP territory: the eip155 namespace alone used to claim it, and every\n // quote then died as \"unknown asset\" (2026-10-16 funded run).\n const listed = ccChain(chain)?.assets.some((a) => a.assetId.length > 0) ?? false;\n return listed ? null : `1Click does not list ${chain}`;\n}\n\nexport const nearIntents = {\n enabled: () => true,\n // Routes between any pair of 1Click-listed chains. 1Click is a NEAR-intents\n // solver network — it settles non-EVM↔non-EVM directly (BTC→Solana, Tron→\n // Base …), so this pre-filter must NOT require an EVM leg (the old \"vault\n // leg is always EVM\" assumption of the off-ramp flow silently blocked those\n // swap routes). A chain counts as listed when the shared catalog carries at\n // least one 1Click asset id for it and it is not suspended above; `getQuote`\n // is the real per-pair check and fail-closes (returns null, naming why) for\n // any pair 1Click can't actually route.\n // 2026-08 sweep: 1Click added LTC/DOGE/XRP/BCH/ADA/XLM/APT (+ the EVM\n // additions Avalanche/Scroll/Berachain, covered by the catalog ids).\n supportsChain(chain: string): boolean {\n return nearIntentsChainRefusal(chain) === null;\n },\n supports(from: string, to: string): boolean {\n return this.supportsChain(from) && this.supportsChain(to);\n },\n};\n\n/**\n * The app's side of a remote NEAR Intents stub: `remoteProvider({name: \"near_intents\", baseUrl, ...nearIntentsPins})`.\n * Every 1Click route is a send to a deposit address minted per quote, so nothing can be pinned ahead: the stub calls\n * no contract and approves no spender, and is opened to deposit-address routes (scan 2026-10-28, F9). The deposit\n * address is your backend's word — run the backend you trust.\n */\nexport const nearIntentsPins: RemotePins = Object.freeze({\n callTargets: (): readonly string[] => [],\n spenders: (): readonly string[] => [],\n depositAddressRoutes: true,\n});\n","/**\n * Activity recognition for NEAR Intents (1Click).\n *\n * The source leg on EVM / TON / Solana / Tron / BTC is a plain transfer to a\n * one-time 1Click deposit address, and the destination leg is a plain transfer\n * from a solver / bridge account that changes per swap — neither carries a\n * stable on-chain marker, so they are NOT recognizable offline. The kit's\n * intent journal (the `intentId` returned by `swap2()`) ties those legs back to\n * the swap; this hook only answers for the legs that do have a fixed\n * counterparty: on NEAR itself, deposits into and withdrawals out of the\n * `intents.near` verifier contract (NEP-141 `ft_transfer_call` / `ft_withdraw`).\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {describeSwapLike} from \"@anywalletkit/protocol-swap2-core/activity\";\n\nexport const NEAR_INTENTS_MODULE = \"@anywalletkit/protocol-swap2-near-intents\";\n\n/** The NEAR Intents verifier / settlement contract. */\nexport const NEAR_INTENTS_CONTRACT = \"intents.near\";\n\nexport function describeNearIntentsActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n if (!tx.chain.startsWith(\"near:\")) return null;\n const isOwn = (a: string) => ctx.own.has(a);\n const touches = tx.transfers.some((t) => (t.from === NEAR_INTENTS_CONTRACT && isOwn(t.to)) || (t.to === NEAR_INTENTS_CONTRACT && isOwn(t.from)));\n if (!touches) return null;\n return describeSwapLike(tx, ctx, {\n protocol: NEAR_INTENTS_MODULE,\n subtitle: \"NEAR Intents\",\n kind: \"bridge\",\n counterparty: NEAR_INTENTS_CONTRACT,\n inSuffix: \"via NEAR Intents\",\n });\n}\n","import {nearIntents as cfg, nearIntentsChainRefusal, type NearIntentsSuspendedChains} from \"./config.js\";\nimport {describeNearIntentsActivity} from \"./activity.js\";\nimport {namespace, timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {CC_DEST, ccAsset, ccAssetByToken, ccChain} from \"@anywalletkit/swap2-assets\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * NEAR Intents (1Click) provider — the core route, broadest coverage:\n * dry quote → pricing preview; live quote → depositAddress the user funds\n * from any wallet; status polled by depositAddress.\n * Runs server-side, so the partner JWT stays here (no proxy needed). Defensive:\n * any API error yields a null quote so the provider drops out of that round.\n */\n\nconst ONE_CLICK_DEFAULT = \"https://1click.chaindefuser.com/v0\";\nconst QUOTE_TTL_MS = 55_000;\n\n/** intentId durably carries both status lookup keys (memo is quote-specific). */\nconst INTENT_PREFIX = \"near1click:\";\n\nfunction encodeIntent(depositAddress: string, depositMemo: string | null): string {\n return `${INTENT_PREFIX}${encodeURIComponent(depositAddress)}|${encodeURIComponent(depositMemo ?? \"\")}`;\n}\n\nfunction decodeIntent(intentId: string): {depositAddress: string; depositMemo?: string} {\n try {\n if (!intentId.startsWith(INTENT_PREFIX)) throw new Error(\"unsupported id version\");\n const raw = intentId.slice(INTENT_PREFIX.length);\n const parts = raw.split(\"|\");\n if (parts.length !== 2 || !parts[0]) throw new Error(\"invalid id shape\");\n const depositAddress = decodeURIComponent(parts[0]);\n const memo = decodeURIComponent(parts[1] ?? \"\");\n if (!depositAddress) throw new Error(\"empty deposit address\");\n return {depositAddress, ...(memo ? {depositMemo: memo} : {})};\n } catch {\n throw new Error(\"near-intents: malformed intent id\");\n }\n}\n\nfunction authHeaders(jwtOverride?: string): Record<string, string> {\n const h: Record<string, string> = {\"content-type\": \"application/json\", accept: \"application/json\"};\n const jwt = jwtOverride;\n if (jwt) h.authorization = `Bearer ${jwt}`;\n return h;\n}\n\n/** Our integrator fee, injected server-side when a recipient is configured. */\nfunction appFees(recipient?: string, bps?: number): {recipient: string; fee: number}[] | undefined {\n return recipient !== undefined && bps !== undefined ? [{recipient, fee: bps}] : undefined;\n}\n\n/**\n * Per-source deposit + refund config. Every live default keeps failed-swap\n * ownership on the caller's source-chain address.\n */\nfunction depositConfig(_sourceChain: string, refundAddress: string, _dry: boolean) {\n // Every source refunds to the caller's own source-chain address (Zcash\n // included — a t-address placeholder serves dry quotes since 2026-10-18).\n // Never redirect failed swaps to an integrator-owned NEAR account.\n return {depositType: \"ORIGIN_CHAIN\", refundType: \"ORIGIN_CHAIN\", refundTo: refundAddress};\n}\n\n/** Placeholder sender/recipient for dry quotes (1Click requires the fields). */\nconst PLACEHOLDER: Record<string, string> = {\n bitcoin: \"bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq\",\n ton: \"UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJKZ\",\n // NOT a token mint: with the USDC mint here, every dry quote whose ORIGIN\n // was Solana USDC answered 500 \"Internal server error\" (2026-10-09) — a\n // refund \"to the asset's own mint\" trips 1Click. The incinerator is a\n // plain, valid system address.\n solana: \"1nc1nerator11111111111111111111111111111111\",\n tron: \"TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9\",\n // NEAR refunds go to an account id; the registrar account always exists.\n near: \"near\",\n // A live transparent address (exchange hot wallet); dry quotes only.\n zcash: \"t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua\",\n eip155: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\",\n};\n\nfunction placeholderFor(chain: string): string {\n return PLACEHOLDER[chain.split(\":\")[0] ?? \"\"] ?? PLACEHOLDER.eip155!;\n}\n\nfunction deadlineIn(minutes: number): string {\n return new Date(Date.now() + minutes * 60_000).toISOString().replace(/\\.\\d{3}Z$/, \"Z\");\n}\n\n/**\n * dest asset id for ANY chain in the catalog (inbound → Ethereum, or the step-2\n * off-ramp → any supported chain). Falls back to the Ethereum omft pattern for\n * a mainnet ERC-20 that isn't in the curated catalog.\n */\nfunction destAssetId(destChain: string, destToken: string): string | null {\n const asset = ccAssetByToken(destChain, destToken);\n if (asset) return asset.assetId;\n if (destChain === CC_DEST.caip2 && /^0x[0-9a-fA-F]{40}$/.test(destToken)) {\n return `nep141:eth-${destToken.toLowerCase()}.omft.near`;\n }\n return null;\n}\n\ntype OneClickQuote = {\n quote?: Record<string, unknown>;\n correlationId?: string;\n error?: string;\n message?: string;\n};\n\n/** 1Click returns tx hashes either as strings or {hash, explorerUrl}. */\nfunction txHashOf(entry: unknown): string | null {\n if (!entry) return null;\n if (typeof entry === \"string\") return entry;\n const h = (entry as {hash?: string}).hash;\n return typeof h === \"string\" ? h : null;\n}\n\n/** `units / 10^decimals` as an exact decimal string (no float on the way, so no Hermes bigint trap). */\nfunction unitsText(units: string, decimals: number): string {\n const digits = units.replace(/^0+(?=\\d)/, \"\").padStart(decimals + 1, \"0\");\n const whole = digits.slice(0, digits.length - decimals);\n const frac = digits.slice(digits.length - decimals).replace(/0+$/, \"\");\n return frac ? `${whole}.${frac}` : whole;\n}\n\n/**\n * 1Click's amount floors, as a stable text an app can show the user. Two wordings, both HTTP 400:\n * - \"Temporary swap limits: minimum swap amount is $1,000\" — the USD floors 1Click announces in its\n * changelog (2026-09-09: $1,000 on BNB Chain and other chains; 2026-09-14: $100 from Tron), seen\n * live 2026-11-04 on Base USDC → BSC USDT and Tron USDT → Base USDC;\n * - \"Amount is too low for bridge, try at least 150000\" — a floor in the ORIGIN asset's base units\n * (live 2026-11-04: Base USDC → Arbitrum answers it below 150000 and quotes at exactly 150000).\n * Only digits are taken from 1Click's text; anything else is not a known floor and returns null.\n */\nfunction minimumRefusal(message: string, origin: {symbol: string; decimals: number}): string | null {\n const usd = /minimum swap amount is \\$([\\d,.]+)/i.exec(message)?.[1]?.replace(/[.,]+$/, \"\");\n if (usd && /\\d/.test(usd)) return `near_intents: below the 1Click minimum ($${usd})`;\n const units = /amount is too low for bridge, try at least (\\d{1,78})\\b/i.exec(message)?.[1];\n if (units) return `near_intents: below the 1Click minimum (at least ${unitsText(units, origin.decimals)} ${origin.symbol})`;\n return null;\n}\n\n/** Explicit constructor configuration; no deployment environment is read. */\nexport interface NearIntentsProviderConfig {\n enabled?: boolean;\n apiUrl?: string;\n jwt?: string;\n feeRecipient?: string;\n feeBps?: number;\n /** Corridors the app has paused (caip2 → reason): refused up front, by name, until the app lifts them. */\n suspendedChains?: NearIntentsSuspendedChains;\n /**\n * Where 1Click credits the output. `DESTINATION_CHAIN` (default) withdraws to\n * `destAddress` on `destChain`. `INTENTS` credits the NEAR Intents account\n * `destAddress` inside intents.near — the account a near.com user holds — with\n * no withdrawal: the asset stays there as the intents token. In this mode\n * `destChain` must be the NEAR chain (`near:mainnet`), and `destToken` may be\n * the intents token id itself (`nep141:…` / `nep245:…`).\n * `CONFIDENTIAL_INTENTS` credits the same account's Confidential Intents\n * balance (where near.com keeps funds); 1Click settles it with a signed\n * transfer intent and serves it to partners only, so it requires `jwt`.\n */\n recipientType?: \"DESTINATION_CHAIN\" | \"INTENTS\" | \"CONFIDENTIAL_INTENTS\";\n}\n\n/** NEAR account id rules (intents.near accounts include implicit hex and 0x ids). */\nconst NEAR_ACCOUNT_ID = /^(?=.{2,64}$)(([a-z\\d]+[-_])*[a-z\\d]+\\.)*([a-z\\d]+[-_])*[a-z\\d]+$/;\nconst INTENTS_TOKEN_ID = /^nep(141|245):\\S+$/;\n\n/**\n * An intents.near account someone can sign for: a named account (`alice.near`), an\n * implicit ed25519 id (64 hex) or an implicit EVM-style id (`0x` + 40 hex). Any other\n * dot-less id passes the NEAR syntax but is a pasted chain address (`bc1q…`, a padded\n * `0x…`), credited to an account no key controls.\n */\nfunction intentsAccountId(id: string): boolean {\n if (!NEAR_ACCOUNT_ID.test(id)) return false;\n return id.includes(\".\") || /^[0-9a-f]{64}$/.test(id) || /^0x[0-9a-f]{40}$/.test(id);\n}\n\nexport function nearIntentsProvider(config: NearIntentsProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const parsedApiUrl = new URL(config.apiUrl ?? ONE_CLICK_DEFAULT);\n if (parsedApiUrl.protocol !== \"https:\" && parsedApiUrl.protocol !== \"http:\") {\n throw new Error(\"near-intents: apiUrl must use http or https\");\n }\n const apiBase = parsedApiUrl.toString().replace(/\\/$/, \"\");\n const recipientType = config.recipientType ?? \"DESTINATION_CHAIN\";\n if (recipientType !== \"DESTINATION_CHAIN\" && recipientType !== \"INTENTS\" && recipientType !== \"CONFIDENTIAL_INTENTS\") {\n throw new Error(\"near-intents: recipientType must be DESTINATION_CHAIN, INTENTS or CONFIDENTIAL_INTENTS\");\n }\n if (recipientType === \"CONFIDENTIAL_INTENTS\" && !config.jwt) {\n throw new Error(\"near-intents: CONFIDENTIAL_INTENTS delivery is partner-only and needs a 1Click jwt\");\n }\n /** Output credited inside NEAR Intents (public or confidential), never withdrawn to a chain. */\n const intents = recipientType !== \"DESTINATION_CHAIN\";\n /**\n * An intents credit lands in the intents.near contract on NEAR, whatever token it is, so\n * only a NEAR destChain names it truthfully: a review of \"USDC on Base to 0x…\" must not\n * be a credit that never reaches Base.\n */\n const intentsDestOk = (destChain: string): boolean => !intents || namespace(destChain) === \"near\";\n /** The 1Click destination asset: an intents token id passes through in INTENTS mode. */\n const destinationAsset = (destChain: string, destToken: string): string | null =>\n intents && INTENTS_TOKEN_ID.test(destToken) ? destToken : destAssetId(destChain, destToken);\n const hasRecipient = config.feeRecipient !== undefined;\n const hasBps = config.feeBps !== undefined;\n if (hasRecipient !== hasBps) throw new Error(\"near-intents: feeRecipient and feeBps must be configured together\");\n if (hasRecipient && (!config.feeRecipient!.trim() || !Number.isInteger(config.feeBps) || config.feeBps! <= 0 || config.feeBps! > 10_000)) {\n throw new Error(\"near-intents: fee config requires a recipient and feeBps between 1 and 10000\");\n }\n return {\n name: \"near_intents\",\n describeActivity: describeNearIntentsActivity,\n enabled: () => config.enabled ?? true,\n\n // Capability discovery comes from the provider itself, so it can run alone\n // or inside the optional aggregator without a central capability table.\n supportsChain: (chain: string) => cfg.supportsChain(chain),\n supportsChainPair: (fromChain: string, toChain: string) => cfg.supports(fromChain, toChain) && intentsDestOk(toChain),\n supportsRoute(from: Asset, to: Asset): boolean {\n // Chain-level gate first (namespace, catalog listing, hand-suspended\n // corridors such as TON while the HOT bridge is dark) …\n if (!cfg.supports(from.chain, to.chain) || !intentsDestOk(to.chain)) return false;\n // … then only pairs present in the curated catalog are offered — and only\n // those with a 1Click asset id (LI.FI-only tokens carry an empty assetId).\n // Both ends: a destination 1Click doesn't list (Unichain, MegaETH, …)\n // answered \"unknown asset\" on every quote (589 of the 2026-10-10 matrix).\n const asset = ccAsset(from.chain, from.token);\n return !!ccChain(from.chain) && !!asset?.assetId && !!destinationAsset(to.chain, to.token);\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n // Every refusal below names itself: on the server these lines are the\n // only visibility into WHY a live quote returned null (the wire answer\n // is just `null`), and \"no route\" bugs hide in exactly that silence.\n // `shown`, when given, is the user-presentable text the caller hands on (a router rejection,\n // the server's {noQuote}); the log line keeps the debug suffix either way.\n const refuse = (reason: string, shown?: string): null => {\n const detail = `${reason} [dry=${params.dry !== false} ${params.sourceChain}->${params.destChain} amount=${params.amountIn}]`;\n // Caller fields and 1Click text are untrusted: no control characters in server logs.\n console.warn(`near-intents: no quote — ${detail.replace(/[\\u0000-\\u001f\\u007f]/g, \" \")}`);\n params.onRefusal?.(shown ?? detail);\n return null;\n };\n // Up-front, named refusals — no wire call for a corridor 1Click cannot\n // serve: a chain outside its list / suspended by hand, or a token the\n // catalog carries without a 1Click asset id (\"1Click does not list …\").\n const paused = config.suspendedChains ?? {};\n // An output credited inside intents.near never touches the destination\n // chain, so only the source corridor can be paused for it.\n const rawIntentsDest = intents && INTENTS_TOKEN_ID.test(params.destToken);\n const chainRefusal = nearIntentsChainRefusal(params.sourceChain, paused)\n ?? (rawIntentsDest ? null : nearIntentsChainRefusal(params.destChain, paused));\n if (chainRefusal) return refuse(chainRefusal);\n if (!intentsDestOk(params.destChain)) return refuse(`${recipientType} credits intents.near: destChain must be a NEAR chain, not ${params.destChain}`);\n if (intents && !intentsAccountId(params.destAddress)) {\n return refuse(`${recipientType} recipient must be a NEAR Intents account id`);\n }\n const origin = ccAsset(params.sourceChain, params.sourceToken);\n if (!origin?.assetId) return refuse(`1Click does not list ${params.sourceChain} ${params.sourceToken}`);\n const destination = destinationAsset(params.destChain, params.destToken);\n if (!destination) return refuse(`1Click does not list ${params.destChain} ${params.destToken}`);\n const dry = params.dry !== false;\n // A live quote derives the deposit address from the refund config —\n // never create one without a real refund destination.\n const refund = params.refundAddress ?? (dry ? placeholderFor(params.sourceChain) : \"\");\n const dcfg = depositConfig(params.sourceChain, refund, dry);\n if (!dry && !dcfg.refundTo) return refuse(\"live quote without a refund address\");\n\n const requestedDeadline = deadlineIn(60);\n const body: Record<string, unknown> = {\n dry,\n // FLEX_INPUT (exchange flow): the address accepts any amount; amountIn\n // is just the pricing notional. Verified against the live API.\n swapType: params.flex ? \"FLEX_INPUT\" : \"EXACT_INPUT\",\n slippageTolerance: params.slippageBps ?? 100,\n originAsset: origin.assetId,\n depositType: dcfg.depositType,\n destinationAsset: destination,\n amount: params.amountIn,\n refundTo: dcfg.refundTo,\n refundType: dcfg.refundType,\n recipient: params.destAddress,\n recipientType,\n deadline: requestedDeadline,\n };\n const fees = appFees(config.feeRecipient, config.feeBps);\n if (fees) body.appFees = fees;\n\n try {\n // 1Click's solver auction flaps: the same body can answer 400 \"No\n // liquidity available\" and 201 seconds apart (observed live on\n // TON USDT -> ETH). A transient flap on the EXECUTION quote would\n // surface as a terminal \"no route\" right after a successful display\n // quote, so ride through it: up to two retries on liquidity flaps,\n // 5xx and network errors. Real rejections (bad address, unknown\n // asset) still fail on the first answer.\n let res: Response | null = null;\n let data: OneClickQuote = {};\n for (let attempt = 0; ; attempt++) {\n try {\n res = await fetch(`${apiBase}/quote`, {\n method: \"POST\",\n headers: authHeaders(config.jwt),\n body: JSON.stringify(body),\n signal: signal ?? timeoutSignal(12_000),\n });\n data = (await res.json().catch(() => ({}))) as OneClickQuote;\n } catch (err) {\n if (attempt >= 2 || signal?.aborted) throw err;\n res = null;\n }\n if (res?.ok) break;\n const flaky =\n res === null ||\n res.status >= 500 ||\n (res.status === 400 && /no liquidity/i.test(String(data.message ?? \"\")));\n if (!flaky || attempt >= 2 || signal?.aborted) break;\n await new Promise((resolve) => setTimeout(resolve, 500 * (attempt + 1)));\n }\n if (!res?.ok) {\n const message = String(data.message ?? \"\").slice(0, 200);\n // A known amount floor goes out as a stable, presentable reason; any other answer keeps the raw text.\n const below = res?.status === 400 ? minimumRefusal(message, origin) : null;\n return refuse(`1Click ${res?.status ?? \"network error\"}: ${message}`, below ?? undefined);\n }\n const q = (data.quote ?? {}) as Record<string, unknown>;\n\n const depositAddress = typeof q.depositAddress === \"string\" ? q.depositAddress : \"\";\n if (!dry && !depositAddress) return refuse(\"live quote came back without a deposit address\");\n const inUsd = Number.parseFloat(String(q.amountInUsd ?? \"0\"));\n const outUsd = Number.parseFloat(String(q.amountOutUsd ?? \"0\"));\n const parsedDeadline = Date.parse(String(q.deadline ?? \"\"));\n if (!dry && (!Number.isFinite(parsedDeadline) || parsedDeadline <= Date.now())) return refuse(`unusable deadline ${String(q.deadline)}`);\n const deadline = Number.isFinite(parsedDeadline) && parsedDeadline > Date.now()\n ? Math.min(parsedDeadline, Date.now() + QUOTE_TTL_MS)\n : Date.now() + QUOTE_TTL_MS;\n\n if (q.amountIn !== undefined && String(q.amountIn) !== params.amountIn) return refuse(`amountIn mismatch (${String(q.amountIn)} vs ${params.amountIn})`);\n\n // amountOut is optimistic, not a guaranteed floor. Live execution must\n // not fabricate a minimum when the provider omits it.\n if (q.minAmountOut === undefined || q.minAmountOut === null) return refuse(\"quote has no minAmountOut\");\n const minDestAmount = String(q.minAmountOut);\n if (params.minAmountOut !== undefined && BigInt(minDestAmount) < BigInt(params.minAmountOut)) return refuse(`floor breach (min=${minDestAmount} < floor=${params.minAmountOut})`);\n const depositMemo =\n (typeof q.depositMemo === \"string\" && q.depositMemo) ||\n (typeof q.memo === \"string\" && q.memo) ||\n null;\n return {\n provider: \"near_intents\",\n intentId: depositAddress ? encodeIntent(depositAddress, depositMemo) : `dry:${crypto.randomUUID()}`,\n depositAddress,\n depositMemo,\n sourceAmount: params.amountIn,\n destAmount: String(q.amountOut ?? \"0\"),\n minDestAmount,\n feeUsd: Math.max(0, inUsd - outUsd),\n etaSeconds: Number(q.timeEstimate ?? 60),\n reliability: 0.95,\n validUntilMs: deadline,\n };\n } catch (err) {\n return refuse(`threw: ${err instanceof Error ? err.message.slice(0, 200) : String(err).slice(0, 200)}`);\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n return {\n chain: \"\",\n to: quote.depositAddress,\n value: quote.sourceAmount,\n ...(quote.depositMemo ? {memo: quote.depositMemo} : {}),\n };\n },\n\n async notifyDeposit(intentId: string, txHash: string): Promise<void> {\n const {depositAddress} = decodeIntent(intentId);\n const res = await fetch(`${apiBase}/deposit/submit`, {\n method: \"POST\",\n headers: authHeaders(config.jwt),\n body: JSON.stringify({depositAddress, txHash}),\n signal: timeoutSignal(12_000),\n });\n if (!res.ok) throw new Error(`near-intents: deposit notification failed (${res.status})`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const {depositAddress, depositMemo} = decodeIntent(ref.intentId);\n // Durable retry: BaseSwap2Protocol embeds the source hash in the swap2\n // id. If the post-broadcast notify failed, every status poll retries it.\n if (ref.sourceTxHash) {\n await this.notifyDeposit?.(ref.intentId, ref.sourceTxHash).catch(() => {});\n }\n try {\n const query = new URLSearchParams({depositAddress});\n if (depositMemo) query.set(\"depositMemo\", depositMemo);\n const res = await fetch(\n `${apiBase}/status?${query.toString()}`,\n {headers: authHeaders(config.jwt), signal: timeoutSignal(12_000)},\n );\n if (!res.ok) return {state: \"pending\"};\n const s = (await res.json()) as {\n status?: string;\n swapDetails?: {destinationChainTxHashes?: unknown[]};\n };\n const map: Record<string, IntentStatus[\"state\"]> = {\n PENDING_DEPOSIT: \"pending\",\n KNOWN_DEPOSIT_TX: \"pending\",\n INCOMPLETE_DEPOSIT: \"pending\",\n PROCESSING: \"pending\",\n SUCCESS: \"completed\",\n FAILED: \"failed\",\n REFUNDED: \"refunded\",\n };\n const state = map[s.status ?? \"PENDING_DEPOSIT\"] ?? \"pending\";\n // KNOWN_DEPOSIT_TX: 1Click has the deposit tx (submitted, not yet\n // credited). Counted as received so a caller with no source hash of\n // its own does not expire a swap that is already on its way.\n const depositReceived = s.status === \"KNOWN_DEPOSIT_TX\" || s.status === \"PROCESSING\" || s.status === \"INCOMPLETE_DEPOSIT\";\n const destTx = txHashOf(s.swapDetails?.destinationChainTxHashes?.[0]);\n return {state, depositReceived, ...(destTx ? {destTxHash: destTx} : {})};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n","import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {nearIntents as nearIntentsCfg} from \"./config.js\";\nimport {nearIntentsProvider, type NearIntentsProviderConfig} from \"./provider.js\";\n\nexport interface NearIntentsSwap2Config extends Swap2EngineConfig, NearIntentsProviderConfig {}\n\nexport class NearIntentsSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: NearIntentsSwap2Config) {\n super(account, config);\n this.provider = nearIntentsProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return nearIntentsCfg.supports(caip2, \"eip155:1\") || nearIntentsCfg.supports(\"eip155:1\", caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return nearIntentsCfg.supports(fromChain, toChain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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,WAAW,MAAM,SAAS,CAAC;AAAA,UACrC,EAAC,SAAS,YAAY,OAAO,GAAG,GAAG,YAAQ,4BAAc,IAAM,EAAC;AAAA,QAClE;AACA,YAAI,CAAC,IAAI,GAAI,QAAO,EAAC,OAAO,UAAS;AACrC,cAAM,IAAK,MAAM,IAAI,KAAK;AAI1B,cAAM,MAA6C;AAAA,UACjD,iBAAiB;AAAA,UACjB,kBAAkB;AAAA,UAClB,oBAAoB;AAAA,UACpB,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,UAAU;AAAA,QACZ;AACA,cAAM,QAAQ,IAAI,EAAE,UAAU,iBAAiB,KAAK;AAIpD,cAAM,kBAAkB,EAAE,WAAW,sBAAsB,EAAE,WAAW,gBAAgB,EAAE,WAAW;AACrG,cAAM,SAAS,SAAS,EAAE,aAAa,2BAA2B,CAAC,CAAC;AACpE,eAAO,EAAC,OAAO,iBAAiB,GAAI,SAAS,EAAC,YAAY,OAAM,IAAI,CAAC,EAAE;AAAA,MACzE,QAAQ;AACN,eAAO,EAAC,OAAO,UAAS;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACF;;;AC3aA,oBAAkC;AAO3B,IAAM,2BAAN,cAAuC,kCAAoB;AAAA,EAC7C;AAAA,EACnB,YAAY,SAAmC,QAAgC;AAC7E,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,oBAAoB,MAAM;AAAA,EAC5C;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,YAAe,SAAS,OAAO,UAAU,KAAK,YAAe,SAAS,YAAY,KAAK;AAAA,EAChG;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,YAAe,SAAS,WAAW,OAAO;AAAA,EACnD;AACF;","names":["import_util","import_swap2_assets"]}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  NearIntentsSwap2Protocol
3
- } from "./chunk-BXDRS5SZ.js";
3
+ } from "./chunk-GE5KDZVH.js";
4
4
  import {
5
5
  nearIntentsProvider
6
- } from "./chunk-ZCU6YSV4.js";
6
+ } from "./chunk-4GRRM3WT.js";
7
7
  import {
8
8
  nearIntents,
9
9
  nearIntentsChainRefusal,