Skip to content

Commit

Permalink
Upstream/genomedomains
Browse files Browse the repository at this point in the history
Merge pull request #138 from ZhongFuze/upstream/genomedomains
  • Loading branch information
ZhongFuze authored May 14, 2024
2 parents c562b2b + e67bc47 commit 6954bd9
Show file tree
Hide file tree
Showing 13 changed files with 521 additions and 26 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
34 changes: 17 additions & 17 deletions src/config/tdb/migrations/LoadingJob_SocialGraph.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ CREATE OR REPLACE QUERY find_expand_identity(STRING platform, STRING identity) F
SetAccum<Address> @owner_address;
SetAccum<Address> @resolve_address;

ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns"];
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns", "genome"];
IF @@domainSystems.contains(platform) == TRUE THEN
tmp = SELECT domain FROM seed:domain-((<Hold_Identity):e)-Identities:owner
ACCUM domain.@owner_address += Address(owner.platform, owner.identity);
Expand Down Expand Up @@ -523,7 +523,7 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
POST-ACCUM @@minUpdateTime += MinUpdatedTimeTuple(tgt.updated_nanosecond, tgt.id);
graph_id = @@minUpdateTime.id;

ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns"];
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns", "genome"];

IF reverse_flag == 1 THEN
vset = SELECT v FROM Identities:v-((PartOfIdentitiesGraph>):e)-identities_graph
Expand All @@ -534,21 +534,21 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS" AND i.platform != "ens" AND i.platform != "sns"
WHERE i.platform != "genome" AND i.platform != "ens" AND i.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS" AND v2.platform != "ens" AND v2.platform != "sns"
WHERE v2.platform != "genome" AND v2.platform != "ens" AND v2.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS" OR v1.platform == "ens" OR v1.platform != "sns"
WHERE v1.platform == "genome" OR v1.platform == "ens" OR v1.platform != "sns"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS" OR v2.platform == "ens" OR v2.platform == "sns"
WHERE v2.platform == "genome" OR v2.platform == "ens" OR v2.platform == "sns"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);

tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
Expand All @@ -564,21 +564,21 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS" AND i.platform != "ens" AND i.platform != "sns"
WHERE i.platform != "genome" AND i.platform != "ens" AND i.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS" AND v2.platform != "ens" AND v2.platform != "sns"
WHERE v2.platform != "genome" AND v2.platform != "ens" AND v2.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS" OR v1.platform == "ens" OR v1.platform == "sns"
WHERE v1.platform == "genome" OR v1.platform == "ens" OR v1.platform == "sns"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS" OR v2.platform == "ens" OR v2.platform == "sns"
WHERE v2.platform == "genome" OR v2.platform == "ens" OR v2.platform == "sns"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);
tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Reverse_Resolve");
Expand All @@ -591,21 +591,21 @@ CREATE OR REPLACE QUERY find_identity_graph(STRING p, INT reverse_flag=0) FOR GR
tmp2 = SELECT v1 FROM vset:v1-((<Proof_Forward|<Proof_Backward):e2)-vset:v2
ACCUM @@edges += IdentityConnection(v2, v1, e2.source, "Proof");
tmp4 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:i-((Resolve>):e2)-vset:v2
WHERE i.platform != "ENS" AND i.platform != "ens" AND i.platform != "sns"
WHERE i.platform != "genome" AND i.platform != "ens" AND i.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, i, e1.source, "Hold"),
i.@owner_address += Address(v1.platform, v1.identity),
i.@resolve_address += Address(v2.platform, v2.identity);
tmp5 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform != "ENS" AND v2.platform != "ens" AND v2.platform != "sns"
WHERE v2.platform != "genome" AND v2.platform != "ens" AND v2.platform != "sns"
ACCUM @@edges += IdentityConnection(v1, v2, e1.source, "Hold"),
v2.@owner_address += Address(v1.platform, v1.identity);
tmp3 = SELECT v1 FROM vset:v1-((Resolve>):r)-vset:v2
WHERE v1.platform == "ENS" OR v1.platform == "ens" OR v1.platform == "sns"
WHERE v1.platform == "genome" OR v1.platform == "ens" OR v1.platform == "sns"
ACCUM
@@edges += IdentityConnection(v1, v2, r.source, "Resolve"),
v1.@resolve_address += Address(v2.platform, v2.identity);
tmp3_1 = SELECT v1 FROM vset:v1-((Hold_Identity>):e1)-vset:v2
WHERE v2.platform == "ENS" OR v2.platform == "ens" OR v2.platform == "sns"
WHERE v2.platform == "genome" OR v2.platform == "ens" OR v2.platform == "sns"
ACCUM v2.@owner_address += Address(v1.platform, v1.identity);

tmp6 = SELECT v1 FROM vset:v1-((Reverse_Resolve>):e1)-vset:v2
Expand All @@ -628,7 +628,7 @@ CREATE OR REPLACE QUERY neighbors(VERTEX<Identities> p, INT depth) FOR GRAPH Soc
ACCUM v.@visited = TRUE, @@edges += pf, @@edges += pw
POST-ACCUM @@vertices += v, @@pool += v;
hold = SELECT v FROM seed-((Hold_Identity>|<Hold_Identity):e)-Identities:v
WHERE v.@visited2 == FALSE AND v.platform != "ENS" AND v.platform != "ens" AND v.platform != "sns"
WHERE v.@visited2 == FALSE AND v.platform != "genome" AND v.platform != "ens" AND v.platform != "sns"
ACCUM v.@visited2 = TRUE, @@edges += e
POST-ACCUM @@vertices += v, @@pool += v;
seed (Identities) = {@@pool};
Expand All @@ -645,7 +645,7 @@ CREATE OR REPLACE QUERY neighbors_with_source_reverse(VERTEX<Identities> p, INT
SetAccum<STRING> @source_list;
SetAccum<EDGE> @@edge_set;
SetAccum<VERTEX<Identities>> @@vertices;
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns"];
ListAccum<STRING> @@domainSystems = ["dotbit", "lens", "unstoppabledomains", "space_id", "crossbell", "ENS", "ens", "sns", "genome"];

##### Initialization #####
seed (Identities) = {p};
Expand Down Expand Up @@ -695,7 +695,7 @@ CREATE OR REPLACE QUERY neighbors_with_source_reverse(VERTEX<Identities> p, INT
ACCUM start.@reverse += true;

address2 = SELECT addr FROM ResultSet:addr-((Reverse_Resolve_Contract>):r)-Contracts:c
WHERE r.system == "ENS" OR r.system == "ens" OR r.system == "sns"
WHERE r.system == "genome" OR r.system == "ens" OR r.system == "sns"
ACCUM addr.@reverse += true;

IF reverse_flag == 0 THEN
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
2 changes: 1 addition & 1 deletion src/tigergraph/upsert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ async fn upsert_edge(
return Err(Error::General(err_message, resp.status()));
}
};
// let json_raw = serde_json::to_string(&result).map_err(|err| Error::JSONParseError(err))?;
// let json_raw = serde_json::to_string(&_result).map_err(|err| Error::JSONParseError(err))?;
// println!("{}", json_raw);
// trace!("TigerGraph upsert_edge ...");
Ok(())
Expand Down
Loading

0 comments on commit 6954bd9

Please sign in to comment.