mirror of
https://github.com/alexgo-io/stacks-subnets.git
synced 2026-04-30 12:42:13 +08:00
feat: integrate burnchain_op info event observer changes from stacks-blockchain
This commit is contained in:
@@ -34,9 +34,11 @@ use stacks::vm::events::{FTEventType, NFTEventType, STXEventType};
|
||||
use stacks::vm::types::{AssetIdentifier, QualifiedContractIdentifier, Value};
|
||||
|
||||
use super::config::{EventKeyType, EventObserverConfig};
|
||||
use stacks::chainstate::burn::operations::BlockstackOperationType;
|
||||
use stacks::chainstate::burn::ConsensusHash;
|
||||
use stacks::chainstate::stacks::db::unconfirmed::ProcessedUnconfirmedState;
|
||||
use stacks::chainstate::stacks::miner::TransactionEvent;
|
||||
use stacks::chainstate::stacks::TransactionPayload;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct EventObserver {
|
||||
@@ -49,6 +51,7 @@ struct ReceiptPayloadInfo<'a> {
|
||||
raw_result: String,
|
||||
raw_tx: String,
|
||||
contract_interface_json: serde_json::Value,
|
||||
burnchain_op_json: serde_json::Value,
|
||||
}
|
||||
|
||||
const STATUS_RESP_TRUE: &str = "success";
|
||||
@@ -192,15 +195,29 @@ impl EventObserver {
|
||||
}
|
||||
}
|
||||
(true, Value::Response(_)) => STATUS_RESP_POST_CONDITION,
|
||||
_ => unreachable!(), // Transaction results should always be a Value::Response type
|
||||
_ => {
|
||||
if let TransactionOrigin::Stacks(inner_tx) = &tx {
|
||||
if let TransactionPayload::PoisonMicroblock(..) = &inner_tx.payload {
|
||||
STATUS_RESP_TRUE
|
||||
} else {
|
||||
unreachable!() // Transaction results should otherwise always be a Value::Response type
|
||||
}
|
||||
} else {
|
||||
unreachable!() // Transaction results should always be a Value::Response type
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let (txid, raw_tx) = match tx {
|
||||
TransactionOrigin::Burn(txid) => (txid.to_string(), "00".to_string()),
|
||||
let (txid, raw_tx, burnchain_op_json) = match tx {
|
||||
TransactionOrigin::Burn(op) => (
|
||||
op.txid().to_string(),
|
||||
"00".to_string(),
|
||||
BlockstackOperationType::blockstack_op_to_json(&op),
|
||||
),
|
||||
TransactionOrigin::Stacks(ref tx) => {
|
||||
let txid = tx.txid().to_string();
|
||||
let bytes = tx.serialize_to_vec();
|
||||
(txid, bytes_to_hex(&bytes))
|
||||
(txid, bytes_to_hex(&bytes), json!(null))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -220,6 +237,7 @@ impl EventObserver {
|
||||
raw_result,
|
||||
raw_tx,
|
||||
contract_interface_json,
|
||||
burnchain_op_json,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +255,7 @@ impl EventObserver {
|
||||
"raw_result": format!("0x{}", &receipt_payload_info.raw_result),
|
||||
"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,
|
||||
"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())),
|
||||
|
||||
Reference in New Issue
Block a user