Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature gate serde usage #145

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ serde_crate = { workspace = true, optional = true }
serde_yaml = { workspace = true, optional = true }
serde_with = { workspace = true, optional = true }
log = { workspace = true, optional = true }
cfg_eval = "0.1.2"

[features]
default = ["esplora_blocking"]
Expand Down
18 changes: 9 additions & 9 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub trait DescriptorRgb<K = XpubDerivable, V = ()>: Descriptor<K, V> {
}

#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display)]
#[derive(Serialize, Deserialize)]
#[serde(crate = "serde_crate", rename_all = "camelCase")]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "serde_crate", rename_all = "camelCase"))]
#[repr(u8)]
pub enum RgbKeychain {
#[display("0", alt = "0")]
Expand Down Expand Up @@ -106,15 +106,15 @@ impl From<RgbKeychain> for Keychain {
fn from(keychain: RgbKeychain) -> Self { Keychain::from(keychain as u8) }
}

#[serde_as]
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)]
#[derive(Clone, Eq, PartialEq, Debug)]
#[derive(Serialize, Deserialize)]
#[serde(crate = "serde_crate", rename_all = "camelCase")]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "serde_crate", rename_all = "camelCase"))]
pub struct TapretKey<K: DeriveXOnly = XpubDerivable> {
pub internal_key: K,
// TODO: Allow multiple tweaks per index by introducing derivation using new Terminal trait
// TODO: Change serde implementation for both Terminal and TapretCommitment
#[serde_as(as = "HashMap<serde_with::DisplayFromStr, serde_with::DisplayFromStr>")]
#[cfg_attr(feature = "serde", serde_as(as = "HashMap<serde_with::DisplayFromStr, serde_with::DisplayFromStr>"))]
pub tweaks: HashMap<Terminal, TapretCommitment>,
}

Expand Down Expand Up @@ -224,15 +224,15 @@ impl<K: DeriveXOnly> DescriptorRgb<K> for TapretKey<K> {
}

#[derive(Clone, Eq, PartialEq, Debug, From)]
#[derive(Serialize, Deserialize)]
#[serde(
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(
crate = "serde_crate",
rename_all = "camelCase",
bound(
serialize = "S::Compr: serde::Serialize, S::XOnly: serde::Serialize",
deserialize = "S::Compr: serde::Deserialize<'de>, S::XOnly: serde::Deserialize<'de>"
)
)]
))]
#[non_exhaustive]
pub enum RgbDescr<S: DeriveSet = XpubDerivable> {
#[from]
Expand Down
7 changes: 6 additions & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
use std::collections::HashMap;
use std::convert::Infallible;
use std::io;
#[cfg(feature = "serde")]
use std::io::ErrorKind;
use std::ops::{Deref, DerefMut};
use std::path::PathBuf;

use amplify::IoError;
use bpstd::{Network, XpubDerivable};
use bpwallet::Wallet;
#[cfg(feature = "serde")]
use rgbfs::StockFs;
use rgbstd::containers::{Contract, LoadError, Transfer};
use rgbstd::interface::{
Expand All @@ -43,7 +45,9 @@ use rgbstd::persistence::{
use rgbstd::resolvers::ResolveHeight;
use rgbstd::validation::{self, ResolveWitness};
use rgbstd::{AssignmentWitness, ContractId, WitnessId, XChain, XOutpoint};
use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError, TypeName};
use strict_types::encoding::{DeserializeError, Ident, SerializeError, TypeName};
#[cfg(feature = "serde")]
use strict_types::encoding::DecodeError;

use crate::{DescriptorRgb, RgbDescr};

Expand Down Expand Up @@ -109,6 +113,7 @@ pub enum RuntimeError {
#[from]
Esplora(esplora::Error),

#[cfg(feature = "serde")]
#[from]
Yaml(serde_yaml::Error),

Expand Down
Loading