Skip to content

Commit

Permalink
pass transaction status to Operations conversion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkuo committed Nov 24, 2024
1 parent 856c895 commit 27bf4f4
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions crates/sui-rosetta/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,16 @@ impl Operations {
}
}

impl TryFrom<SuiTransactionBlockData> for Operations {
type Error = Error;
fn try_from(data: SuiTransactionBlockData) -> Result<Self, Self::Error> {
impl Operations {
fn try_from_data(
data: SuiTransactionBlockData,
status: Option<OperationStatus>,
) -> Result<Self, anyhow::Error> {
let sender = *data.sender();
Ok(Self::new(Self::from_transaction(
data.transaction().clone(),
sender,
None,
status,
)?))
}
}
Expand All @@ -590,8 +592,8 @@ impl Operations {
- gas_summary.computation_cost as i128;

let status = Some(effect.into_status().into());
let ops: Operations = tx.data.try_into()?;
let ops = ops.set_status(status).into_iter();
let ops = Operations::try_from_data(tx.data, status)?;
let ops = ops.into_iter();

// We will need to subtract the operation amounts from the actual balance
// change amount extracted from event to prevent double counting.
Expand Down Expand Up @@ -737,7 +739,10 @@ impl TryFrom<TransactionData> for Operations {
}
}
// Rosetta don't need the call args to be parsed into readable format
SuiTransactionBlockData::try_from(data, &&mut NoOpsModuleResolver)?.try_into()
Ok(Operations::try_from_data(
SuiTransactionBlockData::try_from(data, &&mut NoOpsModuleResolver)?,
None,
)?)
}
}

Expand Down

0 comments on commit 27bf4f4

Please sign in to comment.