diff --git a/.changeset/thirty-beds-fold.md b/.changeset/thirty-beds-fold.md new file mode 100644 index 00000000..f5b5991f --- /dev/null +++ b/.changeset/thirty-beds-fold.md @@ -0,0 +1,6 @@ +--- +'@reservoir0x/relay-kit-hooks': minor +'@reservoir0x/relay-kit-ui': minor +--- + +Upgrade /requests api to /requests/v2 diff --git a/packages/hooks/src/hooks/useRequests.ts b/packages/hooks/src/hooks/useRequests.ts index 1f8d3546..0af65f5d 100644 --- a/packages/hooks/src/hooks/useRequests.ts +++ b/packages/hooks/src/hooks/useRequests.ts @@ -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, @@ -33,7 +33,7 @@ export const queryRequests = function ( pageParam?: string | null ): Promise { 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 } diff --git a/packages/ui/src/types/RelayTransaction.ts b/packages/ui/src/types/RelayTransaction.ts index 9bd9fb12..f3beedc0 100644 --- a/packages/ui/src/types/RelayTransaction.ts +++ b/packages/ui/src/types/RelayTransaction.ts @@ -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['requests'] diff --git a/packages/ui/src/utils/relayTransaction.ts b/packages/ui/src/utils/relayTransaction.ts index 4c6543fb..0c7a8f7a 100644 --- a/packages/ui/src/utils/relayTransaction.ts +++ b/packages/ui/src/utils/relayTransaction.ts @@ -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 @@ -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 =