diff --git a/README.md b/README.md index 3bf71cbc3..3a8d82fb6 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/ cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/vaultBalanceChangesList.graphql > crates/subgraph/src/types/vault_list_balance_changes.rs cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/orderClearsList.graphql > crates/subgraph/src/types/order_clears_list.rs cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/orderTakesList.graphql > crates/subgraph/src/types/order_takes_list.rs +cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/orderTakeDetail.graphql > crates/subgraph/src/types/order_take_detail.rs ``` 2. Prepend each generated types file with the following: diff --git a/crates/cli/src/commands/order_take/detail.rs b/crates/cli/src/commands/order_take/detail.rs new file mode 100644 index 000000000..51702aa3b --- /dev/null +++ b/crates/cli/src/commands/order_take/detail.rs @@ -0,0 +1,30 @@ +use crate::{execute::Execute, subgraph::CliSubgraphArgs}; +use anyhow::Result; +use clap::Args; + +use rain_orderbook_common::subgraph::SubgraphArgs; + +use tracing::info; + +#[derive(Args, Clone)] +pub struct CliOrderTakeDetailArgs { + #[arg(short = 'i', long, help = "ID of the Order Take")] + id: String, + + #[clap(flatten)] + pub subgraph_args: CliSubgraphArgs, +} + +impl Execute for CliOrderTakeDetailArgs { + async fn execute(&self) -> Result<()> { + let subgraph_args: SubgraphArgs = self.subgraph_args.clone().into(); + let order_take = subgraph_args + .to_subgraph_client() + .await? + .order_take_detail(self.id.clone().into()) + .await?; + info!("{:#?}", order_take); + + Ok(()) + } +} diff --git a/crates/cli/src/commands/order_take/mod.rs b/crates/cli/src/commands/order_take/mod.rs index 0a3448e1a..d7ad4c32a 100644 --- a/crates/cli/src/commands/order_take/mod.rs +++ b/crates/cli/src/commands/order_take/mod.rs @@ -1,12 +1,17 @@ +mod detail; mod list; use crate::execute::Execute; use anyhow::Result; use clap::Parser; +use detail::CliOrderTakeDetailArgs; use list::CliOrderTakesListArgs; #[derive(Parser)] pub enum OrderTake { + #[command(about = "View an Order Take", alias = "view")] + Detail(CliOrderTakeDetailArgs), + #[command(about = "List takes for an Order", alias = "ls")] List(CliOrderTakesListArgs), } @@ -14,6 +19,7 @@ pub enum OrderTake { impl Execute for OrderTake { async fn execute(&self) -> Result<()> { match self { + OrderTake::Detail(detail) => detail.execute().await, OrderTake::List(list) => list.execute().await, } } diff --git a/crates/subgraph/queries/orderTakeDetail.graphql b/crates/subgraph/queries/orderTakeDetail.graphql new file mode 100644 index 000000000..c20776457 --- /dev/null +++ b/crates/subgraph/queries/orderTakeDetail.graphql @@ -0,0 +1,40 @@ +query OrderTakeDetailQuery($id: ID!) { + takeOrderEntity(id: $id) { + id + transaction { + id + } + sender { + id + } + timestamp + order { + id + } + IORatio + input + inputDisplay + inputToken { + id + name + symbol + decimals + } + inputIOIndex + output + outputDisplay + outputToken { + id + name + symbol + decimals + } + outputIOIndex + context { + callingContext + calculationsContext + vaultInputsContext + vaultOutputsContext + } + } +} \ No newline at end of file diff --git a/crates/subgraph/src/client.rs b/crates/subgraph/src/client.rs index 65825f7d4..eae82b860 100644 --- a/crates/subgraph/src/client.rs +++ b/crates/subgraph/src/client.rs @@ -7,6 +7,8 @@ use crate::types::{ order_clears_list::{OrderClearsListQuery, OrderClearsListQueryVariables}, order_detail, order_detail::{OrderDetailQuery, OrderDetailQueryVariables}, + order_take_detail, + order_take_detail::{OrderTakeDetailQuery, OrderTakeDetailQueryVariables}, order_takes_list, order_takes_list::{OrderTakesListQuery, OrderTakesListQueryVariables}, orders_list, @@ -177,6 +179,23 @@ impl OrderbookSubgraphClient { Ok(data.take_order_entities) } + + pub async fn order_take_detail( + &self, + id: Id, + ) -> Result { + let data = self + .query::( + self.url.clone(), + OrderTakeDetailQueryVariables { id: &id }, + ) + .await?; + let order_take = data + .take_order_entity + .ok_or(OrderbookSubgraphClientError::Empty)?; + + Ok(order_take) + } } pub struct VaultListBalanceChangesPageQueryClient { diff --git a/crates/subgraph/src/types/mod.rs b/crates/subgraph/src/types/mod.rs index 96e33246f..3575c9f70 100644 --- a/crates/subgraph/src/types/mod.rs +++ b/crates/subgraph/src/types/mod.rs @@ -2,6 +2,7 @@ pub mod flattened; pub mod order_clears_list; pub mod order_detail; pub mod order_detail_traits; +pub mod order_take_detail; pub mod order_takes_list; pub mod orders_list; pub mod vault_balance_change; diff --git a/crates/subgraph/src/types/order_take_detail.rs b/crates/subgraph/src/types/order_take_detail.rs new file mode 100644 index 000000000..ad83fbcd2 --- /dev/null +++ b/crates/subgraph/src/types/order_take_detail.rs @@ -0,0 +1,85 @@ +use crate::schema; +use serde::Serialize; +use typeshare::typeshare; + +#[derive(cynic::QueryVariables, Debug)] +pub struct OrderTakeDetailQueryVariables<'a> { + pub id: &'a cynic::Id, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug)] +#[cynic(graphql_type = "Query", variables = "OrderTakeDetailQueryVariables")] +pub struct OrderTakeDetailQuery { + #[arguments(id: $id)] + pub take_order_entity: Option, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug, Serialize)] +pub struct TakeOrderEntity { + pub id: cynic::Id, + pub transaction: Transaction, + pub sender: Account, + pub timestamp: BigInt, + pub order: Order, + #[cynic(rename = "IORatio")] + pub ioratio: BigDecimal, + pub input: BigInt, + pub input_display: BigDecimal, + pub input_token: Erc20, + #[cynic(rename = "inputIOIndex")] + pub input_ioindex: BigInt, + pub output: BigInt, + pub output_display: BigDecimal, + pub output_token: Erc20, + #[cynic(rename = "outputIOIndex")] + pub output_ioindex: BigInt, + pub context: Option, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug, Serialize)] +pub struct Transaction { + pub id: cynic::Id, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug, Serialize)] +pub struct Order { + pub id: cynic::Id, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug, Serialize)] +#[cynic(graphql_type = "ERC20")] +pub struct Erc20 { + pub id: cynic::Id, + pub name: String, + pub symbol: String, + pub decimals: i32, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug, Serialize)] +pub struct ContextEntity { + pub calling_context: Option>, + pub calculations_context: Option>, + pub vault_inputs_context: Option>, + pub vault_outputs_context: Option>, +} + +#[typeshare] +#[derive(cynic::QueryFragment, Debug, Serialize)] +pub struct Account { + pub id: Bytes, +} + +#[derive(cynic::Scalar, Debug, Clone)] +pub struct BigDecimal(pub String); + +#[derive(cynic::Scalar, Debug, Clone)] +pub struct BigInt(pub String); + +#[derive(cynic::Scalar, Debug, Clone)] +pub struct Bytes(pub String); diff --git a/crates/subgraph/tests/order_take_test.rs b/crates/subgraph/tests/order_take_test.rs new file mode 100644 index 000000000..ecb7d4dec --- /dev/null +++ b/crates/subgraph/tests/order_take_test.rs @@ -0,0 +1,15 @@ +use cynic::Id; +use insta::assert_snapshot; +use rain_orderbook_subgraph_client::types::order_take_detail::{ + OrderTakeDetailQuery, OrderTakeDetailQueryVariables, +}; + +#[test] +fn vaults_query_gql_output() { + use cynic::QueryBuilder; + + let id = Id::new("1234"); + let request_body = OrderTakeDetailQuery::build(OrderTakeDetailQueryVariables { id: &id }); + + assert_snapshot!(request_body.query); +} diff --git a/crates/subgraph/tests/snapshots/order_take_test__vaults_query_gql_output.snap b/crates/subgraph/tests/snapshots/order_take_test__vaults_query_gql_output.snap new file mode 100644 index 000000000..015f0bf11 --- /dev/null +++ b/crates/subgraph/tests/snapshots/order_take_test__vaults_query_gql_output.snap @@ -0,0 +1,46 @@ +--- +source: crates/subgraph/tests/order_take_test.rs +expression: request_body.query +--- +query OrderTakeDetailQuery($id: ID!) { + takeOrderEntity(id: $id) { + id + transaction { + id + } + sender { + id + } + timestamp + order { + id + } + IORatio + input + inputDisplay + inputToken { + id + name + symbol + decimals + } + inputIOIndex + output + outputDisplay + outputToken { + id + name + symbol + decimals + } + outputIOIndex + context { + callingContext + calculationsContext + vaultInputsContext + vaultOutputsContext + } + } +} + + diff --git a/flake.nix b/flake.nix index b59e1e046..c007a12e1 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,7 @@ typeshare crates/subgraph/src/types/orders_list_for_vault.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/ordersListForVault.ts; typeshare crates/subgraph/src/types/order_clears_list.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orderClearsList.ts; typeshare crates/subgraph/src/types/order_takes_list.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orderTakesList.ts; + typeshare crates/subgraph/src/types/order_take_detail.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orderTakeDetail.ts; typeshare tauri-app/src-tauri/src/toast.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/toast.ts; typeshare tauri-app/src-tauri/src/transaction_status.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/transactionStatus.ts; diff --git a/tauri-app/package-lock.json b/tauri-app/package-lock.json index cc83f5ecd..972a22367 100644 --- a/tauri-app/package-lock.json +++ b/tauri-app/package-lock.json @@ -382,262 +382,6 @@ "w3c-keyname": "^2.2.4" } }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.11.tgz", - "integrity": "sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.11.tgz", - "integrity": "sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.11.tgz", - "integrity": "sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.11.tgz", - "integrity": "sha512-eccxjlfGw43WYoY9QgB82SgGgDbibcqyDTlk3l3C0jOVHKxrjdc9CTwDUQd0vkvYg5um0OH+GpxYvp39r+IPOg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.11.tgz", - "integrity": "sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.11.tgz", - "integrity": "sha512-fkFUiS6IUK9WYUO/+22omwetaSNl5/A8giXvQlcinLIjVkxwTLSktbF5f/kJMftM2MJp9+fXqZ5ezS7+SALp4g==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.11.tgz", - "integrity": "sha512-lhoSp5K6bxKRNdXUtHoNc5HhbXVCS8V0iZmDvyWvYq9S5WSfTIHU2UGjcGt7UeS6iEYp9eeymIl5mJBn0yiuxA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.11.tgz", - "integrity": "sha512-JkUqn44AffGXitVI6/AbQdoYAq0TEullFdqcMY/PCUZ36xJ9ZJRtQabzMA+Vi7r78+25ZIBosLTOKnUXBSi1Kw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.11.tgz", - "integrity": "sha512-3CRkr9+vCV2XJbjwgzjPtO8T0SZUmRZla+UL1jw+XqHZPkPgZiyWvbDvl9rqAN8Zl7qJF0O/9ycMtjU67HN9/Q==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.11.tgz", - "integrity": "sha512-LneLg3ypEeveBSMuoa0kwMpCGmpu8XQUh+mL8XXwoYZ6Be2qBnVtcDI5azSvh7vioMDhoJFZzp9GWp9IWpYoUg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.11.tgz", - "integrity": "sha512-caHy++CsD8Bgq2V5CodbJjFPEiDPq8JJmBdeyZ8GWVQMjRD0sU548nNdwPNvKjVpamYYVL40AORekgfIubwHoA==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.11.tgz", - "integrity": "sha512-ppZSSLVpPrwHccvC6nQVZaSHlFsvCQyjnvirnVjbKSHuE5N24Yl8F3UwYUUR1UEPaFObGD2tSvVKbvR+uT1Nrg==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.11.tgz", - "integrity": "sha512-B5x9j0OgjG+v1dF2DkH34lr+7Gmv0kzX6/V0afF41FkPMMqaQ77pH7CrhWeR22aEeHKaeZVtZ6yFwlxOKPVFyg==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.11.tgz", - "integrity": "sha512-MHrZYLeCG8vXblMetWyttkdVRjQlQUb/oMgBNurVEnhj4YWOr4G5lmBfZjHYQHHN0g6yDmCAQRR8MUHldvvRDA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.11.tgz", - "integrity": "sha512-f3DY++t94uVg141dozDu4CCUkYW+09rWtaWfnb3bqe4w5NqmZd6nPVBm+qbz7WaHZCoqXqHz5p6CM6qv3qnSSQ==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.11.tgz", - "integrity": "sha512-A5xdUoyWJHMMlcSMcPGVLzYzpcY8QP1RtYzX5/bS4dvjBGVxdhuiYyFwp7z74ocV7WDc0n1harxmpq2ePOjI0Q==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@esbuild/linux-x64": { "version": "0.19.11", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.11.tgz", @@ -654,102 +398,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.11.tgz", - "integrity": "sha512-13jvrQZJc3P230OhU8xgwUnDeuC/9egsjTkXN49b3GcS5BKvJqZn86aGM8W9pd14Kd+u7HuFBMVtrNGhh6fHEQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.11.tgz", - "integrity": "sha512-ysyOGZuTp6SNKPE11INDUeFVVQFrhcNDVUgSQVDzqsqX38DjhPEPATpid04LCoUr2WXhQTEZ8ct/EgJCUDpyNw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.11.tgz", - "integrity": "sha512-Hf+Sad9nVwvtxy4DXCZQqLpgmRTQqyFyhT3bZ4F2XlJCjxGmRFF0Shwn9rzhOYRB61w9VMXUkxlBy56dk9JJiQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.11.tgz", - "integrity": "sha512-0P58Sbi0LctOMOQbpEOvOL44Ne0sqbS0XWHMvvrg6NE5jQ1xguCSSw9jQeUk2lfrXYsKDdOe6K+oZiwKPilYPQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.11.tgz", - "integrity": "sha512-6YOrWS+sDJDmshdBIQU+Uoyh7pQKrdykdefC1avn76ss5c+RN6gut3LZA4E2cH5xUEp5/cA0+YxRaVtRAb0xBg==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.19.11", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.11.tgz", - "integrity": "sha512-vfkhltrjCAb603XaFhqhAF4LGDi2M4OrCRrFusyQ+iTLQ/o60QQXxc9cZC/FFpihBI9N1Grn6SMKVJ4KP7Fuiw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -1173,110 +821,6 @@ "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==" }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.4.tgz", - "integrity": "sha512-ub/SN3yWqIv5CWiAZPHVS1DloyZsJbtXmX4HxUTIpS0BHm9pW5iYBo2mIZi+hE3AeiTzHz33blwSnhdUo+9NpA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.4.tgz", - "integrity": "sha512-ehcBrOR5XTl0W0t2WxfTyHCR/3Cq2jfb+I4W+Ch8Y9b5G+vbAecVv0Fx/J1QKktOrgUYsIKxWAKgIpvw56IFNA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.4.tgz", - "integrity": "sha512-1fzh1lWExwSTWy8vJPnNbNM02WZDS8AW3McEOb7wW+nPChLKf3WG2aG7fhaUmfX5FKw9zhsF5+MBwArGyNM7NA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.4.tgz", - "integrity": "sha512-Gc6cukkF38RcYQ6uPdiXi70JB0f29CwcQ7+r4QpfNpQFVHXRd0DfWFidoGxjSx1DwOETM97JPz1RXL5ISSB0pA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.4.tgz", - "integrity": "sha512-g21RTeFzoTl8GxosHbnQZ0/JkuFIB13C3T7Y0HtKzOXmoHhewLbVTFBQZu+z5m9STH6FZ7L/oPgU4Nm5ErN2fw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.4.tgz", - "integrity": "sha512-TVYVWD/SYwWzGGnbfTkrNpdE4HON46orgMNHCivlXmlsSGQOx/OHHYiQcMIOx38/GWgwr/po2LBn7wypkWw/Mg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.4.tgz", - "integrity": "sha512-XcKvuendwizYYhFxpvQ3xVpzje2HHImzg33wL9zvxtj77HvPStbSGI9czrdbfrf8DGMcNNReH9pVZv8qejAQ5A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.4.tgz", - "integrity": "sha512-LFHS/8Q+I9YA0yVETyjonMJ3UA+DczeBd/MqNEzsGSTdNvSJa1OJZcSH8GiXLvcizgp9AlHs2walqRcqzjOi3A==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, "node_modules/@rollup/rollup-linux-x64-gnu": { "version": "4.9.4", "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.4.tgz", @@ -1303,45 +847,6 @@ "linux" ] }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.4.tgz", - "integrity": "sha512-T8Q3XHV+Jjf5e49B4EAaLKV74BbX7/qYBRQ8Wop/+TyyU0k+vSjiLVSHNWdVd1goMjZcbhDmYZUYW5RFqkBNHQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.4.tgz", - "integrity": "sha512-z+JQ7JirDUHAsMecVydnBPWLwJjbppU+7LZjffGf+Jvrxq+dVjIE7By163Sc9DKc3ADSU50qPVw0KonBS+a+HQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.4.tgz", - "integrity": "sha512-LfdGXCV9rdEify1oxlN9eamvDSjv9md9ZVMAbNHA87xqIfFCxImxan9qZ8+Un54iK2nnqPlbnSi4R54ONtbWBw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@scure/base": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", @@ -3202,20 +2707,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", diff --git a/tauri-app/src-tauri/src/commands/mod.rs b/tauri-app/src-tauri/src/commands/mod.rs index be23df9c6..12c621f47 100644 --- a/tauri-app/src-tauri/src/commands/mod.rs +++ b/tauri-app/src-tauri/src/commands/mod.rs @@ -5,3 +5,4 @@ pub mod order; pub mod order_clear; pub mod vault; pub mod wallet; +pub mod order_take; \ No newline at end of file diff --git a/tauri-app/src-tauri/src/commands/order_take.rs b/tauri-app/src-tauri/src/commands/order_take.rs new file mode 100644 index 000000000..3e16eef99 --- /dev/null +++ b/tauri-app/src-tauri/src/commands/order_take.rs @@ -0,0 +1,41 @@ +use crate::error::CommandResult; +use rain_orderbook_common::subgraph::SubgraphArgs; +use rain_orderbook_subgraph_client::{ + types::{flattened::{OrderTakeFlattened, TryIntoFlattenedError}, order_takes_list}, + TryIntoCsv, + PaginationArgs, +}; +use std::path::PathBuf; +use std::fs; + +#[tauri::command] +pub async fn order_takes_list( + order_id: String, + subgraph_args: SubgraphArgs, + pagination_args: PaginationArgs, +) -> CommandResult> { + let order_takes = subgraph_args + .to_subgraph_client() + .await? + .order_takes_list(order_id.clone().into(), pagination_args) + .await?; + Ok(order_takes) +} + +#[tauri::command] +pub async fn order_takes_list_write_csv( + path: PathBuf, + order_id: String, + subgraph_args: SubgraphArgs, + pagination_args: PaginationArgs, +) -> CommandResult<()> { + let order_takes = order_takes_list(order_id.clone().into(), subgraph_args, pagination_args).await?; + let order_takes_flattened: Vec = order_takes + .into_iter() + .map(|o| o.try_into()) + .collect::, TryIntoFlattenedError>>()?; + let csv_text = order_takes_flattened.try_into_csv()?; + fs::write(path, csv_text)?; + + Ok(()) +} \ No newline at end of file diff --git a/tauri-app/src-tauri/src/main.rs b/tauri-app/src-tauri/src/main.rs index 8462b93f4..8309ddb47 100644 --- a/tauri-app/src-tauri/src/main.rs +++ b/tauri-app/src-tauri/src/main.rs @@ -11,6 +11,7 @@ use commands::dotrain::parse_dotrain; use commands::dotrain_add_order_lsp::{call_lsp_completion, call_lsp_hover, call_lsp_problems}; use commands::order::{order_add, order_detail, order_remove, orders_list, orders_list_write_csv}; use commands::order_clear::{order_clears_list, order_clears_list_write_csv}; +use commands::order_take::{order_takes_list, order_takes_list_write_csv}; use commands::vault::{ vault_deposit, vault_detail, vault_list_balance_changes, vault_list_balance_changes_write_csv, vault_withdraw, vaults_list, vaults_list_write_csv, @@ -46,6 +47,8 @@ fn run_tauri_app() { order_remove, order_clears_list, order_clears_list_write_csv, + order_takes_list, + order_takes_list_write_csv, get_address_from_ledger, get_chainid, parse_dotrain, diff --git a/tauri-app/src/lib/components/AppTable.svelte b/tauri-app/src/lib/components/AppTable.svelte index f4ca7549c..f1c23554e 100644 --- a/tauri-app/src/lib/components/AppTable.svelte +++ b/tauri-app/src/lib/components/AppTable.svelte @@ -7,14 +7,14 @@ } from 'flowbite-svelte'; import { FileCsvOutline } from 'flowbite-svelte-icons'; import ButtonsPagination from '$lib/components/ButtonsPagination.svelte'; - import type { PaginatedCachedStore } from '$lib/storesGeneric/listStore'; + import type { ListStore } from '$lib/storesGeneric/listStore'; import ButtonLoading from './ButtonLoading.svelte'; import { createEventDispatcher } from 'svelte'; const dispatch = createEventDispatcher(); // eslint-disable-next-line no-undef - export let listStore: PaginatedCachedStore; + export let listStore: ListStore; export let emptyMessage: string = "None found" export let rowHoverable = true; export let enableCsvExport = true; diff --git a/tauri-app/src/lib/components/ChartHistogram.svelte b/tauri-app/src/lib/components/LightweightChart.svelte similarity index 81% rename from tauri-app/src/lib/components/ChartHistogram.svelte rename to tauri-app/src/lib/components/LightweightChart.svelte index a9f9e3eb9..b4769ec37 100644 --- a/tauri-app/src/lib/components/ChartHistogram.svelte +++ b/tauri-app/src/lib/components/LightweightChart.svelte @@ -1,7 +1,11 @@ - -
-
+
+
{#if title !== undefined} diff --git a/tauri-app/src/lib/components/LightweightChartHistogram.svelte b/tauri-app/src/lib/components/LightweightChartHistogram.svelte new file mode 100644 index 000000000..7478c75b2 --- /dev/null +++ b/tauri-app/src/lib/components/LightweightChartHistogram.svelte @@ -0,0 +1,5 @@ + + + chart.addHistogramSeries()} {...$$props} /> \ No newline at end of file diff --git a/tauri-app/src/lib/components/LightweightChartLine.svelte b/tauri-app/src/lib/components/LightweightChartLine.svelte new file mode 100644 index 000000000..0a97e6e30 --- /dev/null +++ b/tauri-app/src/lib/components/LightweightChartLine.svelte @@ -0,0 +1,5 @@ + + + chart.addLineSeries()} {...$$props} /> \ No newline at end of file diff --git a/tauri-app/src/lib/components/TableOrders.svelte b/tauri-app/src/lib/components/TableOrders.svelte index e11881f8a..e91c1efb5 100644 --- a/tauri-app/src/lib/components/TableOrders.svelte +++ b/tauri-app/src/lib/components/TableOrders.svelte @@ -12,13 +12,13 @@ import { orderRemove } from '$lib/utils/orderRemove'; import { formatTimestampSecondsAsLocal } from '$lib/utils/time'; import { walletAddressMatchesOrBlank } from '$lib/stores/settings'; - import type { PaginatedCachedStore } from '$lib/storesGeneric/listStore'; + import type { ListStore } from '$lib/storesGeneric/listStore'; import type { Order } from '$lib/typeshare/ordersList'; import Hash from './Hash.svelte'; import { HashType } from '$lib/utils/hash'; import AppTable from '$lib/components/AppTable.svelte'; - export let ordersList: PaginatedCachedStore; + export let ordersList: ListStore; { goto(`/orders/${e.detail.item.id}`); }}> diff --git a/tauri-app/src/lib/stores/orderTakesList.ts b/tauri-app/src/lib/stores/orderTakesList.ts new file mode 100644 index 000000000..571f8a7b0 --- /dev/null +++ b/tauri-app/src/lib/stores/orderTakesList.ts @@ -0,0 +1,11 @@ +import { get } from 'svelte/store'; +import { invoke } from '@tauri-apps/api'; +import { subgraphUrl } from '$lib/stores/settings'; +import { listStore } from '$lib/storesGeneric/listStore'; +import type { TakeOrderEntity } from '$lib/typeshare/orderTakesList'; + +export const useOrderTakesList = (orderId: string) => listStore( + `orderTakesList-${orderId}`, + (page) => invoke("order_takes_list", {subgraphArgs: { url: get(subgraphUrl)}, orderId, paginationArgs: { page: page+1, page_size: 10 } }), + (path) => invoke("order_takes_list_write_csv", {path, subgraphArgs: { url: get(subgraphUrl)}, orderId, paginationArgs: { page: 1, page_size: 1000 } }) +); diff --git a/tauri-app/src/routes/orders/[id]/+page.svelte b/tauri-app/src/routes/orders/[id]/+page.svelte index a6455da1d..d6d5fc849 100644 --- a/tauri-app/src/routes/orders/[id]/+page.svelte +++ b/tauri-app/src/routes/orders/[id]/+page.svelte @@ -1,16 +1,20 @@ @@ -41,8 +55,8 @@ {#if order === undefined}
Order not found
{:else} -
- +
+
@@ -93,6 +107,45 @@
+ +
+ +
+
+ Takes + + + + Date + Sender + Transaction Hash + Input + Output + IO Ratio + + + + + {formatTimestampSecondsAsLocal(BigInt(item.timestamp))} + + + + + + + + + {item.input_display} {item.input_token.symbol} + + + {item.output_display} {item.output_token.symbol} + + + {item.ioratio} {item.input_token.symbol}/{item.output_token.symbol} + + + +
{/if} diff --git a/tauri-app/src/routes/vaults/[id]/+page.svelte b/tauri-app/src/routes/vaults/[id]/+page.svelte index ee80c89da..83952acac 100644 --- a/tauri-app/src/routes/vaults/[id]/+page.svelte +++ b/tauri-app/src/routes/vaults/[id]/+page.svelte @@ -19,7 +19,7 @@ import { HashType } from '$lib/utils/hash'; import AppTable from '$lib/components/AppTable.svelte'; import { goto } from '$app/navigation'; - import ChartHistogram from '$lib/components/ChartHistogram.svelte'; + import LightweightChartHistogram from '$lib/components/LightweightChartHistogram.svelte'; import { timestampSecondsToUTCTimestamp } from '$lib/utils/time'; import { sortBy } from 'lodash'; import { VaultBalanceChangeType } from '$lib/types/vaultBalanceChange'; @@ -115,7 +115,7 @@ {/if} - +