-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(multichain): enhance search api (#1151)
* feat: add paginated address prefix search * fix: address prefix search * feat: add quick search for dapps * fix: filter out chains with invalid chain_id * fix: adjust order_by * fix: proto fields * feat: add logs for failed search * feat: add setting for default page size
- Loading branch information
Showing
20 changed files
with
460 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
46 changes: 46 additions & 0 deletions
46
multichain-aggregator/multichain-aggregator-logic/src/dapp_client.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,46 @@ | ||
use crate::error::ServiceError; | ||
use serde::Deserialize; | ||
use url::Url; | ||
|
||
pub struct DappClient { | ||
http: reqwest::Client, | ||
url: Url, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Dapp { | ||
pub id: String, | ||
pub title: String, | ||
pub logo: String, | ||
pub short_description: String, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct DappWithChainId { | ||
pub dapp: Dapp, | ||
pub chain_id: String, | ||
} | ||
|
||
impl DappClient { | ||
pub fn new(url: Url) -> Self { | ||
let http = reqwest::Client::new(); | ||
Self { http, url } | ||
} | ||
|
||
pub async fn search_dapps(&self, query: &str) -> Result<Vec<DappWithChainId>, ServiceError> { | ||
let mut url = self.url.clone(); | ||
url.set_path("/api/v1/marketplace/dapps:search"); | ||
url.query_pairs_mut().append_pair("query", query); | ||
|
||
self.http | ||
.get(url) | ||
.send() | ||
.await | ||
.map_err(|e| ServiceError::Internal(e.into()))? | ||
.json::<Vec<DappWithChainId>>() | ||
.await | ||
.map_err(|e| ServiceError::Internal(e.into())) | ||
} | ||
} |
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.