@dashevo/wasm-dpp 4.1.1 → 4.2.0-beta.2

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.
Files changed (26) hide show
  1. package/Cargo.toml +2 -2
  2. package/dist/wasm/wasm_dpp.d.ts +1553 -1065
  3. package/dist/wasm/wasm_dpp.js +290 -66
  4. package/dist/wasm/wasm_dpp_bg.js +1 -1
  5. package/lib/wasm/wasm_dpp.d.ts +1553 -1065
  6. package/package.json +2 -2
  7. package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +3 -2
  8. package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +3 -2
  9. package/src/document/factory.rs +1 -1
  10. package/src/document/state_transition/batch_transition/document_transition/mod.rs +9 -0
  11. package/src/errors/consensus/basic/identity/contract_group_bound_key_not_allowed_in_shielded_identity_creation_error.rs +36 -0
  12. package/src/errors/consensus/basic/identity/mod.rs +2 -0
  13. package/src/errors/consensus/consensus_error.rs +158 -2
  14. package/src/errors/consensus/deserialize.rs +2 -2
  15. package/src/errors/consensus/signature/contract_bounded_key_non_batch_error.rs +29 -0
  16. package/src/errors/consensus/signature/contract_bounded_key_out_of_bounds_error.rs +29 -0
  17. package/src/errors/consensus/signature/mod.rs +6 -0
  18. package/src/errors/consensus/state/document/mod.rs +2 -0
  19. package/src/errors/consensus/state/document/referenced_entity_not_found_error.rs +44 -0
  20. package/src/identity/identity.rs +3 -2
  21. package/src/identity/identity_public_key/mod.rs +3 -2
  22. package/src/identity/mod.rs +1 -1
  23. package/src/lib.rs +4 -0
  24. package/src/state_transition/state_transition_factory.rs +6 -1
  25. package/src/utils.rs +2 -2
  26. package/src/validation/validation_result.rs +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/wasm-dpp",
3
- "version": "4.1.1",
3
+ "version": "4.2.0-beta.2",
4
4
  "description": "The JavaScript implementation of the Dash Platform Protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "@babel/core": "^7.26.10",
45
45
  "@babel/preset-env": "^7.26.9",
46
46
  "@dashevo/dashcore-lib": "~0.22.0",
47
- "@dashevo/dpns-contract": "4.1.1",
47
+ "@dashevo/dpns-contract": "4.2.0-beta.2",
48
48
  "@types/bs58": "^4.0.1",
49
49
  "@types/node": "^20.10.0",
50
50
  "@yarnpkg/pnpify": "^4.0.0-rc.42",
@@ -7,7 +7,7 @@ use crate::errors::protocol_error::from_protocol_error;
7
7
  use dpp::errors::consensus::signature::SignatureError;
8
8
  use dpp::errors::consensus::ConsensusError;
9
9
 
10
- use dpp::serialization::{PlatformDeserializable, PlatformSerializable};
10
+ use dpp::serialization::{PlatformDeserializableUntrusted, PlatformSerializable};
11
11
  use dpp::state_transition::data_contract_create_transition::accessors::DataContractCreateTransitionAccessorsV0;
12
12
  use dpp::state_transition::data_contract_create_transition::DataContractCreateTransition;
13
13
  use dpp::state_transition::StateTransitionHasUserFeeIncrease;
