Skip to content

Commit

Permalink
[#] add genome for Gnosis Domain https://genomedomains.com
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed May 14, 2024
1 parent c562b2b commit e4bcf61
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/main.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ url = "https://indexer.crossbell.io/v1/graphql"

[upstream.solana_rpc]
rpc_url = "https://api.mainnet-beta.solana.com"

[upstream.genome_api]
rpc_url = "http://ec2-18-167-90-166.ap-east-1.compute.amazonaws.com/data_server/genome"
6 changes: 6 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct Upstream {
pub spaceid_api: ConfigSpaceIdAPI,
pub crossbell_api: ConfigCrossbellAPI,
pub solana_rpc: ConfigSolanaRPC,
pub genome_api: ConfigGenomeAPI,
}

#[derive(Clone, Deserialize, Default)]
Expand Down Expand Up @@ -148,6 +149,11 @@ pub struct ConfigSolanaRPC {
pub rpc_url: String,
}

#[derive(Clone, Deserialize, Default)]
pub struct ConfigGenomeAPI {
pub url: String,
}

#[derive(Clone, Deserialize)]
pub enum ConfigCategory {
File,
Expand Down
4 changes: 3 additions & 1 deletion src/controller/tigergraphql/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl IdentityRecord {

/// The expiry date for the domain, from either the registration, or the wrapped domain if PCC is burned
async fn expired_at(&self) -> Option<i64> {
if !vec![Platform::Dotbit, Platform::ENS].contains(&self.platform) {
if !vec![Platform::Dotbit, Platform::ENS, Platform::Genome].contains(&self.platform) {
return None;
}
self.expired_at.map(|dt| dt.and_utc().timestamp())
Expand All @@ -254,6 +254,7 @@ impl IdentityRecord {
Platform::ENS,
Platform::Solana,
Platform::SNS,
Platform::Genome,
]
.contains(&self.platform)
{
Expand All @@ -273,6 +274,7 @@ impl IdentityRecord {
Platform::Crossbell,
Platform::ENS,
Platform::SNS,
Platform::Genome,
]
.contains(&self.platform)
{
Expand Down
5 changes: 3 additions & 2 deletions src/controller/tigergraphql/identity_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::{
};
use async_graphql::{Context, Object};
use dataloader::non_cached::Loader;
use std::str::FromStr;
use tracing::{event, Level};
use uuid::Uuid;

Expand Down Expand Up @@ -141,7 +140,7 @@ impl ExpandIdentityRecord {

/// The expiry date for the domain, from either the registration, or the wrapped domain if PCC is burned
async fn expired_at(&self) -> Option<i64> {
if !vec![Platform::Dotbit, Platform::ENS].contains(&self.platform) {
if !vec![Platform::Dotbit, Platform::ENS, Platform::Genome].contains(&self.platform) {
return None;
}
self.expired_at.map(|dt| dt.and_utc().timestamp())
Expand All @@ -162,6 +161,7 @@ impl ExpandIdentityRecord {
Platform::ENS,
Platform::Solana,
Platform::SNS,
Platform::Genome,
]
.contains(&self.platform)
{
Expand All @@ -181,6 +181,7 @@ impl ExpandIdentityRecord {
Platform::Crossbell,
Platform::ENS,
Platform::SNS,
Platform::Genome,
]
.contains(&self.platform)
{
Expand Down
7 changes: 7 additions & 0 deletions src/upstream/types/contract_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ pub enum ContractCategory {
#[graphql(name = "sns")]
SNS,

#[strum(serialize = "gns")]
#[serde(rename = "gns")]
#[graphql(name = "gns")]
GNS,

#[default]
#[serde(rename = "unknown")]
#[graphql(name = "unknown")]
Expand All @@ -57,6 +62,7 @@ impl ContractCategory {
// TODO: ENS has a complicated contract structure, which cannot determine the "main" contract easily.
ENS => Some("0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85".to_lowercase()),
SNS => Some("4gj2A7SSgWUGfHTm2iG4NeH3kpySmGd54bj78TM4d7Fg".to_string()), // Solana Name Service
GNS => Some("0x5dc881dda4e4a8d312be3544ad13118d1a04cb17".to_string()), // Gnosis Name Service
_ => None,
}
}
Expand All @@ -69,6 +75,7 @@ impl ContractCategory {
ERC1155 => Some(Chain::Ethereum),
POAP => Some(Chain::Ethereum),
SNS => Some(Chain::Solana),
GNS => Some(Chain::Gnosis),
_ => None,
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/upstream/types/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ pub enum Platform {
#[graphql(name = "space_id")]
SpaceId,

/// Genome
#[strum(serialize = "genome")]
#[serde(rename = "genome")]
#[graphql(name = "genome")]
Genome,

/// Crossbell
#[strum(serialize = "crossbell")]
#[serde(rename = "crossbell")]
Expand Down

0 comments on commit e4bcf61

Please sign in to comment.