@dashevo/wasm-dpp 0.24.0-dev.11 → 0.24.0-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +3 -0
- package/README.md +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +9 -0
- package/dist/lib/dpp.d.ts +9 -0
- package/dist/lib/errors/AbstractConsensusError.d.ts +10 -0
- package/dist/lib/errors/DPPError.d.ts +5 -0
- package/dist/lib/errors/patchConsensusErrors.d.ts +1 -0
- package/dist/lib/{patchIdentifier.d.ts → identifier/patchIdentifier.d.ts} +1 -1
- package/dist/{index.d.ts → lib/index.d.ts} +1 -1
- package/dist/lib/utils/extend.d.ts +1 -0
- package/dist/wasm/wasm_dpp.d.ts +1595 -518
- package/karma.conf.js +5 -0
- package/lib/dpp.ts +24 -0
- package/lib/errors/AbstractConsensusError.ts +13 -0
- package/lib/errors/DPPError.ts +15 -0
- package/lib/errors/patchConsensusErrors.ts +175 -0
- package/lib/{patchIdentifier.ts → identifier/patchIdentifier.ts} +6 -5
- package/{index.ts → lib/index.ts} +5 -4
- package/lib/test/bootstrap.js +5 -0
- package/lib/test/expect/expectError.js +4 -2
- package/lib/test/mocks/getBlsAdapterMock.js +36 -0
- package/lib/test/utils/newDocumentsContainer.js +36 -0
- package/lib/utils/extend.ts +6 -0
- package/package.json +9 -6
- package/src/bls_adapter.rs +16 -1
- package/src/data_contract/data_contract.rs +35 -7
- package/src/data_contract/errors/invalid_data_contract.rs +21 -0
- package/src/data_contract/errors/invalid_document_type.rs +1 -1
- package/src/data_contract/index.rs +56 -1
- package/src/data_contract/mod.rs +1 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +6 -8
- package/src/data_contract/state_transition/data_contract_create_transition/validation.rs +4 -4
- package/src/data_contract/state_transition/data_contract_update_transition/apply.rs +44 -0
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +145 -0
- package/src/data_contract/state_transition/data_contract_update_transition/validation.rs +49 -0
- package/src/data_contract/state_transition/mod.rs +2 -0
- package/src/data_contract_factory/data_contract_factory.rs +25 -12
- package/src/document/errors/invalid_document_error.rs +10 -9
- package/src/document/errors/invalid_initial_revision_error.rs +1 -1
- package/src/document/errors/mismatch_owners_ids_error.rs +14 -4
- package/src/document/errors/mod.rs +17 -13
- package/src/document/errors/no_documents_supplied_error.rs +4 -4
- package/src/document/factory.rs +192 -0
- package/src/document/mod.rs +222 -30
- package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +47 -1
- package/src/document/state_transition/document_batch_transition/document_transition/document_delete_transition.rs +25 -1
- package/src/document/state_transition/document_batch_transition/document_transition/document_replace_transition.rs +65 -0
- package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +123 -3
- package/src/document/state_transition/document_batch_transition/mod.rs +378 -0
- package/src/document/validator.rs +30 -0
- package/src/errors/consensus/basic/data_contract/data_contract_max_depth_exceed_error.rs +5 -5
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_ids_error.rs +4 -4
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_indices_error.rs +36 -0
- package/src/errors/consensus/basic/document/missing_document_transition_type_error.rs +20 -0
- package/src/errors/consensus/basic/document/mod.rs +4 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_error.rs +2 -2
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_id_error.rs +2 -2
- package/src/errors/consensus/basic/identity/identity_asset_lock_proof_locked_transaction_mismatch_error.rs +6 -2
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_out_point_already_exists_error.rs +5 -2
- package/src/errors/consensus/basic/identity/invalid_asset_lock_proof_transaction_height_error.rs +3 -3
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_security_level_error.rs +2 -2
- package/src/errors/consensus/basic/json_schema_error.rs +1 -1
- package/src/errors/consensus_error.rs +15 -8
- package/src/errors/dpp_error.rs +17 -0
- package/src/errors/from.rs +6 -1
- package/src/errors/js_conversion.rs +19 -4
- package/src/errors/mod.rs +3 -0
- package/src/errors/protocol_error.rs +15 -0
- package/src/{identifier.rs → identifier/mod.rs} +48 -3
- package/src/identity/errors/asset_lock_output_not_found_error.rs +11 -0
- package/src/identity/errors/asset_lock_transaction_is_not_found_error.rs +20 -0
- package/src/identity/errors/mod.rs +7 -0
- package/src/identity/errors/unknown_asset_lock_proof_type_error.rs +26 -0
- package/src/{identity_facade.rs → identity/identity_facade.rs} +3 -5
- package/src/{identity_public_key → identity/identity_public_key}/key_type.rs +0 -0
- package/src/{identity_public_key → identity/identity_public_key}/mod.rs +41 -10
- package/src/{identity_public_key → identity/identity_public_key}/purpose.rs +0 -0
- package/src/{identity_public_key → identity/identity_public_key}/security_level.rs +0 -0
- package/src/{identity.rs → identity/mod.rs} +20 -12
- package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +132 -0
- package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof_structure_validator.rs +72 -0
- package/src/identity/state_transition/asset_lock_proof/chain/mod.rs +4 -0
- package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +177 -0
- package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof_structure_validator.rs +72 -0
- package/src/identity/state_transition/asset_lock_proof/instant/mod.rs +4 -0
- package/src/identity/state_transition/asset_lock_proof/mod.rs +269 -0
- package/src/identity/state_transition/identity_create_transition/apply_identity_create_transition.rs +26 -0
- package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +335 -0
- package/src/identity/state_transition/identity_create_transition/identity_create_transition_basic_validator.rs +153 -0
- package/src/identity/state_transition/identity_create_transition/identity_create_transition_state_validator.rs +37 -0
- package/src/identity/state_transition/identity_create_transition/mod.rs +8 -0
- package/src/identity/state_transition/identity_create_transition/to_object.rs +46 -0
- package/src/identity/state_transition/identity_topup_transition/apply_identity_topup_transition.rs +31 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +280 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition_basic_validator.rs +113 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition_state_validator.rs +37 -0
- package/src/identity/state_transition/identity_topup_transition/mod.rs +8 -0
- package/src/identity/state_transition/identity_topup_transition/to_object.rs +42 -0
- package/src/identity/state_transition/mod.rs +9 -0
- package/src/identity/state_transition/validate_public_key_signatures.rs +59 -0
- package/src/identity/validation/mod.rs +3 -0
- package/src/identity/validation/public_keys_validator.rs +76 -0
- package/src/identity_public_key/public_keys_validator.rs +1 -1
- package/src/lib.rs +3 -6
- package/src/lodash.rs +7 -0
- package/src/state_repository.rs +188 -36
- package/src/state_transition/mod.rs +12 -0
- package/src/utils.rs +102 -7
- package/src/validation/json_schema_validator.rs +41 -0
- package/src/validation/mod.rs +5 -0
- package/src/{validation_result.rs → validation/validation_result.rs} +23 -5
- package/src/version/mod.rs +2 -0
- package/src/version/protocol_version.rs +26 -0
- package/test/integration/dataContract/validation/validateDataContractFactory.spec.js +579 -502
- package/test/integration/identity/stateTransition/IdentityCreateTransition/validation/basic/validateIdentityCreateTransitionBasicFactory.spec.js +175 -165
- package/test/integration/identity/stateTransition/IdentityTopUpTransition/validation/basic/validateIdentityTopUpTransitionBasicFactory.spec.js +83 -114
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +1 -1
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +82 -91
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +75 -31
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +93 -148
- package/test/integration/identity/stateTransition/assetLockProof/validateAssetLockTransactionFactory.spec.js +63 -75
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +48 -19
- package/test/integration/identity/validation/validatePublicKeysFactory.spec.js +79 -114
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +0 -11
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +1 -1
- package/test/integration/stateTransition/calculateStateTransitionFeeFactory.spec.js +135 -0
- package/test/unit/dataContract/DataContract.spec.js +5 -9
- package/test/unit/dataContract/DataContractFactory.spec.js +13 -6
- package/test/unit/dataContract/createDataContract.spec.js +0 -1
- package/test/unit/dataContract/errors/InvalidDataContractError.spec.js +11 -3
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +3 -3
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +20 -16
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +24 -60
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +27 -23
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateIndicesAreBackwardCompatible.spec.js +29 -12
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/state/validateDataContractUpdateTransitionStateFactory.spec.js +66 -49
- package/test/unit/dataContract/validation/validateDataContractPatterns.spec.js +73 -0
- package/test/unit/decodeProtocolEntityFactory.spec.js +2 -2
- package/test/unit/document/Document.spec.js +147 -155
- package/test/unit/document/DocumentFactory.spec.js +325 -91
- package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +142 -64
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +1 -1
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +1 -1
- package/test/unit/identity/Identity.spec.js +2 -2
- package/test/unit/identity/IdentityPublicKey.spec.js +25 -31
- package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js +69 -30
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +32 -32
- package/test/unit/identity/stateTransition/IdentityCreateTransition/validation/state/validateIdentityCreateTransitionStateFactory.spec.js +56 -25
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition.spec.js +36 -16
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +48 -46
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/validation/state/validateIdentityTopUpTransitionStateFactory.spec.js +24 -6
- package/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js +63 -0
- package/test/unit/identity/stateTransition/assetLockProof/InstantAssetLockProof.spec.js +90 -0
- package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +18 -3
- package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +38 -11
- package/tsconfig.json +1 -1
- package/wasm/package.json +5 -0
- package/wasm/wasm_dpp.d.ts +1595 -518
- package/wasm/wasm_dpp.js +5007 -2172
- package/wasm/wasm_dpp_bg.js +1 -1
- package/wasm/wasm_dpp_bg.wasm +0 -0
- package/wasm/wasm_dpp_bg.wasm.d.ts +566 -365
- package/webpack.config.js +10 -1
- package/test/integration/stateTransition/calculateStateTransitionFee.spec.js +0 -32
- package/test/unit/dataContract/validation/validateDataContractMaxDepthFactory.spec.js +0 -93
- package/test/unit/dataContract/validation/validateDataContractPatternsFactory.spec.js +0 -64
|
@@ -1,14 +1,134 @@
|
|
|
1
1
|
mod document_create_transition;
|
|
2
2
|
mod document_delete_transition;
|
|
3
|
-
mod
|
|
3
|
+
mod document_replace_transition;
|
|
4
4
|
|
|
5
5
|
pub use document_create_transition::*;
|
|
6
6
|
pub use document_delete_transition::*;
|
|
7
|
-
pub use
|
|
7
|
+
pub use document_replace_transition::*;
|
|
8
8
|
|
|
9
|
-
use dpp::
|
|
9
|
+
use dpp::{
|
|
10
|
+
document::document_transition::{DocumentTransitionExt, DocumentTransitionObjectLike},
|
|
11
|
+
prelude::{DocumentTransition, Identifier},
|
|
12
|
+
util::json_schema::JsonSchemaExt,
|
|
13
|
+
};
|
|
14
|
+
use serde::Serialize;
|
|
10
15
|
use wasm_bindgen::prelude::*;
|
|
11
16
|
|
|
17
|
+
use crate::{
|
|
18
|
+
buffer::Buffer, identifier::IdentifierWrapper, utils::WithJsError, with_js_error, BinaryType,
|
|
19
|
+
DataContractWasm,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
#[wasm_bindgen]
|
|
23
|
+
#[derive(Debug, Clone)]
|
|
24
|
+
pub struct DocumentTransitionWasm(DocumentTransition);
|
|
25
|
+
|
|
26
|
+
#[wasm_bindgen(js_class=DocumentTransitionWasm)]
|
|
27
|
+
impl DocumentTransitionWasm {
|
|
28
|
+
#[wasm_bindgen(js_name=getId)]
|
|
29
|
+
pub fn get_id(&self) -> IdentifierWrapper {
|
|
30
|
+
self.0.get_id().to_owned().into()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#[wasm_bindgen(js_name=getType)]
|
|
34
|
+
pub fn get_type(&self) -> String {
|
|
35
|
+
self.0.get_document_type().to_owned()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#[wasm_bindgen(js_name=getAction)]
|
|
39
|
+
pub fn get_action(&self) -> u8 {
|
|
40
|
+
self.0.get_action().into()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#[wasm_bindgen(js_name=getDataContract)]
|
|
44
|
+
pub fn get_data_contract(&self) -> DataContractWasm {
|
|
45
|
+
self.0.get_data_contract().to_owned().into()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[wasm_bindgen(js_name=getDataContractId)]
|
|
49
|
+
pub fn get_data_contract_id(&self) -> IdentifierWrapper {
|
|
50
|
+
self.0.get_data_contract_id().to_owned().into()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#[wasm_bindgen(js_name=get)]
|
|
54
|
+
pub fn get(&self, path: &str) -> JsValue {
|
|
55
|
+
let binary_type = self.get_binary_type_of_path(path);
|
|
56
|
+
|
|
57
|
+
if let Some(value) = self.0.get_dynamic_property(path) {
|
|
58
|
+
match binary_type {
|
|
59
|
+
BinaryType::Identifier => {
|
|
60
|
+
if let Ok(bytes) = serde_json::from_value::<Vec<u8>>(value.to_owned()) {
|
|
61
|
+
let id: IdentifierWrapper = Identifier::from_bytes(&bytes).unwrap().into();
|
|
62
|
+
|
|
63
|
+
return id.into();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
BinaryType::Buffer => {
|
|
67
|
+
if let Ok(bytes) = serde_json::from_value::<Vec<u8>>(value.to_owned()) {
|
|
68
|
+
return Buffer::from_bytes(&bytes).into();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
BinaryType::None => {
|
|
72
|
+
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
|
73
|
+
if let Ok(js_value) = value.serialize(&serializer) {
|
|
74
|
+
return js_value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
JsValue::undefined()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#[wasm_bindgen(js_name=getObject)]
|
|
84
|
+
pub fn to_object(&self, _options: &JsValue) -> Result<JsValue, JsValue> {
|
|
85
|
+
// TODO options??
|
|
86
|
+
|
|
87
|
+
match self.0 {
|
|
88
|
+
DocumentTransition::Create(ref t) => {
|
|
89
|
+
DocumentCreateTransitionWasm::from(t.to_owned()).to_object()
|
|
90
|
+
}
|
|
91
|
+
DocumentTransition::Replace(ref t) => {
|
|
92
|
+
DocumentReplaceTransitionWasm::from(t.to_owned()).to_object()
|
|
93
|
+
}
|
|
94
|
+
DocumentTransition::Delete(ref t) => {
|
|
95
|
+
DocumentDeleteTransitionWasm::from(t.to_owned()).to_object()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[wasm_bindgen(js_name=toJSON)]
|
|
101
|
+
pub fn to_json(&self) -> Result<JsValue, JsValue> {
|
|
102
|
+
let json_value = self.0.to_json().with_js_error()?;
|
|
103
|
+
with_js_error!(json_value.serialize(&serde_wasm_bindgen::Serializer::json_compatible()))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
impl DocumentTransitionWasm {
|
|
108
|
+
fn get_binary_type_of_path(&self, path: impl AsRef<str>) -> BinaryType {
|
|
109
|
+
let maybe_binary_properties = self
|
|
110
|
+
.0
|
|
111
|
+
.get_data_contract()
|
|
112
|
+
.get_binary_properties(self.0.get_document_type());
|
|
113
|
+
|
|
114
|
+
if let Ok(binary_properties) = maybe_binary_properties {
|
|
115
|
+
if let Some(data) = binary_properties.get(path.as_ref()) {
|
|
116
|
+
if data.is_type_of_identifier() {
|
|
117
|
+
return BinaryType::Identifier;
|
|
118
|
+
}
|
|
119
|
+
return BinaryType::Buffer;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
BinaryType::None
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
impl From<DocumentTransition> for DocumentTransitionWasm {
|
|
127
|
+
fn from(v: DocumentTransition) -> Self {
|
|
128
|
+
DocumentTransitionWasm(v)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
12
132
|
pub fn from_document_transition_to_js_value(document_transition: DocumentTransition) -> JsValue {
|
|
13
133
|
match document_transition {
|
|
14
134
|
DocumentTransition::Create(create_transition) => {
|
|
@@ -1 +1,379 @@
|
|
|
1
|
+
use dpp::{
|
|
2
|
+
document::{
|
|
3
|
+
state_transition::documents_batch_transition::property_names, DocumentsBatchTransition,
|
|
4
|
+
},
|
|
5
|
+
prelude::{DataContract, Document, Identifier},
|
|
6
|
+
state_transition::{
|
|
7
|
+
state_transition_execution_context::StateTransitionExecutionContext,
|
|
8
|
+
StateTransitionConvert, StateTransitionIdentitySigned, StateTransitionLike,
|
|
9
|
+
StateTransitionType,
|
|
10
|
+
},
|
|
11
|
+
util::json_value::JsonValueExt,
|
|
12
|
+
};
|
|
13
|
+
use js_sys::{Array, Reflect};
|
|
14
|
+
use serde::Serialize;
|
|
15
|
+
use wasm_bindgen::prelude::*;
|
|
16
|
+
|
|
17
|
+
use crate::{
|
|
18
|
+
bls_adapter::{BlsAdapter, JsBlsAdapter},
|
|
19
|
+
buffer::Buffer,
|
|
20
|
+
document_batch_transition::document_transition::DocumentTransitionWasm,
|
|
21
|
+
identifier::IdentifierWrapper,
|
|
22
|
+
lodash::lodash_set,
|
|
23
|
+
utils::{ToSerdeJSONExt, WithJsError},
|
|
24
|
+
DocumentWasm, IdentityPublicKeyWasm,
|
|
25
|
+
};
|
|
1
26
|
pub mod document_transition;
|
|
27
|
+
|
|
28
|
+
#[derive(Debug)]
|
|
29
|
+
#[wasm_bindgen(js_name = DocumentsBatchTransition)]
|
|
30
|
+
pub struct DocumentsBatchTransitionWASM(DocumentsBatchTransition);
|
|
31
|
+
|
|
32
|
+
/// Collections of Documents split by actions
|
|
33
|
+
#[derive(Debug, Default)]
|
|
34
|
+
#[wasm_bindgen(js_name=DocumentsContainer)]
|
|
35
|
+
pub struct DocumentsContainer {
|
|
36
|
+
create: Vec<Document>,
|
|
37
|
+
replace: Vec<Document>,
|
|
38
|
+
delete: Vec<Document>,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[wasm_bindgen(js_class=DocumentsContainer)]
|
|
42
|
+
impl DocumentsContainer {
|
|
43
|
+
#[wasm_bindgen(constructor)]
|
|
44
|
+
pub fn new() -> Self {
|
|
45
|
+
Default::default()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[wasm_bindgen(js_name=pushDocumentCreate)]
|
|
49
|
+
pub fn push_document_create(&mut self, d: DocumentWasm) {
|
|
50
|
+
self.create.push(d.0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#[wasm_bindgen(js_name=pushDocumentReplace)]
|
|
54
|
+
pub fn push_document_replace(&mut self, d: DocumentWasm) {
|
|
55
|
+
self.replace.push(d.0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#[wasm_bindgen(js_name=pushDocumentDelete)]
|
|
59
|
+
pub fn push_document_delete(&mut self, d: DocumentWasm) {
|
|
60
|
+
self.delete.push(d.0);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
impl DocumentsContainer {
|
|
65
|
+
pub fn take_documents_create(&mut self) -> Vec<Document> {
|
|
66
|
+
std::mem::take(&mut self.create)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
pub fn take_documents_replace(&mut self) -> Vec<Document> {
|
|
70
|
+
std::mem::take(&mut self.replace)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
pub fn take_documents_delete(&mut self) -> Vec<Document> {
|
|
74
|
+
std::mem::take(&mut self.delete)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[wasm_bindgen(js_class=DocumentsBatchTransition)]
|
|
79
|
+
impl DocumentsBatchTransitionWASM {
|
|
80
|
+
#[wasm_bindgen(constructor)]
|
|
81
|
+
pub fn from_raw_object(
|
|
82
|
+
js_raw_transition: JsValue,
|
|
83
|
+
data_contracts: Array,
|
|
84
|
+
) -> Result<DocumentsBatchTransitionWASM, JsValue> {
|
|
85
|
+
let data_contracts_array_js = Array::from(&data_contracts);
|
|
86
|
+
|
|
87
|
+
let mut data_contracts: Vec<DataContract> = vec![];
|
|
88
|
+
for contract in data_contracts_array_js.iter() {
|
|
89
|
+
let json_value = contract.with_serde_to_json_value()?;
|
|
90
|
+
let data_contract = DataContract::from_json_object(json_value).with_js_error()?;
|
|
91
|
+
data_contracts.push(data_contract);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let documents_batch_transition = DocumentsBatchTransition::from_json_object(
|
|
95
|
+
js_raw_transition.with_serde_to_json_value()?,
|
|
96
|
+
data_contracts,
|
|
97
|
+
)
|
|
98
|
+
.with_js_error()?;
|
|
99
|
+
|
|
100
|
+
Ok(documents_batch_transition.into())
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#[wasm_bindgen(js_name=getType)]
|
|
104
|
+
pub fn get_type(&self) -> u8 {
|
|
105
|
+
StateTransitionType::DocumentsBatch.into()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#[wasm_bindgen(js_name=getOwnerId)]
|
|
109
|
+
pub fn get_owner_id(&self) -> IdentifierWrapper {
|
|
110
|
+
self.0.get_owner_id().to_owned().into()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#[wasm_bindgen(js_name=getTransitions)]
|
|
114
|
+
pub fn get_transitions(&self) -> js_sys::Array {
|
|
115
|
+
let array = js_sys::Array::new();
|
|
116
|
+
let transitions = self.0.get_transitions();
|
|
117
|
+
|
|
118
|
+
for tr in transitions.iter().cloned() {
|
|
119
|
+
let transition: DocumentTransitionWasm = tr.into();
|
|
120
|
+
array.push(&transition.into());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
array
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#[wasm_bindgen(js_name=toJSON)]
|
|
127
|
+
pub fn to_json(&self) -> Result<JsValue, JsValue> {
|
|
128
|
+
let value = self.0.to_json(false).with_js_error()?;
|
|
129
|
+
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
|
130
|
+
|
|
131
|
+
let is_null_signature = value.get(property_names::SIGNATURE).is_none();
|
|
132
|
+
let is_null_signature_public_key_id =
|
|
133
|
+
value.get(property_names::SIGNATURE_PUBLIC_KEY_ID).is_none();
|
|
134
|
+
|
|
135
|
+
let js_value = value.serialize(&serializer)?;
|
|
136
|
+
|
|
137
|
+
if is_null_signature {
|
|
138
|
+
js_sys::Reflect::set(
|
|
139
|
+
&js_value,
|
|
140
|
+
&property_names::SIGNATURE.into(),
|
|
141
|
+
&JsValue::undefined(),
|
|
142
|
+
)?;
|
|
143
|
+
}
|
|
144
|
+
if is_null_signature_public_key_id {
|
|
145
|
+
js_sys::Reflect::set(
|
|
146
|
+
&js_value,
|
|
147
|
+
&property_names::SIGNATURE_PUBLIC_KEY_ID.into(),
|
|
148
|
+
&JsValue::undefined(),
|
|
149
|
+
)?;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
Ok(js_value)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#[wasm_bindgen(js_name=toObject)]
|
|
156
|
+
pub fn to_object(&self, options: &JsValue) -> Result<JsValue, JsValue> {
|
|
157
|
+
let skip_signature = if options.is_object() {
|
|
158
|
+
let options = options.with_serde_to_json_value()?;
|
|
159
|
+
options.get_bool("skipSignature").unwrap_or_default()
|
|
160
|
+
} else {
|
|
161
|
+
false
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
let mut value = self.0.to_object(skip_signature).with_js_error()?;
|
|
165
|
+
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
|
166
|
+
let js_value = value.serialize(&serializer)?;
|
|
167
|
+
|
|
168
|
+
// Transform every transition individually
|
|
169
|
+
let transitions = Array::new();
|
|
170
|
+
for transition in self.0.transitions.iter() {
|
|
171
|
+
let js_value =
|
|
172
|
+
DocumentTransitionWasm::from(transition.to_owned()).to_object(options)?;
|
|
173
|
+
transitions.push(&js_value);
|
|
174
|
+
}
|
|
175
|
+
// Replace the whole collection of transitions
|
|
176
|
+
Reflect::set(
|
|
177
|
+
&js_value,
|
|
178
|
+
&property_names::TRANSITIONS.into(),
|
|
179
|
+
&transitions.into(),
|
|
180
|
+
)?;
|
|
181
|
+
|
|
182
|
+
// Transform paths that are specific to the DocumentsBatchTransition
|
|
183
|
+
for path in DocumentsBatchTransition::binary_property_paths() {
|
|
184
|
+
if let Ok(bytes) = value.remove_path_into::<Vec<u8>>(path) {
|
|
185
|
+
let buffer = Buffer::from_bytes(&bytes);
|
|
186
|
+
lodash_set(&js_value, path, buffer.into());
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for path in DocumentsBatchTransition::identifiers_property_paths() {
|
|
190
|
+
if let Ok(bytes) = value.remove_path_into::<Vec<u8>>(path) {
|
|
191
|
+
let id = IdentifierWrapper::new(bytes)?;
|
|
192
|
+
lodash_set(&js_value, path, id.into());
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if value.get(property_names::SIGNATURE).is_none() && !skip_signature {
|
|
197
|
+
js_sys::Reflect::set(
|
|
198
|
+
&js_value,
|
|
199
|
+
&property_names::SIGNATURE.into(),
|
|
200
|
+
&JsValue::undefined(),
|
|
201
|
+
)?;
|
|
202
|
+
}
|
|
203
|
+
if value.get(property_names::SIGNATURE_PUBLIC_KEY_ID).is_none() {
|
|
204
|
+
js_sys::Reflect::set(
|
|
205
|
+
&js_value,
|
|
206
|
+
&property_names::SIGNATURE_PUBLIC_KEY_ID.into(),
|
|
207
|
+
&JsValue::undefined(),
|
|
208
|
+
)?;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
Ok(js_value)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#[wasm_bindgen(js_name=getModifiedDataIds)]
|
|
215
|
+
pub fn get_modified_ids(&self) -> Array {
|
|
216
|
+
let array = Array::new();
|
|
217
|
+
|
|
218
|
+
for id in self.0.get_modified_data_ids() {
|
|
219
|
+
let id = <IdentifierWrapper as From<Identifier>>::from(id.to_owned());
|
|
220
|
+
array.push(&id.into());
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
array
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// AbstractSTateTransitionIdentitySigned methods
|
|
227
|
+
#[wasm_bindgen(js_name=getSignaturePublicKeyId)]
|
|
228
|
+
pub fn get_signature_public_key_id(&self) -> Option<f64> {
|
|
229
|
+
self.0.get_signature_public_key_id().map(|v| v as f64)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
#[wasm_bindgen(js_name=sign)]
|
|
233
|
+
pub fn sign(
|
|
234
|
+
&mut self,
|
|
235
|
+
identity_public_key: &IdentityPublicKeyWasm,
|
|
236
|
+
private_key: &[u8],
|
|
237
|
+
bls: JsBlsAdapter,
|
|
238
|
+
) -> Result<(), JsValue> {
|
|
239
|
+
self.0
|
|
240
|
+
.sign(identity_public_key.inner(), private_key, &BlsAdapter(bls))
|
|
241
|
+
.with_js_error()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
#[wasm_bindgen(js_name=verifyPublicKeyLevelAndPurpose)]
|
|
245
|
+
pub fn verify_public_key_level_and_purpose(
|
|
246
|
+
&self,
|
|
247
|
+
public_key: &IdentityPublicKeyWasm,
|
|
248
|
+
) -> Result<(), JsValue> {
|
|
249
|
+
self.0
|
|
250
|
+
.verify_public_key_level_and_purpose(public_key.inner())
|
|
251
|
+
.with_js_error()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
#[wasm_bindgen(js_name=verifyPublicKeyIsEnabled)]
|
|
255
|
+
pub fn verify_public_key_is_enabled(
|
|
256
|
+
&self,
|
|
257
|
+
public_key: &IdentityPublicKeyWasm,
|
|
258
|
+
) -> Result<(), JsValue> {
|
|
259
|
+
self.0
|
|
260
|
+
.verify_public_key_is_enabled(public_key.inner())
|
|
261
|
+
.with_js_error()
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#[wasm_bindgen(js_name=verifySignature)]
|
|
265
|
+
pub fn verify_signature(
|
|
266
|
+
&self,
|
|
267
|
+
public_key: &IdentityPublicKeyWasm,
|
|
268
|
+
bls: JsBlsAdapter,
|
|
269
|
+
) -> Result<(), JsValue> {
|
|
270
|
+
self.0
|
|
271
|
+
.verify_signature(public_key.inner(), &BlsAdapter(bls))
|
|
272
|
+
.with_js_error()
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#[wasm_bindgen(js_name=setSignaturePublicKey)]
|
|
276
|
+
pub fn set_signature_public_key(&mut self, key_id: u64) {
|
|
277
|
+
self.0.set_signature_public_key_id(key_id)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
#[wasm_bindgen(js_name=getSecurityLevelRequirement)]
|
|
281
|
+
pub fn get_security_level_requirement(&self) -> u8 {
|
|
282
|
+
self.0.get_security_level_requirement().into()
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// AbstractStateTransition methods
|
|
286
|
+
#[wasm_bindgen(js_name=getProtocolVersion)]
|
|
287
|
+
pub fn get_protocol_version(&self) -> u32 {
|
|
288
|
+
self.0.get_protocol_version()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#[wasm_bindgen(js_name=getSignature)]
|
|
292
|
+
pub fn get_signature(&self) -> Vec<u8> {
|
|
293
|
+
self.0.get_signature().to_owned()
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
#[wasm_bindgen(js_name=setSignature)]
|
|
297
|
+
pub fn set_signature(&mut self, signature: Vec<u8>) {
|
|
298
|
+
self.0.set_signature(signature)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#[wasm_bindgen(js_name=calculateFee)]
|
|
302
|
+
pub fn calculate_fee(&self) -> i64 {
|
|
303
|
+
self.0.calculate_fee()
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
#[wasm_bindgen(js_name=isDocumentStateTransition)]
|
|
307
|
+
pub fn is_document_state_transition(&self) -> bool {
|
|
308
|
+
self.0.is_document_state_transition()
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#[wasm_bindgen(js_name=isDataContractStateTransition)]
|
|
312
|
+
pub fn is_data_contract_state_transition(&self) -> bool {
|
|
313
|
+
self.0.is_data_contract_state_transition()
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
#[wasm_bindgen(js_name=isIdentityStateTransition)]
|
|
317
|
+
pub fn is_identity_state_transition(&self) -> bool {
|
|
318
|
+
self.0.is_identity_state_transition()
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
#[wasm_bindgen(js_name=setExecutionContext)]
|
|
322
|
+
pub fn set_execution_context(&mut self, context: StateExecutionContext) {
|
|
323
|
+
self.0.set_execution_context(context.into_inner());
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
#[wasm_bindgen(js_name=getExecutionContext)]
|
|
327
|
+
pub fn get_execution_context(&mut self) -> StateExecutionContext {
|
|
328
|
+
StateExecutionContext(self.0.get_execution_context().to_owned())
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
#[wasm_bindgen(js_name=toBuffer)]
|
|
332
|
+
pub fn to_buffer(&self, options: &JsValue) -> Result<Buffer, JsValue> {
|
|
333
|
+
let skip_signature = if options.is_object() {
|
|
334
|
+
let options = options.with_serde_to_json_value()?;
|
|
335
|
+
options.get_bool("skipSignature").unwrap_or_default()
|
|
336
|
+
} else {
|
|
337
|
+
false
|
|
338
|
+
};
|
|
339
|
+
let bytes = self.0.to_buffer(skip_signature).with_js_error()?;
|
|
340
|
+
|
|
341
|
+
Ok(Buffer::from_bytes(&bytes))
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
#[wasm_bindgen(js_name=hash)]
|
|
345
|
+
pub fn hash(&self, options: JsValue) -> Result<Buffer, JsValue> {
|
|
346
|
+
let skip_signature = if options.is_object() {
|
|
347
|
+
let options = options.with_serde_to_json_value()?;
|
|
348
|
+
options.get_bool("skipSignature").unwrap_or_default()
|
|
349
|
+
} else {
|
|
350
|
+
false
|
|
351
|
+
};
|
|
352
|
+
let bytes = self.0.hash(skip_signature).with_js_error()?;
|
|
353
|
+
|
|
354
|
+
Ok(Buffer::from_bytes(&bytes))
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
#[wasm_bindgen(js_name=StateExecutionContext)]
|
|
359
|
+
pub struct StateExecutionContext(StateTransitionExecutionContext);
|
|
360
|
+
|
|
361
|
+
impl StateExecutionContext {
|
|
362
|
+
pub fn into_inner(self) -> StateTransitionExecutionContext {
|
|
363
|
+
self.0
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
pub fn inner(&self) -> &StateTransitionExecutionContext {
|
|
367
|
+
&self.0
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
pub fn inner_mut(&mut self) -> &mut StateTransitionExecutionContext {
|
|
371
|
+
&mut self.0
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
impl From<DocumentsBatchTransition> for DocumentsBatchTransitionWASM {
|
|
376
|
+
fn from(t: DocumentsBatchTransition) -> Self {
|
|
377
|
+
DocumentsBatchTransitionWASM(t)
|
|
378
|
+
}
|
|
379
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
use std::sync::Arc;
|
|
2
|
+
|
|
3
|
+
use dpp::document::document_validator::DocumentValidator;
|
|
4
|
+
|
|
5
|
+
use wasm_bindgen::prelude::*;
|
|
6
|
+
|
|
7
|
+
use crate::version::ProtocolVersionValidatorWasm;
|
|
8
|
+
|
|
9
|
+
#[wasm_bindgen(js_name = DocumentValidator)]
|
|
10
|
+
pub struct DocumentValidatorWasm(DocumentValidator);
|
|
11
|
+
|
|
12
|
+
#[wasm_bindgen(js_class=DocumentValidator)]
|
|
13
|
+
impl DocumentValidatorWasm {
|
|
14
|
+
#[wasm_bindgen(constructor)]
|
|
15
|
+
pub fn new(protocol_validator: ProtocolVersionValidatorWasm) -> DocumentValidatorWasm {
|
|
16
|
+
DocumentValidatorWasm(DocumentValidator::new(Arc::new(protocol_validator.into())))
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
impl From<DocumentValidator> for DocumentValidatorWasm {
|
|
21
|
+
fn from(doc_validator: DocumentValidator) -> Self {
|
|
22
|
+
DocumentValidatorWasm(doc_validator)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
impl From<DocumentValidatorWasm> for DocumentValidator {
|
|
27
|
+
fn from(val: DocumentValidatorWasm) -> Self {
|
|
28
|
+
val.0
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
use wasm_bindgen::prelude::*;
|
|
2
2
|
|
|
3
|
-
#[wasm_bindgen(js_name=
|
|
4
|
-
pub struct
|
|
3
|
+
#[wasm_bindgen(js_name=DataContractMaxDepthExceedError)]
|
|
4
|
+
pub struct DataContractMaxDepthExceedErrorWasm {
|
|
5
5
|
depth: usize,
|
|
6
6
|
code: u32,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
impl
|
|
9
|
+
impl DataContractMaxDepthExceedErrorWasm {
|
|
10
10
|
pub fn new(depth: usize, code: u32) -> Self {
|
|
11
|
-
|
|
11
|
+
DataContractMaxDepthExceedErrorWasm { depth, code }
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
#[wasm_bindgen(js_class=DataContractMaxDepthError)]
|
|
16
|
-
impl
|
|
16
|
+
impl DataContractMaxDepthExceedErrorWasm {
|
|
17
17
|
#[wasm_bindgen(js_name=getDepth)]
|
|
18
18
|
pub fn get_expected_version(&self) -> usize {
|
|
19
19
|
self.depth
|
package/src/errors/consensus/basic/document/duplicate_document_transitions_with_ids_error.rs
CHANGED
|
@@ -3,19 +3,19 @@ use std::iter::FromIterator;
|
|
|
3
3
|
use wasm_bindgen::prelude::*;
|
|
4
4
|
|
|
5
5
|
#[wasm_bindgen(js_name=DuplicateDocumentTransitionsWithIdsError)]
|
|
6
|
-
pub struct
|
|
6
|
+
pub struct DuplicateDocumentTransitionsWithIdsErrorWasm {
|
|
7
7
|
references: Vec<(String, Vec<u8>)>,
|
|
8
8
|
code: u32,
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
impl
|
|
11
|
+
impl DuplicateDocumentTransitionsWithIdsErrorWasm {
|
|
12
12
|
pub fn new(references: Vec<(String, Vec<u8>)>, code: u32) -> Self {
|
|
13
|
-
|
|
13
|
+
DuplicateDocumentTransitionsWithIdsErrorWasm { references, code }
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
#[wasm_bindgen(js_class=DuplicateDocumentTransitionsWithIdsError)]
|
|
18
|
-
impl
|
|
18
|
+
impl DuplicateDocumentTransitionsWithIdsErrorWasm {
|
|
19
19
|
#[wasm_bindgen(js_name=getReferences)]
|
|
20
20
|
pub fn get_references(&self) -> js_sys::Array {
|
|
21
21
|
self.references
|
package/src/errors/consensus/basic/document/duplicate_document_transitions_with_indices_error.rs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
use crate::buffer::Buffer;
|
|
2
|
+
use std::iter::FromIterator;
|
|
3
|
+
use wasm_bindgen::prelude::*;
|
|
4
|
+
|
|
5
|
+
#[wasm_bindgen(js_name=DuplicateDocumentTransitionsWithIndicesError)]
|
|
6
|
+
pub struct DuplicateDocumentTransitionsWithIndicesErrorWasm {
|
|
7
|
+
references: Vec<(String, Vec<u8>)>,
|
|
8
|
+
code: u32,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
impl DuplicateDocumentTransitionsWithIndicesErrorWasm {
|
|
12
|
+
pub fn new(references: Vec<(String, Vec<u8>)>, code: u32) -> Self {
|
|
13
|
+
DuplicateDocumentTransitionsWithIndicesErrorWasm { references, code }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#[wasm_bindgen(js_class=DuplicateDocumentTransitionsWithIndicesError)]
|
|
18
|
+
impl DuplicateDocumentTransitionsWithIndicesErrorWasm {
|
|
19
|
+
#[wasm_bindgen(js_name=getReferences)]
|
|
20
|
+
pub fn get_references(&self) -> js_sys::Array {
|
|
21
|
+
self.references
|
|
22
|
+
.iter()
|
|
23
|
+
.map(|v| {
|
|
24
|
+
js_sys::Array::from_iter(vec![
|
|
25
|
+
JsValue::from(v.0.clone()),
|
|
26
|
+
JsValue::from(Buffer::from_bytes(&v.1)),
|
|
27
|
+
])
|
|
28
|
+
})
|
|
29
|
+
.collect()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
33
|
+
pub fn get_code(&self) -> u32 {
|
|
34
|
+
self.code
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
#[wasm_bindgen(js_name=MissingDocumentTransitionTypeError)]
|
|
4
|
+
pub struct MissingDocumentTransitionTypeErrorWasm {
|
|
5
|
+
code: u32,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
impl MissingDocumentTransitionTypeErrorWasm {
|
|
9
|
+
pub fn new(code: u32) -> Self {
|
|
10
|
+
MissingDocumentTransitionTypeErrorWasm { code }
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[wasm_bindgen(js_class=MissingDocumentTransitionTypeError)]
|
|
15
|
+
impl MissingDocumentTransitionTypeErrorWasm {
|
|
16
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
17
|
+
pub fn get_code(&self) -> u32 {
|
|
18
|
+
self.code
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
mod data_contract_not_present_error;
|
|
2
2
|
mod duplicate_document_transitions_with_ids_error;
|
|
3
|
+
mod duplicate_document_transitions_with_indices_error;
|
|
3
4
|
mod inconsistent_compound_index_data_error;
|
|
4
5
|
mod invalid_document_transition_action_error;
|
|
5
6
|
mod invalid_document_transition_id_error;
|
|
6
7
|
mod invalid_document_type_error;
|
|
7
8
|
mod missing_data_contract_id_error;
|
|
8
9
|
mod missing_document_transition_action_error;
|
|
10
|
+
mod missing_document_transition_type_error;
|
|
9
11
|
mod missing_document_type_error;
|
|
10
12
|
|
|
11
13
|
pub use data_contract_not_present_error::*;
|
|
12
14
|
pub use duplicate_document_transitions_with_ids_error::*;
|
|
15
|
+
pub use duplicate_document_transitions_with_indices_error::*;
|
|
13
16
|
pub use inconsistent_compound_index_data_error::*;
|
|
14
17
|
pub use invalid_document_transition_action_error::*;
|
|
15
18
|
pub use invalid_document_transition_id_error::*;
|
|
16
19
|
pub use invalid_document_type_error::*;
|
|
17
20
|
pub use missing_data_contract_id_error::*;
|
|
18
21
|
pub use missing_document_transition_action_error::*;
|
|
22
|
+
pub use missing_document_transition_type_error::*;
|
|
19
23
|
pub use missing_document_type_error::*;
|
|
@@ -16,12 +16,12 @@ impl From<&DuplicatedIdentityPublicKeyError> for DuplicatedIdentityPublicKeyErro
|
|
|
16
16
|
#[wasm_bindgen(js_class=DuplicatedIdentityPublicKeyError)]
|
|
17
17
|
impl DuplicatedIdentityPublicKeyErrorWasm {
|
|
18
18
|
#[wasm_bindgen(js_name=getDuplicatedPublicKeysIds)]
|
|
19
|
-
pub fn duplicated_public_keys_ids(&self) ->
|
|
19
|
+
pub fn duplicated_public_keys_ids(&self) -> js_sys::Array {
|
|
20
20
|
// TODO: key ids probably should be u32
|
|
21
21
|
self.inner
|
|
22
22
|
.duplicated_public_keys_ids()
|
|
23
23
|
.iter()
|
|
24
|
-
.map(|id| *id as u32)
|
|
24
|
+
.map(|id| JsValue::from(*id as u32))
|
|
25
25
|
.collect()
|
|
26
26
|
}
|
|
27
27
|
|