Skip to content

Commit

Permalink
[cherrypick][main] - rosetta failed pt fix (#20411) (#20415)
Browse files Browse the repository at this point in the history
## Description 

do not attempt to parse programmable transaction for failed transactions
to avoid parsing error

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:

## Description 

Describe the changes or additions included in this PR.

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
patrickkuo authored Nov 25, 2024
1 parent 252c332 commit e6209b7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions crates/sui-rosetta/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ impl Operations {
status: Option<OperationStatus>,
) -> Result<Vec<Operation>, Error> {
Ok(match tx {
SuiTransactionBlockKind::ProgrammableTransaction(pt) => {
SuiTransactionBlockKind::ProgrammableTransaction(pt)
if status != Some(OperationStatus::Failure) =>
{
Self::parse_programmable_transaction(sender, status, pt)?
}
_ => vec![Operation::generic_op(status, sender, tx)],
Expand Down Expand Up @@ -558,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 @@ -588,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 @@ -735,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 e6209b7

Please sign in to comment.