Skip to content

Commit

Permalink
fix merge conflicts again
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Feb 19, 2025
1 parent 2dbc449 commit b825b7e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions crates/js_api/src/subgraph/remove_order.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cynic::Id;
use rain_orderbook_bindings::wasm_traits::prelude::*;
use rain_orderbook_subgraph_client::{OrderbookSubgraphClient, OrderbookSubgraphClientError};
use reqwest::Url;
use wasm_bindgen_utils::prelude::*;

/// Internal function to fetch Remove Orders for a given transaction
/// Returns an array of RemoveOrder structs
Expand All @@ -12,5 +12,5 @@ pub async fn get_transaction_remove_orders(
) -> Result<JsValue, OrderbookSubgraphClientError> {
let client = OrderbookSubgraphClient::new(Url::parse(url)?);
let remove_orders = client.transaction_remove_orders(Id::new(tx_hash)).await?;
Ok(to_value(&remove_orders)?)
Ok(to_js_value(&remove_orders)?)
}
10 changes: 6 additions & 4 deletions crates/subgraph/src/orderbook_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ use crate::types::order::{
SgOrdersListQuery,
};
use crate::types::order_trade::{SgOrderTradeDetailQuery, SgOrderTradesListQuery};
use crate::types::remove_order::{
SgTransactionRemoveOrdersQuery, TransactionRemoveOrdersVariables,
};
use crate::types::transaction::SgTransactionDetailQuery;
use crate::types::vault::{SgVaultDetailQuery, SgVaultsListQuery};
use crate::types::remove_order::{TransactionRemoveOrdersQuery, TransactionRemoveOrdersVariables};
use crate::vault_balance_changes_query::VaultBalanceChangesListPageQueryClient;
use cynic::Id;
use reqwest::Url;
Expand Down Expand Up @@ -426,11 +428,11 @@ impl OrderbookSubgraphClient {
pub async fn transaction_remove_orders(
&self,
id: Id,
) -> Result<Vec<RemoveOrderWithOrder>, OrderbookSubgraphClientError> {
) -> Result<Vec<SgRemoveOrderWithOrder>, OrderbookSubgraphClientError> {
let data = self
.query::<TransactionRemoveOrdersQuery, TransactionRemoveOrdersVariables>(
.query::<SgTransactionRemoveOrdersQuery, TransactionRemoveOrdersVariables>(
TransactionRemoveOrdersVariables {
id: Bytes(id.inner().to_string()),
id: SgBytes(id.inner().to_string()),
},
)
.await?;
Expand Down
15 changes: 7 additions & 8 deletions crates/subgraph/src/types/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub struct SgOrder {
pub meta: Option<SgRainMetaV1>,
pub add_events: Vec<SgAddOrder>,
pub trades: Vec<SgOrderStructPartialTrade>,
pub remove_events: Vec<RemoveOrder>,
pub remove_events: Vec<SgRemoveOrder>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -366,9 +366,9 @@ pub struct SgAddOrder {
}
#[derive(cynic::QueryFragment, Debug, Serialize, Clone)]
#[cfg_attr(target_family = "wasm", derive(Tsify))]
#[typeshare]
pub struct RemoveOrder {
pub transaction: Transaction,
#[cynic(graphql_type = "RemoveOrder")]
pub struct SgRemoveOrder {
pub transaction: SgTransaction,
}

#[derive(cynic::QueryFragment, Debug, Serialize, Clone)]
Expand All @@ -382,10 +382,9 @@ pub struct SgAddOrderWithOrder {
#[derive(cynic::QueryFragment, Debug, Serialize, Clone)]
#[cfg_attr(target_family = "wasm", derive(Tsify))]
#[cynic(graphql_type = "RemoveOrder")]
pub struct RemoveOrderWithOrder {
pub transaction: Transaction,
#[cfg_attr(target_family = "wasm", tsify(type = "OrderSubgraph"))]
pub order: Order,
pub struct SgRemoveOrderWithOrder {
pub transaction: SgTransaction,
pub order: SgOrder,
}

#[derive(cynic::Scalar, Debug, Clone, PartialEq, Eq, Hash)]
Expand Down
19 changes: 12 additions & 7 deletions crates/subgraph/src/types/remove_order.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
use super::common::{Bytes, RemoveOrderWithOrder};
use super::common::{SgBytes, SgRemoveOrderWithOrder};
use crate::schema;
use typeshare::typeshare;
use serde::Serialize;
#[cfg(target_family = "wasm")]
use wasm_bindgen_utils::{impl_wasm_traits, prelude::*};

#[derive(cynic::QueryVariables, Debug)]
pub struct TransactionRemoveOrdersVariables {
pub id: Bytes,
pub id: SgBytes,
}

#[derive(cynic::QueryFragment, Debug)]
#[derive(cynic::QueryFragment, Debug, Serialize)]
#[cynic(graphql_type = "Query", variables = "TransactionRemoveOrdersVariables")]
#[typeshare]
pub struct TransactionRemoveOrdersQuery {
#[cfg_attr(target_family = "wasm", derive(Tsify))]
#[serde(rename_all = "camelCase")]
pub struct SgTransactionRemoveOrdersQuery {
#[arguments(where: { transaction_: { id: $id } })]
pub remove_orders: Vec<RemoveOrderWithOrder>,
pub remove_orders: Vec<SgRemoveOrderWithOrder>,
}
#[cfg(target_family = "wasm")]
impl_wasm_traits!(SgTransactionRemoveOrdersQuery);
10 changes: 5 additions & 5 deletions packages/orderbook/test/js_api/removeOrder.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import assert from 'assert';
import { getLocal } from 'mockttp';
import { describe, it, beforeEach, afterEach } from 'vitest';
import { Transaction, RemoveOrderWithOrder } from '../../dist/types/js_api.js';
import { SgTransaction, SgRemoveOrderWithOrder } from '../../dist/types/js_api.js';
import { getTransactionRemoveOrders } from '../../dist/cjs/js_api.js';

const transaction1: Transaction = {
const transaction1: SgTransaction = {
id: '0x0da3659c0fd5258e962bf339afeaffddb06cc7a473802228b9586fe7503ed13a',
from: '0xf08bcbce72f62c95dcb7c07dcb5ed26acfcfbc11',
blockNumber: '37623990',
timestamp: '1739815758'
};

const mockRemoveOrder: RemoveOrderWithOrder = {
const mockRemoveOrder: SgRemoveOrderWithOrder = {
transaction: {
id: '0x0da3659c0fd5258e962bf339afeaffddb06cc7a473802228b9586fe7503ed13a',
from: '0xf08bcbce72f62c95dcb7c07dcb5ed26acfcfbc11',
Expand Down Expand Up @@ -120,7 +120,7 @@ const mockRemoveOrder: RemoveOrderWithOrder = {
}
};

const removeOrders: RemoveOrderWithOrder[] = [mockRemoveOrder];
const removeOrders: SgRemoveOrderWithOrder[] = [mockRemoveOrder];

describe('Rain Orderbook JS API Package Bindgen Tests - Remove Order', async function () {
const mockServer = getLocal();
Expand All @@ -132,7 +132,7 @@ describe('Rain Orderbook JS API Package Bindgen Tests - Remove Order', async fun
.forPost('/sg1')
.thenReply(200, JSON.stringify({ data: { removeOrders: removeOrders } }));
try {
const result: RemoveOrderWithOrder[] = await getTransactionRemoveOrders(
const result: SgRemoveOrderWithOrder[] = await getTransactionRemoveOrders(
mockServer.url + '/sg1',
transaction1.id
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function getDeploymentTransactionArgs(
return {
approvals,
deploymentCalldata,
orderbookAddress,
orderbookAddress: orderbookAddress as Hex,
chainId
};
}
2 changes: 1 addition & 1 deletion tauri-app/src-tauri/src/transaction_status.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::types::{TransactionStatus, TransactionStatusNotice};
use alloy::sol_types::SolCall;
use alloy_ethers_typecast::transaction::WriteTransactionStatus;
use chrono::Utc;
use crate::types::{TransactionStatus, TransactionStatusNotice};
use std::sync::RwLock;
use tauri::{AppHandle, Manager};
use uuid::Uuid;
Expand Down

0 comments on commit b825b7e

Please sign in to comment.