Skip to content

fix(contracts,backend,frontend): test fee round-to-zero, BigInt timestamps, event write race, and stray label - #1132

Merged
ogazboiz merged 2 commits into
LabsCrypt:mainfrom
PsalmuelOS:feat/multi-issue-fix
Jul 29, 2026
Merged

fix(contracts,backend,frontend): test fee round-to-zero, BigInt timestamps, event write race, and stray label#1132
ogazboiz merged 2 commits into
LabsCrypt:mainfrom
PsalmuelOS:feat/multi-issue-fix

Conversation

@Psalmuel01

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR addresses issues #794, #830, #831, and #862 on branch feat/multi-issue-fix:

  1. Contract Fee Rounding to Zero Test ([Testing] collect_fee fee-rounds-to-zero branch untested - positive fee rate but amount too small to charge #794)

    • Verified unit test test_no_fee_transfer_or_event_when_fee_rounds_to_zero in contracts/stream_contract/src/test.rs.
    • Confirms that when fee_rate_bps > 0 but amount * bps / 10_000 truncates to 0, no fee transfer or fee_collected event is emitted.
  2. Backend BigInt Unix-Timestamp Schema & Migration ([Backend] Stream/StreamEvent Unix-timestamp columns typed Int overflow at 2038 (endTime can overflow today) #830)

    • Updated startTime, lastUpdateTime, endTime, and pausedAt on Stream and timestamp on StreamEvent from Int to BigInt in backend/prisma/schema.prisma.
    • Added migration 20260729170000_timestamp_bigint.
    • Updated soroban-event-worker.ts to compute timestamps with BigInt math so streams ending past Jan 2038 persist and round-trip correctly.
  3. Controller vs Indexer Event Write Race Fix ([Backend] Action controllers write StreamEvent via create() + ledgerSequence:0, colliding with worker upsert on @@unique([transactionHash,eventType]) #831)

    • Updated action controller in backend/src/routes/v1/streams/withdraw.ts to write StreamEvent using upsert on transactionHash_eventType instead of create, eliminating P2002 500 errors when the worker indexes first.
    • Updated worker upsert calls in soroban-event-worker.ts so update: sets ledgerSequence and timestamp, correctly overwriting placeholder ledgerSequence: 0 entries.
    • Added regression test backend/tests/eventRace.test.ts.
  4. Frontend Stray Label Removal ([Frontend] Stray Token: labeled statement left inside handleWithdraw on stream detail page #862)

    • Verified removal of stray Token: JS labeled statement inside handleWithdraw in frontend/src/app/streams/[id]/stream-details-content.tsx.
    • Confirmed withdraw state toggling and clean lint execution.

Issue Reference

Verification Steps

  • cargo test in contracts/stream_contract
  • npm test in backend
  • npm run lint in frontend

…ypt#830, LabsCrypt#831, and LabsCrypt#862

- LabsCrypt#794: Verify collect_fee rounds-to-zero branch test in contracts/stream_contract/src/test.rs
- LabsCrypt#830: Change Stream (startTime, lastUpdateTime, endTime, pausedAt) and StreamEvent (timestamp) to BigInt in schema.prisma and add migration
- LabsCrypt#831: Fix controller vs indexer event write race using upsert on transactionHash_eventType in withdraw.ts and updating ledgerSequence/timestamp in worker upsert
- LabsCrypt#862: Verify stray Token: label removal in frontend stream detail page
…indexers (LabsCrypt#830)

- Update createStream, topUpStreamHandler, withdrawHandler, and sorobanIndexerService to pass BigInt values for startTime, lastUpdateTime, endTime, and timestamp
- Update ClaimableStreamState interface to accept number | bigint for timestamp fields
@ogazboiz
ogazboiz merged commit df25b66 into LabsCrypt:main Jul 29, 2026
5 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment