@dashevo/wasm-dpp 0.23.0-dev.15 → 0.24.0-dev.10
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/.eslintignore +1 -0
- package/Cargo.toml +23 -0
- package/README.md +21 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +8 -0
- package/dist/lib/patchIdentifier.d.ts +2 -0
- package/dist/wasm/wasm_dpp.d.ts +2756 -0
- package/index.ts +30 -0
- package/karma.conf.js +6 -3
- package/lib/patchIdentifier.ts +37 -0
- package/lib/test/.eslintrc +9 -0
- package/lib/test/bootstrap.js +27 -0
- package/lib/test/expect/expectError.js +34 -0
- package/lib/test/karma/loader.js +6 -0
- package/lib/test/utils/generateRandomIdentifierAsync.js +14 -0
- package/package.json +31 -55
- package/scripts/build.sh +69 -0
- package/scripts/clean.sh +4 -0
- package/src/bls_adapter.rs +71 -0
- package/src/buffer.rs +15 -0
- package/src/dash_platform_protocol.rs +26 -0
- package/src/data_contract/data_contract.rs +290 -0
- package/src/data_contract/errors/data_contract_already_exists.rs +1 -0
- package/src/data_contract/errors/invalid_data_contract.rs +29 -0
- package/src/data_contract/errors/invalid_document_type.rs +33 -0
- package/src/data_contract/errors/mod.rs +37 -0
- package/src/data_contract/index.rs +61 -0
- package/src/data_contract/mod.rs +10 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +37 -0
- package/src/data_contract/state_transition/mod.rs +3 -0
- package/src/data_contract_factory/data_contract_factory.rs +155 -0
- package/src/data_contract_factory/mod.rs +1 -0
- package/src/document/errors/document_already_exists_error.rs +28 -0
- package/src/document/errors/document_not_provided_error.rs +28 -0
- package/src/document/errors/invalid_action_name_error.rs +24 -0
- package/src/document/errors/invalid_document_action_error.rs +28 -0
- package/src/document/errors/invalid_document_error.rs +32 -0
- package/src/document/errors/invalid_initial_revision_error.rs +25 -0
- package/src/document/errors/mismatch_owners_ids_error.rs +27 -0
- package/src/document/errors/mod.rs +55 -0
- package/src/document/errors/no_documents_supplied_error.rs +22 -0
- package/src/document/mod.rs +158 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +22 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_delete_transition.rs +22 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_update_transition.rs +22 -0
- package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +24 -0
- package/src/document/state_transition/document_batch_transition/mod.rs +1 -0
- package/src/document/state_transition/mod.rs +1 -0
- package/src/errors/consensus/basic/data_contract/data_contract_have_new_unique_index_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/data_contract_invalid_index_definition_update_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/data_contract_max_depth_exceed_error.rs +26 -0
- package/src/errors/consensus/basic/data_contract/data_contract_unique_indices_changed_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/duplicate_index_name_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/incompatible_data_contract_schema_error.rs +66 -0
- package/src/errors/consensus/basic/data_contract/incompatible_re2_pattern_error.rs +43 -0
- package/src/errors/consensus/basic/data_contract/index_error/duplicate_index_error.rs +39 -0
- package/src/errors/consensus/basic/data_contract/index_error/invalid_compound_index_error.rs +39 -0
- package/src/errors/consensus/basic/data_contract/index_error/invalid_index_property_type_error.rs +59 -0
- package/src/errors/consensus/basic/data_contract/index_error/invalid_indexed_property_constraint_error.rs +67 -0
- package/src/errors/consensus/basic/data_contract/index_error/mod.rs +15 -0
- package/src/errors/consensus/basic/data_contract/index_error/system_property_index_already_present_error.rs +51 -0
- package/src/errors/consensus/basic/data_contract/index_error/undefined_index_property_error.rs +51 -0
- package/src/errors/consensus/basic/data_contract/index_error/unique_indices_limit_reached_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/invalid_data_contract_id_error.rs +37 -0
- package/src/errors/consensus/basic/data_contract/invalid_data_contract_version_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/invalid_json_schema_ref_error.rs +26 -0
- package/src/errors/consensus/basic/data_contract/mod.rs +25 -0
- package/src/errors/consensus/basic/decode/mod.rs +5 -0
- package/src/errors/consensus/basic/decode/protocol_version_parsing_error.rs +29 -0
- package/src/errors/consensus/basic/decode/serialized_object_parsing_error.rs +29 -0
- package/src/errors/consensus/basic/document/data_contract_not_present_error.rs +32 -0
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_ids_error.rs +36 -0
- package/src/errors/consensus/basic/document/inconsistent_compound_index_data_error.rs +40 -0
- package/src/errors/consensus/basic/document/invalid_document_transition_action_error.rs +26 -0
- package/src/errors/consensus/basic/document/invalid_document_transition_id_error.rs +38 -0
- package/src/errors/consensus/basic/document/invalid_document_type_error.rs +39 -0
- package/src/errors/consensus/basic/document/missing_data_contract_id_error.rs +20 -0
- package/src/errors/consensus/basic/document/missing_document_transition_action_error.rs +20 -0
- package/src/errors/consensus/basic/document/missing_document_type_error.rs +20 -0
- package/src/errors/consensus/basic/document/mod.rs +19 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_error.rs +32 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_id_error.rs +32 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_proof_locked_transaction_mismatch_error.rs +38 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_is_not_found_error.rs +31 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_out_point_already_exists_error.rs +37 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_output_not_found_error.rs +29 -0
- package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +33 -0
- package/src/errors/consensus/basic/identity/invalid_asset_lock_proof_core_chain_height_error.rs +34 -0
- package/src/errors/consensus/basic/identity/invalid_asset_lock_proof_transaction_height_error.rs +34 -0
- package/src/errors/consensus/basic/identity/invalid_asset_lock_transaction_output_return_size_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_error.rs +60 -0
- package/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_output_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_credit_withdrawal_transition_core_fee_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_credit_withdrawal_transition_output_script_error.rs +32 -0
- package/src/errors/consensus/basic/identity/invalid_identity_key_signature_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_data_error.rs +39 -0
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_security_level_error.rs +42 -0
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_type_error.rs +30 -0
- package/src/errors/consensus/basic/identity/invalid_instant_asset_lock_proof_error.rs +22 -0
- package/src/errors/consensus/basic/identity/invalid_instant_asset_lock_proof_signature_error.rs +24 -0
- package/src/errors/consensus/basic/identity/missing_master_public_key_error.rs +22 -0
- package/src/errors/consensus/basic/identity/missing_public_key_error.rs +29 -0
- package/src/errors/consensus/basic/identity/mod.rs +45 -0
- package/src/errors/consensus/basic/incompatible_protocol_version_error.rs +32 -0
- package/src/errors/consensus/basic/invalid_identifier_error.rs +36 -0
- package/src/errors/consensus/basic/invalid_signature_public_key_security_level_error.rs +41 -0
- package/src/errors/consensus/basic/invalid_state_transition_signature_error.rs +20 -0
- package/src/errors/consensus/basic/json_schema_compilation_error.rs +26 -0
- package/src/errors/consensus/basic/json_schema_error.rs +274 -0
- package/src/errors/consensus/basic/mod.rs +30 -0
- package/src/errors/consensus/basic/public_key_is_disabled_error.rs +30 -0
- package/src/errors/consensus/basic/public_key_security_level_not_met_error.rs +41 -0
- package/src/errors/consensus/basic/state_transition/invalid_state_transition_type_error.rs +29 -0
- package/src/errors/consensus/basic/state_transition/missing_state_transition_type_error.rs +20 -0
- package/src/errors/consensus/basic/state_transition/mod.rs +7 -0
- package/src/errors/consensus/basic/state_transition/state_transition_max_size_exceeded_error.rs +36 -0
- package/src/errors/consensus/basic/test_consensus_error.rs +21 -0
- package/src/errors/consensus/basic/unsupported_protocol_version_error.rs +32 -0
- package/src/errors/consensus/basic/wrong_public_key_purpose_error.rs +37 -0
- package/src/errors/consensus/fee/balance_is_not_enough_error.rs +32 -0
- package/src/errors/consensus/fee/mod.rs +3 -0
- package/src/errors/consensus/mod.rs +4 -0
- package/src/errors/consensus/signature/identity_not_found_error.rs +29 -0
- package/src/errors/consensus/signature/mod.rs +3 -0
- package/src/errors/consensus/state/data_contract/data_contract_already_present_error.rs +31 -0
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_condition_error.rs +74 -0
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_execution_error.rs +82 -0
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_invalid_result_error.rs +66 -0
- package/src/errors/consensus/state/data_contract/data_trigger/mod.rs +7 -0
- package/src/errors/consensus/state/data_contract/mod.rs +4 -0
- package/src/errors/consensus/state/document/document_already_present_error.rs +28 -0
- package/src/errors/consensus/state/document/document_not_found_error.rs +28 -0
- package/src/errors/consensus/state/document/document_owner_id_mismatch_error.rs +50 -0
- package/src/errors/consensus/state/document/document_timestamp_window_violation_error.rs +72 -0
- package/src/errors/consensus/state/document/document_timestamps_mismatch_error.rs +28 -0
- package/src/errors/consensus/state/document/duplicate_unique_index_error.rs +42 -0
- package/src/errors/consensus/state/document/invalid_document_revision_error.rs +38 -0
- package/src/errors/consensus/state/document/mod.rs +15 -0
- package/src/errors/consensus/state/identity/identity_already_exists_error.rs +28 -0
- package/src/errors/consensus/state/identity/identity_public_key_disabled_at_window_violation_error.rs +49 -0
- package/src/errors/consensus/state/identity/identity_public_key_is_disabled_error.rs +31 -0
- package/src/errors/consensus/state/identity/identity_public_key_is_read_only_error.rs +28 -0
- package/src/errors/consensus/state/identity/invalid_identity_public_key_id_error.rs +28 -0
- package/src/errors/consensus/state/identity/invalid_identity_revision_error.rs +38 -0
- package/src/errors/consensus/state/identity/max_identity_public_key_limit_reached_error.rs +26 -0
- package/src/errors/consensus/state/identity/mod.rs +15 -0
- package/src/errors/consensus/state/mod.rs +3 -0
- package/src/errors/consensus_error.rs +612 -0
- package/src/errors/from.rs +24 -0
- package/src/errors/js_conversion.rs +63 -0
- package/src/errors/mod.rs +10 -0
- package/src/errors/public_key_validation_error.rs +23 -0
- package/src/identifier.rs +103 -0
- package/src/identity.rs +253 -0
- package/src/identity_facade.rs +55 -0
- package/src/identity_public_key/key_type.rs +22 -0
- package/src/identity_public_key/mod.rs +192 -0
- package/src/identity_public_key/public_keys_validator.rs +44 -0
- package/src/identity_public_key/purpose.rs +24 -0
- package/src/identity_public_key/security_level.rs +21 -0
- package/src/lib.rs +28 -0
- package/src/metadata.rs +54 -0
- package/src/utils.rs +59 -0
- package/src/validation_result.rs +41 -0
- package/test/integration/DashPlatformProtocol.spec.js +4 -4
- package/test/integration/ajv/keywords/byteArray/addByteArrayKeyword.spec.js +2 -2
- package/test/integration/dataContract/DataContractFacade.spec.js +6 -6
- package/test/integration/dataContract/stateTransition/DataContractCreateTransition/validation/basic/validateDataContractCreateTransitionBasicFactory.spec.js +10 -10
- package/test/integration/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateDataContractUpdateTransitionBasicFactory.spec.js +14 -14
- package/test/integration/dataContract/validation/validateDataContractFactory.spec.js +22 -22
- package/test/integration/document/Document.spec.js +10 -5
- package/test/integration/document/DocumentFacade.spec.js +11 -11
- package/test/integration/document/stateTransition/DocumentsBatchTransition/DocumentBatchTransition.spec.js +5 -5
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/basic/validateDocumentsBatchTransitionBasicFactory.spec.js +25 -25
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/state/executeDataTriggersFactory.spec.js +15 -15
- package/test/integration/document/validation/validateDocumentFactory.spec.js +12 -12
- package/test/integration/error/consensus/createConsensusError.spec.js +3 -3
- package/test/integration/identity/IdentityFacade.spec.js +13 -13
- package/test/integration/identity/stateTransition/IdentityCreateTransition/validation/basic/validateIdentityCreateTransitionBasicFactory.spec.js +12 -12
- package/test/integration/identity/stateTransition/IdentityTopUpTransition/validation/basic/validateIdentityTopUpTransitionBasicFactory.spec.js +11 -11
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/basic/validateIdentityUpdateTransitionBasicFactory.spec.js +8 -8
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +24 -39
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validatePublicKeysState.spec.js +7 -7
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +29 -35
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +8 -8
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +11 -11
- package/test/integration/identity/stateTransition/assetLockProof/validateAssetLockTransactionFactory.spec.js +10 -10
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +7 -7
- package/test/integration/identity/validation/validateIdentityFactory.spec.js +8 -8
- package/test/integration/identity/validation/validatePublicKeysFactory.spec.js +50 -24
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +14 -14
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +15 -19
- package/test/integration/stateTransition/calculateStateTransitionFee.spec.js +8 -11
- package/test/integration/util/generateEntropy.spec.js +1 -1
- package/test/integration/util/serializer.spec.js +2 -2
- package/test/unit/DashPlatformProtocol.spec.js +4 -4
- package/test/unit/Identifier.spec.js +2 -2
- package/test/unit/Metadata.spec.js +1 -1
- package/test/unit/dataContract/DataContract.spec.js +100 -159
- package/test/unit/dataContract/DataContractFactory.spec.js +55 -111
- package/test/unit/dataContract/createDataContract.spec.js +20 -10
- package/test/unit/dataContract/errors/InvalidDataContractError.spec.js +2 -2
- package/test/unit/dataContract/generateDataContractId.spec.js +23 -6
- package/test/unit/dataContract/getBinaryPropertiesFromSchema.spec.js +1 -1
- package/test/unit/dataContract/getPropertyDefinitionByPath.spec.js +1 -1
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +8 -8
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +8 -8
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +8 -8
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateIndicesAreBackwardCompatible.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/state/validateDataContractUpdateTransitionStateFactory.spec.js +9 -9
- package/test/unit/dataContract/validation/validateDataContractMaxDepthFactory.spec.js +6 -6
- package/test/unit/dataContract/validation/validateDataContractPatternsFactory.spec.js +3 -3
- package/test/unit/dataTrigger/DataTrigger.spec.js +8 -8
- package/test/unit/dataTrigger/DataTriggerExecutionContext.spec.js +4 -4
- package/test/unit/dataTrigger/dashpayDataTriggers/createContactRequestDataTrigger.spec.js +13 -15
- package/test/unit/dataTrigger/dpnsTriggers/createDomainDataTrigger.spec.js +12 -12
- package/test/unit/dataTrigger/featureFlagDataTriggers/createFeatureFlagDataTrigger.spec.js +11 -13
- package/test/unit/dataTrigger/getDataTriggersFactory.spec.js +7 -7
- package/test/unit/dataTrigger/rejectDataTrigger.spec.js +8 -8
- package/test/unit/dataTrigger/rewardShareDataTriggers/createMasternodeRewardSharesDataTrigger.spec.js +9 -9
- package/test/unit/decodeProtocolEntityFactory.spec.js +4 -4
- package/test/unit/document/Document.spec.js +9 -9
- package/test/unit/document/DocumentFactory.spec.js +19 -19
- package/test/unit/document/errors/InvalidDocumentError.spec.js +2 -2
- package/test/unit/document/fetchAndValidateDataContractFactory.spec.js +8 -8
- package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +8 -8
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +16 -17
- package/test/unit/document/stateTransition/DocumetsBatchTransition/documentTransition/DocumentCreateTransition.spec.js +1 -1
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesById.spec.js +2 -2
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesByIndices.spec.js +6 -6
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/validatePartialCompoundIndices.spec.js +7 -7
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/fetchDocumentsFactory.spec.js +6 -6
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +27 -34
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsUniquenessByIndicesFactory.spec.js +9 -9
- package/test/unit/errors/consensus/codes.spec.js +7 -7
- package/test/unit/identity/Identity.spec.js +98 -69
- package/test/unit/identity/IdentityFactory.spec.js +15 -15
- package/test/unit/identity/IdentityPublicKey.spec.js +53 -66
- package/test/unit/identity/creditsConverter.spec.js +1 -1
- package/test/unit/identity/errors/InvalidIdentityError.spec.js +2 -2
- package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js +7 -7
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +8 -8
- package/test/unit/identity/stateTransition/IdentityCreateTransition/validation/state/validateIdentityCreateTransitionStateFactory.spec.js +6 -6
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition.spec.js +4 -4
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +7 -7
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/validation/state/validateIdentityTopUpTransitionStateFactory.spec.js +2 -2
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +6 -6
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/applyIdentityUpdateTransitionFactory.spec.js +6 -6
- package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +5 -5
- package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +3 -3
- package/test/unit/identity/validation/validateRequiredPurposeAndSecurityLevelFactory.spec.js +5 -5
- package/test/unit/stateTransition/StateTransitionFactory.spec.js +8 -8
- package/test/unit/stateTransition/createStateTransitionFactory.spec.js +8 -8
- package/test/unit/stateTransition/errors/InvalidStateTransitionError.spec.js +3 -3
- package/test/unit/stateTransition/validation/validateStateTransitionBasicFactory.spec.js +12 -12
- package/test/unit/stateTransition/validation/validateStateTransitionFeeFactory.spec.js +15 -15
- package/test/unit/stateTransition/validation/validateStateTransitionIdentitySignatureFactory.spec.js +22 -22
- package/test/unit/stateTransition/validation/validateStateTransitionKeySignatureFactory.spec.js +6 -6
- package/test/unit/stateTransition/validation/validateStateTransitionStateFactory.spec.js +9 -9
- package/test/unit/version/validateProtocolVersionFactory.spec.js +7 -7
- package/tsconfig.json +18 -0
- package/wasm/wasm_dpp.d.ts +2756 -0
- package/wasm/wasm_dpp.js +7750 -0
- package/wasm/wasm_dpp_bg.js +1 -0
- package/wasm/wasm_dpp_bg.wasm +0 -0
- package/wasm/wasm_dpp_bg.wasm.d.ts +518 -0
- package/webpack.config.js +22 -19
- package/CHANGELOG.md +0 -397
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
use crate::state_transition::document_batch_transition::document_transition::from_document_transition_to_js_value;
|
|
2
|
+
use dpp::prelude::DocumentTransition;
|
|
3
|
+
use thiserror::Error;
|
|
4
|
+
|
|
5
|
+
use super::*;
|
|
6
|
+
|
|
7
|
+
#[wasm_bindgen]
|
|
8
|
+
#[derive(Error, Debug)]
|
|
9
|
+
#[error("Document was not provided for apply of state transition")]
|
|
10
|
+
pub struct DocumentNotProvidedError {
|
|
11
|
+
document_transition: DocumentTransition,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[wasm_bindgen]
|
|
15
|
+
impl DocumentNotProvidedError {
|
|
16
|
+
#[wasm_bindgen(js_name=getDocumentTransition)]
|
|
17
|
+
pub fn get_document_transition(&self) -> JsValue {
|
|
18
|
+
from_document_transition_to_js_value(self.document_transition.clone())
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
impl DocumentNotProvidedError {
|
|
23
|
+
pub fn new(document_transition: DocumentTransition) -> DocumentNotProvidedError {
|
|
24
|
+
Self {
|
|
25
|
+
document_transition,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
use thiserror::Error;
|
|
2
|
+
|
|
3
|
+
use super::*;
|
|
4
|
+
|
|
5
|
+
#[wasm_bindgen]
|
|
6
|
+
#[derive(Error, Debug)]
|
|
7
|
+
#[error("Invalid Document action submitted")]
|
|
8
|
+
pub struct InvalidActionNameError {
|
|
9
|
+
actions: Vec<String>,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#[wasm_bindgen]
|
|
13
|
+
impl InvalidActionNameError {
|
|
14
|
+
#[wasm_bindgen(constructor)]
|
|
15
|
+
pub fn new(actions: Vec<JsValue>) -> Self {
|
|
16
|
+
let actions: Vec<String> = into_vec_of(&actions);
|
|
17
|
+
Self { actions }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_name=getActions)]
|
|
21
|
+
pub fn get_actions(&self) -> Vec<JsValue> {
|
|
22
|
+
to_vec_js(self.actions.clone())
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
use crate::state_transition::document_batch_transition::document_transition::from_document_transition_to_js_value;
|
|
2
|
+
use dpp::prelude::DocumentTransition;
|
|
3
|
+
use thiserror::Error;
|
|
4
|
+
|
|
5
|
+
use super::*;
|
|
6
|
+
|
|
7
|
+
#[wasm_bindgen]
|
|
8
|
+
#[derive(Error, Debug)]
|
|
9
|
+
#[error("Invalid Document action: '{}'", document_transition.action())]
|
|
10
|
+
pub struct InvalidDocumentActionError {
|
|
11
|
+
document_transition: DocumentTransition,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[wasm_bindgen]
|
|
15
|
+
impl InvalidDocumentActionError {
|
|
16
|
+
#[wasm_bindgen(js_name=getDocumentTransition)]
|
|
17
|
+
pub fn get_document_transition(&self) -> JsValue {
|
|
18
|
+
from_document_transition_to_js_value(self.document_transition.clone())
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
impl InvalidDocumentActionError {
|
|
23
|
+
pub fn new(document_transition: DocumentTransition) -> Self {
|
|
24
|
+
Self {
|
|
25
|
+
document_transition,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
use thiserror::Error;
|
|
2
|
+
|
|
3
|
+
use crate::DocumentWasm;
|
|
4
|
+
|
|
5
|
+
use super::*;
|
|
6
|
+
|
|
7
|
+
#[wasm_bindgen]
|
|
8
|
+
#[derive(Error, Debug)]
|
|
9
|
+
#[error("Invalid document: {:?}", errors)]
|
|
10
|
+
pub struct InvalidDocumentError {
|
|
11
|
+
// the point is how we hold all there different types in the Vector
|
|
12
|
+
errors: Vec<JsValue>,
|
|
13
|
+
document: DocumentWasm,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen]
|
|
17
|
+
impl InvalidDocumentError {
|
|
18
|
+
#[wasm_bindgen(constructor)]
|
|
19
|
+
pub fn new(document: DocumentWasm, errors: Vec<JsValue>) -> InvalidDocumentError {
|
|
20
|
+
Self { document, errors }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getErrors)]
|
|
24
|
+
pub fn get_errors(&self) -> Vec<JsValue> {
|
|
25
|
+
self.errors.clone()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[wasm_bindgen(js_name=getDocument)]
|
|
29
|
+
pub fn get_document(&self) -> DocumentWasm {
|
|
30
|
+
self.document.clone()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
use thiserror::Error;
|
|
2
|
+
|
|
3
|
+
use crate::DocumentWasm;
|
|
4
|
+
|
|
5
|
+
use super::*;
|
|
6
|
+
|
|
7
|
+
#[wasm_bindgen]
|
|
8
|
+
#[derive(Error, Debug)]
|
|
9
|
+
#[error("Invalid Document Initial revision '{}'", document.get_revision())]
|
|
10
|
+
pub struct InvalidInitialRevisionError {
|
|
11
|
+
document: DocumentWasm,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[wasm_bindgen]
|
|
15
|
+
impl InvalidInitialRevisionError {
|
|
16
|
+
#[wasm_bindgen(constructor)]
|
|
17
|
+
pub fn new(document: DocumentWasm) -> InvalidInitialRevisionError {
|
|
18
|
+
Self { document }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#[wasm_bindgen(js_name=getDocumentTransition)]
|
|
22
|
+
pub fn get_document_transition(&self) -> DocumentWasm {
|
|
23
|
+
self.document.clone()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
use thiserror::Error;
|
|
2
|
+
|
|
3
|
+
use crate::DocumentWasm;
|
|
4
|
+
|
|
5
|
+
use super::*;
|
|
6
|
+
|
|
7
|
+
#[wasm_bindgen]
|
|
8
|
+
#[derive(Error, Debug)]
|
|
9
|
+
#[error("Documents have mixed owner ids")]
|
|
10
|
+
pub struct MismatchOwnersIdsError {
|
|
11
|
+
documents: Vec<DocumentWasm>,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[wasm_bindgen]
|
|
15
|
+
impl MismatchOwnersIdsError {
|
|
16
|
+
#[wasm_bindgen(constructor)]
|
|
17
|
+
pub fn new(documents: Vec<JsValue>) -> MismatchOwnersIdsError {
|
|
18
|
+
Self {
|
|
19
|
+
documents: into_vec_of(&documents),
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getDocumentTransition)]
|
|
24
|
+
pub fn get_documents(&self) -> Vec<JsValue> {
|
|
25
|
+
to_vec_js(self.documents.clone())
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
pub use document_already_exists_error::*;
|
|
4
|
+
pub use document_not_provided_error::*;
|
|
5
|
+
use dpp::document::errors::DocumentError;
|
|
6
|
+
pub use invalid_action_name_error::*;
|
|
7
|
+
pub use invalid_document_action_error::*;
|
|
8
|
+
pub use invalid_document_error::*;
|
|
9
|
+
pub use invalid_initial_revision_error::*;
|
|
10
|
+
pub use mismatch_owners_ids_error::*;
|
|
11
|
+
pub use no_documents_supplied_error::*;
|
|
12
|
+
|
|
13
|
+
use crate::errors::consensus_error::from_consensus_error;
|
|
14
|
+
use crate::{utils::*, DocumentWasm};
|
|
15
|
+
|
|
16
|
+
mod document_already_exists_error;
|
|
17
|
+
mod document_not_provided_error;
|
|
18
|
+
mod invalid_action_name_error;
|
|
19
|
+
mod invalid_document_action_error;
|
|
20
|
+
mod invalid_document_error;
|
|
21
|
+
mod invalid_initial_revision_error;
|
|
22
|
+
mod mismatch_owners_ids_error;
|
|
23
|
+
mod no_documents_supplied_error;
|
|
24
|
+
|
|
25
|
+
pub fn from_document_to_js_error(e: DocumentError) -> JsValue {
|
|
26
|
+
match e {
|
|
27
|
+
DocumentError::DocumentAlreadyExists {
|
|
28
|
+
document_transition,
|
|
29
|
+
} => DocumentAlreadyExistsError::new(document_transition).into(),
|
|
30
|
+
DocumentError::DocumentNotProvided {
|
|
31
|
+
document_transition,
|
|
32
|
+
} => DocumentNotProvidedError::new(document_transition).into(),
|
|
33
|
+
|
|
34
|
+
DocumentError::InvalidActionName { actions } => {
|
|
35
|
+
InvalidActionNameError::new(to_vec_js(actions)).into()
|
|
36
|
+
}
|
|
37
|
+
DocumentError::InvalidDocument { errors, document } => InvalidDocumentError::new(
|
|
38
|
+
(*document).into(),
|
|
39
|
+
errors.into_iter().map(from_consensus_error).collect(),
|
|
40
|
+
)
|
|
41
|
+
.into(),
|
|
42
|
+
DocumentError::InvalidDocumentAction {
|
|
43
|
+
document_transition,
|
|
44
|
+
} => InvalidDocumentActionError::new(document_transition).into(),
|
|
45
|
+
DocumentError::InvalidInitialRevision { document } => {
|
|
46
|
+
InvalidInitialRevisionError::new((*document).into()).into()
|
|
47
|
+
}
|
|
48
|
+
DocumentError::MismatchOwnersIds { documents } => {
|
|
49
|
+
let documents_wasm: Vec<DocumentWasm> =
|
|
50
|
+
documents.into_iter().map(DocumentWasm::from).collect();
|
|
51
|
+
MismatchOwnersIdsError::new(to_vec_js(documents_wasm)).into()
|
|
52
|
+
}
|
|
53
|
+
DocumentError::NotDocumentsSupplied => NotDocumentsSuppliedError::new().into(),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
use thiserror::Error;
|
|
2
|
+
|
|
3
|
+
use super::*;
|
|
4
|
+
|
|
5
|
+
#[wasm_bindgen]
|
|
6
|
+
#[derive(Error, Debug)]
|
|
7
|
+
#[error("No documents were supplied to state transition")]
|
|
8
|
+
pub struct NotDocumentsSuppliedError {}
|
|
9
|
+
|
|
10
|
+
#[wasm_bindgen]
|
|
11
|
+
impl NotDocumentsSuppliedError {
|
|
12
|
+
#[wasm_bindgen(constructor)]
|
|
13
|
+
pub fn new() -> Self {
|
|
14
|
+
NotDocumentsSuppliedError {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
impl Default for NotDocumentsSuppliedError {
|
|
19
|
+
fn default() -> Self {
|
|
20
|
+
Self::new()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
use std::convert::TryInto;
|
|
2
|
+
|
|
3
|
+
use serde::{Deserialize, Serialize};
|
|
4
|
+
use wasm_bindgen::prelude::*;
|
|
5
|
+
|
|
6
|
+
use dpp::document::Document;
|
|
7
|
+
|
|
8
|
+
use crate::errors::{from_dpp_err, RustConversionError};
|
|
9
|
+
use crate::identifier::IdentifierWrapper;
|
|
10
|
+
use crate::with_js_error;
|
|
11
|
+
use crate::{DataContractWasm, MetadataWasm};
|
|
12
|
+
|
|
13
|
+
pub mod errors;
|
|
14
|
+
pub mod state_transition;
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_name=Document)]
|
|
17
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
18
|
+
pub struct DocumentWasm(Document);
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_class=Document)]
|
|
21
|
+
impl DocumentWasm {
|
|
22
|
+
#[wasm_bindgen(js_name=getProtocolVersion)]
|
|
23
|
+
pub fn get_protocol_version(&self) -> u32 {
|
|
24
|
+
self.0.protocol_version
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen(js_name=getId)]
|
|
28
|
+
pub fn get_id(&self) -> IdentifierWrapper {
|
|
29
|
+
self.0.id.clone().into()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getType)]
|
|
33
|
+
pub fn get_type(&self) -> String {
|
|
34
|
+
self.0.document_type.clone()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[wasm_bindgen(js_name=getDataContractId)]
|
|
38
|
+
pub fn get_data_contract_id(&self) -> IdentifierWrapper {
|
|
39
|
+
self.0.data_contract_id.clone().into()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#[wasm_bindgen(js_name=getDataContract)]
|
|
43
|
+
pub fn get_data_contract(&self) -> DataContractWasm {
|
|
44
|
+
self.0.data_contract.clone().into()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#[wasm_bindgen(js_name=getOwnerId)]
|
|
48
|
+
pub fn get_owner_id(&self) -> IdentifierWrapper {
|
|
49
|
+
self.0.owner_id.clone().into()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[wasm_bindgen(js_name=setRevision)]
|
|
53
|
+
pub fn set_revision(&mut self, rev: u32) {
|
|
54
|
+
self.0.revision = rev
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[wasm_bindgen(js_name=getRevision)]
|
|
58
|
+
pub fn get_revision(&self) -> u32 {
|
|
59
|
+
self.0.revision
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[wasm_bindgen(js_name=setEntropy)]
|
|
63
|
+
pub fn set_entropy(&mut self, e: Vec<u8>) -> Result<(), JsValue> {
|
|
64
|
+
let entropy: [u8; 32] = e.try_into().map_err(|_| {
|
|
65
|
+
RustConversionError::Error(String::from(
|
|
66
|
+
"unable to turn the data into 32 bytes array of bytes",
|
|
67
|
+
))
|
|
68
|
+
.to_js_value()
|
|
69
|
+
})?;
|
|
70
|
+
self.0.entropy = entropy;
|
|
71
|
+
Ok(())
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#[wasm_bindgen(js_name=getEntropy)]
|
|
75
|
+
pub fn get_entropy(&mut self) -> Vec<u8> {
|
|
76
|
+
self.0.entropy.to_vec()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#[wasm_bindgen(js_name=setData)]
|
|
80
|
+
pub fn set_data(&mut self, d: JsValue) -> Result<(), JsValue> {
|
|
81
|
+
self.0.data = with_js_error!(serde_wasm_bindgen::from_value(d))?;
|
|
82
|
+
Ok(())
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#[wasm_bindgen(js_name=getData)]
|
|
86
|
+
pub fn get_data(&mut self) -> Result<JsValue, JsValue> {
|
|
87
|
+
with_js_error!(serde_wasm_bindgen::to_value(&self.0.data))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#[wasm_bindgen(js_name=set)]
|
|
91
|
+
pub fn set(&mut self, _path: String, _d: JsValue) {
|
|
92
|
+
// TODO use lodash via extern
|
|
93
|
+
unimplemented!()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#[wasm_bindgen(js_name=get)]
|
|
97
|
+
pub fn get(&mut self, _path: String) -> JsValue {
|
|
98
|
+
// TODO use lodash via extern
|
|
99
|
+
unimplemented!()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[wasm_bindgen(js_name=setCreatedAt)]
|
|
103
|
+
pub fn set_created_at(&mut self, ts: i64) {
|
|
104
|
+
self.0.created_at = Some(ts);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#[wasm_bindgen(js_name=setUpdatedAt)]
|
|
108
|
+
pub fn set_updated_at(&mut self, ts: i64) {
|
|
109
|
+
self.0.updated_at = Some(ts);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#[wasm_bindgen(js_name=getCreatedAt)]
|
|
113
|
+
pub fn get_created_at(&self) -> Option<i64> {
|
|
114
|
+
self.0.created_at
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#[wasm_bindgen(js_name=getUpdatedAt)]
|
|
118
|
+
pub fn get_updated_at(&self) -> Option<i64> {
|
|
119
|
+
self.0.updated_at
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#[wasm_bindgen(js_name=getMetadata)]
|
|
123
|
+
pub fn get_metadata(&self) -> Option<MetadataWasm> {
|
|
124
|
+
self.0.metadata.clone().map(Into::into)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#[wasm_bindgen(js_name=setMetadata)]
|
|
128
|
+
pub fn set_metadata(&mut self, metadata: MetadataWasm) {
|
|
129
|
+
self.0.metadata = Some(metadata.into());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#[wasm_bindgen(js_name=toObject)]
|
|
133
|
+
pub fn to_object(&self) -> Result<JsValue, JsValue> {
|
|
134
|
+
with_js_error!(serde_wasm_bindgen::to_value(&self.0))
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#[wasm_bindgen(js_name=toJSON)]
|
|
138
|
+
pub fn to_json(&self) -> Result<JsValue, JsValue> {
|
|
139
|
+
self.to_object()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#[wasm_bindgen(js_name=toBuffer)]
|
|
143
|
+
pub fn to_buffer(&self) -> Result<Vec<u8>, JsValue> {
|
|
144
|
+
let buffer = self.0.to_buffer().map_err(from_dpp_err)?;
|
|
145
|
+
Ok(buffer)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#[wasm_bindgen(js_name=hash)]
|
|
149
|
+
pub fn hash(&self) -> Result<Vec<u8>, JsValue> {
|
|
150
|
+
self.0.hash().map_err(from_dpp_err)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
impl From<Document> for DocumentWasm {
|
|
155
|
+
fn from(d: Document) -> Self {
|
|
156
|
+
DocumentWasm(d)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
use dpp::document::document_transition::DocumentCreateTransition;
|
|
2
|
+
use wasm_bindgen::prelude::*;
|
|
3
|
+
|
|
4
|
+
#[wasm_bindgen(js_name=DocumentCreateTransition)]
|
|
5
|
+
#[derive(Debug, Clone)]
|
|
6
|
+
pub struct DocumentCreateTransitionWasm {
|
|
7
|
+
inner: DocumentCreateTransition,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl From<DocumentCreateTransition> for DocumentCreateTransitionWasm {
|
|
11
|
+
fn from(v: DocumentCreateTransition) -> Self {
|
|
12
|
+
Self { inner: v }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_class=DocumentCreateTransition)]
|
|
17
|
+
impl DocumentCreateTransitionWasm {
|
|
18
|
+
#[wasm_bindgen(js_name=getAction)]
|
|
19
|
+
pub fn action(&self) -> u8 {
|
|
20
|
+
self.inner.base.action as u8
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
use dpp::document::document_transition::DocumentDeleteTransition;
|
|
2
|
+
use wasm_bindgen::prelude::*;
|
|
3
|
+
|
|
4
|
+
#[wasm_bindgen(js_name=DocumentDeleteTransition)]
|
|
5
|
+
#[derive(Debug, Clone)]
|
|
6
|
+
pub struct DocumentDeleteTransitionWasm {
|
|
7
|
+
inner: DocumentDeleteTransition,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl From<DocumentDeleteTransition> for DocumentDeleteTransitionWasm {
|
|
11
|
+
fn from(v: DocumentDeleteTransition) -> Self {
|
|
12
|
+
Self { inner: v }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_class=DocumentDeleteTransition)]
|
|
17
|
+
impl DocumentDeleteTransitionWasm {
|
|
18
|
+
#[wasm_bindgen(js_name=getAction)]
|
|
19
|
+
pub fn action(&self) -> u8 {
|
|
20
|
+
self.inner.base.action as u8
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
use dpp::document::document_transition::DocumentReplaceTransition;
|
|
2
|
+
use wasm_bindgen::prelude::*;
|
|
3
|
+
|
|
4
|
+
#[wasm_bindgen(js_name=DocumentTransition)]
|
|
5
|
+
#[derive(Debug, Clone)]
|
|
6
|
+
pub struct DocumentReplaceTransitionWasm {
|
|
7
|
+
inner: DocumentReplaceTransition,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl From<DocumentReplaceTransition> for DocumentReplaceTransitionWasm {
|
|
11
|
+
fn from(v: DocumentReplaceTransition) -> Self {
|
|
12
|
+
Self { inner: v }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_class=DocumentTransition)]
|
|
17
|
+
impl DocumentReplaceTransitionWasm {
|
|
18
|
+
#[wasm_bindgen(js_name=getAction)]
|
|
19
|
+
pub fn action(&self) -> u8 {
|
|
20
|
+
self.inner.base.action as u8
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
mod document_create_transition;
|
|
2
|
+
mod document_delete_transition;
|
|
3
|
+
mod document_update_transition;
|
|
4
|
+
|
|
5
|
+
pub use document_create_transition::*;
|
|
6
|
+
pub use document_delete_transition::*;
|
|
7
|
+
pub use document_update_transition::*;
|
|
8
|
+
|
|
9
|
+
use dpp::prelude::DocumentTransition;
|
|
10
|
+
use wasm_bindgen::prelude::*;
|
|
11
|
+
|
|
12
|
+
pub fn from_document_transition_to_js_value(document_transition: DocumentTransition) -> JsValue {
|
|
13
|
+
match document_transition {
|
|
14
|
+
DocumentTransition::Create(create_transition) => {
|
|
15
|
+
DocumentCreateTransitionWasm::from(create_transition).into()
|
|
16
|
+
}
|
|
17
|
+
DocumentTransition::Replace(replace_transition) => {
|
|
18
|
+
DocumentReplaceTransitionWasm::from(replace_transition).into()
|
|
19
|
+
}
|
|
20
|
+
DocumentTransition::Delete(delete_transition) => {
|
|
21
|
+
DocumentDeleteTransitionWasm::from(delete_transition).into()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pub mod document_transition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pub mod document_batch_transition;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
#[wasm_bindgen(js_name=DataContractHaveNewUniqueIndexError)]
|
|
4
|
+
pub struct DataContractHaveNewUniqueIndexErrorWasm {
|
|
5
|
+
document_type: String,
|
|
6
|
+
index_name: String,
|
|
7
|
+
code: u32,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl DataContractHaveNewUniqueIndexErrorWasm {
|
|
11
|
+
pub fn new(document_type: String, index_name: String, code: u32) -> Self {
|
|
12
|
+
DataContractHaveNewUniqueIndexErrorWasm {
|
|
13
|
+
document_type,
|
|
14
|
+
index_name,
|
|
15
|
+
code,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_class=DataContractHaveNewUniqueIndexError)]
|
|
21
|
+
impl DataContractHaveNewUniqueIndexErrorWasm {
|
|
22
|
+
#[wasm_bindgen(js_name=getDocumentType)]
|
|
23
|
+
pub fn get_document_type(&self) -> String {
|
|
24
|
+
self.document_type.clone()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen(js_name=getIndexName)]
|
|
28
|
+
pub fn get_index_name(&self) -> String {
|
|
29
|
+
self.index_name.clone()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
33
|
+
pub fn get_code(&self) -> u32 {
|
|
34
|
+
self.code
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
#[wasm_bindgen(js_name=DataContractImmutablePropertiesUpdateError)]
|
|
4
|
+
pub struct DataContractImmutablePropertiesUpdateErrorWasm {
|
|
5
|
+
operation: String,
|
|
6
|
+
field_path: String,
|
|
7
|
+
code: u32,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl DataContractImmutablePropertiesUpdateErrorWasm {
|
|
11
|
+
pub fn new(operation: String, field_path: String, code: u32) -> Self {
|
|
12
|
+
DataContractImmutablePropertiesUpdateErrorWasm {
|
|
13
|
+
operation,
|
|
14
|
+
field_path,
|
|
15
|
+
code,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_class=DataContractImmutablePropertiesUpdateError)]
|
|
21
|
+
impl DataContractImmutablePropertiesUpdateErrorWasm {
|
|
22
|
+
#[wasm_bindgen(js_name=getOperation)]
|
|
23
|
+
pub fn get_operation(&self) -> String {
|
|
24
|
+
self.operation.clone()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen(js_name=getFieldPath)]
|
|
28
|
+
pub fn get_field_path(&self) -> String {
|
|
29
|
+
self.field_path.clone()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
33
|
+
pub fn get_code(&self) -> u32 {
|
|
34
|
+
self.code
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
#[wasm_bindgen(js_name=DataContractInvalidIndexDefinitionUpdateError)]
|
|
4
|
+
pub struct DataContractInvalidIndexDefinitionUpdateErrorWasm {
|
|
5
|
+
document_type: String,
|
|
6
|
+
index_name: String,
|
|
7
|
+
code: u32,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl DataContractInvalidIndexDefinitionUpdateErrorWasm {
|
|
11
|
+
pub fn new(document_type: String, index_name: String, code: u32) -> Self {
|
|
12
|
+
DataContractInvalidIndexDefinitionUpdateErrorWasm {
|
|
13
|
+
document_type,
|
|
14
|
+
index_name,
|
|
15
|
+
code,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_class=DataContractInvalidIndexDefinitionUpdateError)]
|
|
21
|
+
impl DataContractInvalidIndexDefinitionUpdateErrorWasm {
|
|
22
|
+
#[wasm_bindgen(js_name=getDocumentType)]
|
|
23
|
+
pub fn get_document_type(&self) -> String {
|
|
24
|
+
self.document_type.clone()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen(js_name=getIndexName)]
|
|
28
|
+
pub fn get_index_name(&self) -> String {
|
|
29
|
+
self.index_name.clone()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
33
|
+
pub fn get_code(&self) -> u32 {
|
|
34
|
+
self.code
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
#[wasm_bindgen(js_name=DataContractMaxDepthError)]
|
|
4
|
+
pub struct DataContractMaxDepthErrorWasm {
|
|
5
|
+
depth: usize,
|
|
6
|
+
code: u32,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
impl DataContractMaxDepthErrorWasm {
|
|
10
|
+
pub fn new(depth: usize, code: u32) -> Self {
|
|
11
|
+
DataContractMaxDepthErrorWasm { depth, code }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[wasm_bindgen(js_class=DataContractMaxDepthError)]
|
|
16
|
+
impl DataContractMaxDepthErrorWasm {
|
|
17
|
+
#[wasm_bindgen(js_name=getDepth)]
|
|
18
|
+
pub fn get_expected_version(&self) -> usize {
|
|
19
|
+
self.depth
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
23
|
+
pub fn get_code(&self) -> u32 {
|
|
24
|
+
self.code
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/errors/consensus/basic/data_contract/data_contract_unique_indices_changed_error.rs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
use wasm_bindgen::prelude::*;
|
|
2
|
+
|
|
3
|
+
#[wasm_bindgen(js_name=DataContractUniqueIndicesChangedError)]
|
|
4
|
+
pub struct DataContractUniqueIndicesChangedErrorWasm {
|
|
5
|
+
document_type: String,
|
|
6
|
+
index_name: String,
|
|
7
|
+
code: u32,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl DataContractUniqueIndicesChangedErrorWasm {
|
|
11
|
+
pub fn new(document_type: String, index_name: String, code: u32) -> Self {
|
|
12
|
+
DataContractUniqueIndicesChangedErrorWasm {
|
|
13
|
+
document_type,
|
|
14
|
+
index_name,
|
|
15
|
+
code,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_class=DataContractUniqueIndicesChangedError)]
|
|
21
|
+
impl DataContractUniqueIndicesChangedErrorWasm {
|
|
22
|
+
#[wasm_bindgen(js_name=getDocumentType)]
|
|
23
|
+
pub fn get_document_type(&self) -> String {
|
|
24
|
+
self.document_type.clone()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen(js_name=getIndexName)]
|
|
28
|
+
pub fn get_index_name(&self) -> String {
|
|
29
|
+
self.index_name.clone()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
33
|
+
pub fn get_code(&self) -> u32 {
|
|
34
|
+
self.code
|
|
35
|
+
}
|
|
36
|
+
}
|