Skip to main content

circles_rpc/methods/
token_info.rs

1use crate::client::RpcClient;
2use crate::error::Result;
3use circles_types::{Address, TokenInfo};
4
5/// Methods for retrieving token metadata (`circles_getTokenInfo` + batch).
6#[derive(Clone, Debug)]
7pub struct TokenInfoMethods {
8    client: RpcClient,
9}
10
11impl TokenInfoMethods {
12    /// Create a new accessor for token metadata RPCs.
13    pub fn new(client: RpcClient) -> Self {
14        Self { client }
15    }
16
17    /// circles_getTokenInfo
18    pub async fn get_token_info(&self, token: Address) -> Result<TokenInfo> {
19        self.client.call("circles_getTokenInfo", (token,)).await
20    }
21
22    /// circles_getTokenInfoBatch
23    pub async fn get_token_info_batch(&self, tokens: Vec<Address>) -> Result<Vec<TokenInfo>> {
24        self.client
25            .call("circles_getTokenInfoBatch", (tokens,))
26            .await
27    }
28}