@@ -169,7 +169,8 @@ impl DataContractCreateTransitionWasm {
169
169
  #[wasm_bindgen(js_name=fromBuffer)]
170
170
  pub fn from_buffer(buffer: Vec<u8>) -> Result<DataContractCreateTransitionWasm, JsValue> {
171
171
  let state_transition: StateTransition =
172
- PlatformDeserializable::deserialize_from_bytes(&buffer).with_js_error()?;
172
+ PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(&buffer)
173
+ .with_js_error()?;
173
174
  match state_transition {
174
175
  StateTransition::DataContractCreate(dct) => Ok(dct.into()),
175
176
  _ => Err(JsValue::from_str("Invalid state transition type")),
@@ -4,7 +4,7 @@
4
4
 
5
5
  use dpp::consensus::ConsensusError;
6
6
  use dpp::serialization::ValueConvertible;
7
- use dpp::serialization::{PlatformDeserializable, PlatformSerializable};
7
+ use dpp::serialization::{PlatformDeserializableUntrusted, PlatformSerializable};
8
8
  use dpp::state_transition::data_contract_update_transition::accessors::DataContractUpdateTransitionAccessorsV0;
9
9
  use dpp::state_transition::data_contract_update_transition::DataContractUpdateTransition;
10
10
  use dpp::state_transition::StateTransition;
@@ -164,7 +164,8 @@ impl DataContractUpdateTransitionWasm {
164
164
  #[wasm_bindgen(js_name=fromBuffer)]
165
165
  pub fn from_buffer(buffer: Vec<u8>) -> Result<DataContractUpdateTransitionWasm, JsValue> {
166
166
  let state_transition: StateTransition =
167
- PlatformDeserializable::deserialize_from_bytes(&buffer).with_js_error()?;
167
+ PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(&buffer)
168
+ .with_js_error()?;
168
169
  match state_transition {
169
170
  StateTransition::DataContractUpdate(dct) => Ok(dct.into()),
170
171
  _ => Err(JsValue::from_str("Invalid state transition type")),
@@ -145,7 +145,7 @@ impl DocumentFactoryWASM {
145
145
 
146
146
  let documents_by_action = extract_documents_by_action(documents)?;
147
147
 
148
- for (_, documents) in documents_by_action.iter() {
148
+ for documents in documents_by_action.values() {
149
149
  for document in documents.iter() {
150
150
  if !contract_ids_to_check.contains(&document.data_contract().id()) {
151
151
  return Err(JsValue::from_str(
@@ -23,6 +23,7 @@ use dpp::state_transition::batch_transition::document_replace_transition::v0::v0
23
23
  use dpp::state_transition::batch_transition::batched_transition::document_purchase_transition::v0::v0_methods::DocumentPurchaseTransitionV0Methods;
24
24
  use dpp::state_transition::batch_transition::batched_transition::document_transfer_transition::v0::v0_methods::DocumentTransferTransitionV0Methods;
25
25
  use dpp::state_transition::batch_transition::batched_transition::document_update_price_transition::v0::v0_methods::DocumentUpdatePriceTransitionV0Methods;
26
+ use dpp::state_transition::batch_transition::batched_transition::document_index_only_delete_transition::v0::v0_methods::DocumentIndexOnlyDeleteTransitionV0Methods;
26
27
  use dpp::state_transition::batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods;
27
28
  use crate::{
28
29
  buffer::Buffer,
@@ -67,6 +68,12 @@ impl DocumentTransitionWasm {
67
68
  DocumentTransition::Transfer(_) => JsValue::null(),
68
69
  DocumentTransition::UpdatePrice(_) => JsValue::null(),
69
70
  DocumentTransition::Purchase(_) => JsValue::null(),
71
+ DocumentTransition::IndexOnlyDelete(index_only_delete) => {
72
+ let json_value = index_only_delete.data().to_json_value().unwrap();
73
+ json_value
74
+ .serialize(&serde_wasm_bindgen::Serializer::json_compatible())
75
+ .unwrap()
76
+ }
70
77
  }
71
78
  }
72
79
 
@@ -110,6 +117,7 @@ impl DocumentTransitionWasm {
110
117
  DocumentTransition::Transfer(_) => None,
111
118
  DocumentTransition::UpdatePrice(update_price) => Some(update_price.price()),
112
119
  DocumentTransition::Purchase(purchase) => Some(purchase.price()),
120
+ DocumentTransition::IndexOnlyDelete(_) => None,
113
121
  }
114
122
  }
115
123
 
@@ -122,6 +130,7 @@ impl DocumentTransitionWasm {
122
130
  DocumentTransition::Transfer(transfer) => Some(transfer.recipient_owner_id().into()),
123
131
  DocumentTransition::UpdatePrice(_) => None,
124
132
  DocumentTransition::Purchase(_) => None,
133
+ DocumentTransition::IndexOnlyDelete(_) => None,
125
134
  }
126
135
  }
127
136
 
@@ -0,0 +1,36 @@
1
+ use dpp::consensus::basic::identity::ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError;
2
+ use dpp::consensus::codes::ErrorWithCode;
3
+ use dpp::consensus::ConsensusError;
4
+
5
+ use wasm_bindgen::prelude::*;
6
+
7
+ #[wasm_bindgen(js_name=ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError)]
8
+ pub struct ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm {
9
+ inner: ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError,
10
+ }
11
+
12
+ impl From<&ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError>
13
+ for ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm
14
+ {
15
+ fn from(e: &ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError) -> Self {
16
+ Self { inner: e.clone() }
17
+ }
18
+ }
19
+
20
+ #[wasm_bindgen(js_class=ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError)]
21
+ impl ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm {
22
+ #[wasm_bindgen(js_name=getKeyId)]
23
+ pub fn get_key_id(&self) -> u32 {
24
+ self.inner.key_id()
25
+ }
26
+
27
+ #[wasm_bindgen(js_name=getCode)]
28
+ pub fn get_code(&self) -> u32 {
29
+ ConsensusError::from(self.inner.clone()).code()
30
+ }
31
+
32
+ #[wasm_bindgen(getter)]
33
+ pub fn message(&self) -> String {
34
+ self.inner.to_string()
35
+ }
36
+ }
@@ -1,3 +1,4 @@
1
+ mod contract_group_bound_key_not_allowed_in_shielded_identity_creation_error;
1
2
  mod duplicated_identity_public_key_error;
2
3
  mod duplicated_identity_public_key_id_error;
3
4
  mod identity_asset_lock_proof_locked_transaction_mismatch_error;
@@ -28,6 +29,7 @@ mod missing_master_public_key_error;
28
29
  mod missing_public_key_error;
29
30
  mod not_implemented_credit_withdrawal_transition_pooling_error;
30
31
 
32
+ pub use contract_group_bound_key_not_allowed_in_shielded_identity_creation_error::*;
31
33
  pub use duplicated_identity_public_key_error::*;
32
34
  pub use duplicated_identity_public_key_id_error::*;
33
35
  pub use identity_asset_lock_proof_locked_transaction_mismatch_error::*;
@@ -1,3 +1,6 @@
1
+ use super::signature::ContractBoundedKeyNonBatchErrorWasm;
2
+ use super::signature::ContractBoundedKeyOutOfBoundsErrorWasm;
3
+ use crate::errors::consensus::basic::identity::ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm;
1
4
  use crate::errors::consensus::basic::{
2
5
  IncompatibleProtocolVersionErrorWasm, InvalidIdentifierErrorWasm,
3
6
  InvalidSignaturePublicKeyPurposeErrorWasm, JsonSchemaErrorWasm,
@@ -34,6 +37,7 @@ use crate::errors::consensus::state::identity::{
34
37
  };
35
38
  use dpp::consensus::basic::decode::VersionError;
36
39
  use dpp::consensus::basic::BasicError::{
40
+ ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError,
37
41
  DuplicatedIdentityPublicKeyBasicError, DuplicatedIdentityPublicKeyIdBasicError,
38
42
  IdentityAssetLockProofLockedTransactionMismatchError,
39
43
  IdentityAssetLockStateTransitionReplayError, IdentityAssetLockTransactionIsNotFoundError,
@@ -62,25 +66,50 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{
62
66
  DataTriggerConditionError, DataTriggerExecutionError, DataTriggerInvalidResultError,
63
67
  };
64
68
  use wasm_bindgen::{JsError, JsValue};
65
- use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, DecimalsOverLimitError, DuplicateKeywordsError, GroupExceedsMaxMembersError, GroupHasTooFewMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupRequiredPowerIsInvalidError, GroupTotalPowerLessThanRequiredError, InvalidDescriptionLengthError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidKeywordCharacterError, InvalidKeywordLengthError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, InvalidTokenLanguageCodeError, InvalidTokenNameCharacterError, InvalidTokenNameLengthError, MainGroupIsNotDefinedError, NewTokensDestinationIdentityOptionRequiredError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, RedundantDocumentPaidForByTokenWithContractId, TokenPaymentByBurningOnlyAllowedOnInternalTokenError, TooManyKeywordsError, UnknownDocumentActionTokenEffectError, UnknownDocumentCreationRestrictionModeError, UnknownGasFeesPaidByError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
69
+ use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, DataContractInvalidRequiredFieldsUpdateError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, DecimalsOverLimitError, DuplicateKeywordsError, GroupExceedsMaxMembersError, GroupHasTooFewMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupRequiredPowerIsInvalidError, GroupTotalPowerLessThanRequiredError, InvalidDescriptionLengthError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidKeywordCharacterError, InvalidKeywordLengthError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, InvalidTokenLanguageCodeError, InvalidTokenNameCharacterError, InvalidTokenNameLengthError, MainGroupIsNotDefinedError, NewTokensDestinationIdentityOptionRequiredError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, RedundantDocumentPaidForByTokenWithContractId, TokenPaymentByBurningOnlyAllowedOnInternalTokenError, TooManyKeywordsError, UnknownDocumentActionTokenEffectError, UnknownDocumentCreationRestrictionModeError, UnknownGasFeesPaidByError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
66
70
  use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
67
71
  use dpp::consensus::basic::group::GroupActionNotAllowedOnTransitionError;
68
72
  use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, InvalidKeyPurposeForContractBoundsError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
69
73
  use dpp::consensus::basic::overflow_error::OverflowError;
70
- use dpp::consensus::basic::token::{ChoosingTokenMintRecipientNotAllowedError, ContractHasNoTokensError, DestinationIdentityForTokenMintingNotSetError, InvalidActionIdError, InvalidTokenAmountError, InvalidTokenConfigUpdateNoChangeError, InvalidTokenIdError, InvalidTokenNoteTooBigError, InvalidTokenPositionError, MissingDefaultLocalizationError, TokenNoteOnlyAllowedWhenProposerError, TokenPricingScheduleEmptyError, TokenTransferToOurselfError, InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, InvalidTokenDistributionTimeIntervalTooShortError, InvalidTokenDistributionBlockIntervalTooShortError};
74
+ use dpp::consensus::basic::token::{ChoosingTokenMintRecipientNotAllowedError, ContractHasNoTokensError, DestinationIdentityForTokenMintingNotSetError, InvalidActionIdError, InvalidTokenAmountError, InvalidTokenConfigUpdateNoChangeError, InvalidTokenIdError, InvalidTokenNoteTooBigError, InvalidTokenPositionError, MissingDefaultLocalizationError, TokenNoteOnlyAllowedWhenProposerError, TokenPricingScheduleEmptyError, TokenTransferToOurselfError, InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, InvalidTokenDistributionTimeIntervalTooShortError, InvalidTokenDistributionBlockIntervalTooShortError, InvalidTokenDistributionEpochIntervalTooShortError};
71
75
  use dpp::consensus::state::data_contract::data_contract_not_found_error::DataContractNotFoundError;
72
76
  use dpp::consensus::state::data_contract::data_contract_update_action_not_allowed_error::DataContractUpdateActionNotAllowedError;
73
77
  use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError;
74
78
  use dpp::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError;
75
79
  use dpp::consensus::state::document::document_contest_document_with_same_id_already_present_error::DocumentContestDocumentWithSameIdAlreadyPresentError;
76
80
  use dpp::consensus::state::document::document_contest_identity_already_contestant::DocumentContestIdentityAlreadyContestantError;
81
+ use dpp::consensus::state::document::document_contest_index_mismatch_error::DocumentContestIndexMismatchError;
77
82
  use dpp::consensus::state::document::document_contest_not_joinable_error::DocumentContestNotJoinableError;
78
83
  use dpp::consensus::state::document::document_contest_not_paid_for_error::DocumentContestNotPaidForError;
84
+ use dpp::consensus::state::document::document_contest_not_required_error::DocumentContestNotRequiredError;
79
85
  use dpp::consensus::state::document::document_incorrect_purchase_price_error::DocumentIncorrectPurchasePriceError;
80
86
  use dpp::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError;
87
+ use dpp::consensus::basic::contract_group::{
88
+ ContractGroupMemberNotInContractError, ContractGroupMembershipsOverLimitError,
89
+ DuplicateContractGroupMembershipError,
90
+ InvalidContractGroupDescriptionLengthError, InvalidContractGroupNameLengthError,
91
+ InvalidContractGroupAdminsError, RedundantContractGroupMembershipError,
92
+ };
93
+ use dpp::consensus::state::contract_group::{
94
+ ContractGroupAdminNotFoundError, ContractGroupAlreadyExistsError, ContractGroupNotFoundError,
95
+ IdentityNotContractGroupOwnerOrAdminError,
96
+ };
81
97
  use dpp::consensus::state::group::{GroupActionAlreadyCompletedError, GroupActionAlreadySignedByIdentityError, GroupActionDoesNotExistError, IdentityMemberOfGroupNotFoundError, IdentityNotMemberOfGroupError, ModificationOfGroupActionMainParametersNotPermittedError};
82
98
  use dpp::consensus::state::identity::identity_for_token_configuration_not_found_error::IdentityInTokenConfigurationNotFoundError;
83
99
  use dpp::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError;
100
+ use dpp::consensus::basic::identity::{
101
+ IdentityKeyLimitsUpdateEmptyError, IdentityPublicKeyLimitsNotAllowedError,
102
+ IdentityPublicKeyLimitsNotAllowedInShieldedIdentityCreationError,
103
+ InvalidIdentityPublicKeyBudgetError,
104
+ };
105
+ use dpp::consensus::signature::{
106
+ PublicKeyBudgetExhaustedError, PublicKeyExpiredError,
107
+ PublicKeyWithLimitsCannotUpdateKeyLimitsError,
108
+ };
109
+ use dpp::consensus::state::identity::identity_public_key_already_expired_error::IdentityPublicKeyAlreadyExpiredError;
110
+ use dpp::consensus::state::identity::identity_public_key_limit_not_raised_error::IdentityPublicKeyLimitNotRaisedError;
111
+ use dpp::consensus::state::identity::identity_public_key_limit_not_set_error::IdentityPublicKeyLimitNotSetError;
112
+ use dpp::consensus::state::identity::identity_public_key_budget_exceeded_error::IdentityPublicKeyBudgetExceededError;
84
113
  use dpp::consensus::state::identity::identity_to_freeze_does_not_exist_error::IdentityToFreezeDoesNotExistError;
85
114
  use dpp::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError;
86
115
  use dpp::consensus::state::identity::missing_transfer_key_error::MissingTransferKeyError;
@@ -90,6 +119,14 @@ use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized
90
119
  use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError;
91
120
  use dpp::consensus::state::token::{IdentityDoesNotHaveEnoughTokenBalanceError, IdentityTokenAccountNotFrozenError, IdentityTokenAccountFrozenError, TokenIsPausedError, IdentityTokenAccountAlreadyFrozenError, UnauthorizedTokenActionError, TokenSettingMaxSupplyToLessThanCurrentSupplyError, TokenMintPastMaxSupplyError, NewTokensDestinationIdentityDoesNotExistError, NewAuthorizedActionTakerIdentityDoesNotExistError, NewAuthorizedActionTakerGroupDoesNotExistError, NewAuthorizedActionTakerMainGroupNotSetError, InvalidGroupPositionError, TokenAlreadyPausedError, TokenNotPausedError, InvalidTokenClaimPropertyMismatch, InvalidTokenClaimNoCurrentRewards, InvalidTokenClaimWrongClaimant, TokenTransferRecipientIdentityNotExistError, PreProgrammedDistributionTimestampInPastError, IdentityHasNotAgreedToPayRequiredTokenAmountError, RequiredTokenPaymentInfoNotSetError, IdentityTryingToPayWithWrongTokenError, TokenDirectPurchaseUserPriceTooLow, TokenAmountUnderMinimumSaleAmount, TokenNotForDirectSale, InvalidTokenPositionStateError};
92
121
  use dpp::consensus::state::address_funds::{AddressDoesNotExistError, AddressInvalidNonceError, AddressNotEnoughFundsError, AddressesNotEnoughFundsError};
122
+ use dpp::consensus::state::document::referenced_document_type_deletable_error::ReferencedDocumentTypeDeletableError;
123
+ use dpp::consensus::state::document::referenced_identity_key_disabled_error::ReferencedIdentityKeyDisabledError;
124
+ use dpp::consensus::state::document::referenced_identity_key_not_found_error::ReferencedIdentityKeyNotFoundError;
125
+ use dpp::consensus::state::document::referenced_document_property_agreement_invalid_error::ReferencedDocumentPropertyAgreementInvalidError;
126
+ use dpp::consensus::state::document::referenced_document_property_mismatch_error::ReferencedDocumentPropertyMismatchError;
127
+ use dpp::consensus::state::document::document_immutable_property_changed_error::DocumentImmutablePropertyChangedError;
128
+ use dpp::consensus::state::document::referenced_key_id_property_invalid_error::ReferencedKeyIdPropertyInvalidError;
129
+ use dpp::consensus::state::document::referenced_document_type_not_found_error::ReferencedDocumentTypeNotFoundError;
93
130
  use dpp::consensus::state::shielded::insufficient_pool_notes_error::InsufficientPoolNotesError;
94
131
  use dpp::consensus::state::shielded::insufficient_shielded_fee_error::InsufficientShieldedFeeError;
95
132
  use dpp::consensus::state::shielded::invalid_anchor_error::InvalidAnchorError;
@@ -136,6 +173,7 @@ use crate::errors::consensus::state::document::{
136
173
  DocumentAlreadyPresentErrorWasm, DocumentNotFoundErrorWasm, DocumentOwnerIdMismatchErrorWasm,
137
174
  DocumentTimestampWindowViolationErrorWasm, DocumentTimestampsMismatchErrorWasm,
138
175
  DuplicateUniqueIndexErrorWasm, InvalidDocumentRevisionErrorWasm,
176
+ ReferencedEntityNotFoundErrorWasm,
139
177
  };
140
178
  use crate::errors::consensus::state::identity::{
141
179
  IdentityAlreadyExistsErrorWasm, IdentityPublicKeyIsDisabledErrorWasm,
@@ -325,6 +363,12 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
325
363
  StateError::DocumentContestNotPaidForError(e) => {
326
364
  generic_consensus_error!(DocumentContestNotPaidForError, e).into()
327
365
  }
366
+ StateError::DocumentContestIndexMismatchError(e) => {
367
+ generic_consensus_error!(DocumentContestIndexMismatchError, e).into()
368
+ }
369
+ StateError::DocumentContestNotRequiredError(e) => {
370
+ generic_consensus_error!(DocumentContestNotRequiredError, e).into()
371
+ }
328
372
  StateError::RecipientIdentityDoesNotExistError(e) => {
329
373
  generic_consensus_error!(RecipientIdentityDoesNotExistError, e).into()
330
374
  }
@@ -463,6 +507,57 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
463
507
  StateError::InsufficientShieldedFeeError(e) => {
464
508
  generic_consensus_error!(InsufficientShieldedFeeError, e).into()
465
509
  }
510
+ StateError::ReferencedEntityNotFoundError(e) => {
511
+ ReferencedEntityNotFoundErrorWasm::from(e).into()
512
+ }
513
+ StateError::ReferencedDocumentTypeNotFoundError(e) => {
514
+ generic_consensus_error!(ReferencedDocumentTypeNotFoundError, e).into()
515
+ }
516
+ StateError::ReferencedDocumentTypeDeletableError(e) => {
517
+ generic_consensus_error!(ReferencedDocumentTypeDeletableError, e).into()
518
+ }
519
+ StateError::ReferencedIdentityKeyNotFoundError(e) => {
520
+ generic_consensus_error!(ReferencedIdentityKeyNotFoundError, e).into()
521
+ }
522
+ StateError::ReferencedIdentityKeyDisabledError(e) => {
523
+ generic_consensus_error!(ReferencedIdentityKeyDisabledError, e).into()
524
+ }
525
+ StateError::ReferencedKeyIdPropertyInvalidError(e) => {
526
+ generic_consensus_error!(ReferencedKeyIdPropertyInvalidError, e).into()
527
+ }
528
+ StateError::ReferencedDocumentPropertyAgreementInvalidError(e) => {
529
+ generic_consensus_error!(ReferencedDocumentPropertyAgreementInvalidError, e).into()
530
+ }
531
+ StateError::ReferencedDocumentPropertyMismatchError(e) => {
532
+ generic_consensus_error!(ReferencedDocumentPropertyMismatchError, e).into()
533
+ }
534
+ StateError::ContractGroupAlreadyExistsError(e) => {
535
+ generic_consensus_error!(ContractGroupAlreadyExistsError, e).into()
536
+ }
537
+ StateError::ContractGroupNotFoundError(e) => {
538
+ generic_consensus_error!(ContractGroupNotFoundError, e).into()
539
+ }
540
+ StateError::IdentityNotContractGroupOwnerOrAdminError(e) => {
541
+ generic_consensus_error!(IdentityNotContractGroupOwnerOrAdminError, e).into()
542
+ }
543
+ StateError::ContractGroupAdminNotFoundError(e) => {
544
+ generic_consensus_error!(ContractGroupAdminNotFoundError, e).into()
545
+ }
546
+ StateError::IdentityPublicKeyBudgetExceededError(e) => {
547
+ generic_consensus_error!(IdentityPublicKeyBudgetExceededError, e).into()
548
+ }
549
+ StateError::IdentityPublicKeyAlreadyExpiredError(e) => {
550
+ generic_consensus_error!(IdentityPublicKeyAlreadyExpiredError, e).into()
551
+ }
552
+ StateError::IdentityPublicKeyLimitNotSetError(e) => {
553
+ generic_consensus_error!(IdentityPublicKeyLimitNotSetError, e).into()
554
+ }
555
+ StateError::IdentityPublicKeyLimitNotRaisedError(e) => {
556
+ generic_consensus_error!(IdentityPublicKeyLimitNotRaisedError, e).into()
557
+ }
558
+ StateError::DocumentImmutablePropertyChangedError(e) => {
559
+ generic_consensus_error!(DocumentImmutablePropertyChangedError, e).into()
560
+ }
466
561
  }
467
562
  }
468
563
 
@@ -619,6 +714,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
619
714
  IdentityAssetLockTransactionTooManyInputsError(e) => {
620
715
  IdentityAssetLockTransactionTooManyInputsErrorWasm::from(e).into()
621
716
  }
717
+ ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError(e) => {
718
+ ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm::from(e).into()
719
+ }
622
720
  InvalidInstantAssetLockProofError(e) => {
623
721
  InvalidInstantAssetLockProofErrorWasm::from(e).into()
624
722
  }
@@ -877,6 +975,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
877
975
  generic_consensus_error!(InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, e)
878
976
  .into()
879
977
  }
978
+ BasicError::InvalidTokenDistributionEpochIntervalTooShortError(e) => {
979
+ generic_consensus_error!(InvalidTokenDistributionEpochIntervalTooShortError, e).into()
980
+ }
880
981
  BasicError::RedundantDocumentPaidForByTokenWithContractId(e) => {
881
982
  generic_consensus_error!(RedundantDocumentPaidForByTokenWithContractId, e).into()
882
983
  }
@@ -973,6 +1074,46 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
973
1074
  BasicError::TokenPricingScheduleEmptyError(e) => {
974
1075
  generic_consensus_error!(TokenPricingScheduleEmptyError, e).into()
975
1076
  }
1077
+ BasicError::DataContractInvalidRequiredFieldsUpdateError(e) => {
1078
+ generic_consensus_error!(DataContractInvalidRequiredFieldsUpdateError, e).into()
1079
+ }
1080
+ BasicError::ContractGroupMembershipsOverLimitError(e) => {
1081
+ generic_consensus_error!(ContractGroupMembershipsOverLimitError, e).into()
1082
+ }
1083
+ BasicError::DuplicateContractGroupMembershipError(e) => {
1084
+ generic_consensus_error!(DuplicateContractGroupMembershipError, e).into()
1085
+ }
1086
+ BasicError::RedundantContractGroupMembershipError(e) => {
1087
+ generic_consensus_error!(RedundantContractGroupMembershipError, e).into()
1088
+ }
1089
+ BasicError::ContractGroupMemberNotInContractError(e) => {
1090
+ generic_consensus_error!(ContractGroupMemberNotInContractError, e).into()
1091
+ }
1092
+ BasicError::InvalidContractGroupAdminsError(e) => {
1093
+ generic_consensus_error!(InvalidContractGroupAdminsError, e).into()
1094
+ }
1095
+ BasicError::InvalidContractGroupNameLengthError(e) => {
1096
+ generic_consensus_error!(InvalidContractGroupNameLengthError, e).into()
1097
+ }
1098
+ BasicError::InvalidContractGroupDescriptionLengthError(e) => {
1099
+ generic_consensus_error!(InvalidContractGroupDescriptionLengthError, e).into()
1100
+ }
1101
+ BasicError::IdentityPublicKeyLimitsNotAllowedError(e) => {
1102
+ generic_consensus_error!(IdentityPublicKeyLimitsNotAllowedError, e).into()
1103
+ }
1104
+ BasicError::InvalidIdentityPublicKeyBudgetError(e) => {
1105
+ generic_consensus_error!(InvalidIdentityPublicKeyBudgetError, e).into()
1106
+ }
1107
+ BasicError::IdentityPublicKeyLimitsNotAllowedInShieldedIdentityCreationError(e) => {
1108
+ generic_consensus_error!(
1109
+ IdentityPublicKeyLimitsNotAllowedInShieldedIdentityCreationError,
1110
+ e
1111
+ )
1112
+ .into()
1113
+ }
1114
+ BasicError::IdentityKeyLimitsUpdateEmptyError(e) => {
1115
+ generic_consensus_error!(IdentityKeyLimitsUpdateEmptyError, e).into()
1116
+ }
976
1117
  }
977
1118
  }
978
1119
 
@@ -1006,9 +1147,24 @@ fn from_signature_error(signature_error: &SignatureError) -> JsValue {
1006
1147
  SignatureError::InvalidSignaturePublicKeyPurposeError(err) => {
1007
1148
  InvalidSignaturePublicKeyPurposeErrorWasm::from(err).into()
1008
1149
  }
1150
+ SignatureError::ContractBoundedKeyNonBatchError(err) => {
1151
+ ContractBoundedKeyNonBatchErrorWasm::from(err).into()
1152
+ }
1153
+ SignatureError::ContractBoundedKeyOutOfBoundsError(err) => {
1154
+ ContractBoundedKeyOutOfBoundsErrorWasm::from(err).into()
1155
+ }
1009
1156
  SignatureError::UncompressedPublicKeyNotAllowedError(err) => {
1010
1157
  UncompressedPublicKeyNotAllowedErrorWasm::from(err).into()
1011
1158
  }
1159
+ SignatureError::PublicKeyBudgetExhaustedError(e) => {
1160
+ generic_consensus_error!(PublicKeyBudgetExhaustedError, e).into()
1161
+ }
1162
+ SignatureError::PublicKeyExpiredError(e) => {
1163
+ generic_consensus_error!(PublicKeyExpiredError, e).into()
1164
+ }
1165
+ SignatureError::PublicKeyWithLimitsCannotUpdateKeyLimitsError(e) => {
1166
+ generic_consensus_error!(PublicKeyWithLimitsCannotUpdateKeyLimitsError, e).into()
1167
+ }
1012
1168
  }
1013
1169
  }
1014
1170
 
@@ -1,12 +1,12 @@
1
1
  use crate::errors::consensus::consensus_error::from_consensus_error;
2
2
  use dpp::consensus::ConsensusError;
3
- use dpp::serialization::PlatformDeserializable;
3
+ use dpp::serialization::PlatformDeserializableUntrusted;
4
4
  use wasm_bindgen::prelude::wasm_bindgen;
5
5
  use wasm_bindgen::{JsError, JsValue};
6
6
 
7
7
  #[wasm_bindgen(js_name=deserializeConsensusError)]
8
8
  pub fn deserialize_consensus_error(bytes: Vec<u8>) -> Result<JsValue, JsError> {
9
- ConsensusError::deserialize_from_bytes(bytes.as_slice())
9
+ ConsensusError::deserialize_from_bytes_untrusted(bytes.as_slice())
10
10
  .map(from_consensus_error)
11
11
  .map_err(|e| e.into())
12
12
  }
@@ -0,0 +1,29 @@
1
+ use dpp::consensus::codes::ErrorWithCode;
2
+ use dpp::consensus::signature::ContractBoundedKeyNonBatchError;
3
+ use dpp::consensus::ConsensusError;
4
+
5
+ use wasm_bindgen::prelude::*;
6
+
7
+ #[wasm_bindgen(js_name=ContractBoundedKeyNonBatchError)]
8
+ pub struct ContractBoundedKeyNonBatchErrorWasm {
9
+ inner: ContractBoundedKeyNonBatchError,
10
+ }
11
+
12
+ impl From<&ContractBoundedKeyNonBatchError> for ContractBoundedKeyNonBatchErrorWasm {
13
+ fn from(e: &ContractBoundedKeyNonBatchError) -> Self {
14
+ Self { inner: e.clone() }
15
+ }
16
+ }
17
+
18
+ #[wasm_bindgen(js_class=ContractBoundedKeyNonBatchError)]
19
+ impl ContractBoundedKeyNonBatchErrorWasm {
20
+ #[wasm_bindgen(js_name=getCode)]
21
+ pub fn get_code(&self) -> u32 {
22
+ ConsensusError::from(self.inner.clone()).code()
23
+ }
24
+
25
+ #[wasm_bindgen(getter)]
26
+ pub fn message(&self) -> String {
27
+ self.inner.to_string()
28
+ }
29
+ }
@@ -0,0 +1,29 @@
1
+ use dpp::consensus::codes::ErrorWithCode;
2
+ use dpp::consensus::signature::ContractBoundedKeyOutOfBoundsError;
3
+ use dpp::consensus::ConsensusError;
4
+
5
+ use wasm_bindgen::prelude::*;
6
+
7
+ #[wasm_bindgen(js_name=ContractBoundedKeyOutOfBoundsError)]
8
+ pub struct ContractBoundedKeyOutOfBoundsErrorWasm {
9
+ inner: ContractBoundedKeyOutOfBoundsError,
10
+ }
11
+
12
+ impl From<&ContractBoundedKeyOutOfBoundsError> for ContractBoundedKeyOutOfBoundsErrorWasm {
13
+ fn from(e: &ContractBoundedKeyOutOfBoundsError) -> Self {
14
+ Self { inner: e.clone() }
15
+ }
16
+ }
17
+
18
+ #[wasm_bindgen(js_class=ContractBoundedKeyOutOfBoundsError)]
19
+ impl ContractBoundedKeyOutOfBoundsErrorWasm {
20
+ #[wasm_bindgen(js_name=getCode)]
21
+ pub fn get_code(&self) -> u32 {
22
+ ConsensusError::from(self.inner.clone()).code()
23
+ }
24
+
25
+ #[wasm_bindgen(getter)]
26
+ pub fn message(&self) -> String {
27
+ self.inner.to_string()
28
+ }
29
+ }
@@ -9,3 +9,9 @@ pub use basic_ecdsa_error::*;
9
9
  pub use identity_not_found_error::*;
10
10
  pub use signature_should_not_be_present_error::*;
11
11
  pub use uncompressed_public_key_not_allowed_error::*;
12
+
13
+ mod contract_bounded_key_non_batch_error;
14
+ pub use contract_bounded_key_non_batch_error::ContractBoundedKeyNonBatchErrorWasm;
15
+
16
+ mod contract_bounded_key_out_of_bounds_error;
17
+ pub use contract_bounded_key_out_of_bounds_error::ContractBoundedKeyOutOfBoundsErrorWasm;
@@ -6,6 +6,7 @@ mod document_timestamps_are_equal_error;
6
6
  mod document_timestamps_mismatch_error;
7
7
  mod duplicate_unique_index_error;
8
8
  mod invalid_document_revision_error;
9
+ mod referenced_entity_not_found_error;
9
10
 
10
11
  pub use document_already_present_error::*;
11
12
  pub use document_not_found_error::*;
@@ -15,3 +16,4 @@ pub use document_timestamps_are_equal_error::*;
15
16
  pub use document_timestamps_mismatch_error::*;
16
17
  pub use duplicate_unique_index_error::*;
17
18
  pub use invalid_document_revision_error::*;
19
+ pub use referenced_entity_not_found_error::*;
@@ -0,0 +1,44 @@
1
+ use crate::buffer::Buffer;
2
+ use dpp::consensus::codes::ErrorWithCode;
3
+ use dpp::consensus::state::document::referenced_entity_not_found_error::ReferencedEntityNotFoundError;
4
+ use dpp::consensus::ConsensusError;
5
+ use wasm_bindgen::prelude::*;
6
+
7
+ #[wasm_bindgen(js_name=ReferencedEntityNotFoundError)]
8
+ pub struct ReferencedEntityNotFoundErrorWasm {
9
+ inner: ReferencedEntityNotFoundError,
10
+ }
11
+
12
+ impl From<&ReferencedEntityNotFoundError> for ReferencedEntityNotFoundErrorWasm {
13
+ fn from(e: &ReferencedEntityNotFoundError) -> Self {
14
+ Self { inner: e.clone() }
15
+ }
16
+ }
17
+
18
+ #[wasm_bindgen(js_class=ReferencedEntityNotFoundError)]
19
+ impl ReferencedEntityNotFoundErrorWasm {
20
+ #[wasm_bindgen(js_name=getEntityId)]
21
+ pub fn entity_id(&self) -> Buffer {
22
+ Buffer::from_bytes(self.inner.entity_id().as_bytes())
23
+ }
24
+
25
+ #[wasm_bindgen(js_name=getEntityType)]
26
+ pub fn entity_type(&self) -> String {
27
+ self.inner.entity_type().to_string()
28
+ }
29
+
30
+ #[wasm_bindgen(js_name=getPath)]
31
+ pub fn path(&self) -> String {
32
+ self.inner.path().to_string()
33
+ }
34
+
35
+ #[wasm_bindgen(js_name=getCode)]
36
+ pub fn get_code(&self) -> u32 {
37
+ ConsensusError::from(self.inner.clone()).code()
38
+ }
39
+
40
+ #[wasm_bindgen(getter)]
41
+ pub fn message(&self) -> String {
42
+ self.inner.to_string()
43
+ }
44
+ }
@@ -10,7 +10,7 @@ use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV
10
10
  use dpp::identity::{Identity, IdentityPublicKey, KeyID};
11
11
  use dpp::metadata::Metadata;
12
12
  use dpp::platform_value::ReplacementType;
13
- use dpp::serialization::PlatformDeserializable;
13
+ use dpp::serialization::PlatformDeserializableUntrusted;
14
14
  use dpp::serialization::PlatformSerializable;
15
15
  use dpp::serialization::ValueConvertible;
16
16
  use dpp::version::PlatformVersion;
@@ -267,7 +267,8 @@ impl IdentityWasm {
267
267
  #[wasm_bindgen(js_name=fromBuffer)]
268
268
  pub fn from_buffer(buffer: Vec<u8>) -> Result<IdentityWasm, JsValue> {
269
269
  let identity: Identity =
270
- PlatformDeserializable::deserialize_from_bytes(buffer.as_slice()).with_js_error()?;
270
+ PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(buffer.as_slice())
271
+ .with_js_error()?;
271
272
  Ok(identity.into())
272
273
  }
273
274
  }
@@ -11,7 +11,7 @@ use dpp::identity::identity_public_key::accessors::v0::{
11
11
  use dpp::identity::identity_public_key::hash::IdentityPublicKeyHashMethodsV0;
12
12
  use dpp::identity::{IdentityPublicKey, KeyID, TimestampMillis};
13
13
  use dpp::platform_value::{BinaryData, ReplacementType};
14
- use dpp::serialization::{PlatformDeserializable, PlatformSerializable, ValueConvertible};
14
+ use dpp::serialization::{PlatformDeserializableUntrusted, PlatformSerializable, ValueConvertible};
15
15
  use dpp::ProtocolError;
16
16
 
17
17
  use dpp::version::PlatformVersion;
@@ -196,7 +196,8 @@ impl IdentityPublicKeyWasm {
196
196
  #[wasm_bindgen(js_name=fromBuffer)]
197
197
  pub fn from_buffer(buffer: Vec<u8>) -> Result<IdentityPublicKeyWasm, JsValue> {
198
198
  let key: IdentityPublicKey =
199
- PlatformDeserializable::deserialize_from_bytes(buffer.as_slice()).with_js_error()?;
199
+ PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(buffer.as_slice())
200
+ .with_js_error()?;
200
201
  Ok(key.into())
201
202
  }
202
203
  }
@@ -12,7 +12,7 @@ mod identity_public_key;
12
12
  // use dpp::identity::IdentityPublicKey;
13
13
  // use dpp::identity::{Identity, KeyID};
14
14
  // use dpp::metadata::Metadata;
15
- // use dpp::serialization::serialization_traits::{PlatformDeserializable, PlatformSerializable};
15
+ // use dpp::serialization::serialization_traits::{PlatformDeserializableUntrusted, PlatformSerializable};
16
16
  // use dpp::{ ProtocolError};
17
17
  //
18
18
  // use crate::identifier::IdentifierWrapper;
package/src/lib.rs CHANGED
@@ -1,3 +1,7 @@
1
+ // Same allowance the dpp crate root carries: the `ProtocolError` values
2
+ // threaded through these bindings are larger than clippy's default threshold.
3
+ #![allow(clippy::result_large_err)]
4
+
1
5
  extern crate core;
2
6
 
3
7
  pub use dash_platform_protocol::*;
@@ -84,9 +84,14 @@ impl StateTransitionFactoryWasm {
84
84
  | StateTransition::Unshield(_)
85
85
  | StateTransition::ShieldFromAssetLock(_)
86
86
  | StateTransition::ShieldedWithdrawal(_)
87
- | StateTransition::IdentityCreateFromShieldedPool(_) => Err(JsValue::from_str(
87
+ | StateTransition::IdentityCreateFromShieldedPool(_)
88
+ | StateTransition::ShieldFromIdentity(_)
89
+ | StateTransition::IdentityTopUpFromShieldedPool(_) => Err(JsValue::from_str(
88
90
  "shielded transitions are not yet supported in wasm-dpp StateTransitionFactory",
89
91
  )),
92
+ StateTransition::IdentityKeyLimitsUpdate(_) => Err(JsValue::from_str(
93
+ "identity key limits update transitions are not supported in wasm-dpp StateTransitionFactory; use wasm-dpp2",
94
+ )),
90
95
  },
91
96
  Err(dpp::ProtocolError::StateTransitionError(e)) => match e {
92
97
  StateTransitionError::InvalidStateTransitionError {