-
Notifications
You must be signed in to change notification settings - Fork 56
feat(dpp): AbstractConsensusError tests and extensions #670
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
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
603ca77
feat: public_keys_validator.rs test
antouhou e8338d7
add static fields to the IdentityPublicKey export
antouhou acf1b79
make a declaration that seems to work
antouhou 349b83b
replace uses of KeyPurpose, KeyType, KeySecurityLevel in the public k…
antouhou 4f37000
fix linting errors
antouhou a5618ac
fix ts compilation issue
antouhou 0084f9e
remove unnecessary code
antouhou d4676cf
Merge branch 'v0.24-dev' into feat-public-key-validator-tests
antouhou 5c59eff
fix build issues
antouhou 0332c01
reformat
antouhou d3f5208
fix some other build errors
antouhou 051605a
fix find duplicates by id in the documents batch validator
antouhou 1136f75
fix error code in `DataContractUniqueIndicesChangedError`
antouhou b2b6c5a
Merge branch 'v0.24-dev' into feat-public-key-validator-tests
antouhou d14fa33
fix AbstractConsensusError handling
antouhou 473f1af
remove non-existent errors
antouhou da682aa
remove unused code
antouhou 3a48463
Merge branch 'v0.24-dev' into feat-public-key-validator-tests
antouhou 2a94018
organize ts glue files and refactor
antouhou c419689
updated the lockfile
antouhou 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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
| mod public_keys_validator; | ||
|
|
||
| pub use public_keys_validator::*; |
70 changes: 70 additions & 0 deletions
70
packages/wasm-dpp/src/identity/validation/public_keys_validator.rs
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,70 @@ | ||
| use crate::bls_adapter::{BlsAdapter, JsBlsAdapter}; | ||
|
|
||
| use crate::utils::{to_vec_of_serde_values, ToSerdeJSONExt}; | ||
| use crate::validation::ValidationResultWasm; | ||
| use dpp::identity::validation::{ | ||
| PublicKeysValidator, TPublicKeysValidator, PUBLIC_KEY_SCHEMA_FOR_TRANSITION, | ||
| }; | ||
|
|
||
| use wasm_bindgen::prelude::*; | ||
|
|
||
| #[wasm_bindgen(js_name = PublicKeysValidator)] | ||
| pub struct PublicKeysValidatorWasm { | ||
| public_key_validator: PublicKeysValidator<BlsAdapter>, | ||
| public_key_in_state_transition_validator: PublicKeysValidator<BlsAdapter>, | ||
| } | ||
|
|
||
| #[wasm_bindgen(js_class = PublicKeysValidator)] | ||
| impl PublicKeysValidatorWasm { | ||
| #[wasm_bindgen(constructor)] | ||
| pub fn new(adapter: JsBlsAdapter) -> Result<PublicKeysValidatorWasm, JsError> { | ||
| Ok(Self { | ||
| public_key_validator: PublicKeysValidator::new(BlsAdapter(JsBlsAdapter::from( | ||
| adapter.clone(), | ||
| )))?, | ||
| public_key_in_state_transition_validator: PublicKeysValidator::new_with_schema( | ||
| PUBLIC_KEY_SCHEMA_FOR_TRANSITION.clone(), | ||
| BlsAdapter(adapter), | ||
| )?, | ||
| }) | ||
| } | ||
|
|
||
| #[wasm_bindgen(js_name=validateKeys)] | ||
| pub fn validate_keys( | ||
| &self, | ||
| public_keys: js_sys::Array, | ||
| ) -> Result<ValidationResultWasm, JsValue> { | ||
| let raw_public_keys = to_vec_of_serde_values(public_keys.iter())?; | ||
|
|
||
| self.public_key_validator | ||
| .validate_keys(&raw_public_keys) | ||
| .map(ValidationResultWasm::from) | ||
| .map_err(|e| JsValue::from(e.to_string())) | ||
| } | ||
|
|
||
| #[wasm_bindgen(js_name=validatePublicKeyStructure)] | ||
| pub fn validate_public_key_structure( | ||
| &self, | ||
| public_key: JsValue, | ||
| ) -> Result<ValidationResultWasm, JsValue> { | ||
| let pk_serde_json = public_key.to_serde_json_value()?; | ||
|
|
||
| self.public_key_validator | ||
| .validate_public_key_structure(&pk_serde_json) | ||
| .map(ValidationResultWasm::from) | ||
| .map_err(|e| JsValue::from(e.to_string())) | ||
| } | ||
|
|
||
| #[wasm_bindgen(js_name=validateKeysInStateTransition)] | ||
| pub fn validate_keys_in_state_transition( | ||
| &self, | ||
| public_keys: js_sys::Array, | ||
| ) -> Result<ValidationResultWasm, JsValue> { | ||
| let raw_public_keys = to_vec_of_serde_values(public_keys.iter())?; | ||
|
|
||
| self.public_key_in_state_transition_validator | ||
| .validate_keys(&raw_public_keys) | ||
| .map(ValidationResultWasm::from) | ||
| .map_err(|e| JsValue::from(e.to_string())) | ||
| } | ||
| } |
44 changes: 0 additions & 44 deletions
44
packages/wasm-dpp/src/identity_public_key/public_keys_validator.rs
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
| mod validation_result; | ||
|
|
||
| pub use validation_result::*; |
File renamed without changes.
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.