Skip to content

Commit

Permalink
Merge pull request #212 from reservoirprotocol/pedro/relay-5441-upgra…
Browse files Browse the repository at this point in the history
…de-to-requests-api-v2-in-sdk-and-client

Upgrade to requests api v2 in sdk and client
  • Loading branch information
pedromcunha authored Aug 7, 2024
2 parents e487aa1 + b9db008 commit 38f6b06
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/thirty-beds-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@reservoir0x/relay-kit-hooks': minor
'@reservoir0x/relay-kit-ui': minor
---

Upgrade /requests api to /requests/v2
6 changes: 3 additions & 3 deletions packages/hooks/src/hooks/useRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
import fetcher from '../fetcher.js'

export type UserTransactionQuery =
paths['/requests']['get']['parameters']['query'] & { id?: string }
paths['/requests/v2']['get']['parameters']['query'] & { id?: string }

export type UserTransactionsResponse =
paths['/requests']['get']['responses']['200']['content']['application/json']
paths['/requests/v2']['get']['responses']['200']['content']['application/json']

type InfiniteQueryType = typeof useInfiniteQuery<
UserTransactionsResponse,
Expand All @@ -33,7 +33,7 @@ export const queryRequests = function (
pageParam?: string | null
): Promise<UserTransactionsResponse> {
const baseUrl = typeof window !== 'undefined' ? window.location.origin : ''
const url = new URL(`${baseApiUrl}/requests`, baseUrl)
const url = new URL(`${baseApiUrl}/requests/v2`, baseUrl)

let query: UserTransactionQuery = { ...options }

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/types/RelayTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { paths } from '@reservoir0x/relay-sdk'

export type UserTransactionsResponse =
paths['/requests']['get']['responses']['200']['content']['application/json']
paths['/requests/v2']['get']['responses']['200']['content']['application/json']

export type RelayTransaction = NonNullable<
NonNullable<UserTransactionsResponse>['requests']
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/src/utils/relayTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const extractToChain = (
export const calculateFillTime = (transaction?: RelayTransaction | null) => {
let fillTime = '-'
let seconds = 0
if (transaction?.status !== 'pending' && transaction?.status !== 'received') {
if (
transaction?.status !== 'pending' &&
transaction?.status !== 'waiting' &&
transaction?.status !== 'delayed'
) {
const inTxTimestamps =
transaction?.data?.inTxs?.map((tx) => tx.timestamp as number) ?? null
const txStartTimestamp = inTxTimestamps ? Math.min(...inTxTimestamps) : null
Expand Down Expand Up @@ -57,7 +61,11 @@ export const calculateExecutionTime = (
) => {
let fillTime = '-'
let seconds = 0
if (transaction?.status !== 'pending' && transaction?.status !== 'received') {
if (
transaction?.status !== 'pending' &&
transaction?.status !== 'waiting' &&
transaction?.status !== 'delayed'
) {
const inTxTimestamps =
transaction?.data?.inTxs?.map((tx) => tx.timestamp as number) ?? null
const outTxTimestamps =
Expand Down

0 comments on commit 38f6b06

Please sign in to comment.