sui_json_rpc_api/
move_utils.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use std::collections::BTreeMap;
5
6use jsonrpsee::core::RpcResult;
7use jsonrpsee::proc_macros::rpc;
8
9use sui_json_rpc_types::{
10    MoveFunctionArgType, SuiMoveNormalizedFunction, SuiMoveNormalizedModule,
11    SuiMoveNormalizedStruct,
12};
13use sui_open_rpc_macros::open_rpc;
14use sui_types::base_types::ObjectID;
15
16#[open_rpc(namespace = "sui", tag = "Move Utils")]
17#[rpc(server, client, namespace = "sui")]
18pub trait MoveUtils {
19    /// Return the argument types of a Move function,
20    /// based on normalized Type.
21    #[method(name = "getMoveFunctionArgTypes")]
22    async fn get_move_function_arg_types(
23        &self,
24        package: ObjectID,
25        module: String,
26        function: String,
27    ) -> RpcResult<Vec<MoveFunctionArgType>>;
28
29    /// Return structured representations of all modules in the given package
30    #[method(name = "getNormalizedMoveModulesByPackage")]
31    async fn get_normalized_move_modules_by_package(
32        &self,
33        package: ObjectID,
34    ) -> RpcResult<BTreeMap<String, SuiMoveNormalizedModule>>;
35
36    /// Return a structured representation of Move module
37    #[method(name = "getNormalizedMoveModule")]
38    async fn get_normalized_move_module(
39        &self,
40        package: ObjectID,
41        module_name: String,
42    ) -> RpcResult<SuiMoveNormalizedModule>;
43
44    /// Return a structured representation of Move struct
45    #[method(name = "getNormalizedMoveStruct")]
46    async fn get_normalized_move_struct(
47        &self,
48        package: ObjectID,
49        module_name: String,
50        struct_name: String,
51    ) -> RpcResult<SuiMoveNormalizedStruct>;
52
53    /// Return a structured representation of Move function
54    #[method(name = "getNormalizedMoveFunction")]
55    async fn get_normalized_move_function(
56        &self,
57        package: ObjectID,
58        module_name: String,
59        function_name: String,
60    ) -> RpcResult<SuiMoveNormalizedFunction>;
61}