Skip to content

Commit

Permalink
fix: do not fail explorer when PROD api fails
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito committed May 15, 2024
1 parent 921f2bf commit 8989353
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions apps/explorer/src/api/operator/accountOrderUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { EnrichedOrder } from '@cowprotocol/cow-sdk'
import { EnrichedOrder, SupportedChainId } from '@cowprotocol/cow-sdk'

import { orderBookSDK } from 'cowSdk'

Expand Down Expand Up @@ -30,7 +29,7 @@ export async function getAccountOrders(params: GetAccountOrdersParams): Promise<

const ordersPromise = state.prodHasNext
? orderBookSDK.getOrders({ owner, offset, limit: limitPlusOne }, { chainId: networkId }).catch((error) => {
console.error('[getAccountOrders] Error getting PROD orders for account', owner, networkId, error)
console.error('[getAccountOrders] Error getting PROD orders for account ', owner, error)
return []
})
: []
Expand All @@ -39,7 +38,7 @@ export async function getAccountOrders(params: GetAccountOrdersParams): Promise<
? orderBookSDK
.getOrders({ owner, offset, limit: limitPlusOne }, { chainId: networkId, env: 'staging' })
.catch((error) => {
console.error('[getAccountOrders] Error getting orders for account', owner, networkId, error)
console.error('[getAccountOrders] Error getting BARN orders for account', owner, networkId, error)
return []
})
: []
Expand Down
9 changes: 6 additions & 3 deletions apps/explorer/src/api/operator/operatorApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Address, UID } from '@cowprotocol/cow-sdk'

import { orderBookSDK } from 'cowSdk'

import { GetOrderParams, RawOrder, RawTrade, GetTxOrdersParams, WithNetworkId } from './types'
import { GetOrderParams, GetTxOrdersParams, RawOrder, RawTrade, WithNetworkId } from './types'

export { getAccountOrders } from './accountOrderUtils'

Expand Down Expand Up @@ -53,11 +53,14 @@ export async function getTrades(
const { networkId, owner, orderId: orderUid } = params
console.log(`[getTrades] Fetching trades on network ${networkId} with filters`, { owner, orderUid })

const tradesPromise = orderBookSDK.getTrades({ owner, orderUid }, { chainId: networkId })
const tradesPromise = orderBookSDK.getTrades({ owner, orderUid }, { chainId: networkId }).catch((error) => {
console.error('[getTrades] Error getting PROD trades', params, error)
return []
})
const tradesPromiseBarn = orderBookSDK
.getTrades({ owner, orderUid }, { chainId: networkId, env: 'staging' })
.catch((error) => {
console.error('[getTrades] Error getting the trades for Barn', params, error)
console.error('[getTrades] Error getting BARN trades', params, error)
return []
})

Expand Down

0 comments on commit 8989353

Please sign in to comment.