Skip to content

Commit 7ef26a7

Browse files
committed
just format
1 parent e85c2c5 commit 7ef26a7

File tree

342 files changed

+1069
-3697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+1069
-3697
lines changed

apps/api/src/assets/cilent.rs

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ impl AssetsClient {
1818

1919
pub fn add_assets(&self, assets: Vec<Asset>) -> Result<usize, Box<dyn Error + Send + Sync>> {
2020
let assets = assets.into_iter().map(|x| x.as_basic_primitive()).collect();
21-
self.database
22-
.assets()?
23-
.add_assets(assets)
24-
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
21+
self.database.assets()?.add_assets(assets).map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
2522
}
2623

2724
#[allow(unused)]
@@ -37,20 +34,12 @@ impl AssetsClient {
3734
Ok(self.database.assets()?.get_asset_full(asset_id)?)
3835
}
3936

40-
pub fn get_assets_by_device_id(
41-
&self,
42-
device_id: &str,
43-
wallet_index: i32,
44-
from_timestamp: Option<u32>,
45-
) -> Result<Vec<AssetId>, Box<dyn Error + Send + Sync>> {
37+
pub fn get_assets_by_device_id(&self, device_id: &str, wallet_index: i32, from_timestamp: Option<u32>) -> Result<Vec<AssetId>, Box<dyn Error + Send + Sync>> {
4638
let subscriptions = self.database.subscriptions()?.get_subscriptions_by_device_id(device_id, Some(wallet_index))?;
4739

4840
let chain_addresses = subscriptions.into_iter().map(|x| ChainAddress::new(x.chain, x.address)).collect();
4941

50-
Ok(self
51-
.database
52-
.assets_addresses()?
53-
.get_assets_by_addresses(chain_addresses, from_timestamp, true)?)
42+
Ok(self.database.assets_addresses()?.get_assets_by_addresses(chain_addresses, from_timestamp, true)?)
5443
}
5544
}
5645

@@ -68,14 +57,7 @@ impl SearchClient {
6857

6958
let assets: Vec<AssetDocument> = self
7059
.client
71-
.search(
72-
ASSETS_INDEX_NAME,
73-
&request.query,
74-
&build_filter(filters),
75-
[].as_ref(),
76-
request.limit,
77-
request.offset,
78-
)
60+
.search(ASSETS_INDEX_NAME, &request.query, &build_filter(filters), [].as_ref(), request.limit, request.offset)
7961
.await?;
8062

8163
Ok(assets.into_iter().map(|x| AssetBasic::new(x.asset, x.properties, x.score)).collect())
@@ -84,14 +66,7 @@ impl SearchClient {
8466
pub async fn get_perpetuals_search(&self, request: &SearchRequest) -> Result<Vec<Perpetual>, Box<dyn Error + Send + Sync>> {
8567
let perpetuals: Vec<PerpetualDocument> = self
8668
.client
87-
.search(
88-
PERPETUALS_INDEX_NAME,
89-
&request.query,
90-
&build_filter(vec![]),
91-
[].as_ref(),
92-
request.limit,
93-
request.offset,
94-
)
69+
.search(PERPETUALS_INDEX_NAME, &request.query, &build_filter(vec![]), [].as_ref(), request.limit, request.offset)
9570
.await?;
9671

9772
Ok(perpetuals.into_iter().map(|x| x.perpetual).collect())
@@ -100,14 +75,7 @@ impl SearchClient {
10075
pub async fn get_nfts_search(&self, request: &SearchRequest) -> Result<Vec<NFTCollection>, Box<dyn Error + Send + Sync>> {
10176
let nfts: Vec<NFTDocument> = self
10277
.client
103-
.search(
104-
NFTS_INDEX_NAME,
105-
&request.query,
106-
&build_filter(vec![]),
107-
[].as_ref(),
108-
request.limit,
109-
request.offset,
110-
)
78+
.search(NFTS_INDEX_NAME, &request.query, &build_filter(vec![]), [].as_ref(), request.limit, request.offset)
11179
.await?;
11280

11381
Ok(nfts.into_iter().map(|x| x.collection).collect())

apps/api/src/assets/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ pub async fn add_asset(
3030
let asset = chain_client
3131
.lock()
3232
.await
33-
.get_token_data(
34-
asset_id.chain,
35-
asset_id.token_id.clone().ok_or(ApiError::BadRequest("Missing token_id".to_string()))?,
36-
)
33+
.get_token_data(asset_id.chain, asset_id.token_id.clone().ok_or(ApiError::BadRequest("Missing token_id".to_string()))?)
3734
.await?;
3835
client.lock().await.add_assets(vec![asset.clone()])?;
3936

apps/api/src/chain/balance.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,13 @@ pub async fn get_balances_coin(chain: ChainParam, address: AddressParam, client:
1313
}
1414

1515
#[get("/chain/balances/<chain>/<address>/assets")]
16-
pub async fn get_balances_assets(
17-
chain: ChainParam,
18-
address: AddressParam,
19-
client: &State<Mutex<ChainClient>>,
20-
) -> Result<ApiResponse<Vec<AssetBalance>>, ApiError> {
16+
pub async fn get_balances_assets(chain: ChainParam, address: AddressParam, client: &State<Mutex<ChainClient>>) -> Result<ApiResponse<Vec<AssetBalance>>, ApiError> {
2117
let request = ChainAddress::new(chain.0, address.0);
2218
Ok(client.lock().await.get_balances_assets(request).await?.into())
2319
}
2420

2521
#[get("/chain/balances/<chain>/<address>/staking")]
26-
pub async fn get_balances_staking(
27-
chain: ChainParam,
28-
address: AddressParam,
29-
client: &State<Mutex<ChainClient>>,
30-
) -> Result<ApiResponse<Option<AssetBalance>>, ApiError> {
22+
pub async fn get_balances_staking(chain: ChainParam, address: AddressParam, client: &State<Mutex<ChainClient>>) -> Result<ApiResponse<Option<AssetBalance>>, ApiError> {
3123
let request = ChainAddress::new(chain.0, address.0);
3224
Ok(client.lock().await.get_balances_staking(request).await?.into())
3325
}

apps/api/src/chain/client.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ impl ChainClient {
4040
self.providers.get_staking_apy(chain).await
4141
}
4242

43-
pub async fn get_block_transactions(
44-
&self,
45-
chain: Chain,
46-
block_number: i64,
47-
transaction_type: Option<&str>,
48-
) -> Result<Vec<Transaction>, Box<dyn Error + Send + Sync>> {
43+
pub async fn get_block_transactions(&self, chain: Chain, block_number: i64, transaction_type: Option<&str>) -> Result<Vec<Transaction>, Box<dyn Error + Send + Sync>> {
4944
let transactions = self.providers.get_block_transactions(chain, block_number as u64).await?;
5045
Ok(self.filter_transactions(transactions, transaction_type))
5146
}

apps/api/src/chain/transaction.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ pub async fn get_block_transactions(
2424
transaction_type: Option<&str>,
2525
client: &State<Mutex<ChainClient>>,
2626
) -> Result<ApiResponse<Vec<Transaction>>, ApiError> {
27-
Ok(client
28-
.lock()
29-
.await
30-
.get_block_transactions(chain.0, block_number, transaction_type)
31-
.await?
32-
.into())
27+
Ok(client.lock().await.get_block_transactions(chain.0, block_number, transaction_type).await?.into())
3328
}
3429

3530
#[get("/chain/blocks/<chain>/<block_number>/finalize?<address>&<transaction_type>")]

apps/api/src/fiat/client.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ impl FiatQuotesClient {
6161
self.fiat_client.get_off_ramp_assets().await
6262
}
6363

64-
pub async fn process_and_publish_webhook(
65-
&self,
66-
provider: &str,
67-
webhook_data: serde_json::Value,
68-
) -> Result<streamer::FiatWebhookPayload, Box<dyn Error + Send + Sync>> {
64+
pub async fn process_and_publish_webhook(&self, provider: &str, webhook_data: serde_json::Value) -> Result<streamer::FiatWebhookPayload, Box<dyn Error + Send + Sync>> {
6965
self.fiat_client.process_and_publish_webhook(provider, webhook_data).await
7066
}
7167

apps/api/src/fiat/mod.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ pub async fn get_fiat_quotes_by_type(
7070
}
7171

7272
#[post("/fiat/quotes/url", data = "<request>")]
73-
pub async fn get_fiat_quote_url(
74-
request: Json<FiatQuoteUrlRequest>,
75-
ip: std::net::IpAddr,
76-
client: &State<Mutex<FiatQuotesClient>>,
77-
) -> Result<ApiResponse<FiatQuoteUrl>, ApiError> {
73+
pub async fn get_fiat_quote_url(request: Json<FiatQuoteUrlRequest>, ip: std::net::IpAddr, client: &State<Mutex<FiatQuotesClient>>) -> Result<ApiResponse<FiatQuoteUrl>, ApiError> {
7874
let ip_address = if cfg!(debug_assertions) { DEBUG_FIAT_IP } else { &ip.to_string() };
7975
let (url, quote) = client.lock().await.get_quote_url(&request, ip_address).await?;
8076
metrics_fiat_quote_url(&quote);
@@ -96,16 +92,7 @@ pub async fn get_fiat_on_ramp_quotes(
9692
Ok(client
9793
.lock()
9894
.await
99-
.get_quotes_old(
100-
&asset_id.0,
101-
Some(amount),
102-
None,
103-
FiatQuoteType::Buy,
104-
currency,
105-
&wallet_address.0,
106-
&ip_addr,
107-
provider,
108-
)
95+
.get_quotes_old(&asset_id.0, Some(amount), None, FiatQuoteType::Buy, currency, &wallet_address.0, &ip_addr, provider)
10996
.await?
11097
.into())
11198
}
@@ -132,20 +119,12 @@ pub async fn get_fiat_off_ramp_assets(client: &State<Mutex<FiatQuotesClient>>) -
132119
}
133120

134121
#[post("/fiat/webhooks/<provider>", data = "<webhook_data>")]
135-
pub async fn create_fiat_webhook(
136-
provider: &str,
137-
webhook_data: Json<serde_json::Value>,
138-
client: &State<Mutex<FiatQuotesClient>>,
139-
) -> Result<ApiResponse<FiatWebhook>, ApiError> {
122+
pub async fn create_fiat_webhook(provider: &str, webhook_data: Json<serde_json::Value>, client: &State<Mutex<FiatQuotesClient>>) -> Result<ApiResponse<FiatWebhook>, ApiError> {
140123
Ok(client.lock().await.process_and_publish_webhook(provider, webhook_data.0).await?.payload.into())
141124
}
142125

143126
#[get("/fiat/orders/<provider>/<order_id>")]
144-
pub async fn get_fiat_order(
145-
provider: &str,
146-
order_id: &str,
147-
client: &State<Mutex<FiatQuotesClient>>,
148-
) -> Result<ApiResponse<primitives::FiatTransaction>, ApiError> {
127+
pub async fn get_fiat_order(provider: &str, order_id: &str, client: &State<Mutex<FiatQuotesClient>>) -> Result<ApiResponse<primitives::FiatTransaction>, ApiError> {
149128
Ok(client.lock().await.get_order_status(provider, order_id).await?.into())
150129
}
151130

apps/api/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ async fn rocket_api(settings: Settings) -> Rocket<Build> {
109109
let webhooks_client = WebhooksClient::new(stream_producer.clone());
110110
let support_client = SupportClient::new(database.clone());
111111
let ip_check_providers: Vec<Arc<dyn IpCheckProvider>> = vec![
112-
Arc::new(AbuseIPDBClient::new(
113-
settings.ip.abuseipdb.url.clone(),
114-
settings.ip.abuseipdb.key.secret.clone(),
115-
)),
112+
Arc::new(AbuseIPDBClient::new(settings.ip.abuseipdb.url.clone(), settings.ip.abuseipdb.key.secret.clone())),
116113
Arc::new(IpApiClient::new(settings.ip.ipapi.url.clone(), settings.ip.ipapi.key.secret.clone())),
117114
];
118115
let ip_security_client = IpSecurityClient::new(ip_check_providers, cacher_client.clone());

apps/api/src/metrics/parser.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,17 @@ pub fn init_parser_metrics(registry: &mut Registry) {
3333
}
3434

3535
pub fn update_parser_metrics(database: &Database) {
36-
let states = database
37-
.client()
38-
.ok()
39-
.and_then(|mut c| c.parser_state().get_parser_states().ok())
40-
.unwrap_or_default();
36+
let states = database.client().ok().and_then(|mut c| c.parser_state().get_parser_states().ok()).unwrap_or_default();
4137

4238
for state in states {
4339
if let Some(current_block) = PARSER_CURRENT_BLOCK.get() {
44-
current_block
45-
.get_or_create(&ParserStateLabels { chain: state.clone().chain })
46-
.set(state.current_block);
40+
current_block.get_or_create(&ParserStateLabels { chain: state.clone().chain }).set(state.current_block);
4741
}
4842
if let Some(latest_block) = PARSER_LATEST_BLOCK.get() {
49-
latest_block
50-
.get_or_create(&ParserStateLabels { chain: state.clone().chain })
51-
.set(state.latest_block);
43+
latest_block.get_or_create(&ParserStateLabels { chain: state.clone().chain }).set(state.latest_block);
5244
}
5345
if let Some(is_enabled) = PARSER_IS_ENABLED.get() {
54-
is_enabled
55-
.get_or_create(&ParserStateLabels { chain: state.clone().chain })
56-
.set(state.is_enabled as i64);
46+
is_enabled.get_or_create(&ParserStateLabels { chain: state.clone().chain }).set(state.is_enabled as i64);
5747
}
5848
if let Some(updated_at) = PARSER_UPDATED_AT.get() {
5949
updated_at

apps/api/src/nft/mod.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ use std::io::Cursor;
1313
// by device
1414

1515
#[get("/nft/assets/device/<device_id>?<wallet_index>")]
16-
pub async fn get_nft_assets_old(
17-
device_id: DeviceIdParam,
18-
wallet_index: i32,
19-
client: &State<Mutex<NFTClient>>,
20-
) -> Result<ApiResponse<ResponseResultNew<Vec<NFTData>>>, ApiError> {
16+
pub async fn get_nft_assets_old(device_id: DeviceIdParam, wallet_index: i32, client: &State<Mutex<NFTClient>>) -> Result<ApiResponse<ResponseResultNew<Vec<NFTData>>>, ApiError> {
2117
Ok(ResponseResultNew::new(client.lock().await.get_nft_assets(&device_id.0, wallet_index).await?).into())
2218
}
2319

@@ -29,11 +25,7 @@ pub async fn get_nft_assets_v2(device_id: DeviceIdParam, wallet_index: i32, clie
2925
// by address. mostly for testing purposes
3026

3127
#[get("/nft/assets/chain/<chain>?<address>")]
32-
pub async fn get_nft_assets_by_chain(
33-
chain: ChainParam,
34-
address: AddressParam,
35-
client: &State<Mutex<NFTClient>>,
36-
) -> Result<ApiResponse<Vec<NFTData>>, ApiError> {
28+
pub async fn get_nft_assets_by_chain(chain: ChainParam, address: AddressParam, client: &State<Mutex<NFTClient>>) -> Result<ApiResponse<Vec<NFTData>>, ApiError> {
3729
Ok(client.lock().await.get_nft_assets_by_chain(chain.0, &address.0).await?.into())
3830
}
3931

@@ -85,12 +77,7 @@ pub async fn report_nft(request: Json<ReportNft>, client: &State<Mutex<NFTClient
8577
Ok(client
8678
.lock()
8779
.await
88-
.report_nft(
89-
&request.device_id,
90-
request.collection_id.clone(),
91-
request.asset_id.clone(),
92-
request.reason.clone(),
93-
)?
80+
.report_nft(&request.device_id, request.collection_id.clone(), request.asset_id.clone(), request.reason.clone())?
9481
.into())
9582
}
9683

0 commit comments

Comments
 (0)