sui_rpc_api/grpc/v2/
mod.rs1pub mod ledger_service;
5mod move_package_service;
6mod name_service;
7mod signature_verification_service;
8mod state_service;
9mod subscription_service;
10mod transaction_execution_service;
11pub use ledger_service::protocol_config_to_proto;
12
13fn render_json(
14 service: &crate::RpcService,
15 struct_tag: &move_core_types::language_storage::StructTag,
16 contents: &[u8],
17) -> Option<prost_types::Value> {
18 let layout = service
19 .reader
20 .inner()
21 .get_struct_layout(struct_tag)
22 .ok()
23 .flatten()?;
24
25 sui_types::proto_value::ProtoVisitorBuilder::new(service.config.max_json_move_value_size())
26 .deserialize_value(contents, &layout)
27 .map_err(|e| tracing::debug!("unable to convert move value to JSON: {e}"))
28 .ok()
29}
30
31fn render_object_to_json(
32 service: &crate::RpcService,
33 object: &sui_types::object::Object,
34) -> Option<prost_types::Value> {
35 object.data.try_as_move().and_then(|move_object| {
36 render_json(
37 service,
38 &move_object.type_().clone().into(),
39 move_object.contents(),
40 )
41 })
42}