diff --git a/crypto/src/signature/mod.rs b/crypto/src/signature/mod.rs index 790e130efff..e0aeb0925fa 100644 --- a/crypto/src/signature/mod.rs +++ b/crypto/src/signature/mod.rs @@ -40,6 +40,7 @@ ffi::ffi_item! { #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, getset::Getters)] #[cfg_attr(not(feature="ffi_import"), derive(derive_more::DebugCustom, Hash, Decode, Encode, Deserialize, Serialize, IntoSchema))] #[cfg_attr(not(feature="ffi_import"), debug(fmt = "{{ {} }}", "hex::encode_upper(payload)"))] + #[serde(transparent)] pub struct Signature { #[serde_as(as = "serde_with::hex::Hex")] payload: ConstVec @@ -283,9 +284,7 @@ mod tests { #[test] fn signature_serialized_representation() { - let input = json!({ - "payload": "3A7991AF1ABB77F3FD27CC148404A6AE4439D095A63591B77C788D53F708A02A1509A611AD6D97B01D871E58ED00C8FD7C3917B6CA61A8C2833A19E000AAC2E4" - }); + let input = json!("3A7991AF1ABB77F3FD27CC148404A6AE4439D095A63591B77C788D53F708A02A1509A611AD6D97B01D871E58ED00C8FD7C3917B6CA61A8C2833A19E000AAC2E4"); let signature: Signature = serde_json::from_value(input.clone()).unwrap(); diff --git a/data_model/src/block.rs b/data_model/src/block.rs index 04296c13033..1cbfeb543e0 100644 --- a/data_model/src/block.rs +++ b/data_model/src/block.rs @@ -9,7 +9,7 @@ use alloc::{boxed::Box, format, string::String, vec, vec::Vec}; use core::{fmt::Display, time::Duration}; use derive_more::Display; -use iroha_crypto::{HashOf, MerkleTree, PrivateKey, SignatureOf}; +use iroha_crypto::{HashOf, MerkleTree, PrivateKey, Signature, SignatureOf}; use iroha_data_model_derive::model; use iroha_macro::FromVariant; use iroha_schema::IntoSchema; @@ -305,6 +305,18 @@ impl SignedBlock { } } +impl BlockSignature { + /// Peer topology index + pub fn index(&self) -> u64 { + self.0 + } + + /// Signature itself + pub fn payload(&self) -> &Signature { + &self.1 + } +} + mod candidate { #[cfg(not(feature = "std"))] use alloc::collections::BTreeSet; diff --git a/data_model/src/transaction.rs b/data_model/src/transaction.rs index cc55718e155..eb0a70aa7dc 100644 --- a/data_model/src/transaction.rs +++ b/data_model/src/transaction.rs @@ -11,7 +11,7 @@ use core::{ use derive_more::{DebugCustom, Display}; #[cfg(feature = "http")] pub use http::*; -use iroha_crypto::SignatureOf; +use iroha_crypto::{Signature, SignatureOf}; use iroha_data_model_derive::model; use iroha_macro::FromVariant; use iroha_schema::IntoSchema; @@ -315,6 +315,13 @@ impl AsRef for CommittedTransaction { } } +impl TransactionSignature { + /// Signature itself + pub fn payload(&self) -> &Signature { + &self.0 + } +} + mod candidate { use parity_scale_codec::Input; diff --git a/primitives/numeric/src/lib.rs b/primitives/numeric/src/lib.rs index c33592deb65..dc27d04fd62 100644 --- a/primitives/numeric/src/lib.rs +++ b/primitives/numeric/src/lib.rs @@ -324,6 +324,12 @@ impl NumericSpec { pub const fn fractional(scale: u32) -> Self { Self { scale: Some(scale) } } + + /// Get the scale + #[inline] + pub const fn scale(&self) -> Option { + self.scale + } } impl core::str::FromStr for Numeric {