-
Notifications
You must be signed in to change notification settings - Fork 59
No id creation #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
berendsliedrecht
merged 17 commits into
hyperledger:main
from
berendsliedrecht:no-id-creation
Dec 15, 2022
Merged
No id creation #25
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fd58fed
do not validate and create ids for schema, cred defs and rev reg defs
c9de6d2
tests pass
berendsliedrecht 38e9a55
brought back ffi method to get schema from cred def
berendsliedrecht 210a2df
added a wrapper around the SchemaId type
d3e6205
ran formatter
39667a0
added thin wrapper around anoncred ids
71faf19
ran formatter
ac55a6c
add validation to the identifier
b91b83e
use CredentialDefinitionId internally more
e4d5b22
use CredentialDefinitionId internal
7c31824
removed todo for schema index matching
a02dee0
added more validation
c6ade21
validate schema and credential definition
aa6cc35
ran formatter
d191d98
validate by default
b321bd4
wrapper around rev_reg_id
57ed97a
formatted code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#[macro_export] | ||
macro_rules! impl_anoncreds_object_identifier { | ||
($i:ident) => { | ||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)] | ||
pub struct $i(pub String); | ||
|
||
impl $i { | ||
pub fn new_unchecked(s: impl Into<String>) -> Self { | ||
Self(s.into()) | ||
} | ||
|
||
pub fn new(s: impl Into<String>) -> Result<Self, crate::data_types::ValidationError> { | ||
let s = Self(s.into()); | ||
s.validate()?; | ||
Ok(s) | ||
} | ||
} | ||
|
||
impl crate::data_types::Validatable for $i { | ||
dkulic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn validate(&self) -> Result<(), crate::data_types::ValidationError> { | ||
// TODO: stricten the URI regex. | ||
// Right now everything after the first colon is allowed, we might want to restrict | ||
// this | ||
let uri_regex = regex::Regex::new(r"^[a-zA-Z0-9\+\-\.]+:.+$").unwrap(); | ||
uri_regex | ||
.captures(&self.0) | ||
.ok_or_else(|| { | ||
indy_utils::invalid!( | ||
"type: {}, identifier: {} is invalid. It MUST be a URI.", | ||
stringify!($i), | ||
self.0 | ||
) | ||
}) | ||
.map(|_| ()) | ||
} | ||
} | ||
|
||
impl Into<String> for $i { | ||
fn into(self) -> String { | ||
self.0 | ||
} | ||
} | ||
|
||
// TODO: replace these with TryInto | ||
impl From<String> for $i { | ||
fn from(value: String) -> Self { | ||
$i::new_unchecked(value) | ||
} | ||
} | ||
|
||
// TODO: replace these with TryInto | ||
impl From<&str> for $i { | ||
fn from(value: &str) -> Self { | ||
$i::new_unchecked(value.to_owned()) | ||
} | ||
} | ||
|
||
impl std::fmt::Display for $i { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.0) | ||
} | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ pub mod rev_reg_def; | |
|
||
/// V1 credential schemas | ||
pub mod schema; | ||
|
||
/// Macros for the data types | ||
pub mod macros; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.