Skip to content

Commit

Permalink
Merge pull request #9 from Sajjon/restruct
Browse files Browse the repository at this point in the history
fix typo: -> hierarchical deterministic. Remove unneeded ignore code …
  • Loading branch information
Sajjon authored Nov 24, 2023
2 parents d758b9e + a186acb commit 497fedd
Show file tree
Hide file tree
Showing 25 changed files with 10 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
resolver = "1"

members = ["profile", "hiearchal_deterministic", "wallet_kit_common"]
members = ["profile", "hierarchical_deterministic", "wallet_kit_common"]
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[package]
name = "hiearchal_deterministic"
name = "hierarchical_deterministic"
version = "0.1.0"
edition = "2021"

[lib]
doctest = false
test = false

[dependencies]
serde = { version = "1.0.192", features = ["derive"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ impl HDPath {
}

impl ToString for HDPath {
#[cfg(not(tarpaulin_include))]
fn to_string(&self) -> String {
let rest = self
.components()
Expand All @@ -62,7 +61,6 @@ impl ToString for HDPath {
}
}

#[cfg(not(tarpaulin_include))]
impl Serialize for HDPath {
/// Serializes this `AccountAddress` into its bech32 address string as JSON.
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
Expand All @@ -73,7 +71,6 @@ impl Serialize for HDPath {
}
}

#[cfg(not(tarpaulin_include))]
impl<'de> serde::Deserialize<'de> for HDPath {
/// Tries to deserializes a JSON string as a bech32 address into an `AccountAddress`.
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<HDPath, D::Error> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub type HDPathValue = u32;
pub struct HDPathComponent(HDPathValue);

impl HDPathComponent {
#[cfg(not(tarpaulin_include))]
pub(crate) fn value(&self) -> HDPathValue {
if self.is_hardened() {
self.0 - BIP32_HARDENED
Expand All @@ -30,7 +29,6 @@ impl HDPathComponent {
}

impl ToString for HDPathComponent {
#[cfg(not(tarpaulin_include))]
fn to_string(&self) -> String {
let h_or_empty = if self.is_hardened() { "H" } else { "" };
format!("{}{}", self.value(), h_or_empty)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ pub struct AccountPath {
pub index: HDPathValue,
}
impl CAP26Repr for AccountPath {
#[cfg(not(tarpaulin_include))]
fn hd_path(&self) -> &HDPath {
&self.path
}

#[cfg(not(tarpaulin_include))]
fn entity_kind() -> Option<CAP26EntityKind> {
Some(CAP26EntityKind::Account)
}

#[cfg(not(tarpaulin_include))]
fn __with_path_and_components(
path: HDPath,
network_id: NetworkID,
Expand All @@ -46,15 +43,13 @@ impl CAP26Repr for AccountPath {
}

impl AccountPath {
#[cfg(not(tarpaulin_include))]
pub fn placeholder() -> Self {
Self::from_str("m/44H/1022H/1H/525H/1460H/0H").unwrap()
}
}

impl Serialize for AccountPath {
/// Serializes this `AccountAddress` into its bech32 address string as JSON.
#[cfg(not(tarpaulin_include))]
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where
S: Serializer,
Expand All @@ -65,7 +60,6 @@ impl Serialize for AccountPath {

impl<'de> serde::Deserialize<'de> for AccountPath {
/// Tries to deserializes a JSON string as a bech32 address into an `AccountAddress`.
#[cfg(not(tarpaulin_include))]
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<AccountPath, D::Error> {
let s = String::deserialize(d)?;
AccountPath::from_str(&s).map_err(de::Error::custom)
Expand All @@ -75,7 +69,6 @@ impl<'de> serde::Deserialize<'de> for AccountPath {
impl TryInto<AccountPath> for &str {
type Error = CAP26Error;

#[cfg(not(tarpaulin_include))]
fn try_into(self) -> Result<AccountPath, Self::Error> {
AccountPath::from_str(self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ use super::{
};

pub trait CAP26Repr: Sized {
#[cfg(not(tarpaulin_include))]
fn entity_kind() -> Option<CAP26EntityKind> {
Option::None
}
fn hd_path(&self) -> &HDPath;

#[cfg(not(tarpaulin_include))]
fn to_string(&self) -> String {
self.hd_path().to_string()
}
Expand All @@ -29,7 +27,6 @@ pub trait CAP26Repr: Sized {
index: HDPathValue,
) -> Self;

#[cfg(not(tarpaulin_include))]
fn parse_try_map<T, F>(
path: &Vec<HDPathComponent>,
index: usize,
Expand All @@ -42,7 +39,6 @@ pub trait CAP26Repr: Sized {
try_map(got.value())
}

#[cfg(not(tarpaulin_include))]
fn parse<F>(
path: &Vec<HDPathComponent>,
index: usize,
Expand All @@ -59,7 +55,6 @@ pub trait CAP26Repr: Sized {
Ok(got)
}

#[cfg(not(tarpaulin_include))]
fn from_str(s: &str) -> Result<Self, CAP26Error> {
use CAP26Error::*;
let path = HDPath::from_str(s).map_err(|_| CAP26Error::InvalidBIP32Path(s.to_string()))?;
Expand Down Expand Up @@ -130,7 +125,6 @@ pub trait CAP26Repr: Sized {
));
}

#[cfg(not(tarpaulin_include))]
fn new(network_id: NetworkID, key_kind: CAP26KeyKind, index: HDPathValue) -> Self {
let entity_kind = Self::entity_kind().expect("GetID cannot be used with this constructor");
let c0 = HDPathComponent::bip44_purpose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ pub enum CAP26EntityKind {
}

impl Display for CAP26EntityKind {
#[cfg(not(tarpaulin_include))]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.description())
}
}
impl CAP26EntityKind {
/// The raw representation of this entity kind, an `HDPathValue`.
#[cfg(not(tarpaulin_include))]
pub fn discriminant(&self) -> HDPathValue {
*self as HDPathValue
}

#[cfg(not(tarpaulin_include))]
fn description(&self) -> String {
match self {
Self::Account => "Account".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ pub enum CAP26KeyKind {
}

impl Display for CAP26KeyKind {
#[cfg(not(tarpaulin_include))]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

impl CAP26KeyKind {
/// The raw representation of this key kind, an `HDPathValue`.
#[cfg(not(tarpaulin_include))]
pub fn discriminant(&self) -> HDPathValue {
*self as HDPathValue
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion profile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ serde = { version = "1.0.192", features = ["derive"] }
serde_json = { version = "1.0.108", features = ["preserve_order"] }
serde_repr = "0.1.17"
strum = { version = "0.25.0", features = ["derive"] }
hiearchal_deterministic = { path = "../hiearchal_deterministic" }
hierarchical_deterministic = { path = "../hierarchical_deterministic" }
wallet_kit_common = { path = "../wallet_kit_common" }
enum-iterator = "1.4.1"
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "038ddee8b0f57aa90e36375c69946c4eb634efeb", features = [
Expand Down
5 changes: 2 additions & 3 deletions profile/src/v100/entity/account/account.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hiearchal_deterministic::derivation_path::DerivationPath;
use hierarchical_deterministic::derivation_path::DerivationPath;
use radix_engine_common::crypto::PublicKey;
use serde::{Deserialize, Serialize};
use std::{cell::RefCell, cmp::Ordering, fmt::Display};
Expand Down Expand Up @@ -186,7 +186,6 @@ impl Display for Account {

// CFG test
#[cfg(test)]
#[cfg(not(tarpaulin_include))]
impl Account {
pub fn placeholder() -> Self {
Self::placeholder_mainnet()
Expand Down Expand Up @@ -247,7 +246,7 @@ impl Account {
mod tests {
use std::{cell::RefCell, collections::BTreeSet};

use hiearchal_deterministic::bip32::hd_path_component::HDPathValue;
use hierarchical_deterministic::bip32::hd_path_component::HDPathValue;

use crate::v100::{
address::account_address::AccountAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hiearchal_deterministic::bip32::hd_path_component::HDPathValue;
use hierarchical_deterministic::bip32::hd_path_component::HDPathValue;
use serde::{Deserialize, Serialize};

use crate::v100::factors::hierarchical_deterministic_factor_instance::HierarchicalDeterministicFactorInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hiearchal_deterministic::derivation_path::DerivationPath;
use hierarchical_deterministic::derivation_path::DerivationPath;
use radix_engine_common::crypto::PublicKey;
use serde::{Deserialize, Serialize};

Expand Down
2 changes: 1 addition & 1 deletion profile/src/v100/networks/network/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mod tests {
}

#[test]
#[should_panic(expected = "Discrepancy, found accounts on other network than mainnet\n")]
#[should_panic(expected = "Discrepancy, found accounts on other network than mainnet")]
fn panic_when_network_id_mismatch_between_accounts_and_value() {
Network::new(
NetworkID::Mainnet,
Expand Down
1 change: 0 additions & 1 deletion wallet_kit_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2021"

[lib]
doctest = false
test = false

[dependencies]
serde = { version = "1.0.192", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions wallet_kit_common/src/network_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ impl TryFrom<u8> for NetworkID {

impl Display for NetworkID {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{}", self.logical_name())
write!(f, "{}", self.logical_name())
}
}

impl NetworkID {
/// Looks up a `NetworkDefinition` in a lookup table.
#[cfg(not(tarpaulin_include))]

pub fn network_definition(&self) -> NetworkDefinition {
match self {
NetworkID::Mainnet => NetworkDefinition::mainnet(),
Expand Down
1 change: 0 additions & 1 deletion wallet_kit_common/src/utils/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fn date_to_string(dt: &NaiveDateTime, fmt: &str) -> String {
dt.format(fmt).to_string()
}

#[cfg(not(tarpaulin_include))]
pub fn iso8601(dt: &NaiveDateTime) -> String {
date_to_string(dt, "%Y-%m-%d %H:%M:%S")
}
Expand Down

0 comments on commit 497fedd

Please sign in to comment.