Skip to content

Commit

Permalink
Return error from ots_getInternalOperations for EOFCREATE tx
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane committed Sep 15, 2024
1 parent dbfef33 commit 93a3ef1
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions crates/rpc/rpc/src/otterscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where

/// Handler for `ots_getInternalOperations`
async fn get_internal_operations(&self, tx_hash: TxHash) -> RpcResult<Vec<InternalOperation>> {
let internal_operations = self
let Some(transfer_operations) = self
.eth
.spawn_trace_transaction_in_block_with_inspector(
tx_hash,
Expand All @@ -108,24 +108,29 @@ where
)
.await
.map_err(Into::into)?
.map(|transfer_operations| {
transfer_operations
.iter()
.map(|op| InternalOperation {
from: op.from,
to: op.to,
value: op.value,
r#type: match op.kind {
TransferKind::Call => OperationType::OpTransfer,
TransferKind::Create => OperationType::OpCreate,
TransferKind::Create2 => OperationType::OpCreate2,
TransferKind::SelfDestruct => OperationType::OpSelfDestruct,
TransferKind::EofCreate => todo!(),
},
})
.collect::<Vec<_>>()
else {
return Ok(Vec::new())
};

let mut internal_operations = Vec::with_capacity(transfer_operations.len());

for op in transfer_operations {
internal_operations.push(InternalOperation {
from: op.from,
to: op.to,
value: op.value,
r#type: match op.kind {
TransferKind::Call => OperationType::OpTransfer,
TransferKind::Create => OperationType::OpCreate,
TransferKind::Create2 => OperationType::OpCreate2,
TransferKind::SelfDestruct => OperationType::OpSelfDestruct,
TransferKind::EofCreate => {
return Err(internal_rpc_err("EOFCREATE unsupported"))
}
},
})
.unwrap_or_default();
}

Ok(internal_operations)
}

Expand Down

0 comments on commit 93a3ef1

Please sign in to comment.