Skip to content

Commit

Permalink
chore(post-conditions): add post-condition status to event dispatcher…
Browse files Browse the repository at this point in the history
… payload
  • Loading branch information
ldiego08 committed May 30, 2024
1 parent 9a59ec2 commit fb41b66
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions testnet/stacks-node/src/event_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct ReceiptPayloadInfo<'a> {
raw_tx: String,
contract_interface_json: serde_json::Value,
burnchain_op_json: serde_json::Value,
post_condition_status_json: serde_json::Value,
}

const STATUS_RESP_TRUE: &str = "success";
Expand Down Expand Up @@ -443,20 +444,30 @@ impl EventObserver {
.expect("FATAL: failed to serialize transaction receipt");
bytes_to_hex(&bytes)
};

let contract_interface_json = {
match &receipt.contract_analysis {
Some(analysis) => json!(build_contract_interface(analysis)
.expect("FATAL: failed to serialize contract publish receipt")),
None => json!(null),
}
};

let post_condition_status_json = {
match &receipt.post_condition_status {
Some(status) => json!(status),
None => json!(null),
}
};

ReceiptPayloadInfo {
txid,
success,
raw_result,
raw_tx,
contract_interface_json,
burnchain_op_json,
post_condition_status_json,
}
}

Expand All @@ -475,6 +486,7 @@ impl EventObserver {
"raw_tx": format!("0x{}", &receipt_payload_info.raw_tx),
"contract_abi": receipt_payload_info.contract_interface_json,
"burnchain_op": receipt_payload_info.burnchain_op_json,
"post_condition_status": receipt_payload_info.post_condition_status_json,
"execution_cost": receipt.execution_cost,
"microblock_sequence": receipt.microblock_header.as_ref().map(|x| x.sequence),
"microblock_hash": receipt.microblock_header.as_ref().map(|x| format!("0x{}", x.block_hash())),
Expand Down

0 comments on commit fb41b66

Please sign in to comment.