1use iota_json_rpc_types::{
6 DynamicFieldNameSchema, DynamicFieldPage, EventFilter, EventPage, IotaDynamicFieldInfo,
7 IotaEvent, IotaEventID, IotaNameRecord, IotaObjectDataOptions, IotaObjectResponse,
8 IotaObjectResponseQuery, IotaTransactionBlockEffects, IotaTransactionBlockResponse,
9 IotaTransactionBlockResponseQuery, IotaTransactionBlockResponseQueryV2, ObjectsPage, Page,
10 TransactionBlocksPage, TransactionFilter,
11 iota_primitives::{
12 Base58 as Base58Schema, IotaAddress as IotaAddressSchema, ObjectID as ObjectIDSchema,
13 },
14};
15use iota_open_rpc_macros::open_rpc;
16use iota_types::{
17 base_types::{IotaAddress, ObjectID},
18 digests::TransactionDigest,
19 dynamic_field::DynamicFieldName,
20 event::EventID,
21};
22use jsonrpsee::{
23 core::{RpcResult, SubscriptionResult},
24 proc_macros::rpc,
25};
26
27#[open_rpc(namespace = "iotax", tag = "Extended API")]
30#[rpc(server, client, namespace = "iotax")]
31pub trait IndexerApi {
32 #[rustfmt::skip]
38 #[method(name = "getOwnedObjects")]
39 #[schemars(with = "Page<IotaObjectResponse, ObjectIDSchema>")]
40 async fn get_owned_objects(
41 &self,
42 #[schemars(with = "IotaAddressSchema")]
44 address: IotaAddress,
45 query: Option<IotaObjectResponseQuery>,
47 #[schemars(with = "Option<ObjectIDSchema>")]
49 cursor: Option<ObjectID>,
50 limit: Option<usize>,
52 ) -> RpcResult<ObjectsPage>;
53
54 #[rustfmt::skip]
56 #[method(name = "queryTransactionBlocks", version <= "1.2.10")]
57 #[schemars(with = "Page<IotaTransactionBlockResponse, Base58>")]
58 async fn query_transaction_blocks(
59 &self,
60 query: IotaTransactionBlockResponseQuery,
62 cursor: Option<TransactionDigest>,
64 limit: Option<usize>,
66 descending_order: Option<bool>,
68 ) -> RpcResult<TransactionBlocksPage>;
69
70 #[rustfmt::skip]
72 #[method(name = "queryTransactionBlocks")]
73 #[schemars(with = "Page<IotaTransactionBlockResponse, Base58Schema>")]
74 async fn query_transaction_blocks_v2(
75 &self,
76 query: IotaTransactionBlockResponseQueryV2,
78 #[schemars(with = "Option<Base58Schema>")]
80 cursor: Option<TransactionDigest>,
81 limit: Option<usize>,
83 descending_order: Option<bool>,
85 ) -> RpcResult<TransactionBlocksPage>;
86
87 #[rustfmt::skip]
89 #[method(name = "queryEvents")]
90 #[schemars(with = "Page<IotaEvent, IotaEventID>")]
91 async fn query_events(
92 &self,
93 query: EventFilter,
95 #[schemars(with = "Option<IotaEventID>")]
97 cursor: Option<EventID>,
98 limit: Option<usize>,
100 descending_order: Option<bool>,
102 ) -> RpcResult<EventPage>;
103
104 #[rustfmt::skip]
106 #[subscription(name = "subscribeEvent", item = IotaEvent)]
107 fn subscribe_event(
108 &self,
109 filter: EventFilter,
111 ) -> SubscriptionResult;
112
113 #[subscription(name = "subscribeTransaction", item = IotaTransactionBlockEffects)]
115 fn subscribe_transaction(&self, filter: TransactionFilter) -> SubscriptionResult;
116
117 #[rustfmt::skip]
119 #[method(name = "getDynamicFields")]
120 #[schemars(with = "Page<IotaDynamicFieldInfo, ObjectIDSchema>")]
121 async fn get_dynamic_fields(
122 &self,
123 #[schemars(with = "ObjectIDSchema")]
125 parent_object_id: ObjectID,
126 #[schemars(with = "Option<ObjectIDSchema>")]
128 cursor: Option<ObjectID>,
129 limit: Option<usize>,
131 ) -> RpcResult<DynamicFieldPage>;
132
133 #[rustfmt::skip]
135 #[method(name = "getDynamicFieldObject")]
136 async fn get_dynamic_field_object(
137 &self,
138 #[schemars(with = "ObjectIDSchema")]
140 parent_object_id: ObjectID,
141 #[schemars(with = "DynamicFieldNameSchema")]
143 name: DynamicFieldName,
144 ) -> RpcResult<IotaObjectResponse>;
145
146 #[rustfmt::skip]
149 #[method(name = "getDynamicFieldObjectV2")]
150 async fn get_dynamic_field_object_v2(
151 &self,
152 #[schemars(with = "ObjectIDSchema")]
154 parent_object_id: ObjectID,
155 #[schemars(with = "DynamicFieldNameSchema")]
157 name: DynamicFieldName,
158 options: Option<IotaObjectDataOptions>,
160 ) -> RpcResult<IotaObjectResponse>;
161
162 #[method(name = "iotaNamesLookup")]
164 async fn iota_names_lookup(
165 &self,
166 name: &str,
168 ) -> RpcResult<Option<IotaNameRecord>>;
169
170 #[method(name = "iotaNamesReverseLookup")]
172 async fn iota_names_reverse_lookup(
173 &self,
174 #[schemars(with = "IotaAddressSchema")]
176 address: IotaAddress,
177 ) -> RpcResult<Option<String>>;
178
179 #[method(name = "iotaNamesFindAllRegistrationNFTs")]
181 #[schemars(with = "Page<IotaObjectResponse, ObjectIDSchema>")]
182 async fn iota_names_find_all_registration_nfts(
183 &self,
184 #[schemars(with = "IotaAddressSchema")] address: IotaAddress,
185 #[schemars(with = "Option<ObjectIDSchema>")] cursor: Option<ObjectID>,
186 limit: Option<usize>,
187 options: Option<IotaObjectDataOptions>,
188 ) -> RpcResult<ObjectsPage>;
189}