-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from rainlanguage/2024-02-12-gui-take-orders
2024 02 12 gui take orders
- Loading branch information
Showing
22 changed files
with
396 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TakeOrderEntity>, | ||
} | ||
|
||
#[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<ContextEntity>, | ||
} | ||
|
||
#[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<Vec<BigInt>>, | ||
pub calculations_context: Option<Vec<BigInt>>, | ||
pub vault_inputs_context: Option<Vec<BigInt>>, | ||
pub vault_outputs_context: Option<Vec<BigInt>>, | ||
} | ||
|
||
#[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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
46 changes: 46 additions & 0 deletions
46
crates/subgraph/tests/snapshots/order_take_test__vaults_query_gql_output.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.