Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/explorer/cosmos.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"react-cosmos-plugin-vite"
],
"vite": {
"configPath": "./vite.config.ts",
"configPath": "./vite.config.mts",
"mainScriptUrl": "src/main.tsx"
},
"dom": {
Expand Down
25 changes: 11 additions & 14 deletions apps/explorer/src/api/operator/operatorApi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Address, UID } from '@cowprotocol/cow-sdk'

import { orderBookSDK } from 'cowSdk'

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

export { getAccountOrders } from './accountOrderUtils'

Expand Down Expand Up @@ -56,20 +54,19 @@ export async function getTxOrders(params: GetTxOrdersParams): Promise<RawOrder[]
* Both filters cannot be used at the same time
*/
export async function getTrades(
params: {
owner?: Address
orderId?: UID
} & WithNetworkId
params: GetTradesParams
): Promise<RawTrade[]> {
const { networkId, owner, orderId: orderUid } = params
console.log(`[getTrades] Fetching trades on network ${networkId} with filters`, { owner, orderUid })
const { networkId, owner, orderId: orderUid, offset, limit } = params
console.log(`[getTrades] Fetching trades on network ${networkId} with filters`, { owner, orderUid, offset, limit })

const tradesPromise = orderBookSDK.getTrades({ owner, orderUid }, { chainId: networkId }).catch((error) => {
console.error('[getTrades] Error getting PROD trades', params, error)
return []
})
const tradesPromise = orderBookSDK
.getTrades({ owner, orderUid, offset, limit }, { chainId: networkId })
.catch((error) => {
console.error('[getTrades] Error getting PROD trades', params, error)
return []
})
const tradesPromiseBarn = orderBookSDK
.getTrades({ owner, orderUid }, { chainId: networkId, env: 'staging' })
.getTrades({ owner, orderUid, offset, limit }, { chainId: networkId, env: 'staging' })
.catch((error) => {
console.error('[getTrades] Error getting BARN trades', params, error)
return []
Expand Down
2 changes: 2 additions & 0 deletions apps/explorer/src/api/operator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,6 @@ export type GetTxOrdersParams = WithNetworkId & {
export type GetTradesParams = WithNetworkId & {
owner?: string
orderId?: string
offset?: number
limit?: number
}
10 changes: 3 additions & 7 deletions apps/explorer/src/components/orders/OrderDetails/FillsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,18 @@ type FillsTableProps = SimpleTableProps & {
}

export function FillsTable(props: FillsTableProps): ReactNode {
const { trades, order, tableState, isPriceInverted, invertPrice } = props
const { trades, order, isPriceInverted, invertPrice } = props

const invertButton = useMemo(() => <Icon icon={faExchangeAlt} onClick={invertPrice} />, [invertPrice])

const currentPageTrades = useMemo(() => {
return trades?.slice(tableState.pageOffset, tableState.pageOffset + tableState.pageSize)
}, [tableState.pageOffset, tableState.pageSize, trades])

const tradeItems = !currentPageTrades?.length ? (
const tradeItems = !trades?.length ? (
<tr className="row-empty">
<td className="row-td-empty">
No results found. <br /> Please try another search.
</td>
</tr>
) : (
currentPageTrades.map((item) => <FillsTableRow key={item.txHash} trade={item} isPriceInverted={isPriceInverted} />)
trades.map((item) => <FillsTableRow key={item.txHash} trade={item} isPriceInverted={isPriceInverted} />)
)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,20 @@ const WithProviders = ({ children }: { children: React.ReactNode }) => (
<GlobalStateContext.Provider value={mockGlobalStateContextValue}>{children}</GlobalStateContext.Provider>
)

const mockTableProps = {
tableState: {
pageSize: 10,
pageOffset: 0,
pageIndex: 0,
hasNextPage: false,
totalResults: 0,
},
setPageSize: (): void => {},
setPageOffset: (): void => {},
handleNextPage: (): void => {},
handlePreviousPage: (): void => {},
}

// --- Fixture Definitions ---
const noErrors: Errors = {}
const defaultTrades: Trade[] = []
Expand All @@ -403,6 +417,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -414,6 +429,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -427,6 +443,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -438,6 +455,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -449,6 +467,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -460,6 +479,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -477,6 +497,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -489,6 +510,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -500,6 +522,7 @@ export default {
isOrderLoading={true}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -511,6 +534,7 @@ export default {
isOrderLoading={false}
areTradesLoading={true}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -522,6 +546,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -533,6 +558,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -547,6 +573,7 @@ export default {
error1: { message: 'Failed something something', type: 'error' },
error2: { message: 'Something else failed', type: 'error' },
}}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -559,6 +586,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -571,6 +599,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -582,6 +611,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -593,6 +623,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -604,6 +635,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -615,6 +647,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -626,6 +659,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -638,6 +672,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -649,6 +684,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -660,6 +696,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -671,6 +708,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand All @@ -683,6 +721,7 @@ export default {
isOrderLoading={false}
areTradesLoading={false}
errors={noErrors}
{...mockTableProps}
/>
</WithProviders>
),
Expand Down
Loading