Skip to content

Commit

Permalink
Generics and Cleanup (#84)
Browse files Browse the repository at this point in the history
* Clean up OneOrMany

* Clean up Timestamp

* Replace chrono with time

* Clean up Url

* Move conversion helpers to top-level module

* Move identity_crypto to identity_core::crypto

* Move identity_proof to identity_core::proof

* Clean up Context

* Use did_doc/did_url crates

* Update DID resolution

* Update test fixtures

* Remove old tests

* Refactor Credentials/Presentations

* Manually implement builders
* Replace builders for small structs with explicit ctors

* Refactor IotaDID

* Refactor IotaDocument

* Use identity_core Credentials/Presentations

* Update Client for DID/Document changes

* New identity_iota examples

* Cleanup/Restore normalization

* Update WASM lib

* Pin did_doc crate version

* Fix WASM

* Dont match internal error messages
  • Loading branch information
l1h3r authored Nov 25, 2020
1 parent 734bb8b commit 6605083
Show file tree
Hide file tree
Showing 175 changed files with 3,050 additions and 6,916 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ jobs:
project:
[
identity_core,
identity_crypto,
identity_derive,
identity_diff,
identity_iota,
identity_proof,
]
os: [ubuntu-latest, windows-latest]

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ jobs:
project:
[
identity_core,
identity_crypto,
identity_derive,
identity_diff,
identity_iota,
identity_proof,
libraries/wasm,
]

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ jobs:
project:
[
identity_core,
identity_crypto,
identity_derive,
identity_diff,
identity_iota,
identity_proof,
libraries/wasm,
]

Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[workspace]
members = [
"identity_core",
"identity_crypto",
"identity_derive",
"identity_diff",
"identity_iota",
"identity_proof",
]
exclude = [
"libraries/wasm"
Expand Down
38 changes: 11 additions & 27 deletions identity_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,23 @@ license = "Apache-2.0"
keywords = ["iota", "tangle", "identity"]
homepage = "https://www.iota.org"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# error handling
thiserror = "1.0"
anyhow = "1.0"

anyhow = { version = "1.0" }
async-trait = { version = "0.1", default-features = false }
base64 = { version = "0.12", default-features = false, features = ["std"] }
bs58 = { version = "0.3", default-features = false, features = ["std"] }
chrono = { version = "0.4", features = ["serde"] }
derive_builder = { version = "0.9", default-features = false }
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
did_doc = { git = "https://github.com/l1h3r/did_doc", rev = "a02420805527e8bda45ac48de2b93e8cc1d731de", default-features = false, features = ["std"] }
did_url = { version = "0.1", default-features = false, features = ["std", "serde"] }
ed25519-zebra = { version = "2.2", default-features = false }
hex = { version = "0.4", default-features = false , features = ["std"] }
percent-encoding = { version = "2.1", default-features = false }
url = { version = "2.1", default-features = false, features = ["serde"] }

# serialization
lazy_static = { version = "1.4", default-features = false }
rand = { version = "0.7", default-features = false, features = ["getrandom"] }
serde = { version = "1.0", features = ["derive"] }
serde_jcs = { version = "0.1", default-features = false }
serde_json = { version = "1.0", features = ["preserve_order"] }
sha2 = { version = "0.9" }
thiserror = { version = "1.0" }
zeroize = { version = "1.1" }

identity_crypto = { path = "../identity_crypto" }
identity_diff = { path = "../identity_diff", version = "0.1.0", features = ["diff_derive"] }

# parser crates
pest = "2.1"
pest_derive = "2.1"

[dev-dependencies]
# generative/property testing
proptest = "0.10"

# serde testing
serde_test = "1.0"

# json parsing
json = "0.12"
37 changes: 18 additions & 19 deletions identity_core/src/common/context.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
use core::fmt;
use identity_diff::Diff;
use core::fmt::{Debug, Formatter, Result};
use serde::{Deserialize, Serialize};

use crate::common::{Object, Url};

/// A reference to a JSON-LD context
///
/// [More Info](https://www.w3.org/TR/vc-data-model/#contexts)
#[derive(Clone, PartialEq, Deserialize, Serialize, Diff)]
#[derive(Clone, PartialEq, Deserialize, Serialize)]
#[serde(untagged)]
pub enum Context {
Url(Url),
Obj(Object),
}

impl fmt::Debug for Context {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl Debug for Context {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
Self::Url(inner) => fmt::Debug::fmt(inner, f),
Self::Obj(inner) => fmt::Debug::fmt(inner, f),
Self::Url(inner) => Debug::fmt(inner, f),
Self::Obj(inner) => Debug::fmt(inner, f),
}
}
}
Expand All @@ -29,20 +28,20 @@ impl From<Url> for Context {
}
}

impl From<&'_ str> for Context {
fn from(other: &'_ str) -> Self {
Self::Url(other.into())
}
}

impl From<String> for Context {
fn from(other: String) -> Self {
Self::Url(other.into())
}
}

impl From<Object> for Context {
fn from(other: Object) -> Self {
Self::Obj(other)
}
}

impl<T> PartialEq<T> for Context
where
T: AsRef<str> + ?Sized,
{
fn eq(&self, other: &T) -> bool {
match self {
Self::Url(inner) => inner.as_str() == other.as_ref(),
Self::Obj(_) => false,
}
}
}
68 changes: 0 additions & 68 deletions identity_core/src/common/macros.rs

This file was deleted.

12 changes: 2 additions & 10 deletions identity_core/src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
#[macro_use]
mod macros;

pub mod context;
pub mod convert;
pub mod object;
pub mod one_or_many;
pub mod timestamp;
pub mod url;
pub mod value;

pub use self::url::Url;
pub use context::Context;
pub use convert::{AsJson, FromJson, SerdeInto, ToJson};
pub use object::Object;
pub use did_doc::{Object, Value};
pub use one_or_many::OneOrMany;
pub use timestamp::Timestamp;
pub use value::Value;
pub use url::Url;
Loading

0 comments on commit 6605083

Please sign in to comment.