@dashevo/wasm-dpp 0.24.0-dev.10 → 0.24.0-dev.12
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 -0
- package/dist/index.js +1 -1
- package/dist/lib/dpp.d.ts +9 -0
- package/dist/lib/errors/AbstractConsensusError.d.ts +10 -0
- package/dist/lib/errors/DPPError.d.ts +5 -0
- package/dist/lib/errors/patchConsensusErrors.d.ts +1 -0
- package/dist/lib/{patchIdentifier.d.ts → identifier/patchIdentifier.d.ts} +1 -1
- package/dist/{index.d.ts → lib/index.d.ts} +1 -1
- package/dist/lib/utils/extend.d.ts +1 -0
- package/dist/wasm/wasm_dpp.d.ts +503 -262
- package/lib/dpp.ts +24 -0
- package/lib/errors/AbstractConsensusError.ts +13 -0
- package/lib/errors/DPPError.ts +15 -0
- package/lib/errors/patchConsensusErrors.ts +175 -0
- package/lib/{patchIdentifier.ts → identifier/patchIdentifier.ts} +1 -1
- package/{index.ts → lib/index.ts} +4 -3
- package/lib/test/expect/expectError.js +4 -2
- package/lib/utils/extend.ts +6 -0
- package/package.json +5 -5
- package/src/data_contract/errors/invalid_data_contract.rs +21 -0
- package/src/data_contract/state_transition/data_contract_create_transition/apply.rs +44 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +107 -6
- package/src/data_contract/state_transition/data_contract_create_transition/validation.rs +24 -0
- package/src/data_contract/state_transition/data_contract_update_transition/apply.rs +44 -0
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +147 -0
- package/src/data_contract/state_transition/data_contract_update_transition/validation.rs +46 -0
- package/src/data_contract/state_transition/mod.rs +2 -0
- package/src/data_contract_factory/data_contract_factory.rs +27 -12
- package/src/document/errors/document_already_exists_error.rs +1 -1
- package/src/document/errors/document_not_provided_error.rs +1 -1
- package/src/document/errors/invalid_document_action_error.rs +1 -1
- package/src/errors/consensus/basic/data_contract/data_contract_max_depth_exceed_error.rs +5 -5
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_ids_error.rs +4 -4
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_indices_error.rs +36 -0
- package/src/errors/consensus/basic/document/missing_document_transition_type_error.rs +20 -0
- package/src/errors/consensus/basic/document/mod.rs +4 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_error.rs +2 -2
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_id_error.rs +2 -2
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_security_level_error.rs +2 -2
- package/src/errors/consensus/basic/json_schema_error.rs +1 -1
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_condition_error.rs +1 -1
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_execution_error.rs +1 -1
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_invalid_result_error.rs +1 -1
- package/src/errors/consensus_error.rs +15 -8
- package/src/errors/from.rs +1 -1
- package/src/errors/mod.rs +1 -0
- package/src/errors/protocol_error.rs +12 -0
- package/src/{identifier.rs → identifier/mod.rs} +0 -0
- package/src/{identity_facade.rs → identity/identity_facade.rs} +1 -1
- package/src/{identity_public_key → identity/identity_public_key}/key_type.rs +0 -0
- package/src/{identity_public_key → identity/identity_public_key}/mod.rs +0 -3
- package/src/{identity_public_key → identity/identity_public_key}/purpose.rs +0 -0
- package/src/{identity_public_key → identity/identity_public_key}/security_level.rs +0 -0
- package/src/{identity.rs → identity/mod.rs} +6 -7
- package/src/identity/validation/mod.rs +3 -0
- package/src/identity/validation/public_keys_validator.rs +70 -0
- package/src/lib.rs +4 -8
- package/src/state_repository.rs +229 -0
- package/src/state_transition/mod.rs +41 -0
- package/src/utils.rs +2 -2
- package/src/validation/mod.rs +3 -0
- package/src/{validation_result.rs → validation/validation_result.rs} +0 -0
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +1 -1
- package/test/integration/identity/validation/validatePublicKeysFactory.spec.js +79 -114
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +0 -11
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +1 -1
- package/test/integration/stateTransition/calculateStateTransitionFeeFactory.spec.js +135 -0
- package/test/unit/dataContract/DataContract.spec.js +5 -9
- package/test/unit/dataContract/DataContractFactory.spec.js +13 -6
- package/test/unit/dataContract/errors/InvalidDataContractError.spec.js +11 -3
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +17 -64
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +28 -22
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +49 -42
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +23 -59
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +27 -23
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateIndicesAreBackwardCompatible.spec.js +29 -12
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/state/validateDataContractUpdateTransitionStateFactory.spec.js +66 -49
- package/test/unit/dataContract/validation/validateDataContractPatterns.spec.js +73 -0
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +1 -1
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +1 -1
- package/test/unit/identity/IdentityPublicKey.spec.js +25 -31
- package/tsconfig.json +1 -1
- package/wasm/wasm_dpp.d.ts +503 -262
- package/wasm/wasm_dpp.js +925 -310
- package/wasm/wasm_dpp_bg.js +1 -1
- package/wasm/wasm_dpp_bg.wasm +0 -0
- package/wasm/wasm_dpp_bg.wasm.d.ts +273 -225
- package/webpack.config.js +1 -1
- package/src/identity_public_key/public_keys_validator.rs +0 -44
- package/test/integration/stateTransition/calculateStateTransitionFee.spec.js +0 -32
- package/test/unit/dataContract/validation/validateDataContractMaxDepthFactory.spec.js +0 -93
- package/test/unit/dataContract/validation/validateDataContractPatternsFactory.spec.js +0 -64
|
File without changes
|
|
File without changes
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
pub mod identity_facade;
|
|
2
|
+
mod identity_public_key;
|
|
3
|
+
mod validation;
|
|
4
|
+
|
|
1
5
|
use js_sys::Array;
|
|
2
6
|
use serde_json::Value;
|
|
3
7
|
use wasm_bindgen::prelude::*;
|
|
@@ -12,8 +16,8 @@ use crate::errors::from_dpp_err;
|
|
|
12
16
|
use crate::identifier::IdentifierWrapper;
|
|
13
17
|
use crate::utils;
|
|
14
18
|
use crate::utils::to_vec_of_serde_values;
|
|
15
|
-
use crate::IdentityPublicKeyWasm;
|
|
16
19
|
use crate::MetadataWasm;
|
|
20
|
+
pub use identity_public_key::*;
|
|
17
21
|
|
|
18
22
|
#[wasm_bindgen(js_name=Identity)]
|
|
19
23
|
#[derive(Clone)]
|
|
@@ -60,12 +64,7 @@ impl IdentityWasm {
|
|
|
60
64
|
.into_iter()
|
|
61
65
|
.map(IdentityPublicKey::from_json_object)
|
|
62
66
|
.collect::<Result<_, _>>()
|
|
63
|
-
.map_err(|e| {
|
|
64
|
-
format!(
|
|
65
|
-
"converting to collection of IdentityPublicKeys failed: {:#}",
|
|
66
|
-
e
|
|
67
|
-
)
|
|
68
|
-
})?;
|
|
67
|
+
.map_err(|e| format!("converting to collection of IdentityPublicKeys failed: {e:#}"))?;
|
|
69
68
|
|
|
70
69
|
self.0.set_public_keys(public_keys);
|
|
71
70
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
use crate::bls_adapter::{BlsAdapter, JsBlsAdapter};
|
|
2
|
+
|
|
3
|
+
use crate::utils::{to_vec_of_serde_values, ToSerdeJSONExt};
|
|
4
|
+
use crate::validation::ValidationResultWasm;
|
|
5
|
+
use dpp::identity::validation::{
|
|
6
|
+
PublicKeysValidator, TPublicKeysValidator, PUBLIC_KEY_SCHEMA_FOR_TRANSITION,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
use wasm_bindgen::prelude::*;
|
|
10
|
+
|
|
11
|
+
#[wasm_bindgen(js_name = PublicKeysValidator)]
|
|
12
|
+
pub struct PublicKeysValidatorWasm {
|
|
13
|
+
public_key_validator: PublicKeysValidator<BlsAdapter>,
|
|
14
|
+
public_key_in_state_transition_validator: PublicKeysValidator<BlsAdapter>,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#[wasm_bindgen(js_class = PublicKeysValidator)]
|
|
18
|
+
impl PublicKeysValidatorWasm {
|
|
19
|
+
#[wasm_bindgen(constructor)]
|
|
20
|
+
pub fn new(adapter: JsBlsAdapter) -> Result<PublicKeysValidatorWasm, JsError> {
|
|
21
|
+
Ok(Self {
|
|
22
|
+
public_key_validator: PublicKeysValidator::new(BlsAdapter(JsBlsAdapter::from(
|
|
23
|
+
adapter.clone(),
|
|
24
|
+
)))?,
|
|
25
|
+
public_key_in_state_transition_validator: PublicKeysValidator::new_with_schema(
|
|
26
|
+
PUBLIC_KEY_SCHEMA_FOR_TRANSITION.clone(),
|
|
27
|
+
BlsAdapter(adapter),
|
|
28
|
+
)?,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=validateKeys)]
|
|
33
|
+
pub fn validate_keys(
|
|
34
|
+
&self,
|
|
35
|
+
public_keys: js_sys::Array,
|
|
36
|
+
) -> Result<ValidationResultWasm, JsValue> {
|
|
37
|
+
let raw_public_keys = to_vec_of_serde_values(public_keys.iter())?;
|
|
38
|
+
|
|
39
|
+
self.public_key_validator
|
|
40
|
+
.validate_keys(&raw_public_keys)
|
|
41
|
+
.map(ValidationResultWasm::from)
|
|
42
|
+
.map_err(|e| JsValue::from(e.to_string()))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[wasm_bindgen(js_name=validatePublicKeyStructure)]
|
|
46
|
+
pub fn validate_public_key_structure(
|
|
47
|
+
&self,
|
|
48
|
+
public_key: JsValue,
|
|
49
|
+
) -> Result<ValidationResultWasm, JsValue> {
|
|
50
|
+
let pk_serde_json = public_key.to_serde_json_value()?;
|
|
51
|
+
|
|
52
|
+
self.public_key_validator
|
|
53
|
+
.validate_public_key_structure(&pk_serde_json)
|
|
54
|
+
.map(ValidationResultWasm::from)
|
|
55
|
+
.map_err(|e| JsValue::from(e.to_string()))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#[wasm_bindgen(js_name=validateKeysInStateTransition)]
|
|
59
|
+
pub fn validate_keys_in_state_transition(
|
|
60
|
+
&self,
|
|
61
|
+
public_keys: js_sys::Array,
|
|
62
|
+
) -> Result<ValidationResultWasm, JsValue> {
|
|
63
|
+
let raw_public_keys = to_vec_of_serde_values(public_keys.iter())?;
|
|
64
|
+
|
|
65
|
+
self.public_key_in_state_transition_validator
|
|
66
|
+
.validate_keys(&raw_public_keys)
|
|
67
|
+
.map(ValidationResultWasm::from)
|
|
68
|
+
.map_err(|e| JsValue::from(e.to_string()))
|
|
69
|
+
}
|
|
70
|
+
}
|
package/src/lib.rs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
extern crate web_sys;
|
|
2
|
-
|
|
3
1
|
pub use dash_platform_protocol::*;
|
|
4
2
|
pub use data_contract::*;
|
|
5
3
|
pub use data_contract_factory::*;
|
|
6
4
|
pub use document::*;
|
|
7
5
|
pub use identity::*;
|
|
8
|
-
pub use identity::*;
|
|
9
|
-
pub use identity_facade::*;
|
|
10
|
-
pub use identity_public_key::*;
|
|
11
6
|
pub use metadata::*;
|
|
7
|
+
pub use state_transition::*;
|
|
12
8
|
|
|
13
9
|
mod dash_platform_protocol;
|
|
14
10
|
mod data_contract;
|
|
@@ -17,12 +13,12 @@ mod document;
|
|
|
17
13
|
pub mod errors;
|
|
18
14
|
mod identifier;
|
|
19
15
|
mod identity;
|
|
20
|
-
mod identity_facade;
|
|
21
|
-
mod identity_public_key;
|
|
22
16
|
mod metadata;
|
|
17
|
+
mod state_repository;
|
|
18
|
+
mod state_transition;
|
|
23
19
|
|
|
24
20
|
mod utils;
|
|
25
21
|
|
|
26
22
|
mod bls_adapter;
|
|
27
23
|
mod buffer;
|
|
28
|
-
|
|
24
|
+
mod validation;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
//! Bindings for state repository -like objects coming from JS.
|
|
2
|
+
|
|
3
|
+
use std::{convert::Infallible, pin::Pin, sync::Mutex};
|
|
4
|
+
|
|
5
|
+
use async_trait::async_trait;
|
|
6
|
+
use dpp::{
|
|
7
|
+
dashcore::InstantLock,
|
|
8
|
+
data_contract::DataContract,
|
|
9
|
+
document::Document,
|
|
10
|
+
prelude::{Identifier, Identity},
|
|
11
|
+
state_repository::StateRepositoryLike,
|
|
12
|
+
state_transition::state_transition_execution_context::StateTransitionExecutionContext,
|
|
13
|
+
};
|
|
14
|
+
use wasm_bindgen::prelude::*;
|
|
15
|
+
|
|
16
|
+
use crate::{identifier::IdentifierWrapper, DataContractWasm, StateTransitionExecutionContextWasm};
|
|
17
|
+
|
|
18
|
+
#[wasm_bindgen]
|
|
19
|
+
extern "C" {
|
|
20
|
+
pub type ExternalStateRepositoryLike;
|
|
21
|
+
|
|
22
|
+
#[wasm_bindgen(structural, method, js_name=fetchDataContract)]
|
|
23
|
+
pub fn fetch_data_contract(
|
|
24
|
+
this: &ExternalStateRepositoryLike,
|
|
25
|
+
data_contract_id: IdentifierWrapper,
|
|
26
|
+
execution_context: StateTransitionExecutionContextWasm,
|
|
27
|
+
) -> Option<DataContractWasm>;
|
|
28
|
+
|
|
29
|
+
#[wasm_bindgen(structural, method, js_name=storeDataContract)]
|
|
30
|
+
pub fn store_data_contract(
|
|
31
|
+
this: &ExternalStateRepositoryLike,
|
|
32
|
+
data_contract: DataContractWasm,
|
|
33
|
+
execution_context: StateTransitionExecutionContextWasm,
|
|
34
|
+
) -> JsValue;
|
|
35
|
+
|
|
36
|
+
// TODO add missing declarations
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Wraps external duck-typed thing into pinned box with mutex to ensure it'll stay at the same
|
|
40
|
+
/// place in memory and will have synchronized access.
|
|
41
|
+
pub(crate) struct ExternalStateRepositoryLikeWrapper(Pin<Box<Mutex<ExternalStateRepositoryLike>>>); // bruh
|
|
42
|
+
|
|
43
|
+
unsafe impl Send for ExternalStateRepositoryLikeWrapper {}
|
|
44
|
+
unsafe impl Sync for ExternalStateRepositoryLikeWrapper {}
|
|
45
|
+
|
|
46
|
+
impl ExternalStateRepositoryLikeWrapper {
|
|
47
|
+
pub(crate) fn new(state_repository: ExternalStateRepositoryLike) -> Self {
|
|
48
|
+
ExternalStateRepositoryLikeWrapper(Box::pin(Mutex::new(state_repository)))
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[async_trait]
|
|
53
|
+
impl StateRepositoryLike for ExternalStateRepositoryLikeWrapper {
|
|
54
|
+
type ConversionError = Infallible;
|
|
55
|
+
type FetchDataContract = DataContractWasm;
|
|
56
|
+
|
|
57
|
+
async fn fetch_data_contract(
|
|
58
|
+
&self,
|
|
59
|
+
data_contract_id: &Identifier,
|
|
60
|
+
execution_context: &StateTransitionExecutionContext,
|
|
61
|
+
) -> anyhow::Result<Option<Self::FetchDataContract>> {
|
|
62
|
+
Ok(self
|
|
63
|
+
.0
|
|
64
|
+
.lock()
|
|
65
|
+
.expect("unexpected concurrency issue!")
|
|
66
|
+
.fetch_data_contract(
|
|
67
|
+
data_contract_id.clone().into(),
|
|
68
|
+
execution_context.clone().into(),
|
|
69
|
+
)
|
|
70
|
+
.map(Into::into))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async fn store_data_contract(
|
|
74
|
+
&self,
|
|
75
|
+
data_contract: DataContract,
|
|
76
|
+
execution_context: &StateTransitionExecutionContext,
|
|
77
|
+
) -> anyhow::Result<()> {
|
|
78
|
+
self.0
|
|
79
|
+
.lock()
|
|
80
|
+
.expect("unexpected concurrency issue!")
|
|
81
|
+
.store_data_contract(data_contract.into(), execution_context.clone().into());
|
|
82
|
+
Ok(())
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async fn fetch_documents<T>(
|
|
86
|
+
&self,
|
|
87
|
+
_contract_id: &Identifier,
|
|
88
|
+
_data_contract_type: &str,
|
|
89
|
+
_where_query: serde_json::Value,
|
|
90
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
91
|
+
) -> anyhow::Result<Vec<T>>
|
|
92
|
+
where
|
|
93
|
+
T: for<'de> serde::de::Deserialize<'de> + 'static,
|
|
94
|
+
{
|
|
95
|
+
todo!()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async fn create_document(
|
|
99
|
+
&self,
|
|
100
|
+
_document: &Document,
|
|
101
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
102
|
+
) -> anyhow::Result<()> {
|
|
103
|
+
todo!()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async fn update_document(
|
|
107
|
+
&self,
|
|
108
|
+
_document: &Document,
|
|
109
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
110
|
+
) -> anyhow::Result<()> {
|
|
111
|
+
todo!()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async fn remove_document(
|
|
115
|
+
&self,
|
|
116
|
+
_data_contract: &DataContract,
|
|
117
|
+
_data_contract_type: &str,
|
|
118
|
+
_document_id: &Identifier,
|
|
119
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
120
|
+
) -> anyhow::Result<()> {
|
|
121
|
+
todo!()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async fn fetch_transaction<T>(
|
|
125
|
+
&self,
|
|
126
|
+
_id: &str,
|
|
127
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
128
|
+
) -> anyhow::Result<Option<T>>
|
|
129
|
+
where
|
|
130
|
+
T: for<'de> serde::de::Deserialize<'de> + 'static,
|
|
131
|
+
{
|
|
132
|
+
todo!()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async fn fetch_identity<T>(
|
|
136
|
+
&self,
|
|
137
|
+
_id: &Identifier,
|
|
138
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
139
|
+
) -> anyhow::Result<Option<T>>
|
|
140
|
+
where
|
|
141
|
+
T: for<'de> serde::de::Deserialize<'de> + 'static,
|
|
142
|
+
{
|
|
143
|
+
todo!()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async fn store_identity_public_key_hashes(
|
|
147
|
+
&self,
|
|
148
|
+
_identity_id: &Identifier,
|
|
149
|
+
_public_key_hashes: Vec<Vec<u8>>,
|
|
150
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
151
|
+
) -> anyhow::Result<()> {
|
|
152
|
+
todo!()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async fn fetch_identity_by_public_key_hashes<T>(
|
|
156
|
+
&self,
|
|
157
|
+
_public_key_hashed: Vec<Vec<u8>>,
|
|
158
|
+
) -> anyhow::Result<Vec<T>>
|
|
159
|
+
where
|
|
160
|
+
T: for<'de> serde::de::Deserialize<'de> + 'static,
|
|
161
|
+
{
|
|
162
|
+
todo!()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async fn fetch_latest_platform_block_header<T>(&self) -> anyhow::Result<T>
|
|
166
|
+
where
|
|
167
|
+
T: for<'de> serde::de::Deserialize<'de> + 'static,
|
|
168
|
+
{
|
|
169
|
+
todo!()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async fn verify_instant_lock(
|
|
173
|
+
&self,
|
|
174
|
+
_instant_lock: &InstantLock,
|
|
175
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
176
|
+
) -> anyhow::Result<bool> {
|
|
177
|
+
todo!()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async fn is_asset_lock_transaction_out_point_already_used(
|
|
181
|
+
&self,
|
|
182
|
+
_out_point_buffer: &[u8],
|
|
183
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
184
|
+
) -> anyhow::Result<bool> {
|
|
185
|
+
todo!()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async fn mark_asset_lock_transaction_out_point_as_used(
|
|
189
|
+
&self,
|
|
190
|
+
_out_point_buffer: &[u8],
|
|
191
|
+
) -> anyhow::Result<()> {
|
|
192
|
+
todo!()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async fn fetch_sml_store<T>(&self) -> anyhow::Result<T>
|
|
196
|
+
where
|
|
197
|
+
T: for<'de> serde::de::Deserialize<'de> + 'static,
|
|
198
|
+
{
|
|
199
|
+
todo!()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async fn create_identity(
|
|
203
|
+
&self,
|
|
204
|
+
_identity: &Identity,
|
|
205
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
206
|
+
) -> anyhow::Result<()> {
|
|
207
|
+
todo!()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async fn update_identity(
|
|
211
|
+
&self,
|
|
212
|
+
_identity: &Identity,
|
|
213
|
+
_execution_context: &StateTransitionExecutionContext,
|
|
214
|
+
) -> anyhow::Result<()> {
|
|
215
|
+
todo!()
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async fn fetch_latest_withdrawal_transaction_index(&self) -> anyhow::Result<u64> {
|
|
219
|
+
todo!()
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async fn enqueue_withdrawal_transaction(
|
|
223
|
+
&self,
|
|
224
|
+
_index: u64,
|
|
225
|
+
_transaction_bytes: Vec<u8>,
|
|
226
|
+
) -> anyhow::Result<()> {
|
|
227
|
+
todo!()
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
use dpp::state_transition::state_transition_execution_context::StateTransitionExecutionContext;
|
|
2
|
+
use wasm_bindgen::prelude::*;
|
|
3
|
+
|
|
4
|
+
#[wasm_bindgen(js_name=StateTransitionExecutionContext)]
|
|
5
|
+
pub struct StateTransitionExecutionContextWasm(StateTransitionExecutionContext);
|
|
6
|
+
|
|
7
|
+
impl From<StateTransitionExecutionContext> for StateTransitionExecutionContextWasm {
|
|
8
|
+
fn from(rs: StateTransitionExecutionContext) -> Self {
|
|
9
|
+
StateTransitionExecutionContextWasm(rs)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
impl From<StateTransitionExecutionContextWasm> for StateTransitionExecutionContext {
|
|
14
|
+
fn from(wa: StateTransitionExecutionContextWasm) -> Self {
|
|
15
|
+
wa.0
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
impl<'a> From<&'a StateTransitionExecutionContextWasm> for StateTransitionExecutionContext {
|
|
20
|
+
fn from(wa: &StateTransitionExecutionContextWasm) -> Self {
|
|
21
|
+
wa.0.clone()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#[wasm_bindgen(js_class=StateTransitionExecutionContext)]
|
|
26
|
+
impl StateTransitionExecutionContextWasm {
|
|
27
|
+
#[wasm_bindgen(constructor)]
|
|
28
|
+
pub fn new() -> StateTransitionExecutionContextWasm {
|
|
29
|
+
StateTransitionExecutionContext::default().into()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=enableDryRun)]
|
|
33
|
+
pub fn enable_dry_run(&self) {
|
|
34
|
+
self.0.enable_dry_run();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[wasm_bindgen(js_name=disableDryRun)]
|
|
38
|
+
pub fn disable_dry_run(&self) {
|
|
39
|
+
self.0.disable_dry_run();
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/utils.rs
CHANGED
|
@@ -41,8 +41,8 @@ where
|
|
|
41
41
|
pub fn to_serde_json_value(data: &JsValue) -> Result<Value, JsValue> {
|
|
42
42
|
let data = stringify(data)?;
|
|
43
43
|
let value: Value = serde_json::from_str(&data)
|
|
44
|
-
.with_context(|| format!("cant convert {:#?} to serde json value"
|
|
45
|
-
.map_err(|e| format!("{:#}"
|
|
44
|
+
.with_context(|| format!("cant convert {data:#?} to serde json value"))
|
|
45
|
+
.map_err(|e| format!("{e:#}"))?;
|
|
46
46
|
Ok(value)
|
|
47
47
|
}
|
|
48
48
|
|
|
File without changes
|
|
@@ -36,7 +36,7 @@ describe('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
36
36
|
|
|
37
37
|
blockTime = Date.now();
|
|
38
38
|
|
|
39
|
-
stateRepositoryMock.fetchLatestPlatformBlockTime.
|
|
39
|
+
stateRepositoryMock.fetchLatestPlatformBlockTime.resolves(blockTime);
|
|
40
40
|
|
|
41
41
|
validateIdentityUpdateTransitionState = validateIdentityUpdateTransitionStateFactory(
|
|
42
42
|
stateRepositoryMock,
|