-
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.
- Loading branch information
Showing
16 changed files
with
203 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,4 @@ pretty_assertions = "1.3" | |
regex = "1.10" | ||
reqwest = "0.12" | ||
thiserror = "1.0" | ||
url = { version = "2.4" } |
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
36 changes: 36 additions & 0 deletions
36
multichain-aggregator/multichain-aggregator-logic/src/types/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,36 @@ | ||
use super::ChainId; | ||
use crate::{dapp_client::DappWithChainId, error::ParseError, proto}; | ||
|
||
#[derive(Debug)] | ||
pub struct MarketplaceDapp { | ||
pub id: String, | ||
pub title: String, | ||
pub logo: String, | ||
pub short_description: String, | ||
pub chain_id: ChainId, | ||
} | ||
|
||
impl TryFrom<DappWithChainId> for MarketplaceDapp { | ||
type Error = ParseError; | ||
|
||
fn try_from(v: DappWithChainId) -> Result<Self, Self::Error> { | ||
Ok(Self { | ||
id: v.dapp.id, | ||
title: v.dapp.title, | ||
logo: v.dapp.logo, | ||
short_description: v.dapp.short_description, | ||
chain_id: v.chain_id.parse()?, | ||
}) | ||
} | ||
} | ||
|
||
impl From<MarketplaceDapp> for proto::MarketplaceDapp { | ||
fn from(v: MarketplaceDapp) -> Self { | ||
Self { | ||
id: v.id, | ||
title: v.title, | ||
logo: v.logo, | ||
short_description: v.short_description, | ||
} | ||
} | ||
} |
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
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.