Skip to content

Commit

Permalink
wip: order response
Browse files Browse the repository at this point in the history
  • Loading branch information
NanezX committed Oct 19, 2023
1 parent 0a52a56 commit b7cef60
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion subgraph/tests/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ethers::{
};
use generated::{EvaluableConfigV2, Io, OrderConfigV2};
use hex::FromHex;
use subgraph::{wait, Query};
use subgraph::{query::get_order, wait, Query};
use utils::{
cbor::{decode_rain_meta, encode_rain_docs, RainMapDoc},
deploy::{deploy_erc20_mock, get_orderbook, read_orderbook_meta, touch_deployer},
Expand Down Expand Up @@ -269,8 +269,12 @@ async fn order_entity_test() -> Result<()> {
// Wait for Subgraph sync
wait().await.expect("cannot get SG sync status");

let id = Bytes::from(add_order_data.order_hash);

// let id = response;

let _ = get_order(id).await;

// let response = Query::content_meta_v1(content.hash().as_fixed_bytes().into())
// .await
// .expect("cannot get the query response");
Expand Down
4 changes: 3 additions & 1 deletion subgraph/tests/subgraph/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) mod content_meta_v1;
pub(crate) mod order;
pub(crate) mod orderbook;
pub(crate) mod rain_meta_v1;
pub(crate) mod order;

use anyhow::Result;
use ethers::types::{Address, Bytes};
Expand All @@ -12,6 +12,8 @@ use content_meta_v1::{get_content_meta_v1, ContentMetaV1Response};
use orderbook::{get_orderbook_query, OrderBookResponse};
use rain_meta_v1::{get_rain_meta_v1, RainMetaV1Response};

pub use order::get_order;

pub static SG_URL: Lazy<Url> =
Lazy::new(|| Url::parse("http://localhost:8000/subgraphs/name/test/test").unwrap());

Expand Down
11 changes: 8 additions & 3 deletions subgraph/tests/subgraph/query/order/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ pub struct OrderResponse {
impl OrderResponse {
// pub fn from(response: ResponseData) -> OrderResponse {
pub fn from(response: ResponseData) -> () {
println!("OrderResponse.from()");
let data = response.order.unwrap();

// Check here.
let owner: Bytes = data.owner.id;
println!("owner: {}", owner);
let emitter = data.emitter.id;
println!("emitter: {}", emitter);

let meta = data.meta.unwrap().id;

Expand All @@ -72,8 +74,9 @@ impl OrderResponse {
}

// pub async fn get_content_meta_v1(id: Bytes) -> Result<OrderResponse> {
pub async fn get_content_meta_v1(id: Bytes) -> Result<()> {
pub async fn get_order(id: Bytes) -> Result<()> {
wait().await?;
println!("get_order_0");

let variables = order::Variables {
id: id.to_string().into(),
Expand All @@ -87,12 +90,14 @@ pub async fn get_content_meta_v1(id: Bytes) -> Result<()> {
.send()
.await?;

println!("get_order_1");

let response_body: Response<order::ResponseData> = res.json().await?;
println!("get_order_2.is_some: {}", response_body.data.is_some());

match response_body.data {
Some(data) => {
let response = ();
// let response: OrderResponse = OrderResponse::from(data);
let response = OrderResponse::from(data);
Ok(response)
}
None => Err(anyhow!("Failed to get query")),
Expand Down
6 changes: 3 additions & 3 deletions subgraph/tests/subgraph/query/order/order.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ query Order($id: String) {
order(id: $id) {
id
orderHash
owner {
id
}
interpreter
interpreterStore
expressionDeployer
Expand All @@ -25,6 +22,9 @@ query Order($id: String) {
transaction {
id
}
owner {
id
}
emitter {
id
}
Expand Down

0 comments on commit b7cef60

Please sign in to comment.