From 0c40e3f104a62927e1f0cad53e8c85262b784413 Mon Sep 17 00:00:00 2001 From: Michael Yu Date: Thu, 29 Jun 2023 15:47:14 -0700 Subject: [PATCH 1/3] Include old_owner for transfers in StreamEvent --- src/index/updater/inscription_updater.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index e88cc7cf00..f467d329e7 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -571,6 +571,7 @@ mod stream { // transfer fields old_location: Option, + old_owner: Option
, } impl StreamEvent { @@ -622,6 +623,7 @@ mod stream { brc20: None, domain: None, old_location: None, + old_owner: None, sat_details: None, } } @@ -682,6 +684,21 @@ mod stream { .unwrap_or_else(|_| panic!("Inscription should exist: {}", self.inscription_id)) { self.enrich_content(inscription); + let old_owner: Option
= index + .get_transaction(old_satpoint.outpoint.txid) + .unwrap_or(None) + .and_then(|tx| { + Address::from_script( + &tx + .output + .get(old_satpoint.outpoint.vout as usize) + .unwrap_or(&TxOut::default()) + .script_pubkey, + StreamEvent::get_network(), + ) + .ok() + }); + self.old_owner = old_owner; }; self } From ba35fa59b9894203129fca96358c78c132fa0c27 Mon Sep 17 00:00:00 2001 From: Michael Yu Date: Thu, 29 Jun 2023 17:42:58 -0700 Subject: [PATCH 2/3] handle error and return None --- src/index/updater/inscription_updater.rs | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index f467d329e7..e502adacfc 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -585,7 +585,7 @@ mod stream { block_hash: BlockHash, ) -> Self { StreamEvent { - version: "4.0.0".to_owned(), // should match the ord-kafka docker image version + version: "4.0.2".to_owned(), // should match the ord-kafka docker image version inscription_id, block_timestamp, block_height, @@ -684,21 +684,23 @@ mod stream { .unwrap_or_else(|_| panic!("Inscription should exist: {}", self.inscription_id)) { self.enrich_content(inscription); - let old_owner: Option
= index + self.old_owner = index .get_transaction(old_satpoint.outpoint.txid) .unwrap_or(None) .and_then(|tx| { - Address::from_script( - &tx - .output - .get(old_satpoint.outpoint.vout as usize) - .unwrap_or(&TxOut::default()) - .script_pubkey, - StreamEvent::get_network(), - ) - .ok() + tx.output + .get(old_satpoint.outpoint.vout as usize) + .and_then(|txout| { + Address::from_script(&txout.script_pubkey, StreamEvent::get_network()) + .map_err(|e| { + log::error!( + "StreamEvent::with_transfer could not parse old_owner address: {}", + e + ); + }) + .ok() + }) }); - self.old_owner = old_owner; }; self } From dba66cc6e49410ee318e7395afe5b083e6166c33 Mon Sep 17 00:00:00 2001 From: Michael Yu Date: Thu, 29 Jun 2023 17:50:16 -0700 Subject: [PATCH 3/3] revert version string --- src/index/updater/inscription_updater.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index e502adacfc..d1abf3808b 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -585,7 +585,7 @@ mod stream { block_hash: BlockHash, ) -> Self { StreamEvent { - version: "4.0.2".to_owned(), // should match the ord-kafka docker image version + version: "4.0.0".to_owned(), // should match the ord-kafka docker image version inscription_id, block_timestamp, block_height,