1#[cfg(feature = "native-grpc")]
5use iota_grpc_client::Client as GrpcClient;
6
7use crate::{CommitteeResolution, CommitteeResolver, ProofBuilder, Source};
8
9#[derive(Clone, Debug)]
11pub struct PoiClient<S> {
12 source: S,
13}
14
15impl<S> PoiClient<S> {
16 pub const fn new(source: S) -> Self {
18 Self { source }
19 }
20}
21
22impl<S> PoiClient<S>
23where
24 S: Source + Clone,
25{
26 pub fn proof(&self) -> ProofBuilder<S> {
28 ProofBuilder::new(self.source.clone())
29 }
30
31 pub fn verifier(&self, resolution: CommitteeResolution) -> CommitteeResolver<S> {
36 CommitteeResolver::new(self.source.clone(), resolution)
37 }
38}
39
40#[cfg(feature = "native-grpc")]
41impl PoiClient<GrpcClient> {
42 pub fn mainnet() -> iota_grpc_client::Result<Self> {
44 GrpcClient::new_mainnet().map(Self::new)
45 }
46
47 pub fn testnet() -> iota_grpc_client::Result<Self> {
49 GrpcClient::new_testnet().map(Self::new)
50 }
51
52 pub fn devnet() -> iota_grpc_client::Result<Self> {
54 GrpcClient::new_devnet().map(Self::new)
55 }
56
57 pub const fn from_grpc_client(client: GrpcClient) -> Self {
59 Self::new(client)
60 }
61
62 pub const fn grpc_client(&self) -> &GrpcClient {
64 &self.source
65 }
66}