iota_json_rpc_api/
indexer.rs1use 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_sdk_types::ObjectId;
17use iota_types::{
18 base_types::IotaAddress, digests::TransactionDigest, dynamic_field::DynamicFieldName,
19 event::EventID,
20};
21use jsonrpsee::{
22 core::{RpcResult, SubscriptionResult},
23 proc_macros::rpc,
24};
25
26#[open_rpc(namespace = "iotax", tag = "Extended API")]
29#[rpc(server, client, namespace = "iotax")]
30pub trait IndexerApi {
31 #[rustfmt::skip]
37 #[method(name = "getOwnedObjects")]
38 #[schemars(with = "Page<IotaObjectResponse, ObjectIdSchema>")]
39 async fn get_owned_objects(
40 &self,
41 #[schemars(with = "IotaAddressSchema")]
43 address: IotaAddress,
44 query: Option<IotaObjectResponseQuery>,
46 #[schemars(with = "Option<ObjectIdSchema>")]
48 cursor: Option<ObjectId>,
49 limit: Option<usize>,
51 ) -> RpcResult<ObjectsPage>;
52
53 #[rustfmt::skip]
55 #[method(name = "queryTransactionBlocks", version <= "1.2.10")]
56 #[schemars(with = "Page<IotaTransactionBlockResponse, Base58>")]
57 async fn query_transaction_blocks(
58 &self,
59 query: IotaTransactionBlockResponseQuery,
61 cursor: Option<TransactionDigest>,
63 limit: Option<usize>,
65 descending_order: Option<bool>,
67 ) -> RpcResult<TransactionBlocksPage>;
68
69 #[rustfmt::skip]
71 #[method(name = "queryTransactionBlocks")]
72 #[schemars(with = "Page<IotaTransactionBlockResponse, Base58Schema>")]
73 async fn query_transaction_blocks_v2(
74 &self,
75 query: IotaTransactionBlockResponseQueryV2,
77 #[schemars(with = "Option<Base58Schema>")]
79 cursor: Option<TransactionDigest>,
80 limit: Option<usize>,
82 descending_order: Option<bool>,
84 ) -> RpcResult<TransactionBlocksPage>;
85
86 #[rustfmt::skip]
88 #[method(name = "queryEvents")]
89 #[schemars(with = "Page<IotaEvent, IotaEventID>")]
90 async fn query_events(
91 &self,
92 query: EventFilter,
94 #[schemars(with = "Option<IotaEventID>")]
96 cursor: Option<EventID>,
97 limit: Option<usize>,
99 descending_order: Option<bool>,
101 ) -> RpcResult<EventPage>;
102
103 #[rustfmt::skip]
105 #[subscription(name = "subscribeEvent", item = IotaEvent)]
106 fn subscribe_event(
107 &self,
108 filter: EventFilter,
110 ) -> SubscriptionResult;
111
112 #[subscription(name = "subscribeTransaction", item = IotaTransactionBlockEffects)]
114 fn subscribe_transaction(&self, filter: TransactionFilter) -> SubscriptionResult;
115
116 #[rustfmt::skip]
118 #[method(name = "getDynamicFields")]
119 #[schemars(with = "Page<IotaDynamicFieldInfo, ObjectIdSchema>")]
120 async fn get_dynamic_fields(
121 &self,
122 #[schemars(with = "ObjectIdSchema")]
124 parent_object_id: ObjectId,
125 #[schemars(with = "Option<ObjectIdSchema>")]
127 cursor: Option<ObjectId>,
128 limit: Option<usize>,
130 ) -> RpcResult<DynamicFieldPage>;
131
132 #[rustfmt::skip]
134 #[method(name = "getDynamicFieldObject")]
135 async fn get_dynamic_field_object(
136 &self,
137 #[schemars(with = "ObjectIdSchema")]
139 parent_object_id: ObjectId,
140 #[schemars(with = "DynamicFieldNameSchema")]
142 name: DynamicFieldName,
143 ) -> RpcResult<IotaObjectResponse>;
144
145 #[rustfmt::skip]
148 #[method(name = "getDynamicFieldObjectV2")]
149 async fn get_dynamic_field_object_v2(
150 &self,
151 #[schemars(with = "ObjectIdSchema")]
153 parent_object_id: ObjectId,
154 #[schemars(with = "DynamicFieldNameSchema")]
156 name: DynamicFieldName,
157 options: Option<IotaObjectDataOptions>,
159 ) -> RpcResult<IotaObjectResponse>;
160
161 #[method(name = "iotaNamesLookup")]
163 async fn iota_names_lookup(
164 &self,
165 name: &str,
167 ) -> RpcResult<Option<IotaNameRecord>>;
168
169 #[method(name = "iotaNamesReverseLookup")]
171 async fn iota_names_reverse_lookup(
172 &self,
173 #[schemars(with = "IotaAddressSchema")]
175 address: IotaAddress,
176 ) -> RpcResult<Option<String>>;
177
178 #[method(name = "iotaNamesFindAllRegistrationNFTs")]
180 #[schemars(with = "Page<IotaObjectResponse, ObjectIdSchema>")]
181 async fn iota_names_find_all_registration_nfts(
182 &self,
183 #[schemars(with = "IotaAddressSchema")] address: IotaAddress,
184 #[schemars(with = "Option<ObjectIdSchema>")] cursor: Option<ObjectId>,
185 limit: Option<usize>,
186 options: Option<IotaObjectDataOptions>,
187 ) -> RpcResult<ObjectsPage>;
188}