-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(multichain): token search endpoint (#1164)
* chore: add logs * feat: add tokens for quick search * feat: add paginated search for tokens * fix: remove chain_id from import entities * feat: migrate to api-client-framework
- Loading branch information
Showing
26 changed files
with
1,361 additions
and
594 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
multichain-aggregator/multichain-aggregator-logic/src/clients/dapp.rs
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,52 @@ | ||
use api_client_framework::{ | ||
serialize_query, Endpoint, Error, HttpApiClient as Client, HttpApiClientConfig, | ||
}; | ||
use reqwest::Method; | ||
use serde::{Deserialize, Serialize}; | ||
use url::Url; | ||
|
||
pub fn new_client(url: Url) -> Result<Client, Error> { | ||
let config = HttpApiClientConfig::default(); | ||
Client::new(url, config) | ||
} | ||
|
||
pub struct SearchDapps { | ||
pub params: SearchDappsParams, | ||
} | ||
|
||
#[derive(Serialize, Clone, Debug, Default, PartialEq)] | ||
pub struct SearchDappsParams { | ||
pub query: String, | ||
} | ||
|
||
impl Endpoint for SearchDapps { | ||
type Response = Vec<DappWithChainId>; | ||
|
||
fn method(&self) -> Method { | ||
Method::GET | ||
} | ||
|
||
fn path(&self) -> String { | ||
"/api/v1/marketplace/dapps:search".to_string() | ||
} | ||
|
||
fn query(&self) -> Option<String> { | ||
serialize_query(&self.params) | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct DappWithChainId { | ||
pub dapp: Dapp, | ||
pub chain_id: String, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Dapp { | ||
pub id: String, | ||
pub title: String, | ||
pub logo: String, | ||
pub short_description: String, | ||
} |
2 changes: 2 additions & 0 deletions
2
multichain-aggregator/multichain-aggregator-logic/src/clients/mod.rs
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,2 @@ | ||
pub mod dapp; | ||
pub mod token_info; |
63 changes: 63 additions & 0 deletions
63
multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs
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,63 @@ | ||
use crate::ChainId; | ||
use api_client_framework::{ | ||
serialize_query, Endpoint, Error, HttpApiClient as Client, HttpApiClientConfig, | ||
}; | ||
use reqwest::Method; | ||
use serde::{Deserialize, Serialize}; | ||
use url::Url; | ||
|
||
pub fn new_client(url: Url) -> Result<Client, Error> { | ||
let config = HttpApiClientConfig::default(); | ||
Client::new(url, config) | ||
} | ||
|
||
pub struct SearchTokenInfos { | ||
pub params: SearchTokenInfosParams, | ||
} | ||
|
||
#[serde_with::skip_serializing_none] | ||
#[derive(Serialize, Clone, Debug, Default, PartialEq)] | ||
pub struct SearchTokenInfosParams { | ||
pub query: String, | ||
pub chain_id: Option<ChainId>, | ||
pub page_size: Option<u32>, | ||
pub page_token: Option<String>, | ||
} | ||
|
||
impl Endpoint for SearchTokenInfos { | ||
type Response = TokenInfoSearchResponse; | ||
|
||
fn method(&self) -> Method { | ||
Method::GET | ||
} | ||
|
||
fn path(&self) -> String { | ||
"/api/v1/token-infos:search".to_string() | ||
} | ||
|
||
fn query(&self) -> Option<String> { | ||
serialize_query(&self.params) | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct TokenInfo { | ||
pub token_address: String, | ||
pub chain_id: String, | ||
pub icon_url: String, | ||
pub token_name: Option<String>, | ||
pub token_symbol: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct TokenInfoSearchResponse { | ||
pub token_infos: Vec<TokenInfo>, | ||
pub next_page_params: Option<Pagination>, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Pagination { | ||
pub page_token: String, | ||
pub page_size: u32, | ||
} |
46 changes: 0 additions & 46 deletions
46
multichain-aggregator/multichain-aggregator-logic/src/dapp_client.rs
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.