diff --git a/rusk/src/lib/http/chain/graphql/data.rs b/rusk/src/lib/http/chain/graphql/data.rs index f3110b1f32..098ba2703b 100644 --- a/rusk/src/lib/http/chain/graphql/data.rs +++ b/rusk/src/lib/http/chain/graphql/data.rs @@ -242,99 +242,7 @@ impl Transaction<'_> { } pub async fn json(&self) -> String { - use dusk_bytes::Serializable; - use serde::Serialize; - use serde_json::{json, Map, Value}; - - let tx = &self.0.inner; - - let mut map = Map::new(); - - if let Some(root) = tx.root() { - map.insert("root".into(), json!(hex::encode(root.to_bytes()))); - } - - if let Some(from) = tx.from() { - map.insert("from".into(), json!(hex::encode(from.to_bytes()))); - } - if let Some(to) = tx.to() { - map.insert("to".into(), json!(hex::encode(to.to_bytes()))); - } - if let Some(value) = tx.value() { - map.insert("value".into(), json!(hex::encode(value.to_bytes()))); - } - - let nullifiers: Vec<_> = tx - .nullifiers() - .iter() - .map(|n| hex::encode(n.to_bytes())) - .collect(); - map.insert("nullifiers".into(), json!(nullifiers)); - map.insert( - "deposit".into(), - json!(hex::encode(tx.deposit().to_bytes())), - ); - let notes: Vec<_> = tx - .outputs() - .iter() - .map(|n| { - let mut map = Map::new(); - map.insert("note_type".into(), json!(n.note_type() as u8)); - map.insert( - "value_commitment".into(), - json!([ - hex::encode(n.value_commitment().get_u().to_bytes()), - hex::encode(n.value_commitment().get_v().to_bytes()) - ]), - ); - map.insert( - "stealth_address".into(), - json!(bs58::encode(n.stealth_address().to_bytes()) - .into_string()), - ); - map.insert( - "value_enc".into(), - json!(n - .value_enc() - .iter() - .map(|c| hex::encode(c.to_bytes())) - .collect::>()), - ); - map.insert( - "sender".into(), - json!(hex::encode(n.sender().to_bytes())), - ); - map - }) - .collect(); - map.insert("notes".into(), json!(notes)); - - let mut fee = Map::new(); - - fee.insert("gas_limit".into(), json!(tx.gas_limit())); - fee.insert("gas_price".into(), json!(tx.gas_price())); - - if let Some(stealth_address) = tx.stealth_address() { - fee.insert( - "stealth_address".into(), - json!(bs58::encode(stealth_address.to_bytes()).into_string()), - ); - } - if let Some(sender) = tx.sender() { - fee.insert("sender".into(), json!(hex::encode(sender.to_bytes()))); - } - - map.insert("fee".into(), json!(fee)); - - if let Some(c) = tx.call() { - let mut call = Map::new(); - call.insert("contract".into(), json!(hex::encode(c.contract))); - call.insert("fn_name".into(), json!(&c.fn_name)); - call.insert("fn_args".into(), json!(hex::encode(&c.fn_args))); - map.insert("call".into(), json!(call)); - } - - json!(map).to_string() + self.0.to_json().to_string() } pub async fn id(&self) -> String {