Skip to content
Snippets Groups Projects
Commit e999ecf4 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

update squid API and add endpoints

parent 3bb993f7
No related branches found
No related tags found
No related merge requests found
Pipeline #38014 passed
...@@ -2092,7 +2092,7 @@ dependencies = [ ...@@ -2092,7 +2092,7 @@ dependencies = [
[[package]] [[package]]
name = "gcli" name = "gcli"
version = "0.2.12" version = "0.2.15"
dependencies = [ dependencies = [
"age", "age",
"anyhow", "anyhow",
......
...@@ -10,7 +10,7 @@ license = "AGPL-3.0-only" ...@@ -10,7 +10,7 @@ license = "AGPL-3.0-only"
name = "gcli" name = "gcli"
repository = "https://git.duniter.org/clients/rust/gcli-v2s" repository = "https://git.duniter.org/clients/rust/gcli-v2s"
description = "A command-line interface for Duniter v2s uses" description = "A command-line interface for Duniter v2s uses"
version = "0.2.12" version = "0.2.15"
[dependencies] [dependencies]
# subxt is main dependency # subxt is main dependency
......
...@@ -12,7 +12,7 @@ gcli config show ...@@ -12,7 +12,7 @@ gcli config show
# [stdout] # [stdout]
# Ğcli config # Ğcli config
# duniter endpoint ws://localhost:9944 # duniter endpoint ws://localhost:9944
# indexer endpoint http://localhost:4350/graphql # indexer endpoint http://localhost:8080/v1/graphql
# address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
# use different address in command line # use different address in command line
...@@ -20,7 +20,7 @@ gcli --address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n config show ...@@ -20,7 +20,7 @@ gcli --address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n config show
# [stdout] # [stdout]
# Ğcli config # Ğcli config
# duniter endpoint ws://localhost:9944 # duniter endpoint ws://localhost:9944
# indexer endpoint http://localhost:4350/graphql # indexer endpoint http://localhost:8080/v1/graphql
# address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n # address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n
``` ```
......
...@@ -8,7 +8,7 @@ Update the schema with: ...@@ -8,7 +8,7 @@ Update the schema with:
# install graphql client cli # install graphql client cli
cargo install graphql_client_cli cargo install graphql_client_cli
# download schema from node # download schema from node
graphql-client introspect-schema https://subsquid.gdev.coinduf.eu/graphql --output ./res/indexer-schema.json graphql-client introspect-schema https://squid.gdev.coinduf.eu/v1/graphql --output ./res/indexer-schema.json
``` ```
... ...
......
...@@ -14,18 +14,12 @@ query NamesByIndexes($indexes: [Int!]!) { ...@@ -14,18 +14,12 @@ query NamesByIndexes($indexes: [Int!]!) {
query IdentityInfo($index: Int!) { query IdentityInfo($index: Int!) {
identity(where: { index: { _eq: $index } }) { identity(where: { index: { _eq: $index } }) {
name name
certIssued( certIssued(orderBy: { expireOn: DESC }, where: { isActive: { _eq: true } }) {
orderBy: { expireOn: DESC }
where: { isActive: { _eq: true } }
) {
receiver { receiver {
name name
} }
} }
certReceived( certReceived(orderBy: { expireOn: DESC }, where: { isActive: { _eq: true } }) {
orderBy: { expireOn: DESC }
where: { isActive: { _eq: true } }
) {
issuer { issuer {
name name
} }
...@@ -33,14 +27,21 @@ query IdentityInfo($index: Int!) { ...@@ -33,14 +27,21 @@ query IdentityInfo($index: Int!) {
linkedAccount { linkedAccount {
id id
} }
smithCertIssued(orderBy: { createdOn: DESC }) { smith {
receiver { smithStatus
name smithCertIssued(orderBy: { createdOn: DESC }) {
receiver {
identity {
name
}
}
} }
} smithCertReceived(orderBy: { createdOn: DESC }) {
smithCertReceived(orderBy: { createdOn: DESC }) { issuer {
issuer { identity {
name name
}
}
} }
} }
} }
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -297,44 +297,51 @@ pub async fn get_identity( ...@@ -297,44 +297,51 @@ pub async fn get_identity(
.expect("expected cert meta"); .expect("expected cert meta");
// get certs if possible // get certs if possible
let (cert_issued, cert_received, linked_account, smith_cert_issued, smith_cert_received) = let (cert_issued, cert_received, linked_account, smith_info) = if let Some(indexer) = &indexer {
if let Some(indexer) = &indexer { let info = indexer.identity_info(index).await.expect("no info");
let info = indexer.identity_info(index).await.expect("no info"); (
( info.cert_issued
info.cert_issued .into_iter()
.into_iter() .map(|i| i.receiver.unwrap().name.to_string())
.map(|i| i.receiver.unwrap().name.to_string()) .collect(),
.collect(), info.cert_received
info.cert_received .into_iter()
.into_iter() .map(|i| i.issuer.unwrap().name.to_string())
.map(|i| i.issuer.unwrap().name.to_string()) .collect(),
.collect(), info.linked_account
info.linked_account .into_iter()
.into_iter() .map(|i| AccountId::from_str(&i.id).unwrap())
.map(|i| AccountId::from_str(&i.id).unwrap()) .collect(),
.collect(), info.smith,
info.smith_cert_issued )
.into_iter() } else {
.map(|i| i.receiver.unwrap().name.to_string()) (vec![], vec![], vec![], None)
.collect(), };
info.smith_cert_received
.into_iter()
.map(|i| i.issuer.unwrap().name.to_string())
.collect(),
)
} else {
(vec![], vec![], vec![], vec![], vec![])
};
// get smith info // get smith info
let smith = get_smith(client, index).await?; let smith_meta = get_smith(client, index).await?;
let smith = smith.map(|s| SmithView {
status: s.status, let smith = match (smith_meta, smith_info) {
cert_issued_count: s.issued_certs.len(), (None, None) => Ok(None),
cert_issued: smith_cert_issued, (Some(s), Some(i)) => Ok(Some(SmithView {
cert_received_count: s.received_certs.len(), status: s.status,
cert_received: smith_cert_received, cert_issued_count: s.issued_certs.len(),
}); cert_issued: i
.smith_cert_issued
.into_iter()
.map(|i| i.receiver.unwrap().identity.unwrap().name.to_string())
.collect(),
cert_received_count: s.received_certs.len(),
cert_received: i
.smith_cert_received
.into_iter()
.map(|i| i.issuer.unwrap().identity.unwrap().name.to_string())
.collect(),
})),
_ => Err(GcliError::Indexer(
"Duniter and Indexer do not agree if x is smith".to_string(),
)),
}?;
// build view // build view
let view = IdtyView { let view = IdtyView {
......
...@@ -17,8 +17,9 @@ pub const GDEV_DUNITER_ENDPOINTS: [&str; 5] = [ ...@@ -17,8 +17,9 @@ pub const GDEV_DUNITER_ENDPOINTS: [&str; 5] = [
"wss://gdev.pini.fr:443/ws", "wss://gdev.pini.fr:443/ws",
]; ];
#[cfg(feature = "gdev")] #[cfg(feature = "gdev")]
pub const GDEV_INDEXER_ENDPOINTS: [&str; 1] = [ pub const GDEV_INDEXER_ENDPOINTS: [&str; 2] = [
// "https://subsquid.gdev.coinduf.eu/v1/graphql", // "https://squid.gdev.coinduf.eu/v1/graphql",
"https://squid.gdev.gyroi.de/v1/graphql",
"https://gdev-squid.axiom-team.fr/v1/graphql", "https://gdev-squid.axiom-team.fr/v1/graphql",
]; ];
......
...@@ -20,11 +20,13 @@ impl Indexer { ...@@ -20,11 +20,13 @@ impl Indexer {
&self, &self,
var: <T as GraphQLQuery>::Variables, var: <T as GraphQLQuery>::Variables,
) -> <T as GraphQLQuery>::ResponseData { ) -> <T as GraphQLQuery>::ResponseData {
post_graphql::<T, _>(&self.gql_client, &self.gql_url, var) let response = post_graphql::<T, _>(&self.gql_client, &self.gql_url, var)
.await .await
.expect("indexer connexion error") .expect("indexer connexion error");
.data if let Some(errs) = response.errors {
.expect("indexer error") log::debug!("{:?}", errs)
}
response.data.expect("indexer error")
} }
/// index → name /// index → name
......
...@@ -37,7 +37,7 @@ macro_rules! graphql_query { ...@@ -37,7 +37,7 @@ macro_rules! graphql_query {
pub struct $name; pub struct $name;
}; };
} }
// repeat generation for multiple queries // repeat generation for multiple queries
macro_rules! graphql_query_for { macro_rules! graphql_query_for {
( $($Name:ident),+ ) => { ( $($Name:ident),+ ) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment