fix(frontend): order same-timestamp send/receive pairs (receive above send)#13243
Open
sbpublic wants to merge 3 commits into
Open
fix(frontend): order same-timestamp send/receive pairs (receive above send)#13243sbpublic wants to merge 3 commits into
sbpublic wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Ensures the global Activity list orders same-timestamp transaction pairs (swap/self-transfer send+receive legs) deterministically by adding a tie-breaker to the shared sortTransactions comparator and validating it with a unit test.
Changes:
- Add a same-second tie-breaker in
sortTransactionsthat ranksreceiveabovesend. - Introduce a helper to rank transaction types for tie-breaking.
- Add a unit test asserting receive-before-send ordering regardless of input order.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/frontend/src/lib/utils/transactions.utils.ts | Adds type-based tie-breaker for same-timestamp sorting in sortTransactions. |
| src/frontend/src/tests/lib/utils/transactions.utils.spec.ts | Adds regression test for receive-above-send ordering on timestamp ties. |
sbpublic
added a commit
that referenced
this pull request
Jun 28, 2026
Address Copilot review on #13243: sortTransactions returned 1 for the both-nullish case (and again with the arguments swapped), violating the comparator's antisymmetry contract and leaving such pairs in engine- dependent order. Return 0 when both timestamps are nullish; the single- nullish case still sorts nullish last. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sbpublic
added a commit
that referenced
this pull request
Jun 28, 2026
…ions Address Copilot review on #13243: assert sortTransactions returns 0 when both timestamps are nullish (in both argument orders), locking the comparator-contract fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ve first sortTransactions compared only the (second-normalized) timestamp and returned 0 on ties, so the two legs of one operation — a swap's send and receive, or a self-transfer — fell back to Array.sort insertion order, which depends on token/provider load order and looked arbitrary. Add a deterministic tie-breaker: when timestamps are equal, rank the received leg above the sent one. It applies to every same-second send/receive pair, so swaps and self-transfers now read consistently. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address Copilot review on #13243: sortTransactions returned 1 for the both-nullish case (and again with the arguments swapped), violating the comparator's antisymmetry contract and leaving such pairs in engine- dependent order. Return 0 when both timestamps are nullish; the single- nullish case still sorts nullish last. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ions Address Copilot review on #13243: assert sortTransactions returns 0 when both timestamps are nullish (in both argument orders), locking the comparator-contract fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
07139c2 to
cf86823
Compare
|
✅ No security or compliance issues detected. Reviewed everything up to cf86823. Security Overview
Detected Code Changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In the activity list, the two legs of a single operation — a swap's send + receive, or a self-transfer — share the same block timestamp.
sortTransactionscompared only the (second-normalized) timestamp and returned0on ties, so these pairs fell back toArray.sortinsertion order (driven by token/provider load order). The result looked arbitrary: sometimes the send appeared above the receive, sometimes below.Changes
sortTransactions: when timestamps are equal, break the tie deterministically by type — the received leg sorts above the sent one. This is the single comparator the whole activity list uses, so every same-second send/receive pair (swaps, self-transfers, …) now orders consistently.sortTransactions: return0when both timestamps are nullish (previously1— and1again when swapped, an antisymmetry-contract violation that left such pairs in engine-dependent order). The single-nullish case still sorts nullish last. (From Copilot review.)Tests
sortTransactionstests: the received leg sorts above the sent one for a same-timestamp pair (regardless of input order), and the comparator returns0for two nullish-timestamp transactions in both argument orders.transactions.utils.spec.tspasses in full (78).test_fe_3.Model: Claude Opus 4.8 (
claude-opus-4-8)🤖 Generated with Claude Code