sui_rpc_api/grpc/v2/state_service/
mod.rs1use crate::RpcService;
5use sui_rpc::proto::sui::rpc::v2::GetBalanceRequest;
6use sui_rpc::proto::sui::rpc::v2::GetBalanceResponse;
7use sui_rpc::proto::sui::rpc::v2::GetCoinInfoRequest;
8use sui_rpc::proto::sui::rpc::v2::GetCoinInfoResponse;
9use sui_rpc::proto::sui::rpc::v2::ListBalancesRequest;
10use sui_rpc::proto::sui::rpc::v2::ListBalancesResponse;
11use sui_rpc::proto::sui::rpc::v2::ListDynamicFieldsRequest;
12use sui_rpc::proto::sui::rpc::v2::ListDynamicFieldsResponse;
13use sui_rpc::proto::sui::rpc::v2::ListOwnedObjectsRequest;
14use sui_rpc::proto::sui::rpc::v2::ListOwnedObjectsResponse;
15use sui_rpc::proto::sui::rpc::v2::state_service_server::StateService;
16
17mod get_balance;
18mod get_coin_info;
19mod list_balances;
20mod list_dynamic_fields;
21mod list_owned_objects;
22
23#[tonic::async_trait]
24impl StateService for RpcService {
25 async fn list_dynamic_fields(
26 &self,
27 request: tonic::Request<ListDynamicFieldsRequest>,
28 ) -> Result<tonic::Response<ListDynamicFieldsResponse>, tonic::Status> {
29 list_dynamic_fields::list_dynamic_fields(self, request.into_inner())
30 .map(tonic::Response::new)
31 .map_err(Into::into)
32 }
33
34 async fn list_owned_objects(
35 &self,
36 request: tonic::Request<ListOwnedObjectsRequest>,
37 ) -> Result<tonic::Response<ListOwnedObjectsResponse>, tonic::Status> {
38 list_owned_objects::list_owned_objects(self, request.into_inner())
39 .map(tonic::Response::new)
40 .map_err(Into::into)
41 }
42
43 async fn get_coin_info(
44 &self,
45 request: tonic::Request<GetCoinInfoRequest>,
46 ) -> Result<tonic::Response<GetCoinInfoResponse>, tonic::Status> {
47 get_coin_info::get_coin_info(self, request.into_inner())
48 .map(tonic::Response::new)
49 .map_err(Into::into)
50 }
51
52 async fn get_balance(
53 &self,
54 request: tonic::Request<GetBalanceRequest>,
55 ) -> Result<tonic::Response<GetBalanceResponse>, tonic::Status> {
56 get_balance::get_balance(self, request.into_inner())
57 .map(tonic::Response::new)
58 .map_err(Into::into)
59 }
60
61 async fn list_balances(
62 &self,
63 request: tonic::Request<ListBalancesRequest>,
64 ) -> Result<tonic::Response<ListBalancesResponse>, tonic::Status> {
65 list_balances::list_balances(self, request.into_inner())
66 .map(tonic::Response::new)
67 .map_err(Into::into)
68 }
69}