@dashevo/wasm-dpp 4.2.0-dev.9 → 5.0.0-beta.1
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/dist/wasm/wasm_dpp.d.ts +4480 -3190
- package/dist/wasm/wasm_dpp.js +679 -87
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +4480 -3190
- 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/state_transition/batch_transition/token_transition/claim.rs +1 -0
- package/src/errors/consensus/basic/identity/contract_group_bound_key_not_allowed_in_shielded_identity_creation_error.rs +36 -0
- package/src/errors/consensus/basic/identity/mod.rs +2 -0
- package/src/errors/consensus/consensus_error.rs +384 -4
- package/src/errors/consensus/deserialize.rs +2 -2
- package/src/errors/consensus/signature/contract_bounded_key_non_batch_error.rs +29 -0
- package/src/errors/consensus/signature/contract_bounded_key_out_of_bounds_error.rs +29 -0
- package/src/errors/consensus/signature/mod.rs +6 -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/state_transition/state_transition_factory.rs +9 -0
- package/src/utils.rs +2 -2
- package/src/validation/validation_result.rs +0 -8
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +3 -1
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +3 -1
|
@@ -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;
|
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;
|
|
@@ -89,6 +89,15 @@ impl StateTransitionFactoryWasm {
|
|
|
89
89
|
| StateTransition::IdentityTopUpFromShieldedPool(_) => Err(JsValue::from_str(
|
|
90
90
|
"shielded transitions are not yet supported in wasm-dpp StateTransitionFactory",
|
|
91
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
|
+
)),
|
|
95
|
+
StateTransition::ContractUserModeration(_) => Err(JsValue::from_str(
|
|
96
|
+
"contract user moderation transitions are not supported in wasm-dpp StateTransitionFactory; use wasm-dpp2",
|
|
97
|
+
)),
|
|
98
|
+
StateTransition::ContractFeeClaim(_) => Err(JsValue::from_str(
|
|
99
|
+
"contract fee claim transitions are not supported in wasm-dpp StateTransitionFactory; use wasm-dpp2",
|
|
100
|
+
)),
|
|
92
101
|
},
|
|
93
102
|
Err(dpp::ProtocolError::StateTransitionError(e)) => match e {
|
|
94
103
|
StateTransitionError::InvalidStateTransitionError {
|
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
|
}
|
|
@@ -4,7 +4,6 @@ use crate::{
|
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
use dpp::{consensus::ConsensusError, validation::ConsensusValidationResult};
|
|
7
|
-
use js_sys::JsString;
|
|
8
7
|
use wasm_bindgen::prelude::*;
|
|
9
8
|
|
|
10
9
|
#[wasm_bindgen(js_name=ValidationResult)]
|
|
@@ -35,13 +34,6 @@ impl ValidationResultWasm {
|
|
|
35
34
|
Ok(Self(ConsensusValidationResult::new_with_errors(vec![])))
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
/// This is just a test method - doesn't need to be in the resulted binding. Please
|
|
39
|
-
/// remove before shipping
|
|
40
|
-
#[wasm_bindgen(js_name=errorsText)]
|
|
41
|
-
pub fn errors_text(&self) -> Vec<JsString> {
|
|
42
|
-
self.0.errors.iter().map(|e| e.to_string().into()).collect()
|
|
43
|
-
}
|
|
44
|
-
|
|
45
37
|
#[wasm_bindgen(js_name=isValid)]
|
|
46
38
|
pub fn is_valid(&self) -> bool {
|
|
47
39
|
self.0.is_valid()
|
|
@@ -72,7 +72,9 @@ describe('DataContractCreateTransition', () => {
|
|
|
72
72
|
it('should return serialized State Transition', () => {
|
|
73
73
|
const result = stateTransition.toBuffer();
|
|
74
74
|
expect(result).to.be.instanceOf(Buffer);
|
|
75
|
-
|
|
75
|
+
// The fixture contract carries a V2 config (protocol version 14), whose optional
|
|
76
|
+
// moderation declaration is one more bincode byte than a V1 config.
|
|
77
|
+
expect(result).to.have.lengthOf(2371);
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
it('should be able to restore contract config from bytes', () => {
|
|
@@ -66,7 +66,9 @@ describe('DataContractUpdateTransition', () => {
|
|
|
66
66
|
it('should return serialized State Transition', () => {
|
|
67
67
|
const result = stateTransition.toBuffer();
|
|
68
68
|
expect(result).to.be.instanceOf(Buffer);
|
|
69
|
-
|
|
69
|
+
// The fixture contract carries a V2 config (protocol version 14), whose optional
|
|
70
|
+
// moderation declaration is one more bincode byte than a V1 config.
|
|
71
|
+
expect(result).to.have.lengthOf(2371);
|
|
70
72
|
});
|
|
71
73
|
|
|
72
74
|
it('should be able to restore contract config from bytes', () => {
|