]> Untitled Git - bdk/commitdiff
refactor(chain)!: remove AnchorImpl wrapper for Anchor implementors
authornymius <155548262+nymius@users.noreply.github.com>
Thu, 28 Nov 2024 23:58:36 +0000 (20:58 -0300)
committernymius <155548262+nymius@users.noreply.github.com>
Wed, 4 Dec 2024 17:14:19 +0000 (14:14 -0300)
AnchorImpl was a wrapper created to allow the implementation of foreign
traits, like From/ToJson from serde_json for external unknown structs
implementing the Anchor trait.

As the Anchor generic in the rusqlite implementation for anchored
ChangeSets was the only place where this AnchorImpl was used and it has
been fixed to the anchor ConfirmationBlockTime, there is no more reason
to keep this wrapper around.

crates/chain/src/lib.rs
crates/chain/src/rusqlite_impl.rs

index 8d87da58358a611f8f2cd532e6c19aaf87c64738..557d534946779cd4d654067bc18e0c5b4d1730ea 100644 (file)
@@ -100,27 +100,3 @@ impl<T> core::ops::Deref for Impl<T> {
         &self.0
     }
 }
-
-/// A wrapper that we use to impl remote traits for types in our crate or dependency crates that impl [`Anchor`].
-pub struct AnchorImpl<T>(pub T);
-
-impl<T> AnchorImpl<T> {
-    /// Returns the inner `T`.
-    pub fn into_inner(self) -> T {
-        self.0
-    }
-}
-
-impl<T> From<T> for AnchorImpl<T> {
-    fn from(value: T) -> Self {
-        Self(value)
-    }
-}
-
-impl<T> core::ops::Deref for AnchorImpl<T> {
-    type Target = T;
-
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
index 6b7228273b45fb75975709f0294ebcd817adeb95..f3abca0f250a4777fdffb4322491a2d663bae55c 100644 (file)
@@ -157,22 +157,6 @@ impl ToSql for Impl<bitcoin::Amount> {
     }
 }
 
-impl<A: Anchor + serde::de::DeserializeOwned> FromSql for AnchorImpl<A> {
-    fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
-        serde_json::from_str(value.as_str()?)
-            .map(AnchorImpl)
-            .map_err(from_sql_error)
-    }
-}
-
-impl<A: Anchor + serde::Serialize> ToSql for AnchorImpl<A> {
-    fn to_sql(&self) -> rusqlite::Result<ToSqlOutput<'_>> {
-        serde_json::to_string(&self.0)
-            .map(Into::into)
-            .map_err(to_sql_error)
-    }
-}
-
 #[cfg(feature = "miniscript")]
 impl FromSql for Impl<miniscript::Descriptor<miniscript::DescriptorPublicKey>> {
     fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {