Skip to content

Commit 0aa89f5

Browse files
committed
Harden Swapter timestamp parsing and add changelog entry
Use smartIsoDateFromTimestamp for the Swapter time.create field so the transform produces correct dates whether the partner sends Unix seconds or milliseconds, matching the other reports-server partner plugins. Add the missing CHANGELOG entry for the Swapter integration. Claude-Session: https://claude.ai/code/session_01STk8j8NcL2LgiuXRxirVn6
1 parent efd5290 commit 0aa89f5

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- added: Add Swapter reporting
56
- changed: Add index for orderId
67
- changed: Add EVM chainId, pluginId, and tokenId fields to StandardTx
78
- changed: Update Lifi to provide chainId, pluginId, and tokenId

src/partners/swapter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
StandardTx,
1717
Status
1818
} from '../types'
19-
import { datelog, retryFetch, snooze } from '../util'
19+
import { datelog, retryFetch, smartIsoDateFromTimestamp, snooze } from '../util'
2020

2121
const asSwapterStatus = asMaybe(
2222
asValue(
@@ -198,8 +198,7 @@ export const swapter: PartnerPlugin = {
198198
export function processSwapterTx(rawTx: unknown): StandardTx {
199199
const tx: SwapterTx = asSwapterTx(rawTx)
200200

201-
const date = new Date(tx.time.create)
202-
const timestamp = tx.time.create / 1000
201+
const { timestamp, isoDate } = smartIsoDateFromTimestamp(tx.time.create)
203202

204203
return {
205204
status: statusMap[tx.info.status],
@@ -227,7 +226,7 @@ export function processSwapterTx(rawTx: unknown): StandardTx {
227226
payoutAmount: tx.withdraw.amount,
228227

229228
timestamp,
230-
isoDate: date.toISOString(),
229+
isoDate,
231230

232231
usdValue: tx.info.equivalent > 0 ? tx.info.equivalent : -1,
233232

0 commit comments

Comments
 (0)