Skip to content

Commit

Permalink
Accept time_created and unknown fields in live l2 tx schema (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamiak authored Jul 31, 2023
1 parent 0391ddd commit 5591f7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ import { z } from 'zod'

import { PerpetualL2Transaction } from './PerpetualBatchInfoResponse'

const PerpetualLiveL2TransactionResponseTransactionInfo = z.strictObject({
const PerpetualLiveL2TransactionResponseTransactionInfo = z.object({
tx: PerpetualL2Transaction,
tx_id: z.number(),
})
const PerpetualLiveL2TransactionResponseTransaction = z.strictObject({
const PerpetualLiveL2TransactionResponseTransaction = z.object({
apex_id: z.number(),
tx_info: z
.string()
.transform((s) =>
PerpetualLiveL2TransactionResponseTransactionInfo.parse(JSON.parse(s))
),
time_created: z.number().optional(), // Temporarily optional, only on goerli API
})

export type PerpetualLiveL2TransactionResponse = z.infer<
typeof PerpetualLiveL2TransactionResponse
>
export const PerpetualLiveL2TransactionResponse = z.strictObject({
export const PerpetualLiveL2TransactionResponse = z.object({
count: z.number(),
txs: z.array(PerpetualLiveL2TransactionResponseTransaction),
})
1 change: 1 addition & 0 deletions packages/backend/src/test/starkwareData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,6 @@ export const EXAMPLE_PERPETUAL_TRANSACTIONS = {
tx: transaction,
tx_id: 4000 + index,
}),
time_created: 1681458071 + index,
})),
}

0 comments on commit 5591f7c

Please sign in to comment.