0.7.28 - final
This commit is contained in:
@@ -50,10 +50,15 @@ pub(crate) struct DexDecodedEventMaterializationInput<'a> {
|
||||
pub(crate) async fn materialize_dex_decoded_event(
|
||||
input: crate::dex_decoded_event_materialization::DexDecodedEventMaterializationInput<'_>,
|
||||
) -> Result<crate::DexDecodedEventDto, crate::Error> {
|
||||
let enrichment_payload_json =
|
||||
crate::dex_decoded_event_materialization::prepare_payload_for_transaction_status(
|
||||
input.transaction,
|
||||
input.enrichment_payload_json,
|
||||
);
|
||||
let payload_json_result = crate::enrich_and_serialize_dex_decoded_payload(
|
||||
input.protocol_name.as_str(),
|
||||
input.event_kind.as_str(),
|
||||
input.enrichment_payload_json,
|
||||
enrichment_payload_json,
|
||||
);
|
||||
let payload_json = match payload_json_result {
|
||||
Ok(payload_json) => payload_json,
|
||||
@@ -138,3 +143,32 @@ pub(crate) async fn materialize_dex_decoded_event(
|
||||
}
|
||||
return Ok(fetched);
|
||||
}
|
||||
|
||||
fn prepare_payload_for_transaction_status(
|
||||
transaction: &crate::ChainTransactionDto,
|
||||
payload_json: serde_json::Value,
|
||||
) -> serde_json::Value {
|
||||
if transaction.err_json.is_none() {
|
||||
return payload_json;
|
||||
}
|
||||
let mut object = match payload_json {
|
||||
serde_json::Value::Object(object) => object,
|
||||
other => {
|
||||
let mut object = serde_json::Map::new();
|
||||
object.insert("rawPayload".to_string(), other);
|
||||
object
|
||||
},
|
||||
};
|
||||
object.insert("transactionFailed".to_string(), serde_json::Value::Bool(true));
|
||||
object.insert("tradeCandidate".to_string(), serde_json::Value::Bool(false));
|
||||
object.insert("candleCandidate".to_string(), serde_json::Value::Bool(false));
|
||||
object.insert(
|
||||
"skipTradeReason".to_string(),
|
||||
serde_json::Value::String("failed_transaction".to_string()),
|
||||
);
|
||||
object.insert(
|
||||
"skipCandleReason".to_string(),
|
||||
serde_json::Value::String("failed_transaction".to_string()),
|
||||
);
|
||||
return serde_json::Value::Object(object);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user