1use jsonrpsee::proc_macros::rpc;
5use sui_sdk_types::{Address, Digest, Version};
6
7use crate::msgs::{
8 Checkpoint,
9 CheckpointId,
10 CheckpointPage,
11 ProtocolConfigResponse,
12 SuiEvent,
13 SuiGetPastObjectRequest,
14 SuiObjectDataOptions,
15 SuiObjectResponse,
16 SuiPastObjectResponse,
17 SuiTransactionBlockResponse,
18 SuiTransactionBlockResponseOptions,
19};
20use crate::serde::BigInt;
21
22#[rpc(client, namespace = "sui")]
23pub trait ReadApi {
24 #[method(name = "getTransactionBlock")]
26 async fn get_transaction_block(
27 &self,
28 digest: Digest,
29 options: Option<SuiTransactionBlockResponseOptions>,
30 ) -> RpcResult<SuiTransactionBlockResponse>;
31
32 #[method(name = "multiGetTransactionBlocks")]
36 async fn multi_get_transaction_blocks(
37 &self,
38 digests: Vec<Digest>,
39 options: Option<SuiTransactionBlockResponseOptions>,
40 ) -> RpcResult<Vec<SuiTransactionBlockResponse>>;
41
42 #[method(name = "getObject")]
44 async fn get_object(
45 &self,
46 object_id: Address,
47 options: Option<SuiObjectDataOptions>,
48 ) -> RpcResult<SuiObjectResponse>;
49
50 #[method(name = "multiGetObjects")]
52 async fn multi_get_objects(
53 &self,
54 object_ids: Vec<Address>,
55 options: Option<SuiObjectDataOptions>,
56 ) -> RpcResult<Vec<SuiObjectResponse>>;
57
58 #[method(name = "tryGetPastObject")]
63 async fn try_get_past_object(
64 &self,
65 object_id: Address,
66 version: Version,
67 options: Option<SuiObjectDataOptions>,
68 ) -> RpcResult<SuiPastObjectResponse>;
69
70 #[method(name = "tryMultiGetPastObjects")]
75 async fn try_multi_get_past_objects(
76 &self,
77 past_objects: Vec<SuiGetPastObjectRequest>,
78 options: Option<SuiObjectDataOptions>,
79 ) -> RpcResult<Vec<SuiPastObjectResponse>>;
80
81 #[method(name = "getCheckpoint")]
83 async fn get_checkpoint(&self, id: CheckpointId) -> RpcResult<Checkpoint>;
84
85 #[method(name = "getCheckpoints")]
87 async fn get_checkpoints(
88 &self,
89 cursor: Option<BigInt<u64>>,
90 limit: Option<usize>,
91 descending_order: bool,
92 ) -> RpcResult<CheckpointPage>;
93
94 #[method(name = "getEvents")]
96 async fn get_events(&self, transaction_digest: Digest) -> RpcResult<Vec<SuiEvent>>;
97
98 #[method(name = "getTotalTransactionBlocks")]
100 async fn get_total_transaction_blocks(&self) -> RpcResult<BigInt<u64>>;
101
102 #[method(name = "getLatestCheckpointSequenceNumber")]
104 async fn get_latest_checkpoint_sequence_number(&self) -> RpcResult<BigInt<u64>>;
105
106 #[method(name = "getProtocolConfig")]
109 async fn get_protocol_config(
110 &self,
111 version: Option<BigInt<u64>>,
112 ) -> RpcResult<ProtocolConfigResponse>;
113
114 #[method(name = "getChainIdentifier")]
116 async fn get_chain_identifier(&self) -> RpcResult<String>;
117}