iota_json_rpc_api/
move_utils.rs

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