Skip to content

Commit

Permalink
chore: update from serde_crate to dep:serde
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 22, 2024
1 parent 951fa19 commit b59221a
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 336 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bp-consensus = { version = "0.12.0-beta.2", path = "./consensus" }
bp-dbc = { version = "0.12.0-beta.2", path = "./dbc" }
bp-seals = { version = "0.12.0-beta.2", path = "./seals" }
secp256k1 = { version = "0.30.0", features = ["global-context", "rand"] }
serde_crate = { package = "serde", version = "1", features = ["derive"] }
serde = { version = "1", features = ["derive"] }

[package]
name = "bp-core"
Expand Down Expand Up @@ -65,14 +65,14 @@ single_use_seals = { workspace = true }
bp-consensus = { workspace = true }
bp-dbc = { workspace = true }
bp-seals = { workspace = true }
serde_crate = { workspace = true, optional = true }
serde = { workspace = true, optional = true }

[features]
default = []
all = ["chrono", "serde", "stl"]
chrono = ["bp-consensus/chrono"]
serde = [
"serde_crate",
"dep:serde",
"bp-consensus/serde",
"bp-dbc/serde",
"bp-seals/serde",
Expand Down
4 changes: 2 additions & 2 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ strict_encoding = { workspace = true }
strict_types = { workspace = true, optional = true }
commit_verify = { workspace = true }
secp256k1 = { workspace = true }
serde_crate = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
chrono = { version = "0.4.38", optional = true }

[features]
default = ["chrono"]
all = ["chrono", "stl", "serde"]
stl = ["strict_types"]
serde = [
"serde_crate",
"dep:serde",
"amplify/serde",
"secp256k1/serde"
]
Expand Down
18 changes: 3 additions & 15 deletions consensus/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ use crate::{BlockDataParseError, ConsensusDecode, ConsensusEncode, LIB_NAME_BITC
#[derive(Wrapper, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, From)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 35 in consensus/src/block.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/block.rs#L35

Added line #L35 was not covered by tests
#[wrapper(BorrowSlice, Index, RangeOps, Debug, Hex, Display, FromStr)]
pub struct BlockHash(
#[from]
Expand All @@ -47,11 +43,7 @@ pub struct BlockHash(
#[derive(Wrapper, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, From)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 46 in consensus/src/block.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/block.rs#L46

Added line #L46 was not covered by tests
#[wrapper(BorrowSlice, Index, RangeOps, Debug, Hex, Display, FromStr)]
pub struct BlockMerkleRoot(
#[from]
Expand All @@ -63,11 +55,7 @@ pub struct BlockMerkleRoot(
#[display(LowerHex)]
#[derive(StrictType, StrictEncode, StrictDecode, StrictDumb)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
pub struct BlockHeader {
/// Block version, now repurposed for soft fork signalling.
pub version: i32,
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/coding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ impl ByteStr {
#[cfg(feature = "serde")]
mod _serde {
use amplify::hex::{FromHex, ToHex};
use serde_crate::de::Error;
use serde_crate::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use super::*;

Expand Down
24 changes: 4 additions & 20 deletions consensus/src/hashtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ use crate::{
#[wrapper(Index, RangeOps, AsSlice, BorrowSlice, Hex, Display, FromStr)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 33 in consensus/src/hashtypes.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/hashtypes.rs#L33

Added line #L33 was not covered by tests
pub struct PubkeyHash(
#[from]
#[from([u8; 20])]
Expand Down Expand Up @@ -79,11 +75,7 @@ impl From<LegacyPk> for PubkeyHash {
#[wrapper(Index, RangeOps, AsSlice, BorrowSlice, Hex, Display, FromStr)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 78 in consensus/src/hashtypes.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/hashtypes.rs#L78

Added line #L78 was not covered by tests
pub struct ScriptHash(
#[from]
#[from([u8; 20])]
Expand All @@ -108,11 +100,7 @@ impl From<&RedeemScript> for ScriptHash {
#[wrapper(Index, RangeOps, AsSlice, BorrowSlice, Hex, Display, FromStr)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 103 in consensus/src/hashtypes.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/hashtypes.rs#L103

Added line #L103 was not covered by tests
pub struct WPubkeyHash(
#[from]
#[from([u8; 20])]
Expand All @@ -137,11 +125,7 @@ impl From<CompressedPk> for WPubkeyHash {
#[wrapper(Index, RangeOps, AsSlice, BorrowSlice, Hex, Display, FromStr)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 128 in consensus/src/hashtypes.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/hashtypes.rs#L128

Added line #L128 was not covered by tests
pub struct WScriptHash(
#[from]
#[from([u8; 32])]
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern crate strict_encoding;
extern crate commit_verify;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde_crate as serde;
extern crate serde;

extern crate core;
/// Re-export of `secp256k1` crate.
Expand Down
14 changes: 3 additions & 11 deletions consensus/src/pubkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ pub enum InvalidPubkey<const LEN: usize> {
#[wrapper_mut(DerefMut)]
#[derive(StrictType, StrictDumb)]
#[strict_type(lib = LIB_NAME_BITCOIN, dumb = Self::dumb())]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 60 in consensus/src/pubkeys.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/pubkeys.rs#L60

Added line #L60 was not covered by tests
pub struct CompressedPk(PublicKey);

impl CompressedPk {
Expand Down Expand Up @@ -110,11 +106,7 @@ impl FromStr for CompressedPk {
#[wrapper_mut(DerefMut)]
#[derive(StrictType, StrictDumb)]
#[strict_type(lib = LIB_NAME_BITCOIN, dumb = Self::dumb())]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 109 in consensus/src/pubkeys.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/pubkeys.rs#L109

Added line #L109 was not covered by tests
pub struct UncompressedPk(PublicKey);

impl UncompressedPk {
Expand Down Expand Up @@ -159,7 +151,7 @@ impl FromStr for UncompressedPk {
#[wrapper_mut(DerefMut)]
#[derive(StrictType, StrictDumb)]
#[strict_type(lib = LIB_NAME_BITCOIN, dumb = Self::dumb())]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "serde_crate"))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LegacyPk {
pub compressed: bool,
#[wrap]
Expand Down
23 changes: 5 additions & 18 deletions consensus/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ use crate::{ScriptHash, VarInt, VarIntBytes, WitnessVer, LIB_NAME_BITCOIN};
#[wrapper_mut(DerefMut, AsSliceMut)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 33 in consensus/src/script.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/script.rs#L33

Added line #L33 was not covered by tests
pub struct SigScript(ScriptBytes);

impl TryFrom<Vec<u8>> for SigScript {
Expand Down Expand Up @@ -72,11 +68,7 @@ impl SigScript {
#[wrapper_mut(DerefMut, AsSliceMut)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 71 in consensus/src/script.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/script.rs#L71

Added line #L71 was not covered by tests
pub struct ScriptPubkey(ScriptBytes);

impl TryFrom<Vec<u8>> for ScriptPubkey {
Expand Down Expand Up @@ -163,11 +155,7 @@ impl ScriptPubkey {
#[wrapper_mut(DerefMut, AsSliceMut)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 158 in consensus/src/script.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/script.rs#L158

Added line #L158 was not covered by tests
pub struct RedeemScript(ScriptBytes);

impl TryFrom<Vec<u8>> for RedeemScript {
Expand Down Expand Up @@ -312,9 +300,8 @@ impl ScriptBytes {
#[cfg(feature = "serde")]
mod _serde {
use amplify::hex::{FromHex, ToHex};
use serde::{Deserialize, Serialize};
use serde_crate::de::Error;
use serde_crate::{Deserializer, Serializer};
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use super::*;

Expand Down
17 changes: 4 additions & 13 deletions consensus/src/segwit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,7 @@ impl ScriptPubkey {
#[wrapper_mut(DerefMut, AsSliceMut)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 311 in consensus/src/segwit.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/segwit.rs#L311

Added line #L311 was not covered by tests
pub struct WitnessScript(ScriptBytes);

impl TryFrom<Vec<u8>> for WitnessScript {
Expand Down Expand Up @@ -357,11 +353,7 @@ impl WitnessScript {
#[wrapper(BorrowSlice, Index, RangeOps, Debug, Hex, Display, FromStr)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 356 in consensus/src/segwit.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/segwit.rs#L356

Added line #L356 was not covered by tests
pub struct Wtxid(
#[from]
#[from([u8; 32])]
Expand Down Expand Up @@ -403,9 +395,8 @@ impl Witness {

#[cfg(feature = "serde")]
mod _serde {
use serde::{Deserialize, Serialize};
use serde_crate::ser::SerializeSeq;
use serde_crate::{Deserializer, Serializer};
use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use super::*;

Expand Down
30 changes: 5 additions & 25 deletions consensus/src/sigtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ use crate::{NonStandardValue, ScriptBytes, ScriptPubkey, WitnessScript, LIB_NAME
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Display, Default)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN, tags = repr, into_u8, try_from_u8)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
#[display(uppercase)]
#[repr(u8)]
pub enum SighashFlag {
Expand All @@ -55,11 +51,7 @@ pub enum SighashFlag {
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Default)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
pub struct SighashType {
pub flag: SighashFlag,
pub anyone_can_pay: bool,
Expand Down Expand Up @@ -200,11 +192,7 @@ impl Display for SighashType {
#[wrapper(Index, RangeOps, AsSlice, BorrowSlice, Hex, Display, FromStr)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]

Check warning on line 195 in consensus/src/sigtypes.rs

View check run for this annotation

Codecov / codecov/patch

consensus/src/sigtypes.rs#L195

Added line #L195 was not covered by tests
pub struct Sighash(
#[from]
#[from([u8; 32])]
Expand Down Expand Up @@ -283,11 +271,7 @@ pub enum SigError {
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
#[derive(StrictType)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
pub struct LegacySig {
/// The underlying ECDSA Signature
pub sig: ecdsa::Signature,
Expand Down Expand Up @@ -329,11 +313,7 @@ impl LegacySig {
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
#[derive(StrictType)]
#[strict_type(lib = LIB_NAME_BITCOIN)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
pub struct Bip340Sig {
/// The underlying ECDSA Signature
pub sig: schnorr::Signature,
Expand Down
Loading

0 comments on commit b59221a

Please sign in to comment.