forked from neonevm/neon-evm
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtrace.rs
More file actions
30 lines (24 loc) · 838 Bytes
/
trace.rs
File metadata and controls
30 lines (24 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use serde_json::Value;
use solana_sdk::pubkey::Pubkey;
use crate::commands::get_config::BuildConfigSimulator;
use crate::errors::NeonError;
use crate::rpc::Rpc;
use crate::tracing::tracers::new_tracer;
use crate::types::EmulateRequest;
pub async fn trace_transaction(
rpc: &(impl Rpc + BuildConfigSimulator),
program_id: Pubkey,
emulate_request: EmulateRequest,
) -> Result<Value, NeonError> {
let trace_config = emulate_request
.trace_config
.as_ref()
.map(|c| c.trace_config.clone())
.unwrap_or_default();
let tracer = new_tracer(&trace_config)?;
let (r, traces) =
super::emulate::execute(rpc, program_id, emulate_request, Some(tracer)).await?;
let mut traces = traces.expect("traces should not be None");
traces["gas"] = r.used_gas.into();
Ok(traces)
}