From 5df1eaef1f8dbf0258b9398996e00166c266fa99 Mon Sep 17 00:00:00 2001 From: grw-ms Date: Fri, 29 Sep 2023 05:06:16 -0700 Subject: [PATCH] fix: return correct DebugCallType --- src/debug.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/debug.rs b/src/debug.rs index 9980ed31..5069e584 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -15,7 +15,7 @@ use zksync_types::{ api::{BlockId, BlockNumber, DebugCall, DebugCallType, ResultDebugCall, TracerConfig}, l2::L2Tx, transaction_request::CallRequest, - PackedEthSignature, Transaction, + PackedEthSignature, Transaction, CONTRACT_DEPLOYER_ADDRESS, }; use zksync_web3_decl::error::Web3Error; @@ -109,11 +109,17 @@ impl DebugNamespaceT .unwrap_or_default() }; + let calltype = if l2_tx.recipient_account() == CONTRACT_DEPLOYER_ADDRESS { + DebugCallType::Create + } else { + DebugCallType::Call + }; + let result = match &tx_result.result { ExecutionResult::Success { output } => DebugCall { gas_used: tx_result.statistics.gas_used.into(), output: output.clone().into(), - r#type: DebugCallType::Call, + r#type: calltype, from: l2_tx.initiator_account(), to: l2_tx.recipient_account(), gas: l2_tx.common_data.fee.gas_limit, @@ -126,7 +132,7 @@ impl DebugNamespaceT ExecutionResult::Revert { output } => DebugCall { gas_used: tx_result.statistics.gas_used.into(), output: output.encoded_data().into(), - r#type: DebugCallType::Call, + r#type: calltype, from: l2_tx.initiator_account(), to: l2_tx.recipient_account(), gas: l2_tx.common_data.fee.gas_limit, @@ -139,7 +145,7 @@ impl DebugNamespaceT ExecutionResult::Halt { reason } => DebugCall { gas_used: tx_result.statistics.gas_used.into(), output: vec![].into(), - r#type: DebugCallType::Call, + r#type: calltype, from: l2_tx.initiator_account(), to: l2_tx.recipient_account(), gas: l2_tx.common_data.fee.gas_limit,