sui_json_rpc_api/write.rs
1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use fastcrypto::encoding::Base64;
5use jsonrpsee::core::RpcResult;
6use jsonrpsee::proc_macros::rpc;
7
8use sui_json_rpc_types::{
9 DevInspectArgs, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlockResponse,
10 SuiTransactionBlockResponseOptions,
11};
12use sui_open_rpc_macros::open_rpc;
13use sui_types::base_types::SuiAddress;
14use sui_types::quorum_driver_types::ExecuteTransactionRequestType;
15use sui_types::sui_serde::BigInt;
16
17#[open_rpc(namespace = "sui", tag = "Write API")]
18#[rpc(server, client, namespace = "sui")]
19pub trait WriteApi {
20 /// Execute the transaction and wait for results if desired.
21 /// Request types:
22 /// 1. WaitForEffectsCert: waits for TransactionEffectsCert and then return to client.
23 /// This mode is a proxy for transaction finality.
24 /// 2. WaitForLocalExecution: waits for TransactionEffectsCert and make sure the node
25 /// executed the transaction locally before returning the client. The local execution
26 /// makes sure this node is aware of this transaction when client fires subsequent queries.
27 /// However if the node fails to execute the transaction locally in a timely manner,
28 /// a bool type in the response is set to false to indicated the case.
29 /// request_type is default to be `WaitForEffectsCert` unless options.show_events or options.show_effects is true
30 #[method(name = "executeTransactionBlock")]
31 async fn execute_transaction_block(
32 &self,
33 /// BCS serialized transaction data bytes without its type tag, as base-64 encoded string.
34 tx_bytes: Base64,
35 /// A list of signatures (`flag || signature || pubkey` bytes, as base-64 encoded string). Signature is committed to the intent message of the transaction data, as base-64 encoded string.
36 signatures: Vec<Base64>,
37 /// options for specifying the content to be returned
38 options: Option<SuiTransactionBlockResponseOptions>,
39 /// The request type, derived from `SuiTransactionBlockResponseOptions` if None
40 request_type: Option<ExecuteTransactionRequestType>,
41 ) -> RpcResult<SuiTransactionBlockResponse>;
42
43 /// Runs the transaction in dev-inspect mode. Which allows for nearly any
44 /// transaction (or Move call) with any arguments. Detailed results are
45 /// provided, including both the transaction effects and any return values.
46 #[method(name = "devInspectTransactionBlock")]
47 async fn dev_inspect_transaction_block(
48 &self,
49 sender_address: SuiAddress,
50 /// BCS encoded TransactionKind(as opposed to TransactionData, which include gasBudget and gasPrice)
51 tx_bytes: Base64,
52 /// Gas is not charged, but gas usage is still calculated. Default to use reference gas price
53 gas_price: Option<BigInt<u64>>,
54 /// The epoch to perform the call. Will be set from the system state object if not provided
55 epoch: Option<BigInt<u64>>,
56 /// Additional arguments including gas_budget, gas_objects, gas_sponsor and skip_checks.
57 additional_args: Option<DevInspectArgs>,
58 ) -> RpcResult<DevInspectResults>;
59
60 /// Return transaction execution effects including the gas cost summary,
61 /// while the effects are not committed to the chain.
62 #[method(name = "dryRunTransactionBlock")]
63 async fn dry_run_transaction_block(
64 &self,
65 tx_bytes: Base64,
66 ) -> RpcResult<DryRunTransactionBlockResponse>;
67}