@coinlist-co/react 0.11.1-rc.e102bdb → 0.12.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.
Files changed (33) hide show
  1. package/dist/{chunk-7CTH4KPU.js → chunk-6CQHDASY.js} +648 -620
  2. package/dist/chunk-6CQHDASY.js.map +1 -0
  3. package/dist/{chunk-UZUQALFY.js → chunk-F6WGUKZC.js} +9 -9
  4. package/dist/chunk-F6WGUKZC.js.map +1 -0
  5. package/dist/{chunk-LSPZETDH.js → chunk-ZFBEI3BW.js} +131 -134
  6. package/dist/chunk-ZFBEI3BW.js.map +1 -0
  7. package/dist/client/index.cjs +1489 -1346
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +395 -254
  10. package/dist/client/index.d.ts +395 -254
  11. package/dist/client/index.js +852 -739
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-BBI_XydI.d.cts → collections-DOm9VKVm.d.cts} +1 -1
  14. package/dist/{collections-BrX9rRWc.d.ts → collections-aCv-Wr2a.d.ts} +1 -1
  15. package/dist/{config-CMl1bR3F.d.cts → config-DIaFzrMW.d.cts} +56 -13
  16. package/dist/{config-CMl1bR3F.d.ts → config-DIaFzrMW.d.ts} +56 -13
  17. package/dist/server/index.cjs +262 -236
  18. package/dist/server/index.cjs.map +1 -1
  19. package/dist/server/index.d.cts +4 -4
  20. package/dist/server/index.d.ts +4 -4
  21. package/dist/server/index.js +3 -3
  22. package/dist/server/index.js.map +1 -1
  23. package/dist/{shared → universal}/index.cjs +948 -919
  24. package/dist/universal/index.cjs.map +1 -0
  25. package/dist/{shared → universal}/index.d.cts +566 -536
  26. package/dist/{shared → universal}/index.d.ts +566 -536
  27. package/dist/{shared → universal}/index.js +9 -5
  28. package/package.json +23 -17
  29. package/dist/chunk-7CTH4KPU.js.map +0 -1
  30. package/dist/chunk-LSPZETDH.js.map +0 -1
  31. package/dist/chunk-UZUQALFY.js.map +0 -1
  32. package/dist/shared/index.cjs.map +0 -1
  33. /package/dist/{shared → universal}/index.js.map +0 -0
@@ -5,12 +5,12 @@ import {
5
5
  HttpError,
6
6
  Request,
7
7
  getUUIDv4
8
- } from "./chunk-7CTH4KPU.js";
8
+ } from "./chunk-6CQHDASY.js";
9
9
 
10
- // src/shared/api/nabu/config.ts
10
+ // src/universal/api/nabu/config.ts
11
11
  var NABU_BASE_URL = "https://asset.coinlist.co";
12
12
 
13
- // src/shared/core/observability/pino-logger.ts
13
+ // src/universal/core/shared/observability/pino-logger.ts
14
14
  function toPinoRecord(event) {
15
15
  try {
16
16
  const record = {};
@@ -136,7 +136,7 @@ function reportRenderFailure(sink, error) {
136
136
  }
137
137
  }
138
138
 
139
- // src/shared/api/middleware/attach-session-middleware.ts
139
+ // src/universal/api/middleware/attach-session-middleware.ts
140
140
  function attachSessionMiddleware(fetchAccessToken) {
141
141
  return async (request) => {
142
142
  if (!Attributes.isProtected(request.attributes)) {
@@ -162,7 +162,7 @@ function attachSessionMiddleware(fetchAccessToken) {
162
162
  };
163
163
  }
164
164
 
165
- // src/shared/api/middleware/idempotency-key.ts
165
+ // src/universal/api/middleware/idempotency-key.ts
166
166
  var idempotencyKeyMiddleware = async (request) => {
167
167
  if (!Attributes.isIdempotent(request.attributes)) {
168
168
  return request;
@@ -180,7 +180,7 @@ var idempotencyKeyMiddleware = async (request) => {
180
180
  };
181
181
  };
182
182
 
183
- // src/shared/api/middleware/request-retry.ts
183
+ // src/universal/api/middleware/request-retry.ts
184
184
  var MAX_ATTEMPTS = 3;
185
185
  var INITIAL_DELAY_MS = 300;
186
186
  var MAX_DELAY_MS = 2e3;
@@ -215,7 +215,7 @@ function defaultDelay(ms) {
215
215
  }
216
216
  var requestRetryMiddleware = createRequestRetryMiddleware();
217
217
 
218
- // src/shared/api/middleware/session-renewal.ts
218
+ // src/universal/api/middleware/session-renewal.ts
219
219
  function renewSessionMiddleware(fetchAccessToken) {
220
220
  return async ({ request, response, retry }) => {
221
221
  if (response.status !== 401) {
@@ -240,7 +240,7 @@ function renewSessionMiddleware(fetchAccessToken) {
240
240
  };
241
241
  }
242
242
 
243
- // src/shared/api/authenticated-api-client.ts
243
+ // src/universal/api/authenticated-api-client.ts
244
244
  var AuthenticatedApiClient = class {
245
245
  constructor(config, fetchAccessToken, additionalBeforeRequest = [], logger = null) {
246
246
  this.httpClient = new HttpClient(
@@ -276,4 +276,4 @@ export {
276
276
  SDK_LOGGER_NAME,
277
277
  loggerOverPino
278
278
  };
279
- //# sourceMappingURL=chunk-UZUQALFY.js.map
279
+ //# sourceMappingURL=chunk-F6WGUKZC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/universal/api/nabu/config.ts","../src/universal/core/shared/observability/pino-logger.ts","../src/universal/api/middleware/attach-session-middleware.ts","../src/universal/api/middleware/idempotency-key.ts","../src/universal/api/middleware/request-retry.ts","../src/universal/api/middleware/session-renewal.ts","../src/universal/api/authenticated-api-client.ts"],"sourcesContent":["/**\n * Base URL of CoinList's public token registry (Nabu), a static CDN serving\n * token display metadata keyed by chain + contract address. Override per\n * environment via `Config.tokensBaseUrl`.\n */\nexport const NABU_BASE_URL = 'https://asset.coinlist.co';\n","import type {\n DebugEvent,\n Logger,\n LogLevel,\n SafeEvent,\n} from '@/universal/types/logger';\n\n/**\n * The SDK's logging seam expressed over pino, minus the environment.\n *\n * Imports no pino - {@link PinoSink} is a structural type - so `@/universal`\n * stays pino-free and the `./universal` entry point costs a consumer nothing.\n * Both shipped implementations\n * ({@link pinoClientLogger}, {@link pinoServerLogger}) differ only in the pino\n * instance they construct; everything worth testing lives here.\n *\n * ## Nothing here may throw\n *\n * A {@link Logger} implementation is called inline, on the codepath of the\n * work it reports, and the SDK does not catch it - so a log line that fails to\n * render would turn a successful request into an exception. That risk is real\n * rather than theoretical: `'debug'` fields carry whatever the SDK was\n * handling, and this codebase routinely handles `bigint` (every uint256 on\n * every DTO), which `JSON.stringify` throws on. Response bodies may be\n * circular, params may hold functions, and a host's object may have a getter\n * that throws.\n *\n * So {@link toPinoRecord} is total by construction: every value is rendered\n * into something a JSON serialiser cannot refuse, every property read is\n * guarded, and the whole translation has a fallback. Pino is never handed a\n * value it could fail on.\n */\n\n/**\n * Flattens an event into the object pino merges into its output line.\n *\n * Flat rather than nested, because nesting is what a host has to un-nest\n * before they can facet on it: `scope`, the {@link LogBindings} and every\n * field sit at the top level, and only `cause` stays an object because its\n * arms are a closed union a host switches on.\n *\n * `msg` is **not** included: it is pino's own second argument.\n *\n * Never throws. A value it cannot render becomes a `<tag>` string rather than\n * an exception, and a translation that fails entirely degrades to a record\n * naming the failure.\n */\nexport function toPinoRecord(event: SafeEvent | DebugEvent): PinoRecord {\n try {\n const record: Record<string, unknown> = {};\n\n for (const key of ownKeys(event.fields)) {\n record[key] = readProperty(event.fields, key, 0, new WeakSet());\n }\n\n const cause = 'cause' in event ? event.cause : undefined;\n if (cause !== undefined) {\n record.cause = sanitize(cause, 0, new WeakSet());\n }\n\n // Last, so the stamped keys win. `scope` and the bindings are what a host\n // routes and filters on, and they are stamped by `internalLogger` rather\n // than written at a call site - so a field that happened to be named\n // `scope` or `op` must not be able to take their place.\n return { ...record, scope: event.scope, ...event.bindings };\n } catch (_) {\n // The event itself is malformed - a Proxy for `fields`, a frozen exotic\n // object. Report that rather than losing the line, and never rethrow.\n return { 'log.render': '<unrenderable event>' };\n }\n}\n\n/** What pino merges into one output line. */\nexport type PinoRecord = Readonly<Record<string, unknown>>;\n\n/**\n * The SDK's five levels in pino's vocabulary.\n *\n * `'none'` is pino's `'silent'`; the other four are the same word in both, and\n * deliberately so. The SDK does not adopt pino's seven because `'trace'` would\n * sit below `'debug'`, and the guarantee \"`debug` is unredacted and every\n * other level is not\" only closes while `'debug'` is the bottom.\n */\nexport const PINO_LEVEL = {\n none: 'silent',\n error: 'error',\n warn: 'warn',\n info: 'info',\n debug: 'debug',\n} as const satisfies Record<LogLevel, string>;\n\n/**\n * How deep a `'debug'` field is followed before it is summarised.\n *\n * A bound rather than a guess at what is deep enough: a self-referential\n * structure is already caught by the cycle check, but a legitimately deep DTO\n * would otherwise cost real time inside a log line.\n */\nconst MAX_DEPTH = 8;\n\n/**\n * Renders any value into something a JSON serialiser cannot refuse.\n *\n * `bigint` is the one that matters in practice - every uint256 the SDK handles\n * is one - but the rest are all reachable from a `'debug'` field: `undefined`\n * and functions from an operation's params, `NaN` from arithmetic, symbols\n * from a host's object.\n */\nfunction sanitize(\n value: unknown,\n depth: number,\n seen: WeakSet<object>\n): unknown {\n switch (typeof value) {\n case 'string':\n case 'boolean':\n return value;\n case 'number':\n // `NaN` and the infinities serialise to `null`, which reads as \"absent\"\n // rather than \"not a number\". Name them instead.\n return Number.isFinite(value) ? value : String(value);\n case 'bigint':\n return value.toString();\n case 'undefined':\n return '<undefined>';\n case 'function':\n return '<function>';\n case 'symbol':\n return value.toString();\n case 'object':\n return value === null ? null : sanitizeObject(value, depth, seen);\n default:\n return '<unrenderable>';\n }\n}\n\nfunction sanitizeObject(\n value: object,\n depth: number,\n seen: WeakSet<object>\n): unknown {\n if (seen.has(value)) return '<circular>';\n if (depth >= MAX_DEPTH) return '<max depth>';\n\n // `name`, `message` and `stack` are all non-enumerable, so an `Error` handed\n // to a structured sink as an object serialises to `{}`.\n if (value instanceof Error) return describeError(value);\n if (value instanceof Date) return describeDate(value);\n\n seen.add(value);\n try {\n if (Array.isArray(value)) {\n return value.map((_item, index) =>\n readProperty(value, String(index), depth, seen)\n );\n }\n\n const out: Record<string, unknown> = {};\n for (const key of ownKeys(value)) {\n out[key] = readProperty(value, key, depth, seen);\n }\n return out;\n } finally {\n // Removed on the way out, so a value referenced twice in a tree renders\n // twice. Only a genuine cycle is `<circular>`.\n seen.delete(value);\n }\n}\n\n/**\n * One property read, guarded. A getter may throw, and a log line is not\n * allowed to be the reason a request fails.\n */\nfunction readProperty(\n owner: object,\n key: string,\n depth: number,\n seen: WeakSet<object>\n): unknown {\n try {\n return sanitize((owner as Record<string, unknown>)[key], depth + 1, seen);\n } catch (_) {\n return '<unreadable>';\n }\n}\n\n/** Own enumerable keys, guarded: an exotic object may refuse to be enumerated. */\nfunction ownKeys(value: object): readonly string[] {\n try {\n return Object.keys(value);\n } catch (_) {\n return [];\n }\n}\n\nfunction describeError(error: Error): Record<string, unknown> {\n return {\n name: safeRead(() => error.name),\n message: safeRead(() => error.message),\n stack: safeRead(() => error.stack),\n };\n}\n\nfunction describeDate(date: Date): unknown {\n // An invalid `Date` throws from `toISOString`.\n return safeRead(() => date.toISOString());\n}\n\nfunction safeRead(read: () => unknown): unknown {\n try {\n const value = read();\n return typeof value === 'string' ? value : '<unreadable>';\n } catch (_) {\n return '<unreadable>';\n }\n}\n\n/**\n * The part of a pino logger this adapter uses.\n *\n * Structural rather than `import type { Logger } from 'pino'`, so that\n * `@/universal` takes no dependency on pino at all. A real pino instance - node\n * or browser build - satisfies it.\n */\nexport type PinoSink = {\n debug(record: PinoRecord, msg: string): void;\n info(record: PinoRecord, msg: string): void;\n warn(record: PinoRecord, msg: string): void;\n error(record: PinoRecord, msg: string): void;\n};\n\n/**\n * The `name` binding every SDK line carries, so a partner can separate the\n * SDK's output from their own in a shared aggregator without matching on\n * `scope`.\n *\n * Applied through `pino.child({ name })` rather than pino's `name` *option*,\n * which its browser build ignores. The browser lane's spec is what caught\n * that, and is what keeps it caught.\n */\nexport const SDK_LOGGER_NAME = '@coinlist-co/react';\n\n/**\n * Adapts a pino instance into the {@link Logger} the SDK consumes.\n *\n * **Total, and that is the point.** The SDK calls a `Logger` inline and does\n * not catch it, so an exception raised while reporting a successful request\n * would fail that request. Three things could raise one - the event lambda\n * itself, rendering the event, and the sink - and all three are caught here.\n * A render failure is reported through the sink rather than swallowed, since a\n * log line that silently vanishes is a bug nobody finds; if the sink is what\n * broke, there is nowhere left to report it and the error stops here.\n *\n * **The level is fixed here, and that is this adapter's choice rather than the\n * seam's.** {@link InternalLogger} calls {@link Logger.level} before *every*\n * log call and caches nothing, so a host-implemented `Logger` reading a mutable\n * field has a level they can change at runtime. This adapter captures `level`\n * instead, and the pino instance it wraps is built with a fixed one - so\n * `Logger.level` is a constant lookup and two loggers never interfere. A host\n * who wants to turn `'debug'` on without rebuilding implements {@link Logger}\n * directly over their own pino instance; the port is four methods and this\n * function is the worked example.\n */\nexport function loggerOverPino(sink: PinoSink, level: LogLevel): Logger {\n return {\n level: () => level,\n debug: (event) => emit(sink, 'debug', event),\n info: (event) => emit(sink, 'info', event),\n warn: (event) => emit(sink, 'warn', event),\n error: (event) => emit(sink, 'error', event),\n };\n}\n\nfunction emit(\n sink: PinoSink,\n method: keyof PinoSink,\n event: () => SafeEvent | DebugEvent\n): void {\n try {\n const value = event();\n sink[method](toPinoRecord(value), value.msg);\n } catch (error) {\n reportRenderFailure(sink, error);\n }\n}\n\nfunction reportRenderFailure(sink: PinoSink, error: unknown): void {\n try {\n sink.error(\n { 'error.type': error instanceof Error ? error.name : typeof error },\n 'log event failed to render'\n );\n } catch (_) {\n // The sink itself threw. There is nowhere left to report this, and the SDK\n // is on the other side of the call that got us here.\n }\n}\n","import type { HttpRequest } from '@/universal/api/http';\nimport { Attributes } from '@/universal/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/universal/api/http-client';\nimport type { OAuthAccessToken } from '@/universal/types/oauth-session';\n\nexport function attachSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): BeforeRequestMiddleware {\n return async (request: HttpRequest): Promise<HttpRequest> => {\n if (!Attributes.isProtected(request.attributes)) {\n return request;\n }\n\n let accessToken = await fetchAccessToken(false);\n if (!accessToken) {\n const clientCreds = Attributes.getClientCredentials(request.attributes);\n if (clientCreds) {\n accessToken = clientCreds;\n }\n }\n\n if (accessToken === null) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...(request.headers ?? {}),\n Authorization: `Bearer ${accessToken.value}`,\n },\n };\n };\n}\n","import { HEADER_IDEMPOTENCY_KEY } from '@/universal/api/frontline/config';\nimport type { HttpRequest } from '@/universal/api/http';\nimport { Attributes } from '@/universal/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/universal/api/http-client';\nimport { getUUIDv4 } from '@/universal/core/shared/utils/crypto';\n\nexport const idempotencyKeyMiddleware: BeforeRequestMiddleware = async (\n request: HttpRequest\n): Promise<HttpRequest> => {\n if (!Attributes.isIdempotent(request.attributes)) {\n return request;\n }\n\n const existingHeaders = request.headers ?? {};\n if (existingHeaders[HEADER_IDEMPOTENCY_KEY]) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...existingHeaders,\n [HEADER_IDEMPOTENCY_KEY]: getUUIDv4(),\n },\n };\n};\n","import { Request } from '@/universal/api/http';\nimport { Attributes } from '@/universal/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/universal/api/http-client';\n\nconst MAX_ATTEMPTS = 3;\nconst INITIAL_DELAY_MS = 300;\nconst MAX_DELAY_MS = 2000;\n\nconst RETRYABLE_4XX = new Set([408, 409, 429]);\n\nexport function isRetryableStatus(status: number): boolean {\n return (status >= 500 && status < 600) || RETRYABLE_4XX.has(status);\n}\n\nfunction getRetryDelayMs(attempt: number): number {\n return Math.min(INITIAL_DELAY_MS * 2 ** (attempt - 1), MAX_DELAY_MS);\n}\n\nexport type RequestRetryMiddlewareOptions = {\n /**\n * Optional delay function. Defaults to real setTimeout-based delay.\n * Use a no-op (e.g. () => Promise.resolve()) in tests to avoid slow tests.\n */\n delayFn?: (ms: number) => Promise<void>;\n};\n\n/**\n * Creates the request retry after-request middleware. Inject a no-op delayFn\n * in tests to avoid real delays (unit testing best practice).\n */\nexport function createRequestRetryMiddleware(\n options: RequestRetryMiddlewareOptions = {}\n): AfterRequestMiddleware {\n const delayFn = options.delayFn ?? defaultDelay;\n\n return async ({ request, response, retry }) => {\n if (!isRetryableStatus(response.status)) {\n return response;\n }\n\n const currentAttempt = Attributes.getRetryAttempt(request.attributes);\n if (currentAttempt >= MAX_ATTEMPTS - 1) {\n return response;\n }\n\n const nextAttempt = currentAttempt + 1;\n await delayFn(getRetryDelayMs(nextAttempt));\n\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.retryAttempt(nextAttempt)\n );\n return retry(nextRequest);\n };\n}\n\nfunction defaultDelay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Retries the request up to 3 times with exponential backoff when the response\n * has a retryable status (5xx server errors). Uses request.attributes.retryAttempt\n * to decide delay and whether to retry, so the middleware does not loop when\n * retry() runs the full HTTP middleware chain again.\n */\nexport const requestRetryMiddleware: AfterRequestMiddleware =\n createRequestRetryMiddleware();\n","import { Request } from '@/universal/api/http';\nimport { Attributes } from '@/universal/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/universal/api/http-client';\nimport type { OAuthAccessToken } from '@/universal/types/oauth-session';\n\nexport function renewSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): AfterRequestMiddleware {\n return async ({ request, response, retry }) => {\n if (response.status !== 401) {\n return response;\n }\n if (!Attributes.isProtected(request.attributes)) {\n return response;\n }\n if (Attributes.wasRenewAttempted(request.attributes)) {\n return response;\n }\n\n const newToken = await fetchAccessToken(true);\n if (newToken) {\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.renewAttempted(true)\n );\n return retry(nextRequest);\n } else {\n return response;\n }\n };\n}\n","import type { HttpClientConfig, HttpRequest } from '@/universal/api/http';\nimport { HttpError } from '@/universal/api/http';\nimport type { BeforeRequestMiddleware } from '@/universal/api/http-client';\nimport { HttpClient } from '@/universal/api/http-client';\nimport { attachSessionMiddleware } from '@/universal/api/middleware/attach-session-middleware';\nimport { idempotencyKeyMiddleware } from '@/universal/api/middleware/idempotency-key';\nimport { requestRetryMiddleware } from '@/universal/api/middleware/request-retry';\nimport { renewSessionMiddleware } from '@/universal/api/middleware/session-renewal';\nimport type { Logger } from '@/universal/types/logger';\nimport type { OAuthAccessToken } from '@/universal/types/oauth-session';\n\n/**\n * Isomorphic HTTP client with session attachment, session renewal on 401,\n * idempotency key injection, and request retry. Works in both browser and\n * Node/server environments. Pass `additionalBeforeRequest` to inject\n * environment-specific middleware (e.g. `userAgentMiddleware` on the client).\n *\n * Pass `logger` through to have every request reported; the client logs\n * nothing without one.\n */\nexport class AuthenticatedApiClient {\n private readonly httpClient: HttpClient;\n\n constructor(\n config: HttpClientConfig,\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>,\n additionalBeforeRequest: BeforeRequestMiddleware[] = [],\n logger: Logger | null = null\n ) {\n this.httpClient = new HttpClient(\n config,\n {\n beforeRequest: [\n attachSessionMiddleware(fetchAccessToken),\n ...additionalBeforeRequest,\n idempotencyKeyMiddleware,\n ],\n afterRequest: [\n renewSessionMiddleware(fetchAccessToken),\n requestRetryMiddleware,\n ],\n },\n logger\n );\n }\n\n async send<TResponse>(request: HttpRequest): Promise<TResponse> {\n const response = await this.httpClient.send<TResponse>(request);\n if (response.status >= 200 && response.status < 300) {\n return response.body as TResponse;\n } else {\n throw new HttpError(response);\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAKO,IAAM,gBAAgB;;;AC0CtB,SAAS,aAAa,OAA2C;AACtE,MAAI;AACF,UAAM,SAAkC,CAAC;AAEzC,eAAW,OAAO,QAAQ,MAAM,MAAM,GAAG;AACvC,aAAO,GAAG,IAAI,aAAa,MAAM,QAAQ,KAAK,GAAG,oBAAI,QAAQ,CAAC;AAAA,IAChE;AAEA,UAAM,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AAC/C,QAAI,UAAU,QAAW;AACvB,aAAO,QAAQ,SAAS,OAAO,GAAG,oBAAI,QAAQ,CAAC;AAAA,IACjD;AAMA,WAAO,EAAE,GAAG,QAAQ,OAAO,MAAM,OAAO,GAAG,MAAM,SAAS;AAAA,EAC5D,SAAS,GAAG;AAGV,WAAO,EAAE,cAAc,uBAAuB;AAAA,EAChD;AACF;AAaO,IAAM,aAAa;AAAA,EACxB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM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ACvC;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,KAAgB,SAA0C;AAC9D,UAAM,WAAW,MAAM,KAAK,WAAW,KAAgB,OAAO;AAC9D,QAAI,SAAS,UAAU,OAAO,SAAS,SAAS,KAAK;AACnD,aAAO,SAAS;AAAA,IAClB,OAAO;AACL,YAAM,IAAI,UAAU,QAAQ;AAAA,IAC9B;AAAA,EACF;AACF;","names":[]}
@@ -18,9 +18,9 @@ import {
18
18
  generateSecureRandomBase64Url,
19
19
  internalLogger,
20
20
  sha256
21
- } from "./chunk-7CTH4KPU.js";
21
+ } from "./chunk-6CQHDASY.js";
22
22
 
23
- // src/shared/types/oauth.ts
23
+ // src/universal/types/oauth.ts
24
24
  var AuthorizationCode = (value) => value;
25
25
  var CodeVerifier = (value) => value;
26
26
  var CodeChallenge = (value) => value;
@@ -29,7 +29,7 @@ var RedirectUri = (value) => value;
29
29
  var ClientId = (value) => value;
30
30
  var ClientSecret = (value) => value;
31
31
 
32
- // src/shared/core/auth/pkce.ts
32
+ // src/universal/core/auth/pkce.ts
33
33
  async function generatePKCEParams(config) {
34
34
  const state = generateSecureRandomBase64Url(32);
35
35
  const codeVerifier = generateSecureRandomBase64Url(32);
@@ -46,113 +46,7 @@ async function generatePKCEParams(config) {
46
46
  };
47
47
  }
48
48
 
49
- // src/shared/core/blockchain/bps.ts
50
- var BPS_DENOM = Bps(10000n);
51
- function applyBps(amount, bps) {
52
- return assertUint256(amount * bps / BPS_DENOM);
53
- }
54
-
55
- // src/shared/core/blockchain/erc20/abi.ts
56
- var ERC20_ABI = [
57
- {
58
- type: "function",
59
- name: "allowance",
60
- inputs: [
61
- { name: "owner", type: "address" },
62
- { name: "spender", type: "address" }
63
- ],
64
- outputs: [{ name: "", type: "uint256" }],
65
- stateMutability: "view"
66
- },
67
- {
68
- type: "function",
69
- name: "approve",
70
- inputs: [
71
- { name: "spender", type: "address" },
72
- { name: "amount", type: "uint256" }
73
- ],
74
- outputs: [{ name: "", type: "bool" }],
75
- stateMutability: "nonpayable"
76
- },
77
- {
78
- type: "function",
79
- name: "balanceOf",
80
- inputs: [{ name: "account", type: "address" }],
81
- outputs: [{ name: "", type: "uint256" }],
82
- stateMutability: "view"
83
- },
84
- {
85
- type: "function",
86
- name: "decimals",
87
- inputs: [],
88
- outputs: [{ name: "", type: "uint8" }],
89
- stateMutability: "view"
90
- },
91
- {
92
- type: "function",
93
- name: "name",
94
- inputs: [],
95
- outputs: [{ name: "", type: "string" }],
96
- stateMutability: "view"
97
- },
98
- {
99
- type: "function",
100
- name: "symbol",
101
- inputs: [],
102
- outputs: [{ name: "", type: "string" }],
103
- stateMutability: "view"
104
- },
105
- {
106
- type: "function",
107
- name: "totalSupply",
108
- inputs: [],
109
- outputs: [{ name: "", type: "uint256" }],
110
- stateMutability: "view"
111
- },
112
- {
113
- type: "function",
114
- name: "transfer",
115
- inputs: [
116
- { name: "recipient", type: "address" },
117
- { name: "amount", type: "uint256" }
118
- ],
119
- outputs: [{ name: "", type: "bool" }],
120
- stateMutability: "nonpayable"
121
- },
122
- {
123
- type: "function",
124
- name: "transferFrom",
125
- inputs: [
126
- { name: "sender", type: "address" },
127
- { name: "recipient", type: "address" },
128
- { name: "amount", type: "uint256" }
129
- ],
130
- outputs: [{ name: "", type: "bool" }],
131
- stateMutability: "nonpayable"
132
- },
133
- {
134
- type: "event",
135
- name: "Approval",
136
- inputs: [
137
- { name: "owner", type: "address", indexed: true },
138
- { name: "spender", type: "address", indexed: true },
139
- { name: "value", type: "uint256", indexed: false }
140
- ],
141
- anonymous: false
142
- },
143
- {
144
- type: "event",
145
- name: "Transfer",
146
- inputs: [
147
- { name: "from", type: "address", indexed: true },
148
- { name: "to", type: "address", indexed: true },
149
- { name: "value", type: "uint256", indexed: false }
150
- ],
151
- anonymous: false
152
- }
153
- ];
154
-
155
- // src/shared/core/blockchain/token-registry.ts
49
+ // src/universal/core/shared/blockchain/token-registry.ts
156
50
  var USDC_SYMBOL = StablecoinSymbol("USDC");
157
51
  var USDC = {
158
52
  name: "USD Coin",
@@ -215,15 +109,7 @@ var TOKEN_REGISTRY = {
215
109
  usdtAddress: (chain) => USDT_ADDRESSES[chain]
216
110
  };
217
111
 
218
- // src/shared/core/checkout/ondo/constants.ts
219
- var ONDO_SWAP_CONTRACT_ADDRESSES = {
220
- ethereum_sepolia: EvmContractAddress(
221
- "0x7014019ed51Edab984a71D30F2707D2dB2316A7A"
222
- )
223
- };
224
- function ondoSwapContractAddress(chain) {
225
- return ONDO_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
226
- }
112
+ // src/universal/core/checkout/ondo/constants.ts
227
113
  var ONDO_POLL_INTERVAL_MS = 15e3;
228
114
  var ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5e3;
229
115
  var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
@@ -233,7 +119,7 @@ var ONDO_SUPPORTED_INPUT_ASSETS = [
233
119
  USDC_SYMBOL
234
120
  ];
235
121
 
236
- // src/shared/core/checkout/ondo/math.ts
122
+ // src/universal/core/checkout/ondo/math.ts
237
123
  function computeOndoBuyPrice(transaction) {
238
124
  const { notionalValue, receiveOutputAmount } = transaction;
239
125
  return pricePerShare({
@@ -273,7 +159,7 @@ function assertPriceFits(raw) {
273
159
  }
274
160
  }
275
161
 
276
- // src/shared/core/checkout/superstate/blockchain/abi.ts
162
+ // src/universal/core/checkout/superstate/blockchain/abi.ts
277
163
  var SUPERSTATE_SWAP_ABI = [
278
164
  {
279
165
  type: "function",
@@ -495,7 +381,13 @@ var SUPERSTATE_SWAP_ABI = [
495
381
  }
496
382
  ];
497
383
 
498
- // src/shared/core/checkout/superstate/blockchain/math.ts
384
+ // src/universal/core/shared/blockchain/bps.ts
385
+ var BPS_DENOM = Bps(10000n);
386
+ function applyBps(amount, bps) {
387
+ return assertUint256(amount * bps / BPS_DENOM);
388
+ }
389
+
390
+ // src/universal/core/checkout/superstate/blockchain/math.ts
499
391
  function computePrice({
500
392
  inputTokenAmount,
501
393
  outputTokenAmount
@@ -513,7 +405,7 @@ function computeSlip(amount, slippage) {
513
405
  return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });
514
406
  }
515
407
 
516
- // src/shared/core/checkout/superstate/blockchain/quote.ts
408
+ // src/universal/core/checkout/superstate/blockchain/quote.ts
517
409
  var SwapQuote = {
518
410
  /**
519
411
  * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
@@ -533,12 +425,12 @@ var SwapQuote = {
533
425
  })
534
426
  };
535
427
 
536
- // src/shared/core/checkout/superstate/blockchain/status.ts
428
+ // src/universal/core/checkout/superstate/blockchain/status.ts
537
429
  function isStopped(status) {
538
430
  return (status.stopped & status.swapLevel) !== 0n;
539
431
  }
540
432
 
541
- // src/shared/core/checkout/superstate/blockchain/swapped-event.ts
433
+ // src/universal/core/checkout/superstate/blockchain/swapped-event.ts
542
434
  import { parseEventLogs } from "viem";
543
435
  function decodeSwappedOutputAmount(receipt, outputDecimals) {
544
436
  try {
@@ -556,7 +448,7 @@ function decodeSwappedOutputAmount(receipt, outputDecimals) {
556
448
  }
557
449
  }
558
450
 
559
- // src/shared/core/checkout/superstate/constants.ts
451
+ // src/universal/core/checkout/superstate/constants.ts
560
452
  var SUPERSTATE_ISSUER_NAME = "Superstate";
561
453
  var SUPERSTATE_SUPPORTED_INPUT_ASSETS = [USDC_SYMBOL];
562
454
  var SWAP_POLL_INTERVAL_MS = 15e3;
@@ -573,13 +465,13 @@ function superstateSwapContractAddress(chain) {
573
465
  return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;
574
466
  }
575
467
 
576
- // src/shared/core/checkout/superstate/formatters.ts
468
+ // src/universal/core/checkout/superstate/formatters.ts
577
469
  function formattedPricePerShare(quote, locale) {
578
470
  if (!quote) return NA_AMOUNT_ASSET_UI;
579
471
  return formattedUsdPrice(computePrice(quote), locale);
580
472
  }
581
473
 
582
- // src/shared/core/offers/offers-namespace.ts
474
+ // src/universal/core/offers/offers-namespace.ts
583
475
  var OffersNamespaceImpl = class {
584
476
  constructor(ctx) {
585
477
  this.ctx = ctx;
@@ -605,12 +497,117 @@ var OffersNamespaceImpl = class {
605
497
  }
606
498
  };
607
499
 
608
- // src/shared/types/blockchain/wallet-error.ts
500
+ // src/universal/core/offers/swap-contracts.ts
501
+ function swapSpender(swapContracts, chain) {
502
+ return swapContracts.find((contract) => contract.chain === chain)?.address ?? null;
503
+ }
504
+
505
+ // src/universal/core/shared/blockchain/erc20/abi.ts
506
+ var ERC20_ABI = [
507
+ {
508
+ type: "function",
509
+ name: "allowance",
510
+ inputs: [
511
+ { name: "owner", type: "address" },
512
+ { name: "spender", type: "address" }
513
+ ],
514
+ outputs: [{ name: "", type: "uint256" }],
515
+ stateMutability: "view"
516
+ },
517
+ {
518
+ type: "function",
519
+ name: "approve",
520
+ inputs: [
521
+ { name: "spender", type: "address" },
522
+ { name: "amount", type: "uint256" }
523
+ ],
524
+ outputs: [{ name: "", type: "bool" }],
525
+ stateMutability: "nonpayable"
526
+ },
527
+ {
528
+ type: "function",
529
+ name: "balanceOf",
530
+ inputs: [{ name: "account", type: "address" }],
531
+ outputs: [{ name: "", type: "uint256" }],
532
+ stateMutability: "view"
533
+ },
534
+ {
535
+ type: "function",
536
+ name: "decimals",
537
+ inputs: [],
538
+ outputs: [{ name: "", type: "uint8" }],
539
+ stateMutability: "view"
540
+ },
541
+ {
542
+ type: "function",
543
+ name: "name",
544
+ inputs: [],
545
+ outputs: [{ name: "", type: "string" }],
546
+ stateMutability: "view"
547
+ },
548
+ {
549
+ type: "function",
550
+ name: "symbol",
551
+ inputs: [],
552
+ outputs: [{ name: "", type: "string" }],
553
+ stateMutability: "view"
554
+ },
555
+ {
556
+ type: "function",
557
+ name: "totalSupply",
558
+ inputs: [],
559
+ outputs: [{ name: "", type: "uint256" }],
560
+ stateMutability: "view"
561
+ },
562
+ {
563
+ type: "function",
564
+ name: "transfer",
565
+ inputs: [
566
+ { name: "recipient", type: "address" },
567
+ { name: "amount", type: "uint256" }
568
+ ],
569
+ outputs: [{ name: "", type: "bool" }],
570
+ stateMutability: "nonpayable"
571
+ },
572
+ {
573
+ type: "function",
574
+ name: "transferFrom",
575
+ inputs: [
576
+ { name: "sender", type: "address" },
577
+ { name: "recipient", type: "address" },
578
+ { name: "amount", type: "uint256" }
579
+ ],
580
+ outputs: [{ name: "", type: "bool" }],
581
+ stateMutability: "nonpayable"
582
+ },
583
+ {
584
+ type: "event",
585
+ name: "Approval",
586
+ inputs: [
587
+ { name: "owner", type: "address", indexed: true },
588
+ { name: "spender", type: "address", indexed: true },
589
+ { name: "value", type: "uint256", indexed: false }
590
+ ],
591
+ anonymous: false
592
+ },
593
+ {
594
+ type: "event",
595
+ name: "Transfer",
596
+ inputs: [
597
+ { name: "from", type: "address", indexed: true },
598
+ { name: "to", type: "address", indexed: true },
599
+ { name: "value", type: "uint256", indexed: false }
600
+ ],
601
+ anonymous: false
602
+ }
603
+ ];
604
+
605
+ // src/universal/types/blockchain/wallet-error.ts
609
606
  var RedactedWalletError = {
610
607
  fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
611
608
  };
612
609
 
613
- // src/shared/types/user.ts
610
+ // src/universal/types/user.ts
614
611
  var UserId = (value) => value;
615
612
  var UserEmail = (value) => value;
616
613
  var User = {
@@ -630,14 +627,11 @@ export {
630
627
  ClientSecret,
631
628
  generatePKCEParams,
632
629
  ERC20_ABI,
633
- BPS_DENOM,
634
- applyBps,
635
630
  USDC_SYMBOL,
636
631
  USDC,
637
632
  USDT_SYMBOL,
638
633
  USDT,
639
634
  TOKEN_REGISTRY,
640
- ondoSwapContractAddress,
641
635
  ONDO_POLL_INTERVAL_MS,
642
636
  ONDO_QUOTE_EXPIRY_THRESHOLD_MS,
643
637
  DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE,
@@ -647,6 +641,8 @@ export {
647
641
  computeOndoBuyPrice,
648
642
  computeOndoSellPrice,
649
643
  SUPERSTATE_SWAP_ABI,
644
+ BPS_DENOM,
645
+ applyBps,
650
646
  computePrice,
651
647
  computeSlip,
652
648
  SwapQuote,
@@ -662,9 +658,10 @@ export {
662
658
  superstateSwapContractAddress,
663
659
  formattedPricePerShare,
664
660
  OffersNamespaceImpl,
661
+ swapSpender,
665
662
  RedactedWalletError,
666
663
  UserId,
667
664
  UserEmail,
668
665
  User
669
666
  };
670
- //# sourceMappingURL=chunk-LSPZETDH.js.map
667
+ //# sourceMappingURL=chunk-ZFBEI3BW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/universal/types/oauth.ts","../src/universal/core/auth/pkce.ts","../src/universal/core/shared/blockchain/token-registry.ts","../src/universal/core/checkout/ondo/constants.ts","../src/universal/core/checkout/ondo/math.ts","../src/universal/core/checkout/superstate/blockchain/abi.ts","../src/universal/core/shared/blockchain/bps.ts","../src/universal/core/checkout/superstate/blockchain/math.ts","../src/universal/core/checkout/superstate/blockchain/quote.ts","../src/universal/core/checkout/superstate/blockchain/status.ts","../src/universal/core/checkout/superstate/blockchain/swapped-event.ts","../src/universal/core/checkout/superstate/constants.ts","../src/universal/core/checkout/superstate/formatters.ts","../src/universal/core/offers/offers-namespace.ts","../src/universal/core/offers/swap-contracts.ts","../src/universal/core/shared/blockchain/erc20/abi.ts","../src/universal/types/blockchain/wallet-error.ts","../src/universal/types/user.ts"],"sourcesContent":["import type { Newtype } from '@/universal/types/newtype';\n\nexport type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;\nexport const AuthorizationCode = (value: string): AuthorizationCode =>\n value as AuthorizationCode;\n\nexport type CodeVerifier = Newtype<string, 'CodeVerifier'>;\nexport const CodeVerifier = (value: string): CodeVerifier =>\n value as CodeVerifier;\n\nexport type CodeChallenge = Newtype<string, 'CodeChallenge'>;\nexport const CodeChallenge = (value: string): CodeChallenge =>\n value as CodeChallenge;\n\nexport type PKCEState = Newtype<string, 'PKCEState'>;\nexport const PKCEState = (value: string) => value as PKCEState;\n\nexport type RedirectUri = Newtype<string, 'RedirectUri'>;\nexport const RedirectUri = (value: string): RedirectUri => value as RedirectUri;\n\nexport type ClientId = Newtype<string, 'ClientId'>;\nexport const ClientId = (value: string): ClientId => value as ClientId;\n\nexport type ClientSecret = Newtype<string, 'ClientSecret'>;\nexport const ClientSecret = (value: string): ClientSecret =>\n value as ClientSecret;\n","import {\n arrayBufferToBase64Url,\n generateSecureRandomBase64Url,\n sha256,\n} from '@/universal/core/shared/utils/crypto';\nimport type {\n CodeChallenge as CodeChallengeType,\n CodeVerifier as CodeVerifierType,\n PKCEState as PKCEStateType,\n} from '@/universal/types/oauth';\nimport {\n type ClientId,\n CodeChallenge,\n CodeVerifier,\n PKCEState,\n type RedirectUri,\n} from '@/universal/types/oauth';\n\nexport type PKCEParams = {\n clientId: ClientId;\n responseType: 'code';\n redirectUri: RedirectUri;\n codeChallenge: CodeChallengeType;\n codeChallengeMethod: 'S256';\n state: PKCEStateType;\n codeVerifier: CodeVerifierType;\n};\n\nexport type PKCEConfig = {\n clientId: ClientId;\n redirectUri: RedirectUri;\n};\n\n/**\n * Generates PKCE parameters for an OAuth2 authorization code flow.\n * Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use\n * in server-side code and Next.js middleware.\n */\nexport async function generatePKCEParams(\n config: PKCEConfig\n): Promise<PKCEParams> {\n const state = generateSecureRandomBase64Url(32);\n const codeVerifier = generateSecureRandomBase64Url(32);\n const codeChallengeRaw = await sha256(codeVerifier);\n const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);\n\n return {\n clientId: config.clientId,\n responseType: 'code',\n redirectUri: config.redirectUri,\n codeChallenge: CodeChallenge(codeChallenge),\n codeChallengeMethod: 'S256',\n state: PKCEState(state),\n codeVerifier: CodeVerifier(codeVerifier),\n };\n}\n","import {\n AssetDecimals,\n type Erc20Asset,\n type EthereumChain,\n EvmContractAddress,\n type KnownAssetSymbol,\n StablecoinSymbol,\n} from '@/universal/types/blockchain/core';\nimport { InvariantError } from '@/universal/types/errors';\n\nexport const USDC_SYMBOL: StablecoinSymbol = StablecoinSymbol('USDC');\nexport const USDC: Erc20Asset = {\n name: 'USD Coin',\n symbol: USDC_SYMBOL,\n decimals: AssetDecimals(6),\n};\n\nexport const USDT_SYMBOL: StablecoinSymbol = StablecoinSymbol('USDT');\nexport const USDT: Erc20Asset = {\n name: 'Tether USD',\n symbol: USDT_SYMBOL,\n decimals: AssetDecimals(6),\n};\n\n/** ERC-20 contract addresses for a supported stablecoin, keyed by chain. */\ntype TokenAddresses = Record<EthereumChain, EvmContractAddress>;\n\nconst USDC_ADDRESSES: TokenAddresses = {\n ethereum_mainnet: EvmContractAddress(\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'\n ),\n ethereum_sepolia: EvmContractAddress(\n '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'\n ),\n base_mainnet: EvmContractAddress(\n '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'\n ),\n base_sepolia: EvmContractAddress(\n '0x036CbD53842c5426634e7929541eC2318f3dCF7e'\n ),\n};\n\n/**\n * USDT is not deployed on every chain the SDK models: Tether publishes no\n * Base Sepolia token. The table stays total, with that one absence an\n * explicit `null`, so a new {@link EthereumChain} is still a compile error\n * here until the author decides whether USDT exists on it — the same\n * exhaustiveness the rest of the chain model relies on. A lookup then\n * answers the honest `null` rather than calling a fake address.\n */\nconst USDT_ADDRESSES: Record<EthereumChain, EvmContractAddress | null> = {\n ethereum_mainnet: EvmContractAddress(\n '0xdac17f958d2ee523a2206206994597c13d831ec7'\n ),\n ethereum_sepolia: EvmContractAddress(\n '0x7169D38820dfd117C3FA1f22a697dBA58d90BA06'\n ),\n base_mainnet: EvmContractAddress(\n '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2'\n ),\n base_sepolia: null,\n};\n\n/** Lookups for the stablecoins the SDK's swap flows support out of the box. */\nexport const TOKEN_REGISTRY = {\n erc20: (symbol: KnownAssetSymbol): Erc20Asset => {\n switch (symbol) {\n case 'USDC':\n return USDC;\n case 'USDT':\n return USDT;\n default:\n throw new InvariantError(`Unknown asset symbol: ${symbol}`);\n }\n },\n /**\n * USDC's contract on `chain`. USDC is deployed on every chain the SDK\n * models, so the table is total and the answer is never `null`.\n */\n usdcAddress: (chain: EthereumChain): EvmContractAddress =>\n USDC_ADDRESSES[chain],\n /**\n * USDT's contract on `chain`, or `null` where Tether publishes none —\n * Base Sepolia today. The honest answer, never a fake address a balance\n * read would call.\n */\n usdtAddress: (chain: EthereumChain): EvmContractAddress | null =>\n USDT_ADDRESSES[chain],\n};\n","import { USDC_SYMBOL } from '@/universal/core/shared/blockchain/token-registry';\nimport {\n DecimalString,\n type StablecoinSymbol,\n} from '@/universal/types/blockchain/core';\nimport type { NonEmptyArray } from '@/universal/types/collections';\n\n/**\n * How often the Ondo checkout refreshes what it is allowed to poll: the market\n * status and the indicative price. Both are free - neither spends an\n * attestation - so this is paced for a price the user can trust rather than\n * for cost.\n *\n * A built transaction is deliberately not on this timer. Building spends an\n * attestation, so it happens once per order and once per refresh the user\n * asks for.\n */\nexport const ONDO_POLL_INTERVAL_MS = 15_000;\n\n/**\n * How close to its deadline a built transaction stops being offerable.\n *\n * Placing an order is not instant - the wallet has to prompt, the user has to\n * confirm, and the transaction has to reach a node - so calldata with a second\n * left is one the contract will reject. Treating the last few seconds as\n * already expired turns a paid-for revert into a refresh button.\n */\nexport const ONDO_QUOTE_EXPIRY_THRESHOLD_MS = 5_000;\n\n/**\n * The order size the sidebar prices against before the user names one.\n *\n * Ondo prices by size, so some amount has to be sent. $1,000 is a plausible\n * order rather than a token one: a size so small that Ondo's minimum rejects\n * it would leave the panel permanently blank.\n *\n * Named distinctly from `DEFAULT_AMOUNT_TO_COMPUTE_PRICE` in the swap\n * constants, which is a raw `bigint` of USDC base units for a different\n * endpoint. Both barrels are flat, so two constants of the same name could not\n * coexist - and they mean different things anyway.\n */\nexport const DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString('1000');\n\n/**\n * The coin an Ondo sell settles into, for display only.\n *\n * The scale of every amount on a built transaction comes off the response, so\n * this names the token and never sizes it - `receive_output_decimals` is the\n * only authority on how many decimals the proceeds are counted in, and the two\n * are allowed to disagree.\n *\n * Named apart from {@link ONDO_SUPPORTED_INPUT_ASSETS} rather than read out of\n * it, though both are USDC today. On a buy USDC is what the user funds with\n * and one of a list that may grow; on a sell it is what they settle into and\n * there is one of it. Reading `ONDO_SUPPORTED_INPUT_ASSETS[0]` here would make\n * the sell screen quietly follow whichever funding coin happened to be listed\n * first.\n */\nexport const ONDO_SETTLEMENT_ASSET: StablecoinSymbol = USDC_SYMBOL;\n\n/**\n * The order size the sidebar prices a sell against before the user names one.\n *\n * Sells are quoted by token amount rather than by notional: the fee comes out\n * of dollars, and Ondo's price is size-aware, so a buy's quantity depends on\n * the quote being asked for while a sell is sized by what the user already\n * holds. One whole share is a size Ondo will price - small enough to be\n * plausible for any asset, large enough that Ondo's minimum does not reject it\n * and leave the panel permanently blank.\n *\n * The buy counterpart is {@link DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE}, which\n * is a dollar figure for the same reason in reverse.\n */\nexport const DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;\n\n/**\n * The coins an Ondo buy can be funded with, in display order, with the first\n * preselected.\n *\n * USDC alone today: it is what the Sepolia integration contract accepts. The\n * amount step renders a single entry as a plain card and two or more as a\n * picker, so adding one here is all it takes.\n */\nexport const ONDO_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol> = [\n USDC_SYMBOL,\n];\n","import {\n assertUint256,\n BlockchainAmount,\n MAX_UINT_256,\n type Uint256,\n} from '@/universal/types/blockchain/core';\nimport { MathError } from '@/universal/types/errors';\nimport type {\n OndoBuyTransaction,\n OndoSellOutcome,\n OndoSellTransaction,\n} from '@/universal/types/providers/ondo/ondo';\n\n/**\n * The price of one whole asset token in a built Ondo purchase, in the funding\n * token's units - USD per share.\n *\n * Neither builder publishes a price. Frontline drops Ninshubur's deliberately,\n * because `GET /v1/ondo/swap/quote` already serves one under that name at a\n * different scale, and echoing both would leave a caller to guess which was\n * which.\n *\n * Dividing the two amounts the response *does* carry is better than reading\n * the indicative one anyway: it is the price this transaction fills at, rather\n * than a poll that has since moved and was struck against a different size.\n *\n * **Fee-exclusive.** `notionalValue` is the deposit after CoinList's fee comes\n * off, so this is the price Ondo filled at, not the buyer's all-in cost per\n * token - that would be `spendInputAmount / receiveOutputAmount`, and it is\n * higher. Fee-exclusive is what the review screen wants, because it renders\n * the fee on its own line: price x quantity, plus fee, comes to the total.\n * Making this all-in would double-count the fee against that breakdown.\n *\n * The two are equal until ENG-1718 turns a fee on, which frontline rejects\n * today. They diverge the moment it does, so the choice is load-bearing rather\n * than academic.\n */\nexport function computeOndoBuyPrice(\n transaction: OndoBuyTransaction\n): BlockchainAmount {\n const { notionalValue, receiveOutputAmount } = transaction;\n return pricePerShare({\n usd: notionalValue,\n shares: receiveOutputAmount,\n });\n}\n\n/**\n * The price of one whole asset token in a built Ondo sale, in the settlement\n * token's units - USD per share, the same thing\n * {@link computeOndoBuyPrice} answers with the ratio inverted.\n *\n * **Fee-exclusive, and it takes arithmetic to be so.** `expected.quantity` is\n * published already net of `expected.fee`, so the proceeds are added back\n * before dividing: what comes out is the price Ondo filled at, which is the\n * buy arm's meaning rather than a second one. That is what lets one review row\n * render on either screen, and what keeps the sell breakdown honest - the fee\n * sits on its own line beside this, and a net price would count it twice.\n *\n * Read against {@link OndoSellTransaction.expected} alone. The `minimum` arm\n * describes the same trade at a different outcome, and pricing that one would\n * answer \"the worst price this could fill at\", which no screen asks for.\n *\n * The two readings coincide while frontline forces the fee to zero, which it\n * does today. They diverge the day ENG-1718 lands.\n */\nexport function computeOndoSellPrice(\n transaction: OndoSellTransaction\n): BlockchainAmount {\n const { expected, spendInputAmount } = transaction;\n return pricePerShare({\n usd: grossProceeds(expected),\n shares: spendInputAmount,\n });\n}\n\n/**\n * What Ondo returned before CoinList took its cut: the published quantity with\n * the fee charged on it added back.\n *\n * Bounded before the addition rather than after. The two amounts are parsed\n * independently, each a uint256 in its own right, so nothing in the mapper\n * stops their sum leaving the range - and `BlockchainAmount.add` answers an\n * out-of-range sum with an `InvariantError`, which says the SDK's own\n * arithmetic went wrong. It did not: a gross that no uint256 can hold is a\n * corrupt response, the same kind of thing {@link assertPriceFits} reports, and\n * it has to say so here rather than take the checkout down mid-render.\n *\n * The addition itself is still `BlockchainAmount.add`, so the two amounts\n * disagreeing about their scale stays an `InvariantError`. That one really is\n * internal: `OndoSellTransaction.fromDto` reads both off\n * `receive_output_decimals`.\n */\nfunction grossProceeds(expected: OndoSellOutcome): BlockchainAmount {\n const raw = expected.quantity.raw + expected.fee.raw;\n if (raw > MAX_UINT_256) {\n throw new MathError(`Ondo sell proceeds: out of uint256 bounds (${raw})`);\n }\n return BlockchainAmount.add(expected.quantity, expected.fee);\n}\n\n/**\n * USD per whole share, in the USD amount's decimals.\n *\n * Both prices bottom out here so the scaling, the rounding and the bound are\n * written once: whichever side the amounts came off, a price is one dollar\n * amount divided by one asset amount.\n *\n * {@link BlockchainAmount.div} owns the arithmetic - it scales the numerator\n * by the asset's exponent so the quotient lands back in the funding token's,\n * truncates towards zero so the total a price implies never overstates what\n * was paid, and refuses a zero share quantity rather than dividing by it.\n * That last guard is unreachable through either `fromDto`, which rejects a\n * non-positive amount on both sides of the trade at the boundary - both of\n * them, because which one lands in the denominator here flips with the\n * direction. It matters because this runs during render, where a bare BigInt\n * division would take the checkout down with a RangeError instead of failing\n * one step.\n *\n * What is Ondo's rather than every amount's is the uint256 bound: `div`\n * deliberately does not check one, because scaling can carry a legal pair out\n * of range, and here that can only mean a corrupt response.\n */\nfunction pricePerShare({\n usd,\n shares,\n}: {\n usd: BlockchainAmount;\n shares: BlockchainAmount;\n}): BlockchainAmount {\n const price = BlockchainAmount.div(usd, shares);\n return BlockchainAmount({\n raw: assertPriceFits(price.raw),\n decimals: price.decimals,\n });\n}\n\n/**\n * A price past uint256 needs an output amount of a few base units against a\n * notional no real balance holds. It cannot come off the wire, so it is a\n * corrupt response rather than an expensive order.\n */\nfunction assertPriceFits(raw: bigint): Uint256 {\n try {\n return assertUint256(raw);\n } catch {\n throw new MathError(`Ondo price: out of uint256 bounds (${raw})`);\n }\n}\n","export const SUPERSTATE_SWAP_ABI = [\n {\n type: 'function',\n name: 'authorized',\n inputs: [{ name: 'user', type: 'address', internalType: 'address' }],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'stopped',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'SWAP_LEVEL',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'preview',\n inputs: [\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct Preview',\n components: [\n { name: 'input', type: 'uint256', internalType: 'uint256' },\n { name: 'fee', type: 'uint256', internalType: 'uint256' },\n { name: 'output', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'swap',\n inputs: [\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n { name: 'slip', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'tokenBalance',\n inputs: [{ name: 'token', type: 'address', internalType: 'address' }],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'outputToken',\n inputs: [],\n outputs: [{ name: '', type: 'address', internalType: 'address' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'outputTokenBalance',\n inputs: [],\n outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totals',\n inputs: [{ name: 'token', type: 'address', internalType: 'address' }],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct SwapTotal',\n components: [\n { name: 'inputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'feeSum', type: 'uint256', internalType: 'uint256' },\n { name: 'outputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'count', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totals',\n inputs: [\n { name: 'user', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n ],\n outputs: [\n {\n name: '',\n type: 'tuple',\n internalType: 'struct SwapTotal',\n components: [\n { name: 'inputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'feeSum', type: 'uint256', internalType: 'uint256' },\n { name: 'outputSum', type: 'uint256', internalType: 'uint256' },\n { name: 'count', type: 'uint256', internalType: 'uint256' },\n ],\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'to', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'to', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n { name: 'amount', type: 'uint256', internalType: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'setBps',\n inputs: [{ name: 'points', type: 'uint256', internalType: 'uint256' }],\n outputs: [{ name: '', type: 'bool', internalType: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'event',\n name: 'Swapped',\n inputs: [\n { name: 'user', type: 'address', indexed: true, internalType: 'address' },\n {\n name: 'inputToken',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'outputToken',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'inputAmount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n {\n name: 'outputAmount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transferred',\n inputs: [\n { name: 'to', type: 'address', indexed: true, internalType: 'address' },\n {\n name: 'token',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'amount',\n type: 'uint256',\n indexed: false,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'error',\n name: 'InvalidAddress',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InsufficientAmount',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidAmount',\n inputs: [],\n },\n {\n type: 'error',\n name: 'SwapFailed',\n inputs: [\n { name: 'user', type: 'address', internalType: 'address' },\n { name: 'token', type: 'address', internalType: 'address' },\n ],\n },\n] as const;\n","import {\n assertUint256,\n Bps,\n type Uint256,\n} from '@/universal/types/blockchain/core';\n\n/** Basis-point denominator: 10_000 bps = 100%. */\nexport const BPS_DENOM: Bps = Bps(10_000n);\n\n/**\n * Applies a basis-point fraction to an amount, flooring the result.\n * `floor((amount × bps) / BPS_DENOM)`. The result is bounds-checked, so an\n * overflow (bps far above BPS_DENOM) or a negative product is rejected.\n */\nexport function applyBps(amount: Uint256, bps: Bps): Uint256 {\n return assertUint256((amount * bps) / BPS_DENOM);\n}\n","import type { SwapQuote } from '@/universal/core/checkout/superstate/blockchain/quote';\nimport { applyBps, BPS_DENOM } from '@/universal/core/shared/blockchain/bps';\nimport {\n assertUint256,\n BlockchainAmount,\n Bps,\n} from '@/universal/types/blockchain/core';\n\n/**\n * Price of 1 output token in USD, assuming the input token is a $1 stablecoin.\n *\n * `raw_price = inputTokenAmount.raw × 10^outputDecimals ÷ outputTokenAmount.raw`\n *\n * The multiplication happens before the division so we never lose precision to\n * integer truncation early. This mirrors standard fixed-point practice on-chain.\n * Returned decimals match the input token decimals (always the stablecoin's 6).\n */\nexport function computePrice({\n inputTokenAmount,\n outputTokenAmount,\n}: SwapQuote): BlockchainAmount | null {\n if (outputTokenAmount.raw === 0n) return null;\n\n const scale = 10n ** BigInt(outputTokenAmount.decimals);\n const raw = assertUint256(\n (inputTokenAmount.raw * scale) / outputTokenAmount.raw\n );\n\n return BlockchainAmount({ raw, decimals: inputTokenAmount.decimals });\n}\n\n/**\n * Applies slippage to an amount, returning the minimum acceptable amount:\n * `amount × (BPS_DENOM − slippage) / BPS_DENOM`. Throws when `slippage` exceeds\n * `BPS_DENOM` (the retained fraction would be negative).\n */\nexport function computeSlip(\n amount: BlockchainAmount,\n slippage: Bps\n): BlockchainAmount {\n const retained = Bps(assertUint256(BPS_DENOM - slippage));\n const slipRaw = applyBps(amount.raw, retained);\n return BlockchainAmount({ raw: slipRaw, decimals: amount.decimals });\n}\n","import {\n type AssetDecimals,\n BlockchainAmount,\n} from '@/universal/types/blockchain/core';\nimport type { SwapPreview } from '@/universal/types/providers/superstate/swap';\n\n/**\n * A read-only quote for a swap as domain amounts: how much goes in, the\n * protocol fee, and how much would come out. Derived from the raw\n * {@link SwapPreview} the swap contract returns.\n */\nexport type SwapQuote = {\n inputTokenAmount: BlockchainAmount;\n fee: BlockchainAmount;\n outputTokenAmount: BlockchainAmount;\n};\n\nexport const SwapQuote = {\n /**\n * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The\n * input and fee are denominated in the input token; the output in the output\n * token.\n */\n fromPreview: (\n preview: SwapPreview,\n inputDecimals: AssetDecimals,\n outputDecimals: AssetDecimals\n ): SwapQuote => ({\n inputTokenAmount: BlockchainAmount({\n raw: preview.inputAmount,\n decimals: inputDecimals,\n }),\n fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),\n outputTokenAmount: BlockchainAmount({\n raw: preview.outputAmount,\n decimals: outputDecimals,\n }),\n }),\n};\n","import type { SwapStatus } from '@/universal/types/providers/superstate/swap';\n\n/**\n * Interprets the on-chain swap availability read from `stopped()` and\n * `SWAP_LEVEL()`.\n *\n * The contract tracks paused operations as a bitmask in `stopped`. The swap is\n * stopped when the SWAP_LEVEL flag is set:\n *\n * (stopped & SWAP_LEVEL) != 0 -> stopped (not active)\n */\nexport function isStopped(status: SwapStatus): boolean {\n return (status.stopped & status.swapLevel) !== 0n;\n}\n","import { parseEventLogs, type TransactionReceipt } from 'viem';\nimport { SUPERSTATE_SWAP_ABI } from '@/universal/core/checkout/superstate/blockchain/abi';\nimport {\n type AssetDecimals,\n BlockchainAmount,\n MAX_UINT_256,\n} from '@/universal/types/blockchain/core';\n\n/**\n * Decodes the confirmed output amount from the `Swapped` event in a swap\n * transaction receipt.\n *\n * Returns `null` when the event is absent or the amount is not a valid uint256\n * so callers can fall back to the quote's expected output — the swap already\n * confirmed on-chain, so a missing/undecodable event should not fail the flow.\n */\nexport function decodeSwappedOutputAmount(\n receipt: TransactionReceipt,\n outputDecimals: AssetDecimals\n): BlockchainAmount | null {\n try {\n const [swapped] = parseEventLogs({\n abi: SUPERSTATE_SWAP_ABI,\n eventName: 'Swapped',\n logs: receipt.logs,\n });\n if (!swapped) return null;\n\n const raw = swapped.args.outputAmount;\n if (raw < 0n || raw > MAX_UINT_256) return null;\n return BlockchainAmount({ raw, decimals: outputDecimals });\n } catch {\n // Undecodable log (ABI mismatch / malformed) — fall back to the\n // quote. The swap already confirmed on-chain, so never fail here.\n return null;\n }\n}\n","import { USDC_SYMBOL } from '@/universal/core/shared/blockchain/token-registry';\nimport {\n Bps,\n type EthereumChain,\n EvmContractAddress,\n type StablecoinSymbol,\n} from '@/universal/types/blockchain/core';\nimport type { NonEmptyArray } from '@/universal/types/collections';\n\n/**\n * Who issues the asset a Superstate swap pays out.\n *\n * A constant rather than a field off the offer: no frontline endpoint carries\n * an issuer, and every offer this checkout serves is Superstate's by\n * definition — `CheckoutContainer` routes here on `superstate::swap` alone.\n */\nexport const SUPERSTATE_ISSUER_NAME = 'Superstate';\n\n/**\n * The coins a Superstate swap can be funded with, in display order, with the\n * first preselected.\n *\n * USDC alone today: it is what the deployed swap contract accepts. The amount\n * step renders a single entry as a plain card and two or more as a picker, so\n * adding one here is all it takes.\n */\nexport const SUPERSTATE_SUPPORTED_INPUT_ASSETS: NonEmptyArray<StablecoinSymbol> =\n [USDC_SYMBOL];\n\n/** Poll interval for refreshing on-chain swap quotes and balances. */\nexport const SWAP_POLL_INTERVAL_MS = 15_000;\n\n/**\n * Notional input used to derive a display price-per-share when the user has\n * not yet entered an amount (1 USDC at 6 decimals).\n */\nexport const DEFAULT_AMOUNT_TO_COMPUTE_PRICE = 1_000_000n;\n\n/** Slippage tolerances offered in the review step, in basis points. */\nexport const SLIPPAGE_OPTIONS_BPS: Bps[] = [25n, 50n, 100n, 200n, 500n].map(\n (n) => Bps(n)\n);\n\n/** Default slippage tolerance (0.5%). */\nexport const DEFAULT_SLIPPAGE_BPS: Bps = Bps(50n);\n\n/**\n * The Superstate swap contract on Ethereum Sepolia, and therefore the ERC-20\n * spender the user approves there.\n *\n * Exported in its own right for a partner driving `coinlist.superstate.execute`\n * at Level 1, where the contract is an explicit parameter.\n */\nexport const SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA: EvmContractAddress =\n EvmContractAddress('0x84f8e9a6C9Cc12fe911259372EfCa5582C4ae557');\n\n/**\n * The Superstate swap contract per chain.\n *\n * Mainnet is absent, not zeroed: the production address is not finalized\n * upstream, and a zero address would be approved happily and revert only later.\n * A chain with no entry has no checkout — `useSuperstateSwapCheckoutViewModel`\n * reports it as the flow-level error rather than quoting against nothing.\n */\nconst SUPERSTATE_SWAP_CONTRACT_ADDRESSES: Partial<\n Record<EthereumChain, EvmContractAddress>\n> = {\n ethereum_sepolia: SUPERSTATE_SWAP_CONTRACT_ADDRESS_SEPOLIA,\n};\n\n/**\n * The Superstate swap contract on `chain`, or `null` where none is deployed.\n *\n * TODO(ENG-1734): Ondo now reads its spender off the offer's `swap_contracts`\n * via `swapSpender`, which is why that helper sits in `shared/core/offers/`\n * rather than under a provider. Superstate still resolves from this table, so\n * two mechanisms answer one question. Migrate once frontline serves\n * `swap_contracts` on Superstate offers too.\n */\nexport function superstateSwapContractAddress(\n chain: EthereumChain\n): EvmContractAddress | null {\n return SUPERSTATE_SWAP_CONTRACT_ADDRESSES[chain] ?? null;\n}\n","import { computePrice } from '@/universal/core/checkout/superstate/blockchain/math';\nimport type { SwapQuote } from '@/universal/core/checkout/superstate/blockchain/quote';\nimport {\n formattedUsdPrice,\n NA_AMOUNT_ASSET_UI,\n} from '@/universal/core/shared/blockchain/formatters';\nimport type { FormattedAmountAssetUi } from '@/universal/types/blockchain/ui';\n\n/**\n * Formats a quote's implied price per output token as a USD amount.\n *\n * Lives with the provider rather than in `@/universal/core/shared/blockchain/formatters`\n * because {@link SwapQuote} and {@link computePrice} are Superstate's: the\n * shared formatters stay provider-agnostic.\n */\nexport function formattedPricePerShare(\n quote: SwapQuote | null,\n locale: string\n): FormattedAmountAssetUi {\n if (!quote) return NA_AMOUNT_ASSET_UI;\n return formattedUsdPrice(computePrice(quote), locale);\n}\n","import * as offersApi from '@/universal/api/frontline/offers';\nimport type { UniversalNamespaceContext } from '@/universal/core/shared/namespace-context';\nimport {\n type InternalLogger,\n internalLogger,\n} from '@/universal/core/shared/observability/internal-logger';\nimport type { Offer, OfferId } from '@/universal/types/offer';\nimport type { OfferDetail } from '@/universal/types/offer-detail';\nimport type {\n PaginatedResponse,\n PaginationParams,\n} from '@/universal/types/pagination';\n\n/**\n * Reads over CoinList's offers: the catalogue a user can browse, and the full\n * detail of a single offer.\n *\n * Every method requires an authenticated user and throws\n * {@link NotAuthenticatedError} otherwise. On the server, the same reads are\n * additionally available with an app-level token — see\n * `ServerOffersNamespace`.\n */\nexport interface OffersNamespace {\n /**\n * Fetches every offer, iterating through all pages. Prefer {@link listPage}\n * when you render a paginated list yourself.\n */\n list(): Promise<Offer[]>;\n\n /**\n * Fetches a single page of offers. Pass the previous response's\n * `startingAfter` as `after` to advance.\n */\n listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;\n\n /**\n * Fetches the full detail of one offer, including its options. Note this\n * returns {@link OfferDetail} — a richer model than the {@link Offer}\n * summaries {@link list} returns.\n */\n get(id: OfferId): Promise<OfferDetail>;\n}\n\nexport class OffersNamespaceImpl implements OffersNamespace {\n private readonly log: InternalLogger;\n\n constructor(private readonly ctx: UniversalNamespaceContext) {\n this.log = internalLogger(ctx.logger, 'OFFERS');\n }\n\n async list(): Promise<Offer[]> {\n return this.log.wrap('list', undefined, async () => {\n await this.ctx.ensureUserAuthenticated();\n return offersApi.fetchOffers(this.ctx.api, undefined);\n });\n }\n\n async listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>> {\n return this.log.wrap('listPage', params, async () => {\n await this.ctx.ensureUserAuthenticated();\n return offersApi.fetchOffersPage(this.ctx.api, params, undefined);\n });\n }\n\n async get(id: OfferId): Promise<OfferDetail> {\n return this.log.wrap('get', id, async () => {\n await this.ctx.ensureUserAuthenticated();\n return offersApi.fetchOfferDetails(this.ctx.api, id, undefined);\n });\n }\n}\n","import type {\n EthereumChain,\n EvmContractAddress,\n} from '@/universal/types/blockchain/core';\nimport type { OfferSwapContract } from '@/universal/types/offer-detail';\n\n/**\n * The CoinList contract a swap on `chain` settles through, and therefore the\n * ERC-20 spender the user approves - or `null` where this offer cannot be\n * swapped on that chain.\n *\n * Read off the offer rather than held as a constant because the address varies\n * by environment, not only by chain: beta and production both run\n * `ethereum_sepolia` and deploy a different contract on each, and one constant\n * cannot name both. Frontline resolves it per environment and serves the\n * answer on the offer.\n *\n * The array varies per *offer* as well as per chain - frontline drops a chain\n * whose funding and swap tokens do not both resolve for this asset - so an\n * array read for one symbol must not be reused for another. An empty array\n * means \"cannot swap here\", which is an answer rather than an error.\n *\n * A capability rather than a provider slice, and named for the data it reads\n * rather than for its first caller: `swap_contracts` is an offer field, and\n * `universal-core-isolation-and-sharing` would stop Superstate reusing this if\n * it lived under `checkout/ondo/`. Superstate has not migrated yet - it still\n * reads `superstateSwapContractAddress` - so Ondo is the only caller today.\n */\nexport function swapSpender(\n swapContracts: OfferSwapContract[],\n chain: EthereumChain\n): EvmContractAddress | null {\n return (\n swapContracts.find((contract) => contract.chain === chain)?.address ?? null\n );\n}\n","/**\n * Minimal ERC-20 ABI the SDK writes against (mirrors viem's `erc20Abi`). The\n * swap flow uses `approve`; `allowance`/`balanceOf`/`decimals`/`symbol`/`name`\n * are included so reads share a single SDK-owned ABI.\n */\nexport const ERC20_ABI = [\n {\n type: 'function',\n name: 'allowance',\n inputs: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n ],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'approve',\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'balanceOf',\n inputs: [{ name: 'account', type: 'address' }],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'decimals',\n inputs: [],\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'name',\n inputs: [],\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'symbol',\n inputs: [],\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'totalSupply',\n inputs: [],\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transfer',\n inputs: [\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'transferFrom',\n inputs: [\n { name: 'sender', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n },\n {\n type: 'event',\n name: 'Approval',\n inputs: [\n { name: 'owner', type: 'address', indexed: true },\n { name: 'spender', type: 'address', indexed: true },\n { name: 'value', type: 'uint256', indexed: false },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transfer',\n inputs: [\n { name: 'from', type: 'address', indexed: true },\n { name: 'to', type: 'address', indexed: true },\n { name: 'value', type: 'uint256', indexed: false },\n ],\n anonymous: false,\n },\n] as const;\n","import type { Hash } from 'viem';\n\n/**\n * A classified wallet or transaction failure. The SDK derives this from\n * whatever the {@link EvmWallet} throws, so hosts get a stable, typed error\n * shape regardless of the wallet library underneath.\n *\n * Lives here rather than beside its classifier because it is the failure half\n * of the {@link EvmWallet} contract, and because both `@/universal` and\n * `@/client` name it: {@link LogCause} carries one, and classifying a thrown\n * error into one needs viem's error classes, which are browser-side.\n */\nexport type WalletError =\n | { type: 'user_rejected' }\n | { type: 'insufficient_funds' }\n | {\n type: 'contract_reverted';\n /**\n * What the contract said, when it said anything: a `require` string, a\n * panic description, a custom error's name, or the four-byte selector of\n * an error the ABI could not decode.\n *\n * `null` when a revert carried no data, since the string the RPC node\n * offers in its place is not the contract's - see `classifyWalletError`.\n * Nullable rather than optional so that every arm has to answer the\n * question: \"it reverted and said nothing\" is a fact about the revert,\n * and a caller should have to read it rather than miss it.\n *\n * Never the custom error's arguments. A name is a compile-time\n * identifier; its operands are runtime values - an address, a balance -\n * and those are `'debug'` material.\n */\n reason: string | null;\n }\n | { type: 'timeout'; hash: Hash }\n | { type: 'unknown'; cause: unknown };\n\n/**\n * A {@link WalletError} as it may be reported above `'debug'`: the\n * classification, never the throw.\n *\n * Only the `unknown` arm differs, and it differs because it is the one arm\n * carrying a value the SDK did not author - the raw error the wallet library\n * threw, whose message and metadata hold the transaction's `from`, `to`,\n * `value` and calldata. The other four carry compile-time constants or a\n * server-minted identifier already, so they pass through as they stand.\n *\n * This exists as a type rather than as a scrub some function remembers to\n * apply: `LogCause` names it, so an arm that grew a raw field would fail the\n * build instead of quietly reaching {@link Logger.error}.\n */\nexport type RedactedWalletError =\n | Exclude<WalletError, { type: 'unknown' }>\n | { type: 'unknown' };\n\nexport const RedactedWalletError = {\n fromWalletError: (error: WalletError): RedactedWalletError =>\n error.type === 'unknown' ? { type: 'unknown' } : error,\n};\n","import type { UserDto } from '@/universal/types/dto/user';\nimport type { Newtype } from '@/universal/types/newtype';\n\nexport type UserId = Newtype<string, 'UserId'>;\nexport const UserId = (value: string) => value as UserId;\nexport type UserEmail = Newtype<string, 'UserEmail'>;\nexport const UserEmail = (value: string) => value as UserEmail;\n\nexport type User = {\n id: UserId;\n email: UserEmail;\n};\n\nexport const User = {\n fromDto: (dto: UserDto): User => ({\n id: UserId(dto.id),\n email: UserEmail(dto.email),\n }),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,oBAAoB,CAAC,UAChC;AAGK,IAAM,eAAe,CAAC,UAC3B;AAGK,IAAM,gBAAgB,CAAC,UAC5B;AAGK,IAAM,YAAY,CAAC,UAAkB;AAGrC,IAAM,cAAc,CAAC,UAA+B;AAGpD,IAAM,WAAW,CAAC,UAA4B;AAG9C,IAAM,eAAe,CAAC,UAC3B;;;ACaF,eAAsB,mBACpB,QACqB;AACrB,QAAM,QAAQ,8BAA8B,EAAE;AAC9C,QAAM,eAAe,8BAA8B,EAAE;AACrD,QAAM,mBAAmB,MAAM,OAAO,YAAY;AAClD,QAAM,gBAAgB,uBAAuB,kBAAkB,KAAK;AAEpE,SAAO;AAAA,IACL,UAAU,OAAO;AAAA,IACjB,cAAc;AAAA,IACd,aAAa,OAAO;AAAA,IACpB,eAAe,cAAc,aAAa;AAAA,IAC1C,qBAAqB;AAAA,IACrB,OAAO,UAAU,K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