Skip to content

Commit

Permalink
[!] save sns as solana address' assets
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Apr 14, 2024
1 parent 90d9eee commit fa0556b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/upstream/solana/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use crate::tigergraph::edge::Resolve;
use crate::tigergraph::upsert::create_ens_identity_ownership;
use crate::tigergraph::upsert::create_identity_domain_resolve_record;
use crate::tigergraph::upsert::create_identity_domain_reverse_resolve_record;
use crate::tigergraph::upsert::create_identity_to_contract_hold_record;
use crate::tigergraph::upsert::create_identity_to_identity_proof_two_way_binding;
use crate::tigergraph::upsert::create_isolated_vertex;
use crate::tigergraph::vertex::Identity;
use crate::tigergraph::vertex::{Contract, Identity};
use crate::upstream::ProofLevel;
use crate::upstream::{DataFetcher, DataSource, DomainNameSystem};
use crate::upstream::{Chain, ContractCategory, DataFetcher, DataSource, DomainNameSystem};
use crate::util::{make_http_client, naive_now};
use async_trait::async_trait;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -222,9 +223,19 @@ async fn fetch_by_wallet(target: &Target) -> Result<TargetProcessedList, Error>
updated_at: naive_now(),
};

let contract = Contract {
uuid: Uuid::new_v4(),
category: ContractCategory::SNS,
address: ContractCategory::SNS.default_contract_address().unwrap(),
chain: Chain::Solana,
symbol: Some("SNS".to_string()),
updated_at: naive_now(),
};

create_identity_domain_resolve_record(&client, &sns, &solana, &resolve).await?;
// ownership create `Hold_Identity` connection but only Wallet connected to HyperVertex
create_ens_identity_ownership(&client, &solana, &sns, &hold).await?;
create_identity_to_contract_hold_record(&client, &solana, &contract, &hold).await?;
}

Ok(next_targets)
Expand Down Expand Up @@ -293,9 +304,20 @@ async fn fetch_by_sns_handle(target: &Target) -> Result<TargetProcessedList, Err
fetcher: DataFetcher::RelationService,
updated_at: naive_now(),
};

let contract = Contract {
uuid: Uuid::new_v4(),
category: ContractCategory::SNS,
address: ContractCategory::SNS.default_contract_address().unwrap(),
chain: Chain::Solana,
symbol: Some("SNS".to_string()),
updated_at: naive_now(),
};

create_identity_domain_resolve_record(&client, &sns, &solana, &resolve).await?;
// ownership create `Hold_Identity` connection but only Wallet connected to HyperVertex
create_ens_identity_ownership(&client, &solana, &sns, &hold).await?;
create_identity_to_contract_hold_record(&client, &solana, &contract, &hold).await?;
}
None => trace!(?target, "Owner not found"),
}
Expand Down Expand Up @@ -440,7 +462,6 @@ async fn fetch_register_favourite(
owner: &str,
) -> Result<Option<String>, Error> {
let owner_key = Pubkey::from_str(owner)?;
// let name_service_account = ;
match get_favourite_domain(client, &owner_key).await? {
None => Ok(None),
Some(name_service_account) => match resolve_reverse(client, &name_service_account).await? {
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 @@ -38,6 +38,11 @@ pub enum ContractCategory {
#[graphql(name = "POAP")]
POAP,

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

#[default]
#[serde(rename = "unknown")]
#[graphql(name = "unknown")]
Expand All @@ -51,6 +56,7 @@ impl ContractCategory {
match self {
// 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
_ => None,
}
}
Expand All @@ -62,6 +68,7 @@ impl ContractCategory {
ERC721 => Some(Chain::Ethereum),
ERC1155 => Some(Chain::Ethereum),
POAP => Some(Chain::Ethereum),
SNS => Some(Chain::Solana),
_ => None,
}
}
Expand Down

0 comments on commit fa0556b

Please sign in to comment.