diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index e12ef53510..9243b45f82 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -643,7 +643,6 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { .or_default() .push(InscriptionOp { txid: flotsam.txid, - // TODO by yxq sequence_number, inscription_number: self .sequence_number_to_entry @@ -661,10 +660,11 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { reinscription: _, unbound, inscription, - .. + vindicated, } => Action::New { cursed, unbound, + vindicated, inscription, }, }, diff --git a/src/okx/datastore/ord/operation.rs b/src/okx/datastore/ord/operation.rs index 604b2f8f14..23eb74af89 100644 --- a/src/okx/datastore/ord/operation.rs +++ b/src/okx/datastore/ord/operation.rs @@ -23,6 +23,109 @@ pub enum Action { cursed: bool, unbound: bool, inscription: Inscription, + #[serde(default)] + vindicated: bool, }, Transfer, } + +#[cfg(test)] +mod tests { + + use super::*; + use crate::test::inscription; + use bitcoin::OutPoint; + use std::str::FromStr; + + #[test] + fn test_inscription_op_deserialize_with_default_vindicated() { + let txid = + Txid::from_str("b61b0172d95e266c18aea0c624db987e971a5d6d4ebc2aaed85da4642d635735").unwrap(); + + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] + struct OldInscriptionOp { + pub txid: Txid, + pub action: OldAction, + pub sequence_number: u32, + pub inscription_number: Option, + pub inscription_id: InscriptionId, + pub old_satpoint: SatPoint, + pub new_satpoint: Option, + } + + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] + enum OldAction { + New { + cursed: bool, + unbound: bool, + inscription: Inscription, + }, + Transfer, + } + + let old_action = OldAction::New { + cursed: true, + unbound: true, + inscription: inscription("text/plain;charset=utf-8", "foobar"), + }; + let bytes = rmp_serde::to_vec(&old_action).unwrap(); + let new_action: Action = rmp_serde::from_slice(&bytes).unwrap(); + assert_eq!( + new_action, + Action::New { + cursed: true, + unbound: true, + vindicated: false, + inscription: inscription("text/plain;charset=utf-8", "foobar"), + } + ); + + let old_operation = OldInscriptionOp { + txid, + action: OldAction::New { + cursed: true, + unbound: true, + inscription: inscription("text/plain;charset=utf-8", "foobar"), + }, + sequence_number: 100, + inscription_number: Some(100), + inscription_id: InscriptionId { txid, index: 0 }, + old_satpoint: SatPoint::from_str( + "1111111111111111111111111111111111111111111111111111111111111111:1:1", + ) + .unwrap(), + new_satpoint: Some(SatPoint { + outpoint: OutPoint { txid, vout: 0 }, + offset: 1, + }), + }; + + let bytes = rmp_serde::to_vec(&old_operation).unwrap(); + + let new_operation: InscriptionOp = rmp_serde::from_slice(&bytes).unwrap(); + + assert_eq!( + new_operation, + InscriptionOp { + txid, + action: Action::New { + cursed: true, + unbound: true, + vindicated: false, + inscription: inscription("text/plain;charset=utf-8", "foobar"), + }, + sequence_number: 100, + inscription_number: Some(100), + inscription_id: InscriptionId { txid, index: 0 }, + old_satpoint: SatPoint::from_str( + "1111111111111111111111111111111111111111111111111111111111111111:1:1", + ) + .unwrap(), + new_satpoint: Some(SatPoint { + outpoint: OutPoint { txid, vout: 0 }, + offset: 1, + }), + } + ); + } +} diff --git a/src/okx/datastore/ord/redb/table.rs b/src/okx/datastore/ord/redb/table.rs index 24aaf10780..6bd22d57a4 100644 --- a/src/okx/datastore/ord/redb/table.rs +++ b/src/okx/datastore/ord/redb/table.rs @@ -126,6 +126,7 @@ mod tests { action: Action::New { cursed: false, unbound: false, + vindicated: false, inscription: inscription("text/plain;charset=utf-8", "foobar"), }, sequence_number: 100, diff --git a/src/okx/protocol/brc20/msg_resolver.rs b/src/okx/protocol/brc20/msg_resolver.rs index cb8ec67146..6f4f5e81ba 100644 --- a/src/okx/protocol/brc20/msg_resolver.rs +++ b/src/okx/protocol/brc20/msg_resolver.rs @@ -32,6 +32,7 @@ impl Message { Action::New { cursed: false, unbound: false, + vindicated: false, inscription: _, } if sat_in_outputs => { match deserialize_brc20_operation( diff --git a/src/okx/protocol/brc20/operation/mod.rs b/src/okx/protocol/brc20/operation/mod.rs index 6e2778b960..da558eaf71 100644 --- a/src/okx/protocol/brc20/operation/mod.rs +++ b/src/okx/protocol/brc20/operation/mod.rs @@ -211,6 +211,7 @@ mod tests { &Action::New { cursed: false, unbound: false, + vindicated: false, inscription: inscription.clone() }, ) @@ -233,6 +234,7 @@ mod tests { &Action::New { cursed: false, unbound: false, + vindicated: false, inscription: inscription.clone() }, ) @@ -253,6 +255,7 @@ mod tests { &Action::New { cursed: false, unbound: false, + vindicated: false, inscription: inscription.clone() }, ) diff --git a/src/okx/protocol/ord/bitmap.rs b/src/okx/protocol/ord/bitmap.rs index 843aa50caf..57a4875f90 100644 --- a/src/okx/protocol/ord/bitmap.rs +++ b/src/okx/protocol/ord/bitmap.rs @@ -38,6 +38,7 @@ pub fn index_bitmap( Action::New { cursed: _, unbound: _, + vindicated: _, inscription, } => { if let Some((inscription_id, district)) =