sui_jsonrpc/api/
move_utils.rs

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