Skip to main content

circles_rpc/methods/
avatar.rs

1use crate::client::RpcClient;
2use crate::error::Result;
3use circles_types::{Address, AvatarInfo, Profile};
4
5/// Methods for avatar/profile lookups.
6///
7/// Mirrors Circles RPC `circles_getAvatarInfo` + profile CID/resolution helpers.
8#[derive(Clone, Debug)]
9pub struct AvatarMethods {
10    client: RpcClient,
11}
12
13impl AvatarMethods {
14    /// Create a new accessor for avatar/profile RPCs.
15    pub fn new(client: RpcClient) -> Self {
16        Self { client }
17    }
18
19    /// circles_getAvatarInfo
20    pub async fn get_avatar_info(&self, address: Address) -> Result<AvatarInfo> {
21        self.client.call("circles_getAvatarInfo", (address,)).await
22    }
23
24    /// circles_getAvatarInfoBatch
25    pub async fn get_avatar_info_batch(&self, addresses: Vec<Address>) -> Result<Vec<AvatarInfo>> {
26        self.client
27            .call("circles_getAvatarInfoBatch", (addresses,))
28            .await
29    }
30
31    /// circles_getProfileCid
32    pub async fn get_profile_cid(&self, address: Address) -> Result<String> {
33        self.client.call("circles_getProfileCid", (address,)).await
34    }
35
36    /// circles_getProfileCidBatch
37    pub async fn get_profile_cid_batch(&self, addresses: Vec<Address>) -> Result<Vec<String>> {
38        self.client
39            .call("circles_getProfileCidBatch", (addresses,))
40            .await
41    }
42
43    /// circles_getProfileByCid
44    pub async fn get_profile_by_cid(&self, cid: String) -> Result<Profile> {
45        self.client.call("circles_getProfileByCid", (cid,)).await
46    }
47
48    /// circles_getProfileByCidBatch
49    pub async fn get_profile_by_cid_batch(&self, cids: Vec<String>) -> Result<Vec<Profile>> {
50        self.client
51            .call("circles_getProfileByCidBatch", (cids,))
52            .await
53    }
54
55    /// circles_getProfileByAddress
56    pub async fn get_profile_by_address(&self, address: Address) -> Result<Profile> {
57        self.client
58            .call("circles_getProfileByAddress", (address,))
59            .await
60    }
61
62    /// circles_getProfileByAddressBatch
63    pub async fn get_profile_by_address_batch(
64        &self,
65        addresses: Vec<Address>,
66    ) -> Result<Vec<Profile>> {
67        self.client
68            .call("circles_getProfileByAddressBatch", (addresses,))
69            .await
70    }
71}