From ae920ceb0d8a55accc13bb1c86d578d604739e4d Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 7 Aug 2025 11:27:05 +0700 Subject: [PATCH 1/5] feat: extract types to pallas primitive Signed-off-by: bkioshn --- pallas-hardano/Cargo.toml | 1 + pallas-network/Cargo.toml | 1 + pallas-network/src/miniprotocols/common.rs | 180 +++++++++--------- pallas-network/src/multiplexer.rs | 6 +- pallas-primitives/src/lib.rs | 3 +- pallas-primitives/src/types/mod.rs | 2 + .../src/types/network_constant.rs | 85 +++++++++ pallas-primitives/src/types/point.rs | 68 +++++++ pallas-traverse/src/wellknown.rs | 30 ++- 9 files changed, 277 insertions(+), 99 deletions(-) create mode 100644 pallas-primitives/src/types/mod.rs create mode 100644 pallas-primitives/src/types/network_constant.rs create mode 100644 pallas-primitives/src/types/point.rs diff --git a/pallas-hardano/Cargo.toml b/pallas-hardano/Cargo.toml index ffc0d6b63..920c908b9 100644 --- a/pallas-hardano/Cargo.toml +++ b/pallas-hardano/Cargo.toml @@ -20,6 +20,7 @@ pallas-network = { version = "=1.0.0-alpha.2", path = "../pallas-network" } pallas-addresses = { version = "=1.0.0-alpha.2", path = "../pallas-addresses" } pallas-crypto = { version = "=1.0.0-alpha.2", path = "../pallas-crypto" } pallas-codec = { version = "=1.0.0-alpha.2", path = "../pallas-codec" } +pallas-primitives = { version = "=1.0.0-alpha.2", path = "../pallas-primitives" } serde = { version = "1.0.218", features = ["derive"] } hex = "0.4.3" diff --git a/pallas-network/Cargo.toml b/pallas-network/Cargo.toml index 6598fb97f..a81dc2159 100644 --- a/pallas-network/Cargo.toml +++ b/pallas-network/Cargo.toml @@ -16,6 +16,7 @@ hex = "0.4.3" itertools = "0.13.0" pallas-codec = { version = "=1.0.0-alpha.2", path = "../pallas-codec" } pallas-crypto = { version = "=1.0.0-alpha.2", path = "../pallas-crypto" } +pallas-primitives = { version = "=1.0.0-alpha.2", path = "../pallas-primitives" } rand = "0.8.5" socket2 = "0.5.5" thiserror = "1.0.31" diff --git a/pallas-network/src/miniprotocols/common.rs b/pallas-network/src/miniprotocols/common.rs index 4c3b5e6f4..470e50079 100644 --- a/pallas-network/src/miniprotocols/common.rs +++ b/pallas-network/src/miniprotocols/common.rs @@ -1,24 +1,32 @@ -use std::fmt::Debug; - use pallas_codec::minicbor::{decode, encode, Decode, Decoder, Encode, Encoder}; +use std::fmt::Debug; /// Well-known magic for testnet -pub const TESTNET_MAGIC: u64 = 1097911063; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::TESTNET_MAGIC` instead")] +pub const TESTNET_MAGIC: u64 = pallas_primitives::types::network_constant::TESTNET_MAGIC; /// Well-known magic for mainnet -pub const MAINNET_MAGIC: u64 = 764824073; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::MAINNET_MAGIC` instead")] +pub const MAINNET_MAGIC: u64 = pallas_primitives::types::network_constant::MAINNET_MAGIC; /// Well-known magic for preview -pub const PREVIEW_MAGIC: u64 = 2; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::PREVIEW_MAGIC` instead")] +pub const PREVIEW_MAGIC: u64 = pallas_primitives::types::network_constant::PREVIEW_MAGIC; /// Well-known magic for preprod -pub const PREPROD_MAGIC: u64 = 1; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::PREPROD_MAGIC` instead")] +pub const PREPROD_MAGIC: u64 = pallas_primitives::types::network_constant::PREPROD_MAGIC; /// Alias for PREPROD_MAGIC -pub const PRE_PRODUCTION_MAGIC: u64 = 1; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PRE_PRODUCTION_MAGIC` instead" +)] +pub const PRE_PRODUCTION_MAGIC: u64 = + pallas_primitives::types::network_constant::PRE_PRODUCTION_MAGIC; /// Well-known magic for preprod -pub const SANCHONET_MAGIC: u64 = 4; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::SANCHONET_MAGIC` instead")] +pub const SANCHONET_MAGIC: u64 = pallas_primitives::types::network_constant::SANCHONET_MAGIC; /// Bitflag for client-side version of a known protocol /// # Example @@ -26,7 +34,8 @@ pub const SANCHONET_MAGIC: u64 = 4; /// use pallas_network::miniprotocols::*; /// let channel = PROTOCOL_CLIENT | PROTOCOL_N2N_HANDSHAKE; /// ``` -pub const PROTOCOL_CLIENT: u16 = 0x0; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::PROTOCOL_CLIENT` instead")] +pub const PROTOCOL_CLIENT: u16 = pallas_primitives::types::network_constant::PROTOCOL_CLIENT; /// Bitflag for server-side version of a known protocol /// # Example @@ -34,111 +43,104 @@ pub const PROTOCOL_CLIENT: u16 = 0x0; /// use pallas_network::miniprotocols::*; /// let channel = PROTOCOL_SERVER | PROTOCOL_N2N_CHAIN_SYNC; /// ``` -pub const PROTOCOL_SERVER: u16 = 0x8000; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::PROTOCOL_SERVER` instead")] +pub const PROTOCOL_SERVER: u16 = pallas_primitives::types::network_constant::PROTOCOL_SERVER; /// Protocol channel number for node-to-node handshakes -pub const PROTOCOL_N2N_HANDSHAKE: u16 = 0; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2N_HANDSHAKE` instead" +)] +pub const PROTOCOL_N2N_HANDSHAKE: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2N_HANDSHAKE; /// Protocol channel number for node-to-node chain-sync -pub const PROTOCOL_N2N_CHAIN_SYNC: u16 = 2; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2N_CHAIN_SYNC` instead" +)] +pub const PROTOCOL_N2N_CHAIN_SYNC: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2N_CHAIN_SYNC; /// Protocol channel number for node-to-node block-fetch -pub const PROTOCOL_N2N_BLOCK_FETCH: u16 = 3; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2N_BLOCK_FETCH` instead" +)] +pub const PROTOCOL_N2N_BLOCK_FETCH: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2N_BLOCK_FETCH; /// Protocol channel number for node-to-node tx-submission -pub const PROTOCOL_N2N_TX_SUBMISSION: u16 = 4; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2N_TX_SUBMISSION` instead" +)] +pub const PROTOCOL_N2N_TX_SUBMISSION: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2N_TX_SUBMISSION; /// Protocol channel number for node-to-node Keep-alive -pub const PROTOCOL_N2N_KEEP_ALIVE: u16 = 8; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2N_KEEP_ALIVE` instead" +)] +pub const PROTOCOL_N2N_KEEP_ALIVE: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2N_KEEP_ALIVE; /// Protocol channel number for node-to-node Peer-sharing -pub const PROTOCOL_N2N_PEER_SHARING: u16 = 10; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2N_PEER_SHARING` instead" +)] +pub const PROTOCOL_N2N_PEER_SHARING: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2N_PEER_SHARING; /// Protocol channel number for node-to-client handshakes -pub const PROTOCOL_N2C_HANDSHAKE: u16 = 0; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_HANDSHAKE` instead" +)] +pub const PROTOCOL_N2C_HANDSHAKE: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_HANDSHAKE; /// Protocol channel number for node-to-client chain-sync -pub const PROTOCOL_N2C_CHAIN_SYNC: u16 = 5; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_CHAIN_SYNC` instead" +)] +pub const PROTOCOL_N2C_CHAIN_SYNC: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_CHAIN_SYNC; /// Protocol channel number for node-to-client tx-submission -pub const PROTOCOL_N2C_TX_SUBMISSION: u16 = 6; - -// Protocol channel number for node-to-client state queries -pub const PROTOCOL_N2C_STATE_QUERY: u16 = 7; - -// Protocol channel number for node-to-client mempool monitor -pub const PROTOCOL_N2C_TX_MONITOR: u16 = 9; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_TX_SUBMISSION` instead" +)] +pub const PROTOCOL_N2C_TX_SUBMISSION: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_TX_SUBMISSION; + +/// Protocol channel number for node-to-client state queries +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_STATE_QUERY` instead" +)] +pub const PROTOCOL_N2C_STATE_QUERY: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_STATE_QUERY; + +/// Protocol channel number for node-to-client mempool monitor +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_TX_MONITOR` instead" +)] +pub const PROTOCOL_N2C_TX_MONITOR: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_TX_MONITOR; /// Protocol channel number for node-to-client local message submission /// This protocol is available only on the DMQ node. // TODO: use the final mini-protocol number once available -pub const PROTOCOL_N2C_MSG_SUBMISSION: u16 = 1; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_MSG_SUBMISSION` instead" +)] +pub const PROTOCOL_N2C_MSG_SUBMISSION: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_MSG_SUBMISSION; /// Protocol channel number for node-to-client local message notification /// This protocol is available only on the DMQ node. // TODO: use the final mini-protocol number once available -pub const PROTOCOL_N2C_MSG_NOTIFICATION: u16 = 2; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PROTOCOL_N2C_MSG_NOTIFICATION` instead" +)] +pub const PROTOCOL_N2C_MSG_NOTIFICATION: u16 = + pallas_primitives::types::network_constant::PROTOCOL_N2C_MSG_NOTIFICATION; /// A point within a chain -#[derive(Clone, Eq, PartialEq, Hash)] -pub enum Point { - Origin, - Specific(u64, Vec), -} - -impl Point { - pub fn slot_or_default(&self) -> u64 { - match self { - Point::Origin => 0, - Point::Specific(slot, _) => *slot, - } - } -} - -impl Debug for Point { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Origin => write!(f, "Origin"), - Self::Specific(arg0, arg1) => write!(f, "({}, {})", arg0, hex::encode(arg1)), - } - } -} - -impl Point { - pub fn new(slot: u64, hash: Vec) -> Self { - Point::Specific(slot, hash) - } -} - -impl Encode<()> for Point { - fn encode( - &self, - e: &mut Encoder, - _ctx: &mut (), - ) -> Result<(), encode::Error> { - match self { - Point::Origin => e.array(0)?, - Point::Specific(slot, hash) => e.array(2)?.u64(*slot)?.bytes(hash)?, - }; - - Ok(()) - } -} - -impl<'b> Decode<'b, ()> for Point { - fn decode(d: &mut Decoder<'b>, _ctx: &mut ()) -> Result { - let size = d.array()?; - - match size { - Some(0) => Ok(Point::Origin), - Some(2) => { - let slot = d.u64()?; - let hash = d.bytes()?; - Ok(Point::Specific(slot, Vec::from(hash))) - } - _ => Err(decode::Error::message( - "can't decode Point from array of size", - )), - } - } -} +#[deprecated(note = "Use `pallas_primitives::types::point::Point` instead")] +pub use pallas_primitives::types::point::Point; diff --git a/pallas-network/src/multiplexer.rs b/pallas-network/src/multiplexer.rs index 506c1ff28..bc2796757 100644 --- a/pallas-network/src/multiplexer.rs +++ b/pallas-network/src/multiplexer.rs @@ -487,7 +487,11 @@ impl Plexer { } /// Protocol value that defines max segment length -pub const MAX_SEGMENT_PAYLOAD_LENGTH: usize = 65535; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::MAX_SEGMENT_PAYLOAD_LENGTH` instead" +)] +pub const MAX_SEGMENT_PAYLOAD_LENGTH: usize = + pallas_primitives::types::network_constant::MAX_SEGMENT_PAYLOAD_LENGTH; fn try_decode_message(buffer: &mut Vec) -> Result, Error> where diff --git a/pallas-primitives/src/lib.rs b/pallas-primitives/src/lib.rs index 03269ff5c..f40e94422 100644 --- a/pallas-primitives/src/lib.rs +++ b/pallas-primitives/src/lib.rs @@ -7,8 +7,9 @@ pub mod alonzo; pub mod babbage; pub mod byron; pub mod conway; -pub use plutus_data::*; +pub mod types; +pub use plutus_data::*; pub use framework::*; pub use pallas_codec::codec_by_datatype; diff --git a/pallas-primitives/src/types/mod.rs b/pallas-primitives/src/types/mod.rs new file mode 100644 index 000000000..7eb524907 --- /dev/null +++ b/pallas-primitives/src/types/mod.rs @@ -0,0 +1,2 @@ +pub mod network_constant; +pub mod point; diff --git a/pallas-primitives/src/types/network_constant.rs b/pallas-primitives/src/types/network_constant.rs new file mode 100644 index 000000000..01200064c --- /dev/null +++ b/pallas-primitives/src/types/network_constant.rs @@ -0,0 +1,85 @@ +//! Network constants + +/// Well-known magic for testnet +pub const TESTNET_MAGIC: u64 = 1097911063; +pub const TESTNET_NETWORK_ID: u64 = 0; + +/// Well-known magic for mainnet +pub const MAINNET_MAGIC: u64 = 764824073; +pub const MAINNET_NETWORK_ID: u64 = 1; + +/// Well-known magic for preview +pub const PREVIEW_MAGIC: u64 = 2; +pub const PREVIEW_NETWORK_ID: u64 = 0; + +/// Well-known magic for preprod +pub const PREPROD_MAGIC: u64 = 1; + +/// Alias for PREPROD_MAGIC +pub const PRE_PRODUCTION_MAGIC: u64 = 1; +pub const PRE_PRODUCTION_NETWORK_ID: u64 = 0; + +/// Well-known magic for preprod +pub const SANCHONET_MAGIC: u64 = 4; + +/// Bitflag for client-side version of a known protocol +/// # Example +/// ``` +/// use pallas_network::miniprotocols::*; +/// let channel = PROTOCOL_CLIENT | PROTOCOL_N2N_HANDSHAKE; +/// ``` +pub const PROTOCOL_CLIENT: u16 = 0x0; + +/// Bitflag for server-side version of a known protocol +/// # Example +/// ``` +/// use pallas_network::miniprotocols::*; +/// let channel = PROTOCOL_SERVER | PROTOCOL_N2N_CHAIN_SYNC; +/// ``` +pub const PROTOCOL_SERVER: u16 = 0x8000; + +/// Protocol channel number for node-to-node handshakes +pub const PROTOCOL_N2N_HANDSHAKE: u16 = 0; + +/// Protocol channel number for node-to-node chain-sync +pub const PROTOCOL_N2N_CHAIN_SYNC: u16 = 2; + +/// Protocol channel number for node-to-node block-fetch +pub const PROTOCOL_N2N_BLOCK_FETCH: u16 = 3; + +/// Protocol channel number for node-to-node tx-submission +pub const PROTOCOL_N2N_TX_SUBMISSION: u16 = 4; + +/// Protocol channel number for node-to-node Keep-alive +pub const PROTOCOL_N2N_KEEP_ALIVE: u16 = 8; + +/// Protocol channel number for node-to-node Peer-sharing +pub const PROTOCOL_N2N_PEER_SHARING: u16 = 10; + +/// Protocol channel number for node-to-client handshakes +pub const PROTOCOL_N2C_HANDSHAKE: u16 = 0; + +/// Protocol channel number for node-to-client chain-sync +pub const PROTOCOL_N2C_CHAIN_SYNC: u16 = 5; + +/// Protocol channel number for node-to-client tx-submission +pub const PROTOCOL_N2C_TX_SUBMISSION: u16 = 6; + +// Protocol channel number for node-to-client state queries +pub const PROTOCOL_N2C_STATE_QUERY: u16 = 7; + +// Protocol channel number for node-to-client mempool monitor +pub const PROTOCOL_N2C_TX_MONITOR: u16 = 9; + +/// Protocol channel number for node-to-client local message submission +/// This protocol is available only on the DMQ node. +// TODO: use the final mini-protocol number once available +pub const PROTOCOL_N2C_MSG_SUBMISSION: u16 = 1; + +/// Protocol channel number for node-to-client local message notification +/// This protocol is available only on the DMQ node. +// TODO: use the final mini-protocol number once available +pub const PROTOCOL_N2C_MSG_NOTIFICATION: u16 = 2; + +/// Protocol value that defines max segment length +pub const MAX_SEGMENT_PAYLOAD_LENGTH: usize = 65535; diff --git a/pallas-primitives/src/types/point.rs b/pallas-primitives/src/types/point.rs new file mode 100644 index 000000000..2e2895f62 --- /dev/null +++ b/pallas-primitives/src/types/point.rs @@ -0,0 +1,68 @@ +//! Point in Cardano chain. + +use pallas_codec::minicbor::{decode, encode, Decode, Decoder, Encode, Encoder}; +use std::fmt::Debug; + +/// A point within a chain +#[derive(Clone, Eq, PartialEq, Hash)] +pub enum Point { + Origin, + Specific(u64, Vec), +} + +impl Point { + pub fn slot_or_default(&self) -> u64 { + match self { + Point::Origin => 0, + Point::Specific(slot, _) => *slot, + } + } +} + +impl Debug for Point { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Origin => write!(f, "Origin"), + Self::Specific(arg0, arg1) => write!(f, "({}, {})", arg0, hex::encode(arg1)), + } + } +} + +impl Point { + pub fn new(slot: u64, hash: Vec) -> Self { + Point::Specific(slot, hash) + } +} + +impl Encode<()> for Point { + fn encode( + &self, + e: &mut Encoder, + _ctx: &mut (), + ) -> Result<(), encode::Error> { + match self { + Point::Origin => e.array(0)?, + Point::Specific(slot, hash) => e.array(2)?.u64(*slot)?.bytes(hash)?, + }; + + Ok(()) + } +} + +impl<'b> Decode<'b, ()> for Point { + fn decode(d: &mut Decoder<'b>, _ctx: &mut ()) -> Result { + let size = d.array()?; + + match size { + Some(0) => Ok(Point::Origin), + Some(2) => { + let slot = d.u64()?; + let hash = d.bytes()?; + Ok(Point::Specific(slot, Vec::from(hash))) + } + _ => Err(decode::Error::message( + "can't decode Point from array of size", + )), + } + } +} diff --git a/pallas-traverse/src/wellknown.rs b/pallas-traverse/src/wellknown.rs index aedfbfd99..fe93f034c 100644 --- a/pallas-traverse/src/wellknown.rs +++ b/pallas-traverse/src/wellknown.rs @@ -1,20 +1,34 @@ use serde::{Deserialize, Serialize}; /// Well-known params for testnet -pub const TESTNET_MAGIC: u64 = 1097911063; -pub const TESTNET_NETWORK_ID: u64 = 0; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::TESTNET_MAGIC` instead")] +pub const TESTNET_MAGIC: u64 = pallas_primitives::types::network_constant::TESTNET_MAGIC; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::TESTNET_NETWORK_ID` instead")] +pub const TESTNET_NETWORK_ID: u64 = pallas_primitives::types::network_constant::TESTNET_NETWORK_ID; /// Well-known params for mainnet -pub const MAINNET_MAGIC: u64 = 764824073; -pub const MAINNET_NETWORK_ID: u64 = 1; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::MAINNET_MAGIC` instead")] +pub const MAINNET_MAGIC: u64 = pallas_primitives::types::network_constant::MAINNET_MAGIC; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::MAINNET_NETWORK_ID` instead")] +pub const MAINNET_NETWORK_ID: u64 = pallas_primitives::types::network_constant::MAINNET_NETWORK_ID; /// Well-known params for preview -pub const PREVIEW_MAGIC: u64 = 2; -pub const PREVIEW_NETWORK_ID: u64 = 0; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::PREVIEW_MAGIC` instead")] +pub const PREVIEW_MAGIC: u64 = pallas_primitives::types::network_constant::PREVIEW_MAGIC; +#[deprecated(note = "Use `pallas_primitives::types::network_constant::PREVIEW_NETWORK_ID` instead")] +pub const PREVIEW_NETWORK_ID: u64 = pallas_primitives::types::network_constant::PREVIEW_NETWORK_ID; /// Well-known params for pre-production -pub const PRE_PRODUCTION_MAGIC: u64 = 1; -pub const PRE_PRODUCTION_NETWORK_ID: u64 = 0; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PRE_PRODUCTION_MAGIC` instead" +)] +pub const PRE_PRODUCTION_MAGIC: u64 = + pallas_primitives::types::network_constant::PRE_PRODUCTION_MAGIC; +#[deprecated( + note = "Use `pallas_primitives::types::network_constant::PRE_PRODUCTION_NETWORK_ID` instead" +)] +pub const PRE_PRODUCTION_NETWORK_ID: u64 = + pallas_primitives::types::network_constant::PRE_PRODUCTION_NETWORK_ID; /// Well-known information about specific networks #[derive(Serialize, Deserialize, Debug, Clone)] From c7be2dbd04b68c532c49d1bcfce78284e56a69ba Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 7 Aug 2025 11:50:27 +0700 Subject: [PATCH 2/5] fix: remove unused import Signed-off-by: bkioshn --- pallas-network/src/miniprotocols/common.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/pallas-network/src/miniprotocols/common.rs b/pallas-network/src/miniprotocols/common.rs index 470e50079..2fc6c02d8 100644 --- a/pallas-network/src/miniprotocols/common.rs +++ b/pallas-network/src/miniprotocols/common.rs @@ -1,6 +1,3 @@ -use pallas_codec::minicbor::{decode, encode, Decode, Decoder, Encode, Encoder}; -use std::fmt::Debug; - /// Well-known magic for testnet #[deprecated(note = "Use `pallas_primitives::types::network_constant::TESTNET_MAGIC` instead")] pub const TESTNET_MAGIC: u64 = pallas_primitives::types::network_constant::TESTNET_MAGIC; From 9b67dd991c90548b933632f0fca6bd4649decde6 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 7 Aug 2025 11:53:39 +0700 Subject: [PATCH 3/5] fix: remove pallas primitive from hardano Signed-off-by: bkioshn --- pallas-hardano/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pallas-hardano/Cargo.toml b/pallas-hardano/Cargo.toml index 920c908b9..ffc0d6b63 100644 --- a/pallas-hardano/Cargo.toml +++ b/pallas-hardano/Cargo.toml @@ -20,7 +20,6 @@ pallas-network = { version = "=1.0.0-alpha.2", path = "../pallas-network" } pallas-addresses = { version = "=1.0.0-alpha.2", path = "../pallas-addresses" } pallas-crypto = { version = "=1.0.0-alpha.2", path = "../pallas-crypto" } pallas-codec = { version = "=1.0.0-alpha.2", path = "../pallas-codec" } -pallas-primitives = { version = "=1.0.0-alpha.2", path = "../pallas-primitives" } serde = { version = "1.0.218", features = ["derive"] } hex = "0.4.3" From 9cfb41cb4f15f913fc17388cec4ccd87c3551ff0 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 15 Aug 2025 12:18:56 +0700 Subject: [PATCH 4/5] fix: wasm compatible Signed-off-by: bkioshn --- pallas/Cargo.toml | 4 +++- pallas/src/lib.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pallas/Cargo.toml b/pallas/Cargo.toml index 37c327ce2..11db7ddd1 100644 --- a/pallas/Cargo.toml +++ b/pallas/Cargo.toml @@ -11,7 +11,6 @@ readme = "../README.md" authors = ["Santiago Carmuega "] [dependencies] -pallas-network = { version = "=1.0.0-alpha.2", path = "../pallas-network/" } pallas-primitives = { version = "=1.0.0-alpha.2", path = "../pallas-primitives/" } pallas-traverse = { version = "=1.0.0-alpha.2", path = "../pallas-traverse/" } pallas-addresses = { version = "=1.0.0-alpha.2", path = "../pallas-addresses/" } @@ -21,6 +20,9 @@ pallas-utxorpc = { version = "=1.0.0-alpha.2", path = "../pallas-utxorpc/" } pallas-configs = { version = "=1.0.0-alpha.2", path = "../pallas-configs/" } pallas-txbuilder = { version = "=1.0.0-alpha.2", path = "../pallas-txbuilder/" } pallas-validate = { version = "=1.0.0-alpha.2", path = "../pallas-validate/" } + +[target.'cfg(not(target_family = "wasm"))'.dependencies] +pallas-network = { version = "=1.0.0-alpha.2", path = "../pallas-network/" } pallas-hardano = { version = "=1.0.0-alpha.2", path = "../pallas-hardano/", optional = true } [features] diff --git a/pallas/src/lib.rs b/pallas/src/lib.rs index 5bdc13b20..9059d6780 100644 --- a/pallas/src/lib.rs +++ b/pallas/src/lib.rs @@ -10,6 +10,7 @@ #![warn(missing_doc_code_examples)] #[doc(inline)] +#[cfg(not(target_family = "wasm"))] pub use pallas_network as network; pub mod ledger { @@ -53,6 +54,7 @@ pub mod interop { pub use pallas_utxorpc as utxorpc; #[cfg(feature = "pallas-hardano")] + #[cfg(not(target_family = "wasm"))] pub mod hardano { //! Interoperability with the Haskell Cardano node @@ -68,6 +70,7 @@ pub mod storage { //! Storage engines for chain-related persistence #[cfg(feature = "pallas-hardano")] + #[cfg(not(target_family = "wasm"))] #[doc(inline)] // WARNING: this is deprecated, use `pallas::interop::hardano::storage` instead. // Since deprecation notices don't work for re-exports we don't have a way to notify users. From da55afb0cf1c4903fdb4f0d79cb1a5552107067a Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 25 Nov 2025 21:36:22 +0700 Subject: [PATCH 5/5] fix docs Signed-off-by: bkioshn --- pallas-primitives/src/types/network_constant.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallas-primitives/src/types/network_constant.rs b/pallas-primitives/src/types/network_constant.rs index 0643c16a0..b00e498bb 100644 --- a/pallas-primitives/src/types/network_constant.rs +++ b/pallas-primitives/src/types/network_constant.rs @@ -25,7 +25,7 @@ pub const SANCHONET_MAGIC: u64 = 4; /// Bitflag for client-side version of a known protocol /// # Example /// ``` -/// use pallas_network::miniprotocols::*; +/// use pallas_primitives::types::network_constant::*; /// let channel = PROTOCOL_CLIENT | PROTOCOL_N2N_HANDSHAKE; /// ``` pub const PROTOCOL_CLIENT: u16 = 0x0; @@ -33,7 +33,7 @@ pub const PROTOCOL_CLIENT: u16 = 0x0; /// Bitflag for server-side version of a known protocol /// # Example /// ``` -/// use pallas_network::miniprotocols::*; +/// use pallas_primitives::types::network_constant::*; /// let channel = PROTOCOL_SERVER | PROTOCOL_N2N_CHAIN_SYNC; /// ``` pub const PROTOCOL_SERVER: u16 = 0x8000;