feat: conditional streaming (#1482), TimescaleDB analytics (#1480), developer portal (#1481), copy feedback (#1483) - #1556
Conversation
|
CI on this PR was failing before any of this PR's code ran, because Pushed a fix on the branch: Note on the remaining checks: the Soroban Contracts CI job fails looking for a root |
7e2874e to
541e4d5
Compare
…edback - LabsCrypt#1482: oracle-triggered conditional streaming. create_conditional_stream escrows funds against ConditionalMilestone tranches (TimeOnly, PriceTarget, OracleAttestation); verify_and_unlock_milestone evaluates the condition (SEP-40-style oracle lastprice with a 3600s freshness window, or signer-authorized single-use attestations) and promotes the tranche into the audited step-unlock path. Emits milestone_condition_unlocked. Errors 28-35 appended to StreamError. - LabsCrypt#1480: TimescaleDB hypertable + hourly/daily continuous aggregates + compression policy (migration 20261001000000), analytics.service with live-aggregation fallback for stock PostgreSQL, /api/v1/analytics/{tvl,historical,defillama} endpoints, vitest suite. - LabsCrypt#1481: Docusaurus developer portal in docs-site/ (contracts, backend, SDKs, guides, API reference), interactive Soroban RPC playground and OpenAPI try-it-out console, Mermaid sequence diagrams, and a deploy-docs CI workflow that builds on PRs. - LabsCrypt#1483: reusable CopyButton with 2s checkmark, tooltip and keyboard support; replaces raw clipboard handlers in StreamDetailsModal and ShareAddressModal. Closes LabsCrypt#1482, closes LabsCrypt#1480, closes LabsCrypt#1481, closes LabsCrypt#1483.
setup-node cache: npm fails when cache-dependency-path does not resolve; the portal ships no package-lock.json, so plain npm install is used instead.
…rmaid remark-mermaid@^0.3.0 does not exist on npm, so install failed in CI. Docusaurus renders mermaid natively via @docusaurus/theme-mermaid.
…aid theme Docusaurus v3 resolves doc links by route id, not relative .md path, and pages embedding JSX components must be .mdx with @site imports.
…real route The navbar's '/' (title) and '/playground' links were the two remaining broken references reported by the link checker.
homePageId was removed in Docusaurus 3; the v3 mechanism is slug: / on the doc that should act as the home page.
541e4d5 to
a305fc8
Compare
|
CI triage note: the 5 failing checks here are not caused by this PR — they reproduce on
This PR touches no schema files (only a migration SQL + analytics code/docs), so it will go green once main deduplicates the model. Happy to pick that dedup up as a separate PR if useful. |
Closes #1482
Closes #1480
Closes #1481
Closes #1483
Summary
create_conditional_streamescrows funds (same gross-transfer + fee flow ascreate_stream) againstConditionalMilestonetranches whoseUnlockConditionisTimeOnly,PriceTarget(oracle, target, is_above)orOracleAttestation(signer, id).verify_and_unlock_milestone(sender or recipient) evaluates the condition: SEP-40-stylelastpricecross-contract call via a generatedOracleClientwith a 3600s freshness window (OraclePriceUnavailable/OraclePriceStale), or signer-authorized single-use attestation ids per stream. On success the tranche's unlock time is rewritten fromu64::MAXtonow— i.e. verification only flips a gate, and claim/withdraw math stays the audited step-tranche code. Emitsmilestone_condition_unlocked.StreamError28–35 appended (append-only). A malformed upstream refactor in main (23 pre-existingcargo checkerrors, incl. literal74tokens in test.rs) means this crate does not compile at HEAD for anyone; this PR adds zero new errors.20261001000000_add_timescaledb_analyticscreates thestream_flow_snapshotshypertable, hourly/daily continuous aggregates with refresh policies, and a 14-day compression policy.analytics.service.tsreads the latest snapshot per token (DISTINCT ON) and the bucketed views, with a live Prisma fallback (source: "live") so stock PostgreSQL deployments keep working. New public endpoints:GET /api/v1/analytics/tvl,/historical?period=7d|30d|90d|1y&interval=1h|1d, and a DefiLlama adapter at/defillama. Vitest suite (backend/tests/analytics.test.ts) mocks the pool/prisma boundary.docs-site/: protocol overview, quickstart (TS/Python/cURL), contracts (lifecycle, storage TTLs, batch ops, emergency pause, conditional streams, Soroban reference), backend (event ingestion, SSE, webhooks, dead-letter triage, analytics), four SDK pages, three recipes, and an API reference. Interactive pieces: an embedded OpenAPI try-it-out console (OpenApiConsole.tsx) and a live Soroban RPC playground (SorobanPlayground.tsx, read calls against Testnet with decoded output). Mermaid diagrams cover client signing, event ingestion→SSE fanout, webhook retry/dead-letter, and the analytics pipeline..github/workflows/deploy-docs.ymlbuilds the site on every docs PR (broken links fail the build) and deploys to GitHub Pages from main.frontend/src/components/dashboard/CopyButton.tsx: icon → green checkmark for 2 seconds, tooltip flips "Copy" → "Copied!", accessible name flips for screen readers, native<button>so focus+Enter works, toasts via the sharedcopyToClipboardhelper. Wired intoStreamDetailsModal(replacing the hand-rolled handler while preserving its existing test contract: same aria labels and success toast) andShareAddressModal.Scope
contracts/stream_contract/src/{types,errors,events,lib}.rs— [Smart Contracts] Oracle-Triggered Conditional Streaming & KPI-Gated Milestone Releases #1482 only. No existing variant, key, event field, or discriminant changed.backend/prisma/migrations/20261001000000_add_timescaledb_analytics/,backend/src/{services/analytics.service.ts,controllers/analytics.controller.ts,routes/v1/analytics.routes.ts},routes/v1/index.ts(2-line mount),backend/tests/analytics.test.ts— [Backend/Analytics] TimescaleDB Hypertables & Real-Time Protocol TVL and Velocity Aggregation #1480.docs-site/**,.github/workflows/deploy-docs.yml— [Docs] Interactive Developer Hub, Live RPC Playground & Protocol Architecture Portal #1481.frontend/src/components/dashboard/CopyButton.tsx(new),StreamDetailsModal.tsx,ShareAddressModal.tsx— [Frontend] Add visual feedback tooltip and temporary checkmark to Address Copy button #1483.Testing
cargo check -p stream_contract— 23 errors before and after my change (all pre-existing at upstreammain; the crate is mid-refactor withnet_amountResult-propagation breakage and stray74tokens intest.rs). Every error in my added code regions was fixed;cargo fmtis clean on the files I touched. CI will show the same baseline for any PR until the refactor lands.backend/tests/analytics.test.tscovers the live fallback, the TimescaleDB snapshot path, DefiLlama mapping, and empty-series degradation; prisma/pg-pool/logger mocked at module boundary, no DB needed. Vitest could not run locally (nonode_modules, installs avoided per environment policy) — CI covers it.onBrokenLinks: throwmakes the CI build the link checker; the site compiles withnpm run buildindocs-site/.Files changed
contracts/stream_contract/src/types.rs,errors.rs,events.rs,lib.rsbackend/prisma/migrations/20261001000000_add_timescaledb_analytics/migration.sqlbackend/src/services/analytics.service.ts,backend/src/controllers/analytics.controller.ts,backend/src/routes/v1/analytics.routes.ts,backend/src/routes/v1/index.ts,backend/tests/analytics.test.tsdocs-site/(config, sidebar, 20 content pages, 2 interactive components, CSS, README),.github/workflows/deploy-docs.ymlfrontend/src/components/dashboard/CopyButton.tsx,StreamDetailsModal.tsx,ShareAddressModal.tsx