@usewhisk/cctp 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +218 -0
- package/dist/abi.cjs +239 -0
- package/dist/abi.cjs.map +1 -0
- package/dist/abi.d.cts +401 -0
- package/dist/abi.d.ts +401 -0
- package/dist/abi.js +234 -0
- package/dist/abi.js.map +1 -0
- package/dist/attestation-D52iUV0y.d.cts +188 -0
- package/dist/attestation-D52iUV0y.d.ts +188 -0
- package/dist/chains.cjs +1621 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.cts +2 -0
- package/dist/chains.d.ts +2 -0
- package/dist/chains.js +1514 -0
- package/dist/chains.js.map +1 -0
- package/dist/index-BIerSvES.d.cts +4070 -0
- package/dist/index-O0Ms-Fa5.d.ts +4070 -0
- package/dist/index.cjs +4003 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +940 -0
- package/dist/index.d.ts +940 -0
- package/dist/index.js +3785 -0
- package/dist/index.js.map +1 -0
- package/dist/iris.cjs +557 -0
- package/dist/iris.cjs.map +1 -0
- package/dist/iris.d.cts +205 -0
- package/dist/iris.d.ts +205 -0
- package/dist/iris.js +538 -0
- package/dist/iris.js.map +1 -0
- package/package.json +85 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iris/urls.ts","../src/errors.ts","../src/iris/limiter.ts","../src/iris/fetch.ts","../src/iris/types.ts","../src/fees/math.ts","../src/iris/fees.ts","../src/iris/messages.ts","../src/iris/reattest.ts","../src/iris/quote.ts"],"names":["sleep","DEFAULT_TIMEOUT_MS"],"mappings":";;;AAEO,IAAM,gBAAA,GAAmB;AACzB,IAAM,gBAAA,GAAmB;AAEzB,SAAS,YAAY,OAAA,EAA0B;AACpD,EAAA,OAAO,OAAA,KAAY,YAAY,gBAAA,GAAmB,gBAAA;AACpD;;;AC8BO,IAAM,SAAA,GAAN,cA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A,IAAY,QAAQ,IAAA,IAAQ,WAAA,IAAe,GAAA,GACtD,GAAA,CAAI,SAAA,GACJ,MAAA;AACN,EAAA,IAAI,OAAO,UAAU,QAAA,IAAY,CAAC,OAAO,QAAA,CAAS,KAAK,CAAA,IAAK,KAAA,GAAQ,CAAA,EAAG;AACrE,IAAA,MAAM,IAAI,eAAe,6CAA6C,CAAA;AAAA,EACxE;AAGA,EAAA,MAAM,KAAA,GAAQ,qBAAA,CAAsB,IAAA,CAAK,MAAA,CAAO,KAAK,CAAC,CAAA;AACtD,EAAA,IAAI,CAAC,KAAA;AACH,IAAA,MAAM,IAAI,cAAA,CAAe,CAAA,eAAA,EAAkB,KAAK,CAAA,eAAA,CAAiB,CAAA;AACnE,EAAA,MAAM,IAAA,GAAA,CAAQ,KAAA,CAAM,CAAC,CAAA,IAAK,EAAA,EAAI,MAAA,CAAO,CAAA,EAAG,GAAG,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AACvD,EAAA,OAAO,OAAO,KAAA,CAAM,CAAC,CAAE,CAAA,GAAI,QAAA,GAAa,OAAO,IAAI,CAAA;AACrD","file":"iris.cjs","sourcesContent":["import type { Network } from \"../chains/types.js\";\n\nexport const IRIS_MAINNET_URL = \"https://iris-api.circle.com\";\nexport const IRIS_SANDBOX_URL = \"https://iris-api-sandbox.circle.com\";\n\nexport function irisBaseUrl(network: Network): string {\n return network === \"mainnet\" ? IRIS_MAINNET_URL : IRIS_SANDBOX_URL;\n}\n","/**\n * Error hierarchy for `@usewhisk/cctp`.\n *\n * Each subclass has a stable `code` callers can switch on, plus a\n * machine-readable `name`. Human-readable detail goes in `message`.\n *\n * Layers:\n * - `InvalidInputError`: caller passed bad data\n * - `IrisError`: HTTP / parse failures from Iris\n * - `ProtocolError`: CCTP-level invariant violated\n * - `UnsupportedError`: the chain or ecosystem can't serve the call\n */\n\nexport type CctpErrorCode =\n // input\n | \"invalid_address\"\n | \"invalid_bytes32\"\n | \"invalid_amount\"\n | \"invalid_chain\"\n | \"invalid_domain\"\n | \"invalid_input\"\n // iris\n | \"iris_http\"\n | \"iris_network\"\n | \"iris_parse\"\n | \"iris_aborted\"\n | \"iris_rate_limited\"\n // protocol\n | \"amount_too_large\"\n | \"fee_unavailable\"\n | \"tier_not_found\"\n | \"no_route\"\n | \"rpc_unavailable\"\n // unsupported\n | \"unsupported_chain\"\n | \"unsupported_ecosystem\";\n\nexport class CctpError extends Error {\n readonly code: CctpErrorCode;\n override readonly cause?: unknown;\n\n constructor(code: CctpErrorCode, message: string, cause?: unknown) {\n super(message);\n this.name = \"CctpError\";\n this.code = code;\n if (cause !== undefined) this.cause = cause;\n }\n}\n\n/** Caller passed bad input. The fix is in the calling code. */\nexport class InvalidInputError extends CctpError {\n constructor(code: CctpErrorCode, message: string, cause?: unknown) {\n super(code, message, cause);\n this.name = \"InvalidInputError\";\n }\n}\n\n/** HTTP, JSON, or network failures from Iris. May be transient. */\nexport class IrisError extends CctpError {\n constructor(code: CctpErrorCode, message: string, cause?: unknown) {\n super(code, message, cause);\n this.name = \"IrisError\";\n }\n}\n\n/** HTTP non-2xx response from Iris. */\nexport class IrisHttpError extends IrisError {\n readonly status: number;\n readonly bodySnippet: string;\n readonly url: string;\n constructor(status: number, url: string, bodySnippet: string) {\n super(\n \"iris_http\",\n `Iris ${status} on ${url}: ${bodySnippet.slice(0, 200)}`,\n );\n this.name = \"IrisHttpError\";\n this.status = status;\n this.url = url;\n this.bodySnippet = bodySnippet;\n }\n}\n\n/**\n * Iris answered 429, which blocks every request from this IP for five\n * minutes. `retryAt` is when this process will ask again, in ms since the\n * epoch.\n */\nexport class IrisRateLimitedError extends IrisError {\n readonly retryAt: number;\n readonly host: string;\n constructor(host: string, retryAt: number) {\n super(\n \"iris_rate_limited\",\n `Iris rate limit reached on ${host}; requests resume at ${new Date(retryAt).toISOString()}`,\n );\n this.name = \"IrisRateLimitedError\";\n this.host = host;\n this.retryAt = retryAt;\n }\n}\n\n/** Network failure or per-request timeout, after retries. */\nexport class IrisNetworkError extends IrisError {\n constructor(message: string, cause?: unknown) {\n super(\"iris_network\", message, cause);\n this.name = \"IrisNetworkError\";\n }\n}\n\n/** Iris returned non-JSON or unexpected JSON shape. */\nexport class IrisParseError extends IrisError {\n constructor(message: string, cause?: unknown) {\n super(\"iris_parse\", message, cause);\n this.name = \"IrisParseError\";\n }\n}\n\n/** The caller's AbortSignal fired. */\nexport class IrisAbortedError extends IrisError {\n constructor(message: string) {\n super(\"iris_aborted\", message);\n this.name = \"IrisAbortedError\";\n }\n}\n\n/** CCTP-level invariant violated. */\nexport class ProtocolError extends CctpError {\n constructor(code: CctpErrorCode, message: string, cause?: unknown) {\n super(code, message, cause);\n this.name = \"ProtocolError\";\n }\n}\n\n/** The chain or ecosystem can't serve this call. */\nexport class UnsupportedError extends CctpError {\n constructor(code: CctpErrorCode, message: string) {\n super(code, message);\n this.name = \"UnsupportedError\";\n }\n}\n\nexport function isCctpError(value: unknown): value is CctpError {\n return value instanceof CctpError;\n}\n","import { IrisRateLimitedError } from \"../errors.js\";\n\nexport type IrisLimiterOptions = {\n /** Circle's limit is 35 a second; staying under it leaves room for others. */\n ratePerSecond?: number;\n /** Circle blocks the IP for five minutes after a 429. */\n standDownMs?: number;\n now?: () => number;\n sleep?: (ms: number) => Promise<void>;\n};\n\nexport type IrisLimiter = {\n /** Waits for a request slot, or throws while the host is standing down. */\n acquire(host: string): Promise<void>;\n /** Records a 429 and returns when requests may resume. */\n standDown(host: string): number;\n now(): number;\n sleep(ms: number): Promise<void>;\n};\n\ntype Bucket = { tokens: number; updatedAt: number; blockedUntil: number };\n\nexport function createIrisLimiter(\n options: IrisLimiterOptions = {},\n): IrisLimiter {\n const rate = options.ratePerSecond ?? 30;\n const standDownMs = options.standDownMs ?? 5 * 60_000;\n const now = options.now ?? (() => Date.now());\n const sleep =\n options.sleep ??\n ((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));\n const buckets = new Map<string, Bucket>();\n\n const bucket = (host: string): Bucket => {\n let b = buckets.get(host);\n if (!b) {\n b = { tokens: rate, updatedAt: now(), blockedUntil: 0 };\n buckets.set(host, b);\n }\n return b;\n };\n\n return {\n async acquire(host) {\n const b = bucket(host);\n if (now() < b.blockedUntil) {\n throw new IrisRateLimitedError(host, b.blockedUntil);\n }\n const elapsed = (now() - b.updatedAt) / 1000;\n b.tokens = Math.min(rate, b.tokens + elapsed * rate);\n b.updatedAt = now();\n if (b.tokens < 1) {\n const waitMs = Math.ceil(((1 - b.tokens) / rate) * 1000);\n await sleep(waitMs);\n b.tokens += (waitMs / 1000) * rate;\n b.updatedAt = now();\n }\n b.tokens -= 1;\n },\n standDown(host) {\n const b = bucket(host);\n b.blockedUntil = now() + standDownMs;\n return b.blockedUntil;\n },\n now,\n sleep,\n };\n}\n\n/** Shared by every Iris call in the process, as Circle's limit is per IP. */\nexport const defaultIrisLimiter = createIrisLimiter();\n","/**\n * Iris fetch wrapper with timeout, retry, and `AbortSignal`.\n *\n * Error mapping:\n * - 4xx (except 429) → IrisHttpError (no retry)\n * - 429 → IrisRateLimitedError (no retry)\n * - 5xx → retry, then IrisHttpError\n * - Network failure → retry, then IrisNetworkError\n * - Caller-signaled abort → IrisAbortedError\n * - Per-request timeout → retry, then IrisNetworkError\n * - JSON parse failure → IrisParseError (no retry)\n */\n\nimport {\n IrisAbortedError,\n IrisHttpError,\n IrisNetworkError,\n IrisParseError,\n IrisRateLimitedError,\n} from \"../errors.js\";\nimport { defaultIrisLimiter, type IrisLimiter } from \"./limiter.js\";\n\nexport type FetchJsonOptions = {\n /** Per-request timeout in ms. Default 5000. */\n timeoutMs?: number;\n /** Retries after the first attempt. Default 3. */\n maxRetries?: number;\n /** Base delay between retries in ms. Backoff multiplies by retry index. */\n baseDelayMs?: number;\n signal?: AbortSignal;\n /** Defaults to the global `fetch`. */\n fetch?: typeof fetch;\n /** Defaults to one limiter shared by every Iris call in the process. */\n limiter?: IrisLimiter;\n};\n\nconst DEFAULT_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_BASE_DELAY_MS = 300;\n\nexport async function fetchIrisJson<T>(\n url: string,\n options: FetchJsonOptions = {},\n request: { method: \"POST\"; body: unknown } | { method: \"GET\" } = {\n method: \"GET\",\n },\n): Promise<T> {\n const {\n timeoutMs = DEFAULT_TIMEOUT_MS,\n maxRetries = DEFAULT_MAX_RETRIES,\n baseDelayMs = DEFAULT_BASE_DELAY_MS,\n signal,\n fetch: fetchImpl = fetch,\n limiter = defaultIrisLimiter,\n } = options;\n const host = new URL(url).host;\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n if (signal?.aborted) throw new IrisAbortedError(\"Aborted by caller\");\n await limiter.acquire(host);\n\n const ctrl = new AbortController();\n const timer = setTimeout(() => ctrl.abort(), timeoutMs);\n const onCallerAbort = () => ctrl.abort();\n signal?.addEventListener(\"abort\", onCallerAbort);\n\n try {\n const res = await fetchImpl(url, {\n method: request.method,\n headers: {\n accept: \"application/json\",\n ...(request.method === \"POST\" && {\n \"content-type\": \"application/json\",\n }),\n },\n ...(request.method === \"POST\" && {\n body: JSON.stringify(request.body),\n }),\n signal: ctrl.signal,\n });\n\n if (res.ok) {\n let json: unknown;\n try {\n json = await res.json();\n } catch (err) {\n throw new IrisParseError(`Invalid JSON from ${url}`, err);\n }\n return json as T;\n }\n\n // A retry inside the block would extend it, so stop asking at once.\n if (res.status === 429) {\n throw new IrisRateLimitedError(host, limiter.standDown(host));\n }\n\n if (res.status >= 400 && res.status < 500 && res.status !== 429) {\n throw new IrisHttpError(res.status, url, await safeText(res));\n }\n\n lastError = new IrisHttpError(res.status, url, await safeText(res));\n } catch (err) {\n // Parse errors and 4xx HTTP errors bypass the retry loop.\n if (err instanceof IrisParseError) throw err;\n if (err instanceof IrisRateLimitedError) throw err;\n if (err instanceof IrisHttpError) {\n if (err.status < 500 && err.status !== 429) throw err;\n }\n // A timeout aborts too, but only the caller's signal stops the retries.\n if (signal?.aborted) throw new IrisAbortedError(\"Aborted by caller\");\n lastError = err;\n } finally {\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onCallerAbort);\n }\n\n if (attempt < maxRetries) {\n await sleep(baseDelayMs * (attempt + 1), signal);\n }\n }\n\n if (lastError instanceof IrisHttpError) throw lastError;\n throw new IrisNetworkError(\n `Iris request failed after ${maxRetries + 1} attempts`,\n lastError,\n );\n}\n\nasync function safeText(res: Response): Promise<string> {\n try {\n return await res.text();\n } catch {\n return \"\";\n }\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(new IrisAbortedError(\"Aborted by caller\"));\n return;\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }, ms);\n function onAbort() {\n clearTimeout(timer);\n reject(new IrisAbortedError(\"Aborted by caller\"));\n }\n signal?.addEventListener(\"abort\", onAbort);\n });\n}\n","import type { CctpDomain } from \"../chains/types.js\";\n\n/** Fast Transfer attests after a block or two, before hard finality. */\nexport const FINALITY_FAST = 1000 as const;\n/** Standard Transfer attests after hard finality. */\nexport const FINALITY_STANDARD = 2000 as const;\nexport type FinalityThreshold = typeof FINALITY_FAST | typeof FINALITY_STANDARD;\n\nexport type TransferSpeed = \"fast\" | \"standard\";\n\n/**\n * Forwarder fee levels returned per finality level, in USDC subunits.\n * Circle recommends `med` or higher.\n */\nexport type ForwarderFeeTier = {\n low: bigint;\n med: bigint;\n high: bigint;\n};\n\n/**\n * A Fast or Standard row of the `/v2/burn/USDC/fees/{src}/{dst}` response, parsed.\n *\n * `minimumFee` is in hundredths of a basis point: Iris's `1.3` is `130n`.\n * `forwardFee` is present only when `?forward=true` is set on the request.\n */\nexport type BurnFeeTier = {\n finalityThreshold: FinalityThreshold;\n minimumFee: bigint;\n forwardFee?: ForwarderFeeTier;\n};\n\n/** Iris never reports a failed attestation; a slow one stays pending. */\nexport type IrisAttestationStatus = \"pending_confirmations\" | \"complete\";\n\n/** Why a message is slower than asked. None of these is a failure. */\nexport type IrisDelayReason =\n | \"insufficient_fee\"\n | \"amount_above_max\"\n | \"insufficient_allowance_available\";\n\n/**\n * Circle Orbit forwarder lifecycle status. Present only when the burn\n * was triggered with the forwarder hookData.\n *\n * - `PENDING`: relayer is processing.\n * - `CONFIRMED`: relayer submitted the mint, waiting on finality.\n * - `COMPLETE`: mint finalized.\n * - `FAILED`: relayer rejected; fall back to manual mint.\n */\nexport type ForwardState = \"PENDING\" | \"CONFIRMED\" | \"COMPLETE\" | \"FAILED\";\n\n/**\n * Single message returned by `/v2/messages/{srcDomain}`.\n */\nexport type IrisMessage = {\n /** Raw 0x-prefixed CCTP message bytes; pass to receiveMessage. */\n message: `0x${string}`;\n /** Raw 0x-prefixed attestation bytes; pass to receiveMessage. */\n attestation: `0x${string}`;\n /** Decimal string. */\n eventNonce: string;\n status: IrisAttestationStatus;\n cctpVersion: 2;\n /** Present when burn included forwarder hookData. */\n forwardState?: ForwardState | null;\n /** Destination tx hash when forwardState is CONFIRMED or COMPLETE. */\n forwardTxHash?: string | null;\n delayReason?: IrisDelayReason | null;\n /** Decoded message and message body, if Iris can decode them. */\n decodedMessage?: {\n sourceDomain: string;\n destinationDomain: string;\n nonce: `0x${string}`;\n sender: string | null;\n recipient: string | null;\n destinationCaller: string | null;\n minFinalityThreshold: string;\n finalityThresholdExecuted: string;\n messageBody: `0x${string}`;\n decodedMessageBody?: {\n burnToken: string | null;\n mintRecipient: string | null;\n amount: string;\n messageSender: string | null;\n maxFee: string;\n feeExecuted: string;\n expirationBlock: string;\n hookData: `0x${string}` | null;\n };\n };\n};\n\nexport type IrisMessagesResponse = {\n messages: IrisMessage[];\n};\n\n/**\n * Filters for getMessages. Pass at least one of `transactionHash` or `nonce`.\n */\nexport type GetMessagesQuery = {\n sourceDomain: CctpDomain;\n transactionHash?: string;\n nonce?: string;\n};\n","/**\n * Fee math for CCTP V2 bridges.\n *\n * Two protocol-level fees stack on a Fast Transfer + Forwarder bridge:\n *\n * 1. Burn fee: a rate on the transfer amount, charged by CCTP. Iris\n * returns `minimumFee` in basis points with up to two decimals\n * (`1.3` is 0.013%). Whisk holds it as hundredths of a basis\n * point, so `1.3` becomes `130n`.\n *\n * 2. Forwarder fee: a flat USDC fee that pays for destination gas\n * and the relayer. Iris returns low, med and high levels in USDC\n * subunits. Whisk defaults to `med`.\n *\n * `maxFee` on `depositForBurnWithHook` must cover both. Every step\n * rounds up: a `maxFee` one subunit short turns a Fast transfer into a\n * Standard one.\n */\n\nimport type { BurnFeeTier, ForwarderFeeTier } from \"../iris/types.js\";\nimport { InvalidInputError, IrisParseError, ProtocolError } from \"../errors.js\";\n\nconst CENTI_BPS_PER_UNIT = 1_000_000n;\n\nconst DECIMAL = /^(\\d+)(?:\\.(\\d+))?$/;\n\n// JSON numbers reach us already parsed. String() gives back the shortest\n// decimal that round-trips, which is the literal Iris sent for any value\n// with 15 or fewer significant digits. Exponent forms are refused.\nfunction ceilDecimal(raw: unknown, decimals: number, what: string): bigint {\n const text =\n typeof raw === \"number\" ? String(raw) : typeof raw === \"string\" ? raw : \"\";\n const match = DECIMAL.exec(text);\n if (!match) {\n throw new IrisParseError(`Iris ${what} is invalid: ${String(raw)}`);\n }\n const fraction = match[2] ?? \"\";\n const kept = fraction.slice(0, decimals).padEnd(decimals, \"0\");\n const dropped = /[1-9]/.test(fraction.slice(decimals)) ? 1n : 0n;\n return BigInt((match[1] ?? \"0\") + kept) + dropped;\n}\n\n/** Iris's `minimumFee` as hundredths of a basis point: `1.3` is `130n`. */\nexport function parseFeeBps(raw: unknown): bigint {\n return ceilDecimal(raw, 2, \"minimumFee\");\n}\n\n/** An Iris forwarder fee in USDC subunits, rounded up. */\nexport function parseForwarderFee(raw: unknown): bigint {\n return ceilDecimal(raw, 0, \"forwardFee\");\n}\n\n/**\n * The CCTP burn fee on `amount` subunits at `feeCentiBps` hundredths of\n * a basis point, rounded up.\n */\nexport function computeBurnFee(amount: bigint, feeCentiBps: bigint): bigint {\n if (amount < 0n) {\n throw new InvalidInputError(\n \"invalid_amount\",\n `amount must be non-negative, got ${amount}`,\n );\n }\n if (feeCentiBps < 0n) {\n throw new InvalidInputError(\n \"invalid_input\",\n `feeCentiBps must be non-negative, got ${feeCentiBps}`,\n );\n }\n return ceilDiv(amount * feeCentiBps, CENTI_BPS_PER_UNIT);\n}\n\n/** The forwarder fee for a level, in USDC subunits. */\nexport function selectForwarderFee(\n tier: BurnFeeTier,\n level: keyof ForwarderFeeTier = \"med\",\n): bigint {\n if (!tier.forwardFee) {\n throw new ProtocolError(\n \"fee_unavailable\",\n \"Tier has no forwardFee. Fetch burn fees with includeForwarderFee=true\",\n );\n }\n const value = tier.forwardFee[level];\n if (value < 0n) {\n throw new ProtocolError(\n \"fee_unavailable\",\n `Invalid forwardFee.${level}: ${value}`,\n );\n }\n return value;\n}\n\nexport type ComputeMaxFeeInput = {\n /** Transfer amount in USDC subunits. */\n amount: bigint;\n /** Selected tier (Fast or Standard). */\n tier: BurnFeeTier;\n /** Forwarder fee level; defaults to `\"med\"`. */\n forwarderLevel?: keyof ForwarderFeeTier;\n /**\n * Whole basis points added to the forwarder fee (0 to 10000). Iris's\n * `high` level already carries a buffer, so this defaults to 0.\n */\n forwarderBufferBps?: number;\n /** Whether to include the forwarder fee. Defaults to `true`. */\n includeForwarder?: boolean;\n /**\n * Whole basis points added to the protocol fee in `maxFee` only. Circle\n * takes the fee it executes, so the buffer is a ceiling, not a charge.\n */\n burnFeeBufferBps?: number;\n /** The on-chain minimum from `getMinFeeAmount`, in USDC subunits. */\n minBurnFee?: bigint;\n};\n\nexport type ComputeMaxFeeResult = {\n /** The protocol fee, raised to `minBurnFee` if lower, before any buffer. */\n burnFee: bigint;\n forwarderFee: bigint;\n /** Total cap to pass as `maxFee` on `depositForBurnWithHook`. */\n maxFee: bigint;\n};\n\n/**\n * maxFee = burnFee (+ buffer) + forwarderFee (+ buffer)\n *\n * The result is a cap; the actual deducted fee can be less.\n */\nexport function computeMaxFee(input: ComputeMaxFeeInput): ComputeMaxFeeResult {\n const {\n amount,\n tier,\n forwarderLevel = \"med\",\n forwarderBufferBps = 0,\n includeForwarder = true,\n burnFeeBufferBps = 0,\n minBurnFee = 0n,\n } = input;\n\n const irisFee = computeBurnFee(amount, tier.minimumFee);\n const burnFee = irisFee > minBurnFee ? irisFee : minBurnFee;\n const forwarderFee = includeForwarder\n ? applyBufferBps(\n selectForwarderFee(tier, forwarderLevel),\n forwarderBufferBps,\n )\n : 0n;\n\n return {\n burnFee,\n forwarderFee,\n maxFee: applyBufferBps(burnFee, burnFeeBufferBps) + forwarderFee,\n };\n}\n\nfunction applyBufferBps(value: bigint, bps: number): bigint {\n if (!Number.isSafeInteger(bps) || bps < 0) {\n throw new InvalidInputError(\n \"invalid_input\",\n `bufferBps must be a non-negative whole number, got ${bps}`,\n );\n }\n return ceilDiv(value * (10_000n + BigInt(bps)), 10_000n);\n}\n\nfunction ceilDiv(numerator: bigint, denominator: bigint): bigint {\n return (numerator + denominator - 1n) / denominator;\n}\n","/**\n * Iris burn fees endpoint.\n *\n * GET /v2/burn/USDC/fees/{src}/{dst}?forward=true\n *\n * Returns one row per finality threshold (1000 = Fast, 2000 = Standard).\n * Each row has the protocol fee in basis points and, with ?forward=true,\n * the forwarder fee levels low/med/high in USDC subunits.\n */\nimport type { CctpDomain, Network } from \"../chains/types.js\";\nimport { irisBaseUrl } from \"./urls.js\";\nimport { fetchIrisJson, type FetchJsonOptions } from \"./fetch.js\";\nimport type {\n BurnFeeTier,\n FinalityThreshold,\n ForwarderFeeTier,\n TransferSpeed,\n} from \"./types.js\";\nimport { FINALITY_FAST, FINALITY_STANDARD } from \"./types.js\";\nimport { IrisParseError, ProtocolError } from \"../errors.js\";\nimport {\n parseFeeBps,\n parseForwarderFee,\n selectForwarderFee,\n} from \"../fees/math.js\";\n\nexport type GetBurnFeesOptions = FetchJsonOptions & {\n /** Default `true`. Set to `false` if you only need protocol fees. */\n includeForwarderFee?: boolean;\n};\n\n/**\n * Rows for thresholds other than Fast and Standard are dropped. Use\n * `pickFeeTier` to choose one.\n */\nexport async function getBurnFees(\n network: Network,\n sourceDomain: CctpDomain,\n destinationDomain: CctpDomain,\n options: GetBurnFeesOptions = {},\n): Promise<BurnFeeTier[]> {\n const { includeForwarderFee = true, ...fetchOpts } = options;\n const base = irisBaseUrl(network);\n const url = new URL(\n `${base}/v2/burn/USDC/fees/${sourceDomain}/${destinationDomain}`,\n );\n if (includeForwarderFee) url.searchParams.set(\"forward\", \"true\");\n\n const raw = await fetchIrisJson<unknown>(url.toString(), fetchOpts);\n if (!Array.isArray(raw)) {\n throw new IrisParseError(\"Iris burn-fees response is not an array\");\n }\n return raw\n .map((row) => normalizeTier(row))\n .filter((t): t is BurnFeeTier => t !== null);\n}\n\nfunction normalizeTier(row: unknown): BurnFeeTier | null {\n if (!row || typeof row !== \"object\") {\n throw new IrisParseError(\"Iris fee tier is not an object\");\n }\n const r = row as Record<string, unknown>;\n const threshold = r.finalityThreshold;\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) {\n return null;\n }\n const out: BurnFeeTier = {\n finalityThreshold: threshold,\n minimumFee: parseFeeBps(r.minimumFee),\n };\n if (r.forwardFee && typeof r.forwardFee === \"object\") {\n const ff = r.forwardFee as Record<string, unknown>;\n out.forwardFee = {\n low: parseForwarderFee(ff.low),\n med: parseForwarderFee(ff.med),\n high: parseForwarderFee(ff.high),\n };\n }\n return out;\n}\n\n/** The row for `speed`. Throws if Iris returned none for this route. */\nexport function pickFeeTier(\n tiers: readonly BurnFeeTier[],\n speed: TransferSpeed,\n): BurnFeeTier {\n const threshold: FinalityThreshold =\n speed === \"fast\" ? FINALITY_FAST : FINALITY_STANDARD;\n const tier = tiers.find((t) => t.finalityThreshold === threshold);\n if (!tier) {\n throw new ProtocolError(\n \"tier_not_found\",\n `Iris returned no ${speed === \"fast\" ? \"Fast\" : \"Standard\"} Transfer fee for this route.`,\n );\n }\n return tier;\n}\n\n/** The forwarder fee for a level, in USDC subunits. */\nexport function pickForwarderFee(\n tier: BurnFeeTier,\n level: keyof ForwarderFeeTier = \"med\",\n): bigint {\n return selectForwarderFee(tier, level);\n}\n","/**\n * Iris messages endpoint.\n *\n * GET /v2/messages/{srcDomain}?transactionHash=...\n * GET /v2/messages/{srcDomain}?nonce=...\n *\n * Returns the message + attestation + forwarder state in a single\n * call. Use this to drive recovery polling.\n */\nimport type { CctpDomain, Network } from \"../chains/types.js\";\nimport { irisBaseUrl } from \"./urls.js\";\nimport { fetchIrisJson, type FetchJsonOptions } from \"./fetch.js\";\nimport {\n IrisAbortedError,\n IrisHttpError,\n IrisRateLimitedError,\n} from \"../errors.js\";\nimport type { SecondsRange } from \"../chains/attestation.js\";\nimport { defaultIrisLimiter } from \"./limiter.js\";\nimport type {\n GetMessagesQuery,\n IrisMessage,\n IrisMessagesResponse,\n} from \"./types.js\";\n\nexport type GetMessagesOptions = FetchJsonOptions & {\n network: Network;\n /** Defaults to Circle's Iris host for `network`. */\n baseUrl?: string;\n};\n\n/**\n * Single fetch. Returns an empty array when Iris doesn't yet know about\n * the burn, whether it answers `messages: []` or 404.\n */\nexport async function getMessages(\n query: GetMessagesQuery,\n options: GetMessagesOptions,\n): Promise<IrisMessage[]> {\n const { network, baseUrl, ...fetchOpts } = options;\n const base = (baseUrl ?? irisBaseUrl(network)).replace(/\\/+$/, \"\");\n const url = new URL(`${base}/v2/messages/${query.sourceDomain}`);\n if (query.transactionHash) {\n url.searchParams.set(\"transactionHash\", query.transactionHash);\n }\n if (query.nonce) {\n url.searchParams.set(\"nonce\", query.nonce);\n }\n try {\n const json = await fetchIrisJson<IrisMessagesResponse>(\n url.toString(),\n fetchOpts,\n );\n return json.messages ?? [];\n } catch (err) {\n if (err instanceof IrisHttpError && err.status === 404) {\n return [];\n }\n throw err;\n }\n}\n\nexport type PollMessageOptions = GetMessagesOptions & {\n /** Polling interval in ms. Default 3000, or from {@link pollBudget}. */\n intervalMs?: number;\n /** Total timeout in ms. Default 15 minutes, or from {@link pollBudget}. */\n timeoutMs?: number;\n /**\n * Custom predicate to decide when polling is \"done\". Default: a forwarded\n * message once Circle's relayer is done or has failed, otherwise once the\n * attestation is complete.\n */\n isDone?: (message: IrisMessage) => boolean;\n /**\n * Called when a 429 makes the poll stand down, with the time it resumes.\n * The wait does not count against `timeoutMs`.\n */\n onRateLimited?: (retryAt: number) => void;\n};\n\nconst DEFAULT_INTERVAL_MS = 3000;\nconst DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;\nconst TIMEOUT_MARGIN_MS = 5 * 60 * 1000;\n\n/**\n * How often and how long to poll for a route whose attestation takes\n * `eta` seconds. Fast routes poll often so the payer hears at once; hour-long\n * ones poll gently so they do not eat the shared rate limit.\n */\nexport function pollBudget(eta: SecondsRange): {\n intervalMs: number;\n timeoutMs: number;\n} {\n const intervalMs =\n eta.max <= 60 ? 2_000 : eta.max <= 30 * 60 ? 10_000 : 30_000;\n return { intervalMs, timeoutMs: eta.max * 2 * 1000 + TIMEOUT_MARGIN_MS };\n}\n\n/**\n * Circle's relayer has minted once it reports the mint `CONFIRMED` or\n * `COMPLETE` with its tx hash. `PENDING` can carry a hash that is not mined.\n */\nexport function isForwardDone(message: IrisMessage): boolean {\n return (\n (message.forwardState === \"CONFIRMED\" ||\n message.forwardState === \"COMPLETE\") &&\n !!message.forwardTxHash\n );\n}\n\nfunction defaultIsDone(message: IrisMessage): boolean {\n if (message.forwardState != null) {\n return isForwardDone(message) || message.forwardState === \"FAILED\";\n }\n return message.status === \"complete\";\n}\n\n/**\n * Returns the message once `isDone` holds, or on timeout the latest one\n * seen (`null` if none). Throws if Iris keeps failing; a slow attestation\n * only times out.\n */\nexport async function pollMessages(\n query: GetMessagesQuery,\n options: PollMessageOptions,\n): Promise<IrisMessage | null> {\n const {\n intervalMs = DEFAULT_INTERVAL_MS,\n timeoutMs = DEFAULT_TIMEOUT_MS,\n isDone = defaultIsDone,\n onRateLimited,\n signal,\n ...rest\n } = options;\n const limiter = rest.limiter ?? defaultIrisLimiter;\n\n let deadline = limiter.now() + timeoutMs;\n let latest: IrisMessage | null = null;\n\n while (limiter.now() < deadline) {\n if (signal?.aborted) throw new IrisAbortedError(\"Aborted by caller\");\n\n let messages: IrisMessage[];\n try {\n messages = await getMessages(query, { ...rest, signal });\n } catch (err) {\n if (!(err instanceof IrisRateLimitedError)) throw err;\n onRateLimited?.(err.retryAt);\n const waitMs = Math.max(0, err.retryAt - limiter.now());\n deadline += waitMs;\n await limiter.sleep(waitMs);\n continue;\n }\n if (messages.length > 0) {\n const first = messages[0];\n if (first) {\n latest = first;\n if (isDone(first)) return first;\n }\n }\n\n await sleep(intervalMs, signal);\n }\n\n return latest;\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(new IrisAbortedError(\"Aborted by caller\"));\n return;\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }, ms);\n function onAbort() {\n clearTimeout(timer);\n reject(new IrisAbortedError(\"Aborted by caller\"));\n }\n signal?.addEventListener(\"abort\", onAbort);\n });\n}\n","/**\n * Iris reattest endpoint.\n *\n * POST /v2/reattest/{nonce}\n *\n * Asks Circle to sign an expired or pre-finality message again. Circle only\n * acknowledges the request; the new attestation is then read from\n * `/v2/messages` by nonce.\n */\nimport type { Network } from \"../chains/types.js\";\nimport { irisBaseUrl } from \"./urls.js\";\nimport { fetchIrisJson, type FetchJsonOptions } from \"./fetch.js\";\nimport { IrisHttpError, IrisParseError } from \"../errors.js\";\n\nexport type ReattestOptions = FetchJsonOptions & {\n network: Network;\n};\n\n/** Returns Circle's acknowledgement, or `null` when Iris has no such nonce. */\nexport async function reattest(\n nonce: string,\n options: ReattestOptions,\n): Promise<{ nonce: string } | null> {\n const { network, ...fetchOpts } = options;\n const url = `${irisBaseUrl(network)}/v2/reattest/${nonce}`;\n let json: unknown;\n try {\n json = await fetchIrisJson<unknown>(url, fetchOpts, {\n method: \"POST\",\n body: {},\n });\n } catch (err) {\n if (err instanceof IrisHttpError && err.status === 404) return null;\n throw err;\n }\n const acknowledged =\n typeof json === \"object\" && json !== null && \"nonce\" in json\n ? json.nonce\n : undefined;\n if (typeof acknowledged !== \"string\") {\n throw new IrisParseError(\"Iris reattest reply has no nonce\");\n }\n return { nonce: acknowledged };\n}\n","import type { Address, CctpDomain, Network } from \"../chains/types.js\";\nimport { IrisParseError } from \"../errors.js\";\nimport { fetchIrisJson, type FetchJsonOptions } from \"./fetch.js\";\nimport { irisBaseUrl } from \"./urls.js\";\n\nexport type UpfrontFeeType = \"FORWARD\" | \"PRE_FINALITY\";\n\nexport type SignedBurnQuoteRequest = {\n /** The burn amount in USDC subunits. The quote is bound to it. */\n amount: bigint;\n /** The source chain's USDC: Whisk pays fees in USDC, never native gas. */\n feeToken: Address;\n requests: readonly UpfrontFeeType[];\n};\n\nexport type SignedQuoteExpiry =\n | { mode: \"TIMESTAMP\"; expiresAt: number }\n | { mode: \"BLOCK_NUMBER\"; expiresAtBlock: bigint };\n\nexport type SignedBurnQuote = {\n /** Submitted as-is to `TokenMessengerWithFees`. */\n signedQuote: `0x${string}`;\n /** Circle's clock, in Unix seconds. */\n issuedAt: number;\n expiry: SignedQuoteExpiry;\n feeTotalAmount: bigint;\n feeToken: Address;\n /**\n * Absent from Circle's schema but present in its replies. When it is\n * missing, the contract alone holds the quote to the amount.\n */\n burnAmount?: bigint;\n items: { type: UpfrontFeeType; amount: bigint }[];\n};\n\n/**\n * `POST /v2/quote/burn/usdc/{source}/{destination}`: Circle's signed price\n * for paying the Fast and forwarding fees on the source chain. No API key.\n */\nexport async function getSignedBurnQuote(\n network: Network,\n sourceDomain: CctpDomain,\n destinationDomain: CctpDomain,\n request: SignedBurnQuoteRequest,\n options: FetchJsonOptions = {},\n): Promise<SignedBurnQuote> {\n const url = `${irisBaseUrl(network)}/v2/quote/burn/usdc/${sourceDomain}/${destinationDomain}`;\n const raw = await fetchIrisJson<unknown>(url, options, {\n method: \"POST\",\n body: {\n amount: request.amount.toString(),\n feeToken: request.feeToken,\n requests: request.requests.map((type) => ({ type })),\n },\n });\n const quote = parseQuote(raw);\n if (quote.burnAmount !== undefined && quote.burnAmount !== request.amount) {\n throw new IrisParseError(\n `Iris quoted ${quote.burnAmount} subunits, not the ${request.amount} requested`,\n );\n }\n if (quote.feeToken.toLowerCase() !== request.feeToken.toLowerCase()) {\n throw new IrisParseError(\n `Iris priced the fee in ${quote.feeToken}, not ${request.feeToken}`,\n );\n }\n const types = quote.items.map((i) => i.type).sort();\n if (types.join() !== [...request.requests].sort().join()) {\n throw new IrisParseError(\n `Iris priced ${types.join(\", \")}, not ${request.requests.join(\", \")}`,\n );\n }\n return quote;\n}\n\nfunction parseQuote(raw: unknown): SignedBurnQuote {\n const fail = (what: string): never => {\n throw new IrisParseError(`Iris quote: ${what}`);\n };\n if (typeof raw !== \"object\" || raw === null) return fail(\"not an object\");\n const r = raw as Record<string, unknown>;\n\n const signedQuote = r.signedQuote;\n if (\n typeof signedQuote !== \"string\" ||\n !/^0x([0-9a-fA-F]{2})+$/.test(signedQuote)\n ) {\n return fail(\"signedQuote is not hex bytes\");\n }\n if (!Number.isSafeInteger(r.issuedAt))\n return fail(\"issuedAt is not a timestamp\");\n const feeToken = r.feeToken;\n if (typeof feeToken !== \"string\" || !/^0x[0-9a-fA-F]{40}$/.test(feeToken)) {\n return fail(\"feeToken is not an address\");\n }\n const feeTotalAmount = subunits(r.feeTotalAmount) ?? fail(\"feeTotalAmount\");\n const burnAmount =\n r.burnAmount === undefined\n ? undefined\n : (subunits(r.burnAmount) ?? fail(\"burnAmount\"));\n\n if (!Array.isArray(r.items) || r.items.length === 0) return fail(\"no items\");\n const items = r.items.map(\n (item: unknown): SignedBurnQuote[\"items\"][number] => {\n const i = (item ?? {}) as Record<string, unknown>;\n if (i.type !== \"FORWARD\" && i.type !== \"PRE_FINALITY\") {\n return fail(`unknown item type ${String(i.type)}`);\n }\n return {\n type: i.type,\n amount: subunits(i.amount) ?? fail(\"item amount\"),\n };\n },\n );\n if (items.reduce((sum, i) => sum + i.amount, 0n) !== feeTotalAmount) {\n return fail(\"items do not add up to feeTotalAmount\");\n }\n\n return {\n signedQuote: signedQuote as `0x${string}`,\n issuedAt: r.issuedAt as number,\n expiry: parseExpiry(r.expiry) ?? fail(\"expiry\"),\n feeTotalAmount,\n feeToken: feeToken as Address,\n ...(burnAmount !== undefined && { burnAmount }),\n items,\n };\n}\n\nfunction parseExpiry(raw: unknown): SignedQuoteExpiry | undefined {\n if (typeof raw !== \"object\" || raw === null) return undefined;\n const e = raw as Record<string, unknown>;\n if (e.mode === \"TIMESTAMP\" && Number.isSafeInteger(e.expiresAt)) {\n return { mode: \"TIMESTAMP\", expiresAt: e.expiresAt as number };\n }\n if (e.mode === \"BLOCK_NUMBER\" && Number.isSafeInteger(e.expiresAtBlock)) {\n return {\n mode: \"BLOCK_NUMBER\",\n expiresAtBlock: BigInt(e.expiresAtBlock as number),\n };\n }\n return undefined;\n}\n\nfunction subunits(raw: unknown): bigint | undefined {\n return typeof raw === \"string\" && /^(0|[1-9]\\d*)$/.test(raw)\n ? BigInt(raw)\n : undefined;\n}\n\n/**\n * Circle's remaining Fast Transfer allowance, in USDC subunits rounded down.\n * Iris sends it as a JSON number of whole USDC.\n */\nexport async function getFastBurnAllowance(\n network: Network,\n options: FetchJsonOptions = {},\n): Promise<bigint> {\n const raw = await fetchIrisJson<unknown>(\n `${irisBaseUrl(network)}/v2/fastBurn/USDC/allowance`,\n options,\n );\n const value =\n typeof raw === \"object\" && raw !== null && \"allowance\" in raw\n ? raw.allowance\n : undefined;\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n throw new IrisParseError(\"Iris allowance is not a non-negative number\");\n }\n // The shortest decimal form of a double reads back as the same double,\n // so this is the text Iris sent for any allowance below 2^53.\n const match = /^(\\d+)(?:\\.(\\d+))?$/.exec(String(value));\n if (!match)\n throw new IrisParseError(`Iris allowance ${value} is not decimal`);\n const frac = (match[2] ?? \"\").padEnd(6, \"0\").slice(0, 6);\n return BigInt(match[1]!) * 1_000_000n + BigInt(frac);\n}\n"]}
|
package/dist/iris.d.cts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { N as Network, e as CctpDomain, B as BurnFeeTier, T as TransferSpeed, F as ForwarderFeeTier, m as IrisMessage, G as GetMessagesQuery, o as SecondsRange, A as Address } from './attestation-D52iUV0y.cjs';
|
|
2
|
+
export { i as FINALITY_FAST, j as FINALITY_STANDARD, b as FinalityThreshold, k as ForwardState, I as IrisAttestationStatus, l as IrisDelayReason, n as IrisMessagesResponse } from './attestation-D52iUV0y.cjs';
|
|
3
|
+
|
|
4
|
+
declare const IRIS_MAINNET_URL = "https://iris-api.circle.com";
|
|
5
|
+
declare const IRIS_SANDBOX_URL = "https://iris-api-sandbox.circle.com";
|
|
6
|
+
declare function irisBaseUrl(network: Network): string;
|
|
7
|
+
|
|
8
|
+
type IrisLimiterOptions = {
|
|
9
|
+
/** Circle's limit is 35 a second; staying under it leaves room for others. */
|
|
10
|
+
ratePerSecond?: number;
|
|
11
|
+
/** Circle blocks the IP for five minutes after a 429. */
|
|
12
|
+
standDownMs?: number;
|
|
13
|
+
now?: () => number;
|
|
14
|
+
sleep?: (ms: number) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
type IrisLimiter = {
|
|
17
|
+
/** Waits for a request slot, or throws while the host is standing down. */
|
|
18
|
+
acquire(host: string): Promise<void>;
|
|
19
|
+
/** Records a 429 and returns when requests may resume. */
|
|
20
|
+
standDown(host: string): number;
|
|
21
|
+
now(): number;
|
|
22
|
+
sleep(ms: number): Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
declare function createIrisLimiter(options?: IrisLimiterOptions): IrisLimiter;
|
|
25
|
+
/** Shared by every Iris call in the process, as Circle's limit is per IP. */
|
|
26
|
+
declare const defaultIrisLimiter: IrisLimiter;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Iris fetch wrapper with timeout, retry, and `AbortSignal`.
|
|
30
|
+
*
|
|
31
|
+
* Error mapping:
|
|
32
|
+
* - 4xx (except 429) → IrisHttpError (no retry)
|
|
33
|
+
* - 429 → IrisRateLimitedError (no retry)
|
|
34
|
+
* - 5xx → retry, then IrisHttpError
|
|
35
|
+
* - Network failure → retry, then IrisNetworkError
|
|
36
|
+
* - Caller-signaled abort → IrisAbortedError
|
|
37
|
+
* - Per-request timeout → retry, then IrisNetworkError
|
|
38
|
+
* - JSON parse failure → IrisParseError (no retry)
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type FetchJsonOptions = {
|
|
42
|
+
/** Per-request timeout in ms. Default 5000. */
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
/** Retries after the first attempt. Default 3. */
|
|
45
|
+
maxRetries?: number;
|
|
46
|
+
/** Base delay between retries in ms. Backoff multiplies by retry index. */
|
|
47
|
+
baseDelayMs?: number;
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
/** Defaults to the global `fetch`. */
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
/** Defaults to one limiter shared by every Iris call in the process. */
|
|
52
|
+
limiter?: IrisLimiter;
|
|
53
|
+
};
|
|
54
|
+
declare function fetchIrisJson<T>(url: string, options?: FetchJsonOptions, request?: {
|
|
55
|
+
method: "POST";
|
|
56
|
+
body: unknown;
|
|
57
|
+
} | {
|
|
58
|
+
method: "GET";
|
|
59
|
+
}): Promise<T>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Iris burn fees endpoint.
|
|
63
|
+
*
|
|
64
|
+
* GET /v2/burn/USDC/fees/{src}/{dst}?forward=true
|
|
65
|
+
*
|
|
66
|
+
* Returns one row per finality threshold (1000 = Fast, 2000 = Standard).
|
|
67
|
+
* Each row has the protocol fee in basis points and, with ?forward=true,
|
|
68
|
+
* the forwarder fee levels low/med/high in USDC subunits.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
type GetBurnFeesOptions = FetchJsonOptions & {
|
|
72
|
+
/** Default `true`. Set to `false` if you only need protocol fees. */
|
|
73
|
+
includeForwarderFee?: boolean;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Rows for thresholds other than Fast and Standard are dropped. Use
|
|
77
|
+
* `pickFeeTier` to choose one.
|
|
78
|
+
*/
|
|
79
|
+
declare function getBurnFees(network: Network, sourceDomain: CctpDomain, destinationDomain: CctpDomain, options?: GetBurnFeesOptions): Promise<BurnFeeTier[]>;
|
|
80
|
+
/** The row for `speed`. Throws if Iris returned none for this route. */
|
|
81
|
+
declare function pickFeeTier(tiers: readonly BurnFeeTier[], speed: TransferSpeed): BurnFeeTier;
|
|
82
|
+
/** The forwarder fee for a level, in USDC subunits. */
|
|
83
|
+
declare function pickForwarderFee(tier: BurnFeeTier, level?: keyof ForwarderFeeTier): bigint;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Iris messages endpoint.
|
|
87
|
+
*
|
|
88
|
+
* GET /v2/messages/{srcDomain}?transactionHash=...
|
|
89
|
+
* GET /v2/messages/{srcDomain}?nonce=...
|
|
90
|
+
*
|
|
91
|
+
* Returns the message + attestation + forwarder state in a single
|
|
92
|
+
* call. Use this to drive recovery polling.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
type GetMessagesOptions = FetchJsonOptions & {
|
|
96
|
+
network: Network;
|
|
97
|
+
/** Defaults to Circle's Iris host for `network`. */
|
|
98
|
+
baseUrl?: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Single fetch. Returns an empty array when Iris doesn't yet know about
|
|
102
|
+
* the burn, whether it answers `messages: []` or 404.
|
|
103
|
+
*/
|
|
104
|
+
declare function getMessages(query: GetMessagesQuery, options: GetMessagesOptions): Promise<IrisMessage[]>;
|
|
105
|
+
type PollMessageOptions = GetMessagesOptions & {
|
|
106
|
+
/** Polling interval in ms. Default 3000, or from {@link pollBudget}. */
|
|
107
|
+
intervalMs?: number;
|
|
108
|
+
/** Total timeout in ms. Default 15 minutes, or from {@link pollBudget}. */
|
|
109
|
+
timeoutMs?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Custom predicate to decide when polling is "done". Default: a forwarded
|
|
112
|
+
* message once Circle's relayer is done or has failed, otherwise once the
|
|
113
|
+
* attestation is complete.
|
|
114
|
+
*/
|
|
115
|
+
isDone?: (message: IrisMessage) => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Called when a 429 makes the poll stand down, with the time it resumes.
|
|
118
|
+
* The wait does not count against `timeoutMs`.
|
|
119
|
+
*/
|
|
120
|
+
onRateLimited?: (retryAt: number) => void;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* How often and how long to poll for a route whose attestation takes
|
|
124
|
+
* `eta` seconds. Fast routes poll often so the payer hears at once; hour-long
|
|
125
|
+
* ones poll gently so they do not eat the shared rate limit.
|
|
126
|
+
*/
|
|
127
|
+
declare function pollBudget(eta: SecondsRange): {
|
|
128
|
+
intervalMs: number;
|
|
129
|
+
timeoutMs: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Circle's relayer has minted once it reports the mint `CONFIRMED` or
|
|
133
|
+
* `COMPLETE` with its tx hash. `PENDING` can carry a hash that is not mined.
|
|
134
|
+
*/
|
|
135
|
+
declare function isForwardDone(message: IrisMessage): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the message once `isDone` holds, or on timeout the latest one
|
|
138
|
+
* seen (`null` if none). Throws if Iris keeps failing; a slow attestation
|
|
139
|
+
* only times out.
|
|
140
|
+
*/
|
|
141
|
+
declare function pollMessages(query: GetMessagesQuery, options: PollMessageOptions): Promise<IrisMessage | null>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Iris reattest endpoint.
|
|
145
|
+
*
|
|
146
|
+
* POST /v2/reattest/{nonce}
|
|
147
|
+
*
|
|
148
|
+
* Asks Circle to sign an expired or pre-finality message again. Circle only
|
|
149
|
+
* acknowledges the request; the new attestation is then read from
|
|
150
|
+
* `/v2/messages` by nonce.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
type ReattestOptions = FetchJsonOptions & {
|
|
154
|
+
network: Network;
|
|
155
|
+
};
|
|
156
|
+
/** Returns Circle's acknowledgement, or `null` when Iris has no such nonce. */
|
|
157
|
+
declare function reattest(nonce: string, options: ReattestOptions): Promise<{
|
|
158
|
+
nonce: string;
|
|
159
|
+
} | null>;
|
|
160
|
+
|
|
161
|
+
type UpfrontFeeType = "FORWARD" | "PRE_FINALITY";
|
|
162
|
+
type SignedBurnQuoteRequest = {
|
|
163
|
+
/** The burn amount in USDC subunits. The quote is bound to it. */
|
|
164
|
+
amount: bigint;
|
|
165
|
+
/** The source chain's USDC: Whisk pays fees in USDC, never native gas. */
|
|
166
|
+
feeToken: Address;
|
|
167
|
+
requests: readonly UpfrontFeeType[];
|
|
168
|
+
};
|
|
169
|
+
type SignedQuoteExpiry = {
|
|
170
|
+
mode: "TIMESTAMP";
|
|
171
|
+
expiresAt: number;
|
|
172
|
+
} | {
|
|
173
|
+
mode: "BLOCK_NUMBER";
|
|
174
|
+
expiresAtBlock: bigint;
|
|
175
|
+
};
|
|
176
|
+
type SignedBurnQuote = {
|
|
177
|
+
/** Submitted as-is to `TokenMessengerWithFees`. */
|
|
178
|
+
signedQuote: `0x${string}`;
|
|
179
|
+
/** Circle's clock, in Unix seconds. */
|
|
180
|
+
issuedAt: number;
|
|
181
|
+
expiry: SignedQuoteExpiry;
|
|
182
|
+
feeTotalAmount: bigint;
|
|
183
|
+
feeToken: Address;
|
|
184
|
+
/**
|
|
185
|
+
* Absent from Circle's schema but present in its replies. When it is
|
|
186
|
+
* missing, the contract alone holds the quote to the amount.
|
|
187
|
+
*/
|
|
188
|
+
burnAmount?: bigint;
|
|
189
|
+
items: {
|
|
190
|
+
type: UpfrontFeeType;
|
|
191
|
+
amount: bigint;
|
|
192
|
+
}[];
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* `POST /v2/quote/burn/usdc/{source}/{destination}`: Circle's signed price
|
|
196
|
+
* for paying the Fast and forwarding fees on the source chain. No API key.
|
|
197
|
+
*/
|
|
198
|
+
declare function getSignedBurnQuote(network: Network, sourceDomain: CctpDomain, destinationDomain: CctpDomain, request: SignedBurnQuoteRequest, options?: FetchJsonOptions): Promise<SignedBurnQuote>;
|
|
199
|
+
/**
|
|
200
|
+
* Circle's remaining Fast Transfer allowance, in USDC subunits rounded down.
|
|
201
|
+
* Iris sends it as a JSON number of whole USDC.
|
|
202
|
+
*/
|
|
203
|
+
declare function getFastBurnAllowance(network: Network, options?: FetchJsonOptions): Promise<bigint>;
|
|
204
|
+
|
|
205
|
+
export { BurnFeeTier, type FetchJsonOptions, ForwarderFeeTier, type GetBurnFeesOptions, type GetMessagesOptions, GetMessagesQuery, IRIS_MAINNET_URL, IRIS_SANDBOX_URL, type IrisLimiter, type IrisLimiterOptions, IrisMessage, type PollMessageOptions, type ReattestOptions, type SignedBurnQuote, type SignedBurnQuoteRequest, type SignedQuoteExpiry, TransferSpeed, type UpfrontFeeType, createIrisLimiter, defaultIrisLimiter, fetchIrisJson, getBurnFees, getFastBurnAllowance, getMessages, getSignedBurnQuote, irisBaseUrl, isForwardDone, pickFeeTier, pickForwarderFee, pollBudget, pollMessages, reattest };
|
package/dist/iris.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { N as Network, e as CctpDomain, B as BurnFeeTier, T as TransferSpeed, F as ForwarderFeeTier, m as IrisMessage, G as GetMessagesQuery, o as SecondsRange, A as Address } from './attestation-D52iUV0y.js';
|
|
2
|
+
export { i as FINALITY_FAST, j as FINALITY_STANDARD, b as FinalityThreshold, k as ForwardState, I as IrisAttestationStatus, l as IrisDelayReason, n as IrisMessagesResponse } from './attestation-D52iUV0y.js';
|
|
3
|
+
|
|
4
|
+
declare const IRIS_MAINNET_URL = "https://iris-api.circle.com";
|
|
5
|
+
declare const IRIS_SANDBOX_URL = "https://iris-api-sandbox.circle.com";
|
|
6
|
+
declare function irisBaseUrl(network: Network): string;
|
|
7
|
+
|
|
8
|
+
type IrisLimiterOptions = {
|
|
9
|
+
/** Circle's limit is 35 a second; staying under it leaves room for others. */
|
|
10
|
+
ratePerSecond?: number;
|
|
11
|
+
/** Circle blocks the IP for five minutes after a 429. */
|
|
12
|
+
standDownMs?: number;
|
|
13
|
+
now?: () => number;
|
|
14
|
+
sleep?: (ms: number) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
type IrisLimiter = {
|
|
17
|
+
/** Waits for a request slot, or throws while the host is standing down. */
|
|
18
|
+
acquire(host: string): Promise<void>;
|
|
19
|
+
/** Records a 429 and returns when requests may resume. */
|
|
20
|
+
standDown(host: string): number;
|
|
21
|
+
now(): number;
|
|
22
|
+
sleep(ms: number): Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
declare function createIrisLimiter(options?: IrisLimiterOptions): IrisLimiter;
|
|
25
|
+
/** Shared by every Iris call in the process, as Circle's limit is per IP. */
|
|
26
|
+
declare const defaultIrisLimiter: IrisLimiter;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Iris fetch wrapper with timeout, retry, and `AbortSignal`.
|
|
30
|
+
*
|
|
31
|
+
* Error mapping:
|
|
32
|
+
* - 4xx (except 429) → IrisHttpError (no retry)
|
|
33
|
+
* - 429 → IrisRateLimitedError (no retry)
|
|
34
|
+
* - 5xx → retry, then IrisHttpError
|
|
35
|
+
* - Network failure → retry, then IrisNetworkError
|
|
36
|
+
* - Caller-signaled abort → IrisAbortedError
|
|
37
|
+
* - Per-request timeout → retry, then IrisNetworkError
|
|
38
|
+
* - JSON parse failure → IrisParseError (no retry)
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type FetchJsonOptions = {
|
|
42
|
+
/** Per-request timeout in ms. Default 5000. */
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
/** Retries after the first attempt. Default 3. */
|
|
45
|
+
maxRetries?: number;
|
|
46
|
+
/** Base delay between retries in ms. Backoff multiplies by retry index. */
|
|
47
|
+
baseDelayMs?: number;
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
/** Defaults to the global `fetch`. */
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
/** Defaults to one limiter shared by every Iris call in the process. */
|
|
52
|
+
limiter?: IrisLimiter;
|
|
53
|
+
};
|
|
54
|
+
declare function fetchIrisJson<T>(url: string, options?: FetchJsonOptions, request?: {
|
|
55
|
+
method: "POST";
|
|
56
|
+
body: unknown;
|
|
57
|
+
} | {
|
|
58
|
+
method: "GET";
|
|
59
|
+
}): Promise<T>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Iris burn fees endpoint.
|
|
63
|
+
*
|
|
64
|
+
* GET /v2/burn/USDC/fees/{src}/{dst}?forward=true
|
|
65
|
+
*
|
|
66
|
+
* Returns one row per finality threshold (1000 = Fast, 2000 = Standard).
|
|
67
|
+
* Each row has the protocol fee in basis points and, with ?forward=true,
|
|
68
|
+
* the forwarder fee levels low/med/high in USDC subunits.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
type GetBurnFeesOptions = FetchJsonOptions & {
|
|
72
|
+
/** Default `true`. Set to `false` if you only need protocol fees. */
|
|
73
|
+
includeForwarderFee?: boolean;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Rows for thresholds other than Fast and Standard are dropped. Use
|
|
77
|
+
* `pickFeeTier` to choose one.
|
|
78
|
+
*/
|
|
79
|
+
declare function getBurnFees(network: Network, sourceDomain: CctpDomain, destinationDomain: CctpDomain, options?: GetBurnFeesOptions): Promise<BurnFeeTier[]>;
|
|
80
|
+
/** The row for `speed`. Throws if Iris returned none for this route. */
|
|
81
|
+
declare function pickFeeTier(tiers: readonly BurnFeeTier[], speed: TransferSpeed): BurnFeeTier;
|
|
82
|
+
/** The forwarder fee for a level, in USDC subunits. */
|
|
83
|
+
declare function pickForwarderFee(tier: BurnFeeTier, level?: keyof ForwarderFeeTier): bigint;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Iris messages endpoint.
|
|
87
|
+
*
|
|
88
|
+
* GET /v2/messages/{srcDomain}?transactionHash=...
|
|
89
|
+
* GET /v2/messages/{srcDomain}?nonce=...
|
|
90
|
+
*
|
|
91
|
+
* Returns the message + attestation + forwarder state in a single
|
|
92
|
+
* call. Use this to drive recovery polling.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
type GetMessagesOptions = FetchJsonOptions & {
|
|
96
|
+
network: Network;
|
|
97
|
+
/** Defaults to Circle's Iris host for `network`. */
|
|
98
|
+
baseUrl?: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Single fetch. Returns an empty array when Iris doesn't yet know about
|
|
102
|
+
* the burn, whether it answers `messages: []` or 404.
|
|
103
|
+
*/
|
|
104
|
+
declare function getMessages(query: GetMessagesQuery, options: GetMessagesOptions): Promise<IrisMessage[]>;
|
|
105
|
+
type PollMessageOptions = GetMessagesOptions & {
|
|
106
|
+
/** Polling interval in ms. Default 3000, or from {@link pollBudget}. */
|
|
107
|
+
intervalMs?: number;
|
|
108
|
+
/** Total timeout in ms. Default 15 minutes, or from {@link pollBudget}. */
|
|
109
|
+
timeoutMs?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Custom predicate to decide when polling is "done". Default: a forwarded
|
|
112
|
+
* message once Circle's relayer is done or has failed, otherwise once the
|
|
113
|
+
* attestation is complete.
|
|
114
|
+
*/
|
|
115
|
+
isDone?: (message: IrisMessage) => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Called when a 429 makes the poll stand down, with the time it resumes.
|
|
118
|
+
* The wait does not count against `timeoutMs`.
|
|
119
|
+
*/
|
|
120
|
+
onRateLimited?: (retryAt: number) => void;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* How often and how long to poll for a route whose attestation takes
|
|
124
|
+
* `eta` seconds. Fast routes poll often so the payer hears at once; hour-long
|
|
125
|
+
* ones poll gently so they do not eat the shared rate limit.
|
|
126
|
+
*/
|
|
127
|
+
declare function pollBudget(eta: SecondsRange): {
|
|
128
|
+
intervalMs: number;
|
|
129
|
+
timeoutMs: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Circle's relayer has minted once it reports the mint `CONFIRMED` or
|
|
133
|
+
* `COMPLETE` with its tx hash. `PENDING` can carry a hash that is not mined.
|
|
134
|
+
*/
|
|
135
|
+
declare function isForwardDone(message: IrisMessage): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the message once `isDone` holds, or on timeout the latest one
|
|
138
|
+
* seen (`null` if none). Throws if Iris keeps failing; a slow attestation
|
|
139
|
+
* only times out.
|
|
140
|
+
*/
|
|
141
|
+
declare function pollMessages(query: GetMessagesQuery, options: PollMessageOptions): Promise<IrisMessage | null>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Iris reattest endpoint.
|
|
145
|
+
*
|
|
146
|
+
* POST /v2/reattest/{nonce}
|
|
147
|
+
*
|
|
148
|
+
* Asks Circle to sign an expired or pre-finality message again. Circle only
|
|
149
|
+
* acknowledges the request; the new attestation is then read from
|
|
150
|
+
* `/v2/messages` by nonce.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
type ReattestOptions = FetchJsonOptions & {
|
|
154
|
+
network: Network;
|
|
155
|
+
};
|
|
156
|
+
/** Returns Circle's acknowledgement, or `null` when Iris has no such nonce. */
|
|
157
|
+
declare function reattest(nonce: string, options: ReattestOptions): Promise<{
|
|
158
|
+
nonce: string;
|
|
159
|
+
} | null>;
|
|
160
|
+
|
|
161
|
+
type UpfrontFeeType = "FORWARD" | "PRE_FINALITY";
|
|
162
|
+
type SignedBurnQuoteRequest = {
|
|
163
|
+
/** The burn amount in USDC subunits. The quote is bound to it. */
|
|
164
|
+
amount: bigint;
|
|
165
|
+
/** The source chain's USDC: Whisk pays fees in USDC, never native gas. */
|
|
166
|
+
feeToken: Address;
|
|
167
|
+
requests: readonly UpfrontFeeType[];
|
|
168
|
+
};
|
|
169
|
+
type SignedQuoteExpiry = {
|
|
170
|
+
mode: "TIMESTAMP";
|
|
171
|
+
expiresAt: number;
|
|
172
|
+
} | {
|
|
173
|
+
mode: "BLOCK_NUMBER";
|
|
174
|
+
expiresAtBlock: bigint;
|
|
175
|
+
};
|
|
176
|
+
type SignedBurnQuote = {
|
|
177
|
+
/** Submitted as-is to `TokenMessengerWithFees`. */
|
|
178
|
+
signedQuote: `0x${string}`;
|
|
179
|
+
/** Circle's clock, in Unix seconds. */
|
|
180
|
+
issuedAt: number;
|
|
181
|
+
expiry: SignedQuoteExpiry;
|
|
182
|
+
feeTotalAmount: bigint;
|
|
183
|
+
feeToken: Address;
|
|
184
|
+
/**
|
|
185
|
+
* Absent from Circle's schema but present in its replies. When it is
|
|
186
|
+
* missing, the contract alone holds the quote to the amount.
|
|
187
|
+
*/
|
|
188
|
+
burnAmount?: bigint;
|
|
189
|
+
items: {
|
|
190
|
+
type: UpfrontFeeType;
|
|
191
|
+
amount: bigint;
|
|
192
|
+
}[];
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* `POST /v2/quote/burn/usdc/{source}/{destination}`: Circle's signed price
|
|
196
|
+
* for paying the Fast and forwarding fees on the source chain. No API key.
|
|
197
|
+
*/
|
|
198
|
+
declare function getSignedBurnQuote(network: Network, sourceDomain: CctpDomain, destinationDomain: CctpDomain, request: SignedBurnQuoteRequest, options?: FetchJsonOptions): Promise<SignedBurnQuote>;
|
|
199
|
+
/**
|
|
200
|
+
* Circle's remaining Fast Transfer allowance, in USDC subunits rounded down.
|
|
201
|
+
* Iris sends it as a JSON number of whole USDC.
|
|
202
|
+
*/
|
|
203
|
+
declare function getFastBurnAllowance(network: Network, options?: FetchJsonOptions): Promise<bigint>;
|
|
204
|
+
|
|
205
|
+
export { BurnFeeTier, type FetchJsonOptions, ForwarderFeeTier, type GetBurnFeesOptions, type GetMessagesOptions, GetMessagesQuery, IRIS_MAINNET_URL, IRIS_SANDBOX_URL, type IrisLimiter, type IrisLimiterOptions, IrisMessage, type PollMessageOptions, type ReattestOptions, type SignedBurnQuote, type SignedBurnQuoteRequest, type SignedQuoteExpiry, TransferSpeed, type UpfrontFeeType, createIrisLimiter, defaultIrisLimiter, fetchIrisJson, getBurnFees, getFastBurnAllowance, getMessages, getSignedBurnQuote, irisBaseUrl, isForwardDone, pickFeeTier, pickForwarderFee, pollBudget, pollMessages, reattest };
|