iota_json_rpc_api/
coin.rs1use iota_json_rpc_types::{
6 Balance, Coin, CoinPage, IotaCirculatingSupply, IotaCoinMetadata, IotaSupply, Page,
7 iota_primitives::{IotaAddress as IotaAddressSchema, ObjectID as ObjectIDSchema},
8};
9use iota_open_rpc_macros::open_rpc;
10use iota_types::base_types::{IotaAddress, ObjectID};
11use jsonrpsee::{core::RpcResult, proc_macros::rpc};
12
13#[open_rpc(namespace = "iotax", tag = "Coin Query API")]
16#[rpc(server, client, namespace = "iotax")]
17pub trait CoinReadApi {
18 #[rustfmt::skip]
20 #[method(name = "getCoins")]
21 #[schemars(with = "Page<Coin, ObjectIDSchema>")]
22 async fn get_coins(
23 &self,
24 #[schemars(with = "IotaAddressSchema")]
26 owner: IotaAddress,
27 coin_type: Option<String>,
29 #[schemars(with = "Option<ObjectIDSchema>")]
31 cursor: Option<ObjectID>,
32 limit: Option<usize>,
34 ) -> RpcResult<CoinPage>;
35
36 #[rustfmt::skip]
38 #[method(name = "getAllCoins")]
39 #[schemars(with = "Page<Coin, ObjectIDSchema>")]
40 async fn get_all_coins(
41 &self,
42 #[schemars(with = "IotaAddressSchema")]
44 owner: IotaAddress,
45 #[schemars(with = "Option<ObjectIDSchema>")]
47 cursor: Option<ObjectID>,
48 limit: Option<usize>,
50 ) -> RpcResult<CoinPage>;
51
52 #[rustfmt::skip]
54 #[method(name = "getBalance")]
55 async fn get_balance(
56 &self,
57 #[schemars(with = "IotaAddressSchema")]
59 owner: IotaAddress,
60 coin_type: Option<String>,
62 ) -> RpcResult<Balance>;
63
64 #[rustfmt::skip]
66 #[method(name = "getAllBalances")]
67 async fn get_all_balances(
68 &self,
69 #[schemars(with = "IotaAddressSchema")]
71 owner: IotaAddress,
72 ) -> RpcResult<Vec<Balance>>;
73
74 #[rustfmt::skip]
76 #[method(name = "getCoinMetadata")]
77 async fn get_coin_metadata(
78 &self,
79 coin_type: String,
81 ) -> RpcResult<Option<IotaCoinMetadata>>;
82
83 #[rustfmt::skip]
85 #[method(name = "getTotalSupply")]
86 async fn get_total_supply(
87 &self,
88 coin_type: String,
90 ) -> RpcResult<IotaSupply>;
91
92 #[method(name = "getCirculatingSupply")]
94 async fn get_circulating_supply(&self) -> RpcResult<IotaCirculatingSupply>;
95}