Skip to content

Commit

Permalink
[!] modify Platform, Category all items to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Apr 23, 2024
1 parent 6370dfd commit b99f9d4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/controller/tigergraphql/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl IdentityQuery {
) -> Result<Option<ExpandIdentityRecord>> {
let client = make_http_client();

let platform: Platform = platform.parse()?;
let platform: Platform = platform.to_lowercase().parse()?;

let target = match platform {
Platform::ENS => Target::NFT(
Expand Down
24 changes: 21 additions & 3 deletions src/upstream/rss3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,28 @@ async fn save_item(p: ResultItem) -> Result<TargetProcessedList, Error> {
{
return Ok(vec![]);
}
let mut nft_category = ContractCategory::Unknown;
let standard = real_action.metadata.standard.clone();
if let Some(standard) = standard {
if standard == "ERC-721".to_string() {
nft_category = ContractCategory::ERC721;
} else if standard == "ERC-1155".to_string() {
nft_category = ContractCategory::ERC1155;
}
}

let mut nft_category =
ContractCategory::from_str(real_action.metadata.standard.as_ref().unwrap().as_str())
.unwrap_or_default();
// let mut nft_category = ContractCategory::from_str(
// real_action
// .metadata
// .standard
// .as_ref()
// .unwrap()
// .to_lowercase()
// .as_str(),
// )
// .unwrap_or_default();
println!("{:?}", real_action.metadata.standard);
println!("{:?}", nft_category.to_string());

if real_action.tag_type == "poap".to_string() {
nft_category = ContractCategory::POAP;
Expand Down
13 changes: 12 additions & 1 deletion src/upstream/space_id/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[cfg(test)]
mod tests {
use crate::error::Error;
use crate::upstream::space_id::{get_address, get_name};
use crate::upstream::space_id::{get_address, get_name, SpaceId};
use crate::upstream::{Fetcher, Platform, Target};

#[tokio::test]
async fn test_get_address() -> Result<(), Error> {
Expand All @@ -20,4 +21,14 @@ mod tests {
println!("name: {:?}", name);
Ok(())
}

#[tokio::test]
async fn test_fetch() -> Result<(), Error> {
let target = Target::Identity(
Platform::Ethereum,
"0x934b510d4c9103e6a87aef13b816fb080286d649".to_lowercase(),
);
let _ = SpaceId::fetch(&target).await?;
Ok(())
}
}
30 changes: 15 additions & 15 deletions src/upstream/types/contract_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ use strum_macros::{Display, EnumIter, EnumString};
Hash,
)]
pub enum ContractCategory {
#[strum(serialize = "ENS")]
#[serde(rename = "ENS")]
#[graphql(name = "ENS")]
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
#[graphql(name = "ens")]
ENS,

#[strum(serialize = "ERC721", serialize = "ERC-721")]
#[serde(rename = "ERC721")]
#[graphql(name = "ERC721")]
#[strum(serialize = "erc721")]
#[serde(rename = "erc721")]
#[graphql(name = "erc721")]
ERC721,

#[strum(serialize = "ERC1155", serialize = "ERC-1155")]
#[serde(rename = "ERC1155")]
#[graphql(name = "ERC1155")]
#[strum(serialize = "erc1155")]
#[serde(rename = "erc1155")]
#[graphql(name = "erc1155")]
ERC1155,

#[strum(serialize = "POAP")]
#[serde(rename = "POAP")]
#[graphql(name = "POAP")]
#[strum(serialize = "poap")]
#[serde(rename = "poap")]
#[graphql(name = "poap")]
POAP,

#[strum(serialize = "SNS")]
#[serde(rename = "SNS")]
#[graphql(name = "SNS")]
#[strum(serialize = "sns")]
#[serde(rename = "sns")]
#[graphql(name = "sns")]
SNS,

#[default]
Expand Down
6 changes: 3 additions & 3 deletions src/upstream/types/domain_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use strum_macros::{Display, EnumIter, EnumString};
pub enum DomainNameSystem {
/// ENS name system on the ETH chain.
/// https://ens.domains
#[strum(serialize = "ENS")]
#[serde(rename = "ENS")]
#[graphql(name = "ENS")]
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
#[graphql(name = "ens")]
ENS,

/// https://www.sns.id: Solana Name Service
Expand Down
6 changes: 3 additions & 3 deletions src/upstream/types/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ pub enum Platform {
HackerNews,

/// ENS
#[strum(serialize = "ENS")]
#[serde(rename = "ENS")]
#[graphql(name = "ENS")]
#[strum(serialize = "ens")]
#[serde(rename = "ens")]
#[graphql(name = "ens")]
ENS,

/// https://www.sns.id: Solana Name Service
Expand Down

0 comments on commit b99f9d4

Please sign in to comment.