Skip to content

Commit

Permalink
fix(data-model,crypto,primitives)!: misc chores (#4992)
Browse files Browse the repository at this point in the history
Signed-off-by: 0x009922 <[email protected]>
  • Loading branch information
0x009922 authored Aug 21, 2024
1 parent d2b70d3 commit 176d7b2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
5 changes: 2 additions & 3 deletions crypto/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<serde_with::formats::Uppercase>")]
payload: ConstVec<u8>
Expand Down Expand Up @@ -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();

Expand Down
14 changes: 13 additions & 1 deletion data_model/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion data_model/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -315,6 +315,13 @@ impl AsRef<SignedTransaction> for CommittedTransaction {
}
}

impl TransactionSignature {
/// Signature itself
pub fn payload(&self) -> &Signature {
&self.0
}
}

mod candidate {
use parity_scale_codec::Input;

Expand Down
6 changes: 6 additions & 0 deletions primitives/numeric/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32> {
self.scale
}
}

impl core::str::FromStr for Numeric {
Expand Down

0 comments on commit 176d7b2

Please sign in to comment.