diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index b51f67563..2b45e796f 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -8,8 +8,8 @@ sol!( #[cfg(test)] pub mod test { use crate::IOrderBookV3::*; - use alloy_sol_types::{SolCall, SolError, SolEvent, abi::token::WordToken}; - use alloy_primitives::{hex, Address, U256, keccak256}; + use alloy_primitives::{hex, keccak256, Address, U256}; + use alloy_sol_types::{abi::token::WordToken, SolCall, SolError, SolEvent}; #[test] fn test_deposit_function() { @@ -29,10 +29,7 @@ pub mod test { "0000000000000000000000000000000000000000000000000000000000000001" // vaultId ); - assert_eq!( - call_data, - expected_call_data - ); + assert_eq!(call_data, expected_call_data); } #[test] @@ -45,13 +42,11 @@ pub mod test { ); assert_eq!( ZeroDepositAmount::abi_decode_raw(&call_data, true), - Ok( - ZeroDepositAmount { - sender: Address::repeat_byte(0x11), - token: Address::repeat_byte(0x22), - vaultId: U256::from(1), - } - ) + Ok(ZeroDepositAmount { + sender: Address::repeat_byte(0x11), + token: Address::repeat_byte(0x22), + vaultId: U256::from(1), + }) ); } @@ -67,9 +62,7 @@ pub mod test { }; assert_eq!( deposit_event.encode_topics_array::<1>(), - [ - WordToken(Deposit::SIGNATURE_HASH) - ] + [WordToken(Deposit::SIGNATURE_HASH)] ); assert_eq!( deposit_event.encode_data(), @@ -86,7 +79,7 @@ pub mod test { assert_eq!(T::SIGNATURE, expected); assert_eq!(T::SELECTOR, keccak256(expected)[..4]); } - + fn assert_error_signature(expected: &str) { assert_eq!(T::SIGNATURE, expected); assert_eq!(T::SELECTOR, keccak256(expected)[..4]); @@ -95,5 +88,5 @@ pub mod test { fn assert_event_signature(expected: &str) { assert_eq!(T::SIGNATURE, expected); assert_eq!(T::SIGNATURE_HASH, keccak256(expected)); - } -} \ No newline at end of file + } +} diff --git a/crates/cli/src/cli/mod.rs b/crates/cli/src/cli/mod.rs index 07ac4e018..56b8878bf 100644 --- a/crates/cli/src/cli/mod.rs +++ b/crates/cli/src/cli/mod.rs @@ -1,7 +1,7 @@ +use crate::cli::order::Order; use anyhow::Result; use clap::command; use clap::{Parser, Subcommand}; -use crate::cli::order::Order; mod order; @@ -15,16 +15,14 @@ struct Cli { #[derive(Subcommand)] pub enum Orderbook { #[command(subcommand)] - Order(Order) + Order(Order), } pub async fn dispatch(orderbook: Orderbook) -> Result<()> { match orderbook { - Orderbook::Order(order) => { - match order { - Order::Ls => Ok(order::ls().await?), - } - } + Orderbook::Order(order) => match order { + Order::Ls => Ok(order::ls().await?), + }, } } diff --git a/crates/cli/src/cli/order.rs b/crates/cli/src/cli/order.rs index 89577b7d5..63fe4b3f2 100644 --- a/crates/cli/src/cli/order.rs +++ b/crates/cli/src/cli/order.rs @@ -1,14 +1,14 @@ -use clap::{Subcommand}; +use clap::Subcommand; #[derive(Subcommand)] #[command(about = "Interact with an order(s) onchain and offchain.")] pub enum Order { #[command(about = "List all orders from the subgraph.")] - Ls + Ls, } pub async fn ls() -> anyhow::Result<()> { let orders = rain_orderbook_subgraph_queries::orders::query().await?; dbg!(orders); Ok(()) -} \ No newline at end of file +} diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index d00eea471..e2d66a68a 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -3,4 +3,4 @@ mod cli; #[tokio::main] async fn main() -> anyhow::Result<()> { cli::main().await -} \ No newline at end of file +} diff --git a/crates/subgraph/src/lib.rs b/crates/subgraph/src/lib.rs index 09949f3e2..f667fd4cb 100644 --- a/crates/subgraph/src/lib.rs +++ b/crates/subgraph/src/lib.rs @@ -1 +1 @@ -pub mod orders; \ No newline at end of file +pub mod orders; diff --git a/crates/subgraph/src/orders/mod.rs b/crates/subgraph/src/orders/mod.rs index 886044967..3422de62b 100644 --- a/crates/subgraph/src/orders/mod.rs +++ b/crates/subgraph/src/orders/mod.rs @@ -1,15 +1,16 @@ +use anyhow::anyhow; use graphql_client::GraphQLQuery; use graphql_client::Response; +use once_cell::sync::Lazy; use reqwest::Url; use rust_bigint::BigInt; use serde_bytes::ByteBuf as Bytes; -use anyhow::anyhow; -use once_cell::sync::Lazy; use crate::orders::orders_query::OrdersQueryOrders; -static BASE_URL: Lazy = - Lazy::new(|| Url::parse("https://api.thegraph.com/subgraphs/name/siddharth2207/rainorderbook").unwrap()); +static BASE_URL: Lazy = Lazy::new(|| { + Url::parse("https://api.thegraph.com/subgraphs/name/siddharth2207/rainorderbook").unwrap() +}); #[derive(GraphQLQuery)] #[graphql( @@ -23,13 +24,17 @@ pub async fn query() -> anyhow::Result> { let variables = orders_query::Variables {}; let request_body = OrdersQuery::build_query(variables); let client = reqwest::Client::new(); - let res = client.post((*BASE_URL).clone()).json(&request_body).send().await?; + let res = client + .post((*BASE_URL).clone()) + .json(&request_body) + .send() + .await?; let response_body: Response = res.json().await?; match response_body { Response { data: Some(orders_query::ResponseData { orders }), .. } => Ok(orders), - _ => Err(anyhow!("Failed to get orders")) + _ => Err(anyhow!("Failed to get orders")), } -} \ No newline at end of file +}