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 Address as AddressSchema, Base58 as Base58Schema, ObjectId as ObjectIdSchema,
13 },
14};
15use iota_open_rpc_macros::open_rpc;
16use iota_sdk_types::{Address, ObjectId, TransactionDigest};
17use iota_types::{dynamic_field::DynamicFieldName, event::EventID};
18use jsonrpsee::{
19 core::{RpcResult, SubscriptionResult},
20 proc_macros::rpc,
21};
22
23#[open_rpc(namespace = "iotax", tag = "Extended API")]
26#[rpc(server, client, namespace = "iotax")]
27pub trait IndexerApi {
28 #[rustfmt::skip]
34 #[method(name = "getOwnedObjects")]
35 #[schemars(with = "Page<IotaObjectResponse, ObjectIdSchema>")]
36 async fn get_owned_objects(
37 &self,
38 #[schemars(with = "AddressSchema")]
40 address: Address,
41 query: Option<IotaObjectResponseQuery>,
43 #[schemars(with = "Option<ObjectIdSchema>")]
45 cursor: Option<ObjectId>,
46 limit: Option<usize>,
48 ) -> RpcResult<ObjectsPage>;
49
50 #[rustfmt::skip]
52 #[method(name = "queryTransactionBlocks", version <= "1.2.10")]
53 #[schemars(with = "Page<IotaTransactionBlockResponse, Base58>")]
54 async fn query_transaction_blocks(
55 &self,
56 query: IotaTransactionBlockResponseQuery,
58 cursor: Option<TransactionDigest>,
60 limit: Option<usize>,
62 descending_order: Option<bool>,
64 ) -> RpcResult<TransactionBlocksPage>;
65
66 #[rustfmt::skip]
68 #[method(name = "queryTransactionBlocks")]
69 #[schemars(with = "Page<IotaTransactionBlockResponse, Base58Schema>")]
70 async fn query_transaction_blocks_v2(
71 &self,
72 query: IotaTransactionBlockResponseQueryV2,
74 #[schemars(with = "Option<Base58Schema>")]
76 cursor: Option<TransactionDigest>,
77 limit: Option<usize>,
79 descending_order: Option<bool>,
81 ) -> RpcResult<TransactionBlocksPage>;
82
83 #[rustfmt::skip]
85 #[method(name = "queryEvents")]
86 #[schemars(with = "Page<IotaEvent, IotaEventID>")]
87 async fn query_events(
88 &self,
89 query: EventFilter,
91 #[schemars(with = "Option<IotaEventID>")]
93 cursor: Option<EventID>,
94 limit: Option<usize>,
96 descending_order: Option<bool>,
98 ) -> RpcResult<EventPage>;
99
100 #[rustfmt::skip]
102 #[subscription(name = "subscribeEvent", item = IotaEvent)]
103 fn subscribe_event(
104 &self,
105 filter: EventFilter,
107 ) -> SubscriptionResult;
108
109 #[subscription(name = "subscribeTransaction", item = IotaTransactionBlockEffects)]
111 fn subscribe_transaction(&self, filter: TransactionFilter) -> SubscriptionResult;
112
113 #[rustfmt::skip]
115 #[method(name = "getDynamicFields")]
116 #[schemars(with = "Page<IotaDynamicFieldInfo, ObjectIdSchema>")]
117 async fn get_dynamic_fields(
118 &self,
119 #[schemars(with = "ObjectIdSchema")]
121 parent_object_id: ObjectId,
122 #[schemars(with = "Option<ObjectIdSchema>")]
124 cursor: Option<ObjectId>,
125 limit: Option<usize>,
127 ) -> RpcResult<DynamicFieldPage>;
128
129 #[rustfmt::skip]
131 #[method(name = "getDynamicFieldObject")]
132 async fn get_dynamic_field_object(
133 &self,
134 #[schemars(with = "ObjectIdSchema")]
136 parent_object_id: ObjectId,
137 #[schemars(with = "DynamicFieldNameSchema")]
139 name: DynamicFieldName,
140 ) -> RpcResult<IotaObjectResponse>;
141
142 #[rustfmt::skip]
145 #[method(name = "getDynamicFieldObjectV2")]
146 async fn get_dynamic_field_object_v2(
147 &self,
148 #[schemars(with = "ObjectIdSchema")]
150 parent_object_id: ObjectId,
151 #[schemars(with = "DynamicFieldNameSchema")]
153 name: DynamicFieldName,
154 options: Option<IotaObjectDataOptions>,
156 ) -> RpcResult<IotaObjectResponse>;
157
158 #[method(name = "iotaNamesLookup")]
160 async fn iota_names_lookup(
161 &self,
162 name: &str,
164 ) -> RpcResult<Option<IotaNameRecord>>;
165
166 #[method(name = "iotaNamesReverseLookup")]
168 async fn iota_names_reverse_lookup(
169 &self,
170 #[schemars(with = "AddressSchema")]
172 address: Address,
173 ) -> RpcResult<Option<String>>;
174
175 #[method(name = "iotaNamesFindAllRegistrationNFTs")]
177 #[schemars(with = "Page<IotaObjectResponse, ObjectIdSchema>")]
178 async fn iota_names_find_all_registration_nfts(
179 &self,
180 #[schemars(with = "AddressSchema")] address: Address,
181 #[schemars(with = "Option<ObjectIdSchema>")] cursor: Option<ObjectId>,
182 limit: Option<usize>,
183 options: Option<IotaObjectDataOptions>,
184 ) -> RpcResult<ObjectsPage>;
185}