1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::error::Error;
use flow_sdk::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let mut client = TonicHyperFlowClient::mainnet().await?;
client.ping().await?;
let mut latest_block = client.latest_block(Seal::Sealed).await?;
let collection_guarrantee = loop {
if latest_block.collection_guarantees.is_empty() {
latest_block = client.block_by_id(&latest_block.parent_id).await?;
} else {
break latest_block.collection_guarantees.pop().unwrap();
}
};
let collection = client
.collection_by_id(&collection_guarrantee.collection_id)
.await?;
println!("OK: {:#?}", collection);
Ok(())
}