Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[transaction-block-rename][3/n] Update RPC types and endpoints #9972

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[transaction-block-rename][3/n] Update RPC types
  • Loading branch information
666lcz committed Mar 28, 2023
commit 35b929d56701a9e8671d1fe47f70555b44025eda
8 changes: 4 additions & 4 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ use sui_config::genesis::Genesis;
use sui_config::node::{AuthorityStorePruningConfig, DBCheckpointConfig};
use sui_framework::{MoveStdlib, SuiFramework, SuiSystem, SystemPackage};
use sui_json_rpc_types::{
Checkpoint, DevInspectResults, DryRunTransactionResponse, EventFilter, SuiEvent, SuiMoveValue,
SuiObjectDataFilter, SuiTransactionBlockEvents,
Checkpoint, DevInspectResults, DryRunTransactionBlockResponse, EventFilter, SuiEvent,
SuiMoveValue, SuiObjectDataFilter, SuiTransactionBlockEvents,
};
use sui_macros::{fail_point, fail_point_async, nondeterministic};
use sui_protocol_config::SupportedProtocolVersions;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl AuthorityState {
transaction_digest: TransactionDigest,
) -> Result<
(
DryRunTransactionResponse,
DryRunTransactionBlockResponse,
BTreeMap<ObjectID, (ObjectRef, Object, WriteKind)>,
TransactionEffects,
),
Expand Down Expand Up @@ -1105,7 +1105,7 @@ impl AuthorityState {
let balance_changes = Vec::new();

Ok((
DryRunTransactionResponse {
DryRunTransactionBlockResponse {
effects: effects.clone().try_into()?,
events: SuiTransactionBlockEvents::try_from(
inner_temp_store.events.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ async fn test_for_inc_201_dry_run() {
let txn_data = TransactionData::new_with_gas_coins(kind, sender, vec![], 10000, 1);

let signed = to_sender_signed_transaction(txn_data, &sender_key);
let (DryRunTransactionResponse { events, .. }, _, _) = fullnode
let (DryRunTransactionBlockResponse { events, .. }, _, _) = fullnode
.dry_exec_transaction(
signed.data().intent_message().value.clone(),
*signed.digest(),
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-indexer/src/apis/write_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use jsonrpsee::RpcModule;
use sui_json_rpc::api::{WriteApiClient, WriteApiServer};
use sui_json_rpc::SuiRpcModule;
use sui_json_rpc_types::{
BigInt, DevInspectResults, DryRunTransactionResponse, SuiTransactionBlockResponse,
BigInt, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
};
use sui_open_rpc::Module;
Expand Down Expand Up @@ -57,7 +57,7 @@ impl WriteApiServer for WriteApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> RpcResult<DryRunTransactionResponse> {
) -> RpcResult<DryRunTransactionBlockResponse> {
self.fullnode.dry_run_transaction_block(tx_bytes).await
}
}
Expand Down
42 changes: 16 additions & 26 deletions crates/sui-json-rpc-types/src/sui_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ impl Display for BigInt {
pub type SuiEpochId = BigInt;

#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase", rename = "TransactionResponseQuery", default)]
#[serde(
rename_all = "camelCase",
rename = "TransactionBlockResponseQuery",
default
)]
pub struct SuiTransactionBlockResponseQuery {
/// If None, no filter will be applied
pub filter: Option<TransactionFilter>,
Expand Down Expand Up @@ -99,7 +103,7 @@ pub type TransactionBlocksPage = Page<SuiTransactionBlockResponse, TransactionDi
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, Eq, PartialEq, Default)]
#[serde(
rename_all = "camelCase",
rename = "TransactionResponseOptions",
rename = "TransactionBlockResponseOptions",
default
)]
pub struct SuiTransactionBlockResponseOptions {
Expand Down Expand Up @@ -196,7 +200,7 @@ impl SuiTransactionBlockResponseOptions {

#[serde_as]
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone, Default)]
#[serde(rename_all = "camelCase", rename = "TransactionResponse")]
#[serde(rename_all = "camelCase", rename = "TransactionBlockResponse")]
pub struct SuiTransactionBlockResponse {
pub digest: TransactionDigest,
/// Transaction input data
Expand Down Expand Up @@ -253,7 +257,7 @@ impl PartialEq for SuiTransactionBlockResponse {
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename = "TransactionKind", tag = "kind")]
#[serde(rename = "TransactionBlockKind", tag = "kind")]
pub enum SuiTransactionBlockKind {
/// A system transaction that will update epoch information on-chain.
ChangeEpoch(SuiChangeEpoch),
Expand Down Expand Up @@ -355,7 +359,7 @@ pub struct SuiChangeEpoch {
#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[enum_dispatch(SuiTransactionBlockEffectsAPI)]
#[serde(
rename = "TransactionEffects",
rename = "TransactionBlockEffects",
rename_all = "camelCase",
tag = "messageVersion"
)]
Expand Down Expand Up @@ -390,7 +394,7 @@ pub trait SuiTransactionBlockEffectsAPI {

#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(
rename = "TransactionEffectsModifiedAtVersions",
rename = "TransactionBlockEffectsModifiedAtVersions",
rename_all = "camelCase"
)]
pub struct SuiTransactionBlockEffectsModifiedAtVersions {
Expand All @@ -400,7 +404,7 @@ pub struct SuiTransactionBlockEffectsModifiedAtVersions {

/// The response from processing a transaction or a certified transaction
#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransactionEffectsV1", rename_all = "camelCase")]
#[serde(rename = "TransactionBlockEffectsV1", rename_all = "camelCase")]
pub struct SuiTransactionBlockEffectsV1 {
/// The status of the execution
pub status: SuiExecutionStatus,
Expand Down Expand Up @@ -650,15 +654,15 @@ impl Display for SuiTransactionBlockEffects {

#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct DryRunTransactionResponse {
pub struct DryRunTransactionBlockResponse {
pub effects: SuiTransactionBlockEffects,
pub events: SuiTransactionBlockEvents,
pub object_changes: Vec<ObjectChange>,
pub balance_changes: Vec<BalanceChange>,
}

#[derive(Eq, PartialEq, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransactionEvents", transparent)]
#[serde(rename = "TransactionBlockEvents", transparent)]
pub struct SuiTransactionBlockEvents {
pub data: Vec<SuiEvent>,
}
Expand Down Expand Up @@ -865,7 +869,7 @@ pub struct SuiGasData {
#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[enum_dispatch(SuiTransactionBlockDataAPI)]
#[serde(
rename = "TransactionData",
rename = "TransactionBlockData",
rename_all = "camelCase",
tag = "messageVersion"
)]
Expand All @@ -881,7 +885,7 @@ pub trait SuiTransactionBlockDataAPI {
}

#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[serde(rename = "TransactionDataV1", rename_all = "camelCase")]
#[serde(rename = "TransactionBlockDataV1", rename_all = "camelCase")]
pub struct SuiTransactionBlockDataV1 {
pub transaction: SuiTransactionBlockKind,
pub sender: SuiAddress,
Expand Down Expand Up @@ -972,7 +976,7 @@ impl SuiTransactionBlockData {
}

#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[serde(rename = "Transaction", rename_all = "camelCase")]
#[serde(rename = "TransactionBlock", rename_all = "camelCase")]
pub struct SuiTransactionBlock {
pub data: SuiTransactionBlockData,
pub tx_signatures: Vec<GenericSignature>,
Expand Down Expand Up @@ -1014,20 +1018,6 @@ pub struct SuiConsensusCommitPrologue {
pub commit_timestamp_ms: u64,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransferObject", rename_all = "camelCase")]
pub struct SuiTransferObject {
pub recipient: SuiAddress,
pub object_ref: SuiObjectRef,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "TransferSui", rename_all = "camelCase")]
pub struct SuiTransferSui {
pub recipient: SuiAddress,
pub amount: Option<u64>,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "InputObjectKind")]
pub enum SuiInputObjectKind {
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-json-rpc/src/api/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use fastcrypto::encoding::Base64;
use jsonrpsee::core::RpcResult;
use jsonrpsee_proc_macros::rpc;
use sui_json_rpc_types::{
BigInt, DevInspectResults, DryRunTransactionResponse, SuiTransactionBlockResponse,
BigInt, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
};

Expand Down Expand Up @@ -60,5 +60,5 @@ pub trait WriteApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> RpcResult<DryRunTransactionResponse>;
) -> RpcResult<DryRunTransactionBlockResponse>;
}
8 changes: 4 additions & 4 deletions crates/sui-json-rpc/src/transaction_execution_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sui_core::authority::AuthorityState;
use sui_core::authority_client::NetworkAuthorityClient;
use sui_core::transaction_orchestrator::TransactiondOrchestrator;
use sui_json_rpc_types::{
BigInt, DevInspectResults, DryRunTransactionResponse, SuiTransactionBlock,
BigInt, DevInspectResults, DryRunTransactionBlockResponse, SuiTransactionBlock,
SuiTransactionBlockEvents, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions,
};
use sui_open_rpc::Module;
Expand Down Expand Up @@ -156,7 +156,7 @@ impl TransactionExecutionApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> Result<DryRunTransactionResponse, Error> {
) -> Result<DryRunTransactionBlockResponse, Error> {
let (txn_data, txn_digest) = get_transaction_data_and_digest(tx_bytes)?;
let (resp, written_objects, transaction_effects) = self
.state
Expand All @@ -174,7 +174,7 @@ impl TransactionExecutionApi {
)
.await?;

Ok(DryRunTransactionResponse {
Ok(DryRunTransactionBlockResponse {
effects: resp.effects,
events: resp.events,
object_changes,
Expand Down Expand Up @@ -215,7 +215,7 @@ impl WriteApiServer for TransactionExecutionApi {
async fn dry_run_transaction_block(
&self,
tx_bytes: Base64,
) -> RpcResult<DryRunTransactionResponse> {
) -> RpcResult<DryRunTransactionBlockResponse> {
Ok(self.dry_run_transaction_block(tx_bytes).await?)
}
}
Expand Down
Loading