@dashevo/wasm-dpp 4.2.0-dev.1 → 4.2.0-dev.11
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 +2 -2
- package/dist/wasm/wasm_dpp.d.ts +1027 -893
- package/dist/wasm/wasm_dpp.js +111 -47
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +1027 -893
- package/package.json +2 -2
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +3 -2
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +3 -2
- package/src/document/factory.rs +1 -1
- package/src/document/state_transition/batch_transition/document_transition/mod.rs +9 -0
- package/src/errors/consensus/consensus_error.rs +40 -2
- package/src/errors/consensus/deserialize.rs +2 -2
- package/src/errors/consensus/state/document/mod.rs +2 -0
- package/src/errors/consensus/state/document/referenced_entity_not_found_error.rs +44 -0
- package/src/identity/identity.rs +3 -2
- package/src/identity/identity_public_key/mod.rs +3 -2
- package/src/identity/mod.rs +1 -1
- package/src/lib.rs +4 -0
- package/src/state_transition/state_transition_factory.rs +3 -1
- package/src/utils.rs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/wasm-dpp",
|
|
3
|
-
"version": "4.2.0-dev.
|
|
3
|
+
"version": "4.2.0-dev.11",
|
|
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.2.0-dev.
|
|
47
|
+
"@dashevo/dpns-contract": "4.2.0-dev.11",
|
|
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::{
|
|
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
|
-
|
|
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::{
|
|
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
|
-
|
|
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")),
|
package/src/document/factory.rs
CHANGED
|
@@ -145,7 +145,7 @@ impl DocumentFactoryWASM {
|
|
|
145
145
|
|
|
146
146
|
let documents_by_action = extract_documents_by_action(documents)?;
|
|
147
147
|
|
|
148
|
-
for
|
|
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
|
|
|
@@ -62,12 +62,12 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{
|
|
|
62
62
|
DataTriggerConditionError, DataTriggerExecutionError, DataTriggerInvalidResultError,
|
|
63
63
|
};
|
|
64
64
|
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};
|
|
65
|
+
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
66
|
use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
|
|
67
67
|
use dpp::consensus::basic::group::GroupActionNotAllowedOnTransitionError;
|
|
68
68
|
use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, InvalidKeyPurposeForContractBoundsError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
|
|
69
69
|
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};
|
|
70
|
+
use dpp::consensus::basic::token::{ChoosingTokenMintRecipientNotAllowedError, ContractHasNoTokensError, DestinationIdentityForTokenMintingNotSetError, InvalidActionIdError, InvalidTokenAmountError, InvalidTokenConfigUpdateNoChangeError, InvalidTokenIdError, InvalidTokenNoteTooBigError, InvalidTokenPositionError, MissingDefaultLocalizationError, TokenNoteOnlyAllowedWhenProposerError, TokenPricingScheduleEmptyError, TokenTransferToOurselfError, InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, InvalidTokenDistributionTimeIntervalTooShortError, InvalidTokenDistributionBlockIntervalTooShortError, InvalidTokenDistributionEpochIntervalTooShortError};
|
|
71
71
|
use dpp::consensus::state::data_contract::data_contract_not_found_error::DataContractNotFoundError;
|
|
72
72
|
use dpp::consensus::state::data_contract::data_contract_update_action_not_allowed_error::DataContractUpdateActionNotAllowedError;
|
|
73
73
|
use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError;
|
|
@@ -92,6 +92,13 @@ use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized
|
|
|
92
92
|
use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError;
|
|
93
93
|
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};
|
|
94
94
|
use dpp::consensus::state::address_funds::{AddressDoesNotExistError, AddressInvalidNonceError, AddressNotEnoughFundsError, AddressesNotEnoughFundsError};
|
|
95
|
+
use dpp::consensus::state::document::referenced_document_type_deletable_error::ReferencedDocumentTypeDeletableError;
|
|
96
|
+
use dpp::consensus::state::document::referenced_identity_key_disabled_error::ReferencedIdentityKeyDisabledError;
|
|
97
|
+
use dpp::consensus::state::document::referenced_identity_key_not_found_error::ReferencedIdentityKeyNotFoundError;
|
|
98
|
+
use dpp::consensus::state::document::referenced_document_property_agreement_invalid_error::ReferencedDocumentPropertyAgreementInvalidError;
|
|
99
|
+
use dpp::consensus::state::document::referenced_document_property_mismatch_error::ReferencedDocumentPropertyMismatchError;
|
|
100
|
+
use dpp::consensus::state::document::referenced_key_id_property_invalid_error::ReferencedKeyIdPropertyInvalidError;
|
|
101
|
+
use dpp::consensus::state::document::referenced_document_type_not_found_error::ReferencedDocumentTypeNotFoundError;
|
|
95
102
|
use dpp::consensus::state::shielded::insufficient_pool_notes_error::InsufficientPoolNotesError;
|
|
96
103
|
use dpp::consensus::state::shielded::insufficient_shielded_fee_error::InsufficientShieldedFeeError;
|
|
97
104
|
use dpp::consensus::state::shielded::invalid_anchor_error::InvalidAnchorError;
|
|
@@ -138,6 +145,7 @@ use crate::errors::consensus::state::document::{
|
|
|
138
145
|
DocumentAlreadyPresentErrorWasm, DocumentNotFoundErrorWasm, DocumentOwnerIdMismatchErrorWasm,
|
|
139
146
|
DocumentTimestampWindowViolationErrorWasm, DocumentTimestampsMismatchErrorWasm,
|
|
140
147
|
DuplicateUniqueIndexErrorWasm, InvalidDocumentRevisionErrorWasm,
|
|
148
|
+
ReferencedEntityNotFoundErrorWasm,
|
|
141
149
|
};
|
|
142
150
|
use crate::errors::consensus::state::identity::{
|
|
143
151
|
IdentityAlreadyExistsErrorWasm, IdentityPublicKeyIsDisabledErrorWasm,
|
|
@@ -471,6 +479,30 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
|
|
|
471
479
|
StateError::InsufficientShieldedFeeError(e) => {
|
|
472
480
|
generic_consensus_error!(InsufficientShieldedFeeError, e).into()
|
|
473
481
|
}
|
|
482
|
+
StateError::ReferencedEntityNotFoundError(e) => {
|
|
483
|
+
ReferencedEntityNotFoundErrorWasm::from(e).into()
|
|
484
|
+
}
|
|
485
|
+
StateError::ReferencedDocumentTypeNotFoundError(e) => {
|
|
486
|
+
generic_consensus_error!(ReferencedDocumentTypeNotFoundError, e).into()
|
|
487
|
+
}
|
|
488
|
+
StateError::ReferencedDocumentTypeDeletableError(e) => {
|
|
489
|
+
generic_consensus_error!(ReferencedDocumentTypeDeletableError, e).into()
|
|
490
|
+
}
|
|
491
|
+
StateError::ReferencedIdentityKeyNotFoundError(e) => {
|
|
492
|
+
generic_consensus_error!(ReferencedIdentityKeyNotFoundError, e).into()
|
|
493
|
+
}
|
|
494
|
+
StateError::ReferencedIdentityKeyDisabledError(e) => {
|
|
495
|
+
generic_consensus_error!(ReferencedIdentityKeyDisabledError, e).into()
|
|
496
|
+
}
|
|
497
|
+
StateError::ReferencedKeyIdPropertyInvalidError(e) => {
|
|
498
|
+
generic_consensus_error!(ReferencedKeyIdPropertyInvalidError, e).into()
|
|
499
|
+
}
|
|
500
|
+
StateError::ReferencedDocumentPropertyAgreementInvalidError(e) => {
|
|
501
|
+
generic_consensus_error!(ReferencedDocumentPropertyAgreementInvalidError, e).into()
|
|
502
|
+
}
|
|
503
|
+
StateError::ReferencedDocumentPropertyMismatchError(e) => {
|
|
504
|
+
generic_consensus_error!(ReferencedDocumentPropertyMismatchError, e).into()
|
|
505
|
+
}
|
|
474
506
|
}
|
|
475
507
|
}
|
|
476
508
|
|
|
@@ -885,6 +917,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
|
|
|
885
917
|
generic_consensus_error!(InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, e)
|
|
886
918
|
.into()
|
|
887
919
|
}
|
|
920
|
+
BasicError::InvalidTokenDistributionEpochIntervalTooShortError(e) => {
|
|
921
|
+
generic_consensus_error!(InvalidTokenDistributionEpochIntervalTooShortError, e).into()
|
|
922
|
+
}
|
|
888
923
|
BasicError::RedundantDocumentPaidForByTokenWithContractId(e) => {
|
|
889
924
|
generic_consensus_error!(RedundantDocumentPaidForByTokenWithContractId, e).into()
|
|
890
925
|
}
|
|
@@ -981,6 +1016,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
|
|
|
981
1016
|
BasicError::TokenPricingScheduleEmptyError(e) => {
|
|
982
1017
|
generic_consensus_error!(TokenPricingScheduleEmptyError, e).into()
|
|
983
1018
|
}
|
|
1019
|
+
BasicError::DataContractInvalidRequiredFieldsUpdateError(e) => {
|
|
1020
|
+
generic_consensus_error!(DataContractInvalidRequiredFieldsUpdateError, e).into()
|
|
1021
|
+
}
|
|
984
1022
|
}
|
|
985
1023
|
}
|
|
986
1024
|
|
|
@@ -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::
|
|
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::
|
|
9
|
+
ConsensusError::deserialize_from_bytes_untrusted(bytes.as_slice())
|
|
10
10
|
.map(from_consensus_error)
|
|
11
11
|
.map_err(|e| e.into())
|
|
12
12
|
}
|
|
@@ -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
|
+
}
|
package/src/identity/identity.rs
CHANGED
|
@@ -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::
|
|
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
|
-
|
|
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::{
|
|
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
|
-
|
|
199
|
+
PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(buffer.as_slice())
|
|
200
|
+
.with_js_error()?;
|
|
200
201
|
Ok(key.into())
|
|
201
202
|
}
|
|
202
203
|
}
|
package/src/identity/mod.rs
CHANGED
|
@@ -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::{
|
|
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
|
@@ -84,7 +84,9 @@ impl StateTransitionFactoryWasm {
|
|
|
84
84
|
| StateTransition::Unshield(_)
|
|
85
85
|
| StateTransition::ShieldFromAssetLock(_)
|
|
86
86
|
| StateTransition::ShieldedWithdrawal(_)
|
|
87
|
-
| StateTransition::IdentityCreateFromShieldedPool(_)
|
|
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
|
)),
|
|
90
92
|
},
|
package/src/utils.rs
CHANGED
|
@@ -5,7 +5,7 @@ use anyhow::{anyhow, bail, Context};
|
|
|
5
5
|
use dpp::{consensus::ConsensusError, ProtocolError};
|
|
6
6
|
|
|
7
7
|
use dpp::platform_value::Value;
|
|
8
|
-
use dpp::serialization::
|
|
8
|
+
use dpp::serialization::PlatformDeserializableUntrusted;
|
|
9
9
|
use js_sys::{Function, Uint8Array};
|
|
10
10
|
use serde::de::DeserializeOwned;
|
|
11
11
|
use serde_json::Value as JsonValue;
|
|
@@ -355,7 +355,7 @@ pub(crate) fn consensus_errors_from_buffers(
|
|
|
355
355
|
.to_vec()
|
|
356
356
|
})
|
|
357
357
|
.map(|error_bytes| {
|
|
358
|
-
ConsensusError::
|
|
358
|
+
ConsensusError::deserialize_from_bytes_untrusted(&error_bytes.to_vec()).with_js_error()
|
|
359
359
|
})
|
|
360
360
|
.collect::<Result<Vec<ConsensusError>, JsValue>>()
|
|
361
361
|
}
|