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

feat(json-rpc): get transaction block raw effects #19438

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
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
45 changes: 27 additions & 18 deletions crates/sui-json-rpc/src/read_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,28 +1325,36 @@ fn convert_to_response(
let mut response = SuiTransactionBlockResponse::new(cache.digest);
response.errors = cache.errors;

if opts.show_raw_input && cache.transaction.is_some() {
let sender_signed_data = cache.transaction.as_ref().unwrap().data();
let raw_tx = bcs::to_bytes(sender_signed_data)
.map_err(|e| anyhow!("Failed to serialize raw transaction with error: {}", e))?; // TODO: is this a client or server error?
response.raw_transaction = raw_tx;
}
if let Some(transaction) = cache.transaction {
if opts.show_raw_input {
response.raw_transaction = bcs::to_bytes(transaction.data()).map_err(|e| {
// TODO: is this a client or server error?
anyhow!("Failed to serialize raw transaction with error: {e}")
})?;
}

if opts.show_input && cache.transaction.is_some() {
let tx_block =
SuiTransactionBlock::try_from(cache.transaction.unwrap().into_data(), module_cache)?;
response.transaction = Some(tx_block);
if opts.show_input {
response.transaction = Some(SuiTransactionBlock::try_from(
transaction.into_data(),
module_cache,
)?);
}
}

if opts.show_effects && cache.effects.is_some() {
let effects = cache.effects.unwrap().try_into().map_err(|e| {
anyhow!(
if let Some(effects) = cache.effects {
if opts.show_raw_effects {
response.raw_effects = bcs::to_bytes(&effects).map_err(|e| {
// TODO: is this a client or server error?
"Failed to convert transaction block effects with error: {}",
e
)
})?;
response.effects = Some(effects);
anyhow!("Failed to serialize transaction block effects with error: {e}")
})?;
}

if opts.show_effects {
response.effects = Some(effects.try_into().map_err(|e| {
// TODO: is this a client or server error?
anyhow!("Failed to convert transaction block effects with error: {e}")
})?);
}
}

response.checkpoint = cache.checkpoint_seq;
Expand All @@ -1363,6 +1371,7 @@ fn convert_to_response(
if opts.show_object_changes {
response.object_changes = cache.object_changes;
}

Ok(response)
}

Expand Down
Loading