From 83be29b6afbada80988a466f9d91aa6c0d90d82f Mon Sep 17 00:00:00 2001 From: findolor Date: Mon, 9 Sep 2024 15:55:07 +0300 Subject: [PATCH 01/11] feat: add new field to query and Order struct --- crates/subgraph/queries/ordersList.graphql | 3 +++ crates/subgraph/src/orderbook_client.rs | 1 + crates/subgraph/src/types/common.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/crates/subgraph/queries/ordersList.graphql b/crates/subgraph/queries/ordersList.graphql index 47901c884..894491b34 100644 --- a/crates/subgraph/queries/ordersList.graphql +++ b/crates/subgraph/queries/ordersList.graphql @@ -36,5 +36,8 @@ query OrdersListQuery($skip: Int = 0, $first: Int = 25) { timestamp } } + trades(first: 1) { + id + } } } \ No newline at end of file diff --git a/crates/subgraph/src/orderbook_client.rs b/crates/subgraph/src/orderbook_client.rs index cc8a18a97..872540e9c 100644 --- a/crates/subgraph/src/orderbook_client.rs +++ b/crates/subgraph/src/orderbook_client.rs @@ -92,6 +92,7 @@ impl OrderbookSubgraphClient { let data = self .query::(variables) .await?; + Ok(data.orders) } diff --git a/crates/subgraph/src/types/common.rs b/crates/subgraph/src/types/common.rs index 8aa75ee79..fcd312588 100644 --- a/crates/subgraph/src/types/common.rs +++ b/crates/subgraph/src/types/common.rs @@ -72,6 +72,7 @@ pub struct Order { pub timestamp_added: BigInt, pub meta: Option, pub add_events: Vec, + pub trades: Vec, } #[derive(cynic::QueryFragment, Debug, Serialize, Clone)] From 268e59115da8dc9d6fd1c7364d697d7ef3e543df Mon Sep 17 00:00:00 2001 From: findolor Date: Mon, 9 Sep 2024 18:55:14 +0300 Subject: [PATCH 02/11] feat: add trades field to order struct and update orders list table --- crates/subgraph/src/types/common.rs | 10 ++++++++- .../components/tables/OrdersListTable.svelte | 22 +++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/crates/subgraph/src/types/common.rs b/crates/subgraph/src/types/common.rs index fcd312588..8fe0ece97 100644 --- a/crates/subgraph/src/types/common.rs +++ b/crates/subgraph/src/types/common.rs @@ -72,7 +72,8 @@ pub struct Order { pub timestamp_added: BigInt, pub meta: Option, pub add_events: Vec, - pub trades: Vec, + #[arguments(first: 1000)] + pub trades: Vec, } #[derive(cynic::QueryFragment, Debug, Serialize, Clone)] @@ -222,6 +223,13 @@ pub struct Trade { pub orderbook: Orderbook, } +#[derive(cynic::QueryFragment, Debug, Clone, Serialize)] +#[cynic(graphql_type = "Trade")] +#[typeshare] +pub struct TradePartial { + pub id: Bytes, +} + #[derive(cynic::QueryFragment, Debug, Serialize, Clone)] #[cynic(graphql_type = "ERC20")] #[typeshare] diff --git a/tauri-app/src/lib/components/tables/OrdersListTable.svelte b/tauri-app/src/lib/components/tables/OrdersListTable.svelte index da6e7f180..e2e887666 100644 --- a/tauri-app/src/lib/components/tables/OrdersListTable.svelte +++ b/tauri-app/src/lib/components/tables/OrdersListTable.svelte @@ -71,6 +71,7 @@ Output Token(s) + Trades @@ -82,15 +83,15 @@ Inactive {/if} - - - + + + + + + + + + {formatTimestampSecondsAsLocal(BigInt(item.timestampAdded))} @@ -100,6 +101,9 @@ {item.outputs?.map((t) => t.token.symbol)} + {item.trades.length} {#if $walletAddressMatchesOrBlank(item.owner) && item.active}