You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:prisma/schema.prisma's Token model defines priceUsd Float? as explicitly nullable ("Latest known USD price (nullable – updated by a price-feed worker)"), and issue #55 backs the Token model with a real repository/service, but neither src/tokens/tokens.service.ts nor src/tokens/tokens.controller.ts currently has verified, tested behavior for the null case — before a price-feed worker (issue #8's pluggable price-feed provider) has ever populated a token's price.
Problem Statement & Context: Between issue #55 (real Token repository) and issue #8 (pluggable price-feed provider) landing, there's a real window — and likely a permanent steady-state for newly-listed tokens — where priceUsd is null. Any consumer (quote calculation, RoutingService, API responses) that assumes a numeric price without checking will produce NaN/crash rather than a clear "price unavailable" signal.
Scope & Acceptance Criteria:
Audit every read site of Token.priceUsd (via src/tokens/tokens.service.ts and any downstream consumer such as quote-calculation logic) and ensure each handles null explicitly (typed as number | null throughout, never silently coerced).
Add a documented, explicit behavior for API consumers when priceUsd is null (e.g. the field is omitted vs. returned as null in the response — pick one and make it consistent, then document it in Swagger per the pattern in issue Add an audit trail for cancelled and expired intents #62).
Out of scope: implementing the price-feed worker itself (issue feat: port /api/v1/intents routes to Nest #8) — this issue only hardens the null-handling path that exists regardless of when/whether a price feed is populating data.
Key files: prisma/schema.prisma (Token.priceUsd), src/tokens/tokens.service.ts, src/tokens/tokens.controller.ts, src/tokens/tokens.data.ts (current static data source, useful for comparing pre/post issue Replace SolversService's in-memory Map with persistent storage #55 shapes).
Trace any arithmetic performed on priceUsd (e.g. USD-value calculations feeding stats/quote logic) and guard each with an explicit null check rather than relying on TypeScript's optional-chaining alone to prevent a runtime NaN.
Testing: minimum 90% branch coverage on the null-handling paths specifically; add test cases for a token with priceUsd: null at every read site identified in the audit, plus a regression test confirming no NaN/unhandled-exception path exists.
Definition of Done:
Null-handling audited and hardened across all identified read sites, tested, documented.
Description:
prisma/schema.prisma'sTokenmodel definespriceUsd Float?as explicitly nullable ("Latest known USD price (nullable – updated by a price-feed worker)"), and issue #55 backs theTokenmodel with a real repository/service, but neithersrc/tokens/tokens.service.tsnorsrc/tokens/tokens.controller.tscurrently has verified, tested behavior for the null case — before a price-feed worker (issue #8's pluggable price-feed provider) has ever populated a token's price.Problem Statement & Context: Between issue #55 (real
Tokenrepository) and issue #8 (pluggable price-feed provider) landing, there's a real window — and likely a permanent steady-state for newly-listed tokens — wherepriceUsdisnull. Any consumer (quote calculation,RoutingService, API responses) that assumes a numeric price without checking will produceNaN/crash rather than a clear "price unavailable" signal.Scope & Acceptance Criteria:
Token.priceUsd(viasrc/tokens/tokens.service.tsand any downstream consumer such as quote-calculation logic) and ensure each handlesnullexplicitly (typed asnumber | nullthroughout, never silently coerced).priceUsdis null (e.g. the field is omitted vs. returned asnullin the response — pick one and make it consistent, then document it in Swagger per the pattern in issue Add an audit trail for cancelled and expired intents #62).TokensService.getByChain()'s separately-tracked return-shape bug (issue feat: port /api/v1/stats endpoint to Nest #9).Implementation Guidelines:
prisma/schema.prisma(Token.priceUsd),src/tokens/tokens.service.ts,src/tokens/tokens.controller.ts,src/tokens/tokens.data.ts(current static data source, useful for comparing pre/post issue Replace SolversService's in-memory Map with persistent storage #55 shapes).priceUsd(e.g. USD-value calculations feeding stats/quote logic) and guard each with an explicit null check rather than relying on TypeScript's optional-chaining alone to prevent a runtimeNaN.TokensController, so the two stay consistent.priceUsd: nullat every read site identified in the audit, plus a regression test confirming noNaN/unhandled-exception path exists.Definition of Done:
Resources:
prisma/schema.prisma,src/tokens/tokens.service.ts,src/tokens/tokens.controller.ts,src/tokens/tokens.data.tsComplexity: High (200 points)