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 = [
[[package]]
name = "gcli"
version = "0.2.12"
version = "0.2.15"
dependencies = [
"age",
"anyhow",
......
......@@ -10,7 +10,7 @@ license = "AGPL-3.0-only"
name = "gcli"
repository = "https://git.duniter.org/clients/rust/gcli-v2s"
description = "A command-line interface for Duniter v2s uses"
version = "0.2.12"
version = "0.2.15"
[dependencies]
# subxt is main dependency
......
......@@ -12,7 +12,7 @@ gcli config show
# [stdout]
# Ğcli config
# duniter endpoint ws://localhost:9944
# indexer endpoint http://localhost:4350/graphql
# indexer endpoint http://localhost:8080/v1/graphql
# address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
# use different address in command line
......@@ -20,7 +20,7 @@ gcli --address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n config show
# [stdout]
# Ğcli config
# duniter endpoint ws://localhost:9944
# indexer endpoint http://localhost:4350/graphql
# indexer endpoint http://localhost:8080/v1/graphql
# address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n
```
......
......@@ -8,7 +8,7 @@ Update the schema with:
# install graphql client cli
cargo install graphql_client_cli
# 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!]!) {
query IdentityInfo($index: Int!) {
identity(where: { index: { _eq: $index } }) {
name
certIssued(
orderBy: { expireOn: DESC }
where: { isActive: { _eq: true } }
) {
certIssued(orderBy: { expireOn: DESC }, where: { isActive: { _eq: true } }) {
receiver {
name
}
}
certReceived(
orderBy: { expireOn: DESC }
where: { isActive: { _eq: true } }
) {
certReceived(orderBy: { expireOn: DESC }, where: { isActive: { _eq: true } }) {
issuer {
name
}
......@@ -33,18 +27,25 @@ query IdentityInfo($index: Int!) {
linkedAccount {
id
}
smith {
smithStatus
smithCertIssued(orderBy: { createdOn: DESC }) {
receiver {
identity {
name
}
}
}
smithCertReceived(orderBy: { createdOn: DESC }) {
issuer {
identity {
name
}
}
}
}
}
}
query IdentityNameByPubkey($pubkey: String!) {
identity(where: { account: { id: { _eq: $pubkey } } }) {
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -297,8 +297,7 @@ pub async fn get_identity(
.expect("expected cert meta");
// get certs if possible
let (cert_issued, cert_received, linked_account, smith_cert_issued, smith_cert_received) =
if let Some(indexer) = &indexer {
let (cert_issued, cert_received, linked_account, smith_info) = if let Some(indexer) = &indexer {
let info = indexer.identity_info(index).await.expect("no info");
(
info.cert_issued
......@@ -313,28 +312,36 @@ pub async fn get_identity(
.into_iter()
.map(|i| AccountId::from_str(&i.id).unwrap())
.collect(),
info.smith_cert_issued
.into_iter()
.map(|i| i.receiver.unwrap().name.to_string())
.collect(),
info.smith_cert_received
.into_iter()
.map(|i| i.issuer.unwrap().name.to_string())
.collect(),
info.smith,
)
} else {
(vec![], vec![], vec![], vec![], vec![])
(vec![], vec![], vec![], None)
};
// get smith info
let smith = get_smith(client, index).await?;
let smith = smith.map(|s| SmithView {
let smith_meta = get_smith(client, index).await?;
let smith = match (smith_meta, smith_info) {
(None, None) => Ok(None),
(Some(s), Some(i)) => Ok(Some(SmithView {
status: s.status,
cert_issued_count: s.issued_certs.len(),
cert_issued: smith_cert_issued,
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: smith_cert_received,
});
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
let view = IdtyView {
......
......@@ -17,8 +17,9 @@ pub const GDEV_DUNITER_ENDPOINTS: [&str; 5] = [
"wss://gdev.pini.fr:443/ws",
];
#[cfg(feature = "gdev")]
pub const GDEV_INDEXER_ENDPOINTS: [&str; 1] = [
// "https://subsquid.gdev.coinduf.eu/v1/graphql",
pub const GDEV_INDEXER_ENDPOINTS: [&str; 2] = [
// "https://squid.gdev.coinduf.eu/v1/graphql",
"https://squid.gdev.gyroi.de/v1/graphql",
"https://gdev-squid.axiom-team.fr/v1/graphql",
];
......
......@@ -20,11 +20,13 @@ impl Indexer {
&self,
var: <T as GraphQLQuery>::Variables,
) -> <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
.expect("indexer connexion error")
.data
.expect("indexer error")
.expect("indexer connexion error");
if let Some(errs) = response.errors {
log::debug!("{:?}", errs)
}
response.data.expect("indexer error")
}
/// index → name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment