Skip to content

a0b32b4e - Expose order timestamps in the Safe activity history - #4448

Merged
TaprootFreak merged 2 commits into
developfrom
fix/custody-order-history-date
Jul 29, 2026
Merged

a0b32b4e - Expose order timestamps in the Safe activity history#4448
TaprootFreak merged 2 commits into
developfrom
fix/custody-order-history-date

Conversation

@TaprootFreak

@TaprootFreak TaprootFreak commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

What

CustodyOrderHistoryDto carried no timestamp at all — only type, status and the amount/asset pairs. A client rendering the account activity had no way to date an entry.

The DTO now carries both timestamps of the order, passed through separately:

  • created — when the order was recorded, always present.
  • completedAt — the valuta timestamp, present only once the order has completed.

Why not a single field

Collapsing the two (completedAt ?? created) would hand the client a date without telling it what that date means, and would quietly claim a valuta for orders that never completed — including orders stuck in Created, where the gap between the two is precisely the interesting part. The choice of which one to display belongs to the caller.

CustodyOrderHistoryDtoMapper had no test coverage; the added spec pins the pass-through and, in particular, that an unfinished order keeps completedAt undefined rather than inheriting the creation date.

Consumers

Both history endpoints go through the same mapper, so GET /custody/account/:id/order and the user-scoped history gain the fields together. Purely additive — no existing field changes shape.

The UI side is DFXswiss/services#1207, which needs this deployed first; without it the rows simply show no date.

The order history DTO carried no timestamp at all, so a client had no way
to date an entry. Pass both the creation date and the valuta timestamp
separately rather than collapsing them: an order only gets completedAt
once it completes, and the distinction between when an order was recorded
and when it was valuated is exactly what a reader needs.
The valuta timestamp is only ever set once an order completes. A later
refactoring that collapses it onto the creation date would claim a valuta
that never happened, so assert the undefined case explicitly.
@TaprootFreak

Copy link
Copy Markdown
Collaborator Author

Two review passes, no changes required to the diff.

Two neighbouring observations came up that are deliberately not addressed here, both in code this PR does not touch:

  1. confirmOrder/approveOrder set the status without a precondition on the previous one, so a completed order could in principle be moved back while keeping its completedAt. Checked against production: 189 completed orders, zero rows with Completed and a null valuta, zero rows with a valuta and another status. Pre-existing and not observable today — worth its own ticket.

  2. getOrdersByUserData orders by created, while a client displaying the valuta timestamp sorts by a different key. Fixing that properly means moving the query from find() to a QueryBuilder with COALESCE over two camelCase columns — raw SQL whose quoting behaviour mocked unit tests do not catch. That is more risk than a field pass-through should carry, so it stays out. The rows are dated correctly either way; only their order can differ from the dates shown.

@TaprootFreak
TaprootFreak marked this pull request as ready for review July 29, 2026 13:20
@TaprootFreak
TaprootFreak merged commit 3057a4d into develop Jul 29, 2026
12 checks passed
@TaprootFreak
TaprootFreak deleted the fix/custody-order-history-date branch July 29, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant