@dashevo/wasm-dpp 1.0.0-dev.7 → 1.0.0-dev.8
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 +1 -1
- package/dist/wasm/wasm_dpp.d.ts +813 -853
- package/dist/wasm/wasm_dpp.js +306 -405
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/test/fixtures/getIdentityUpdateTransitionFixture.js +0 -1
- package/lib/wasm/wasm_dpp.d.ts +813 -853
- package/package.json +2 -2
- package/src/data_contract/data_contract.rs +6 -1
- package/src/data_contract/data_contract_facade.rs +0 -1
- package/src/data_contract/errors/mod.rs +0 -11
- package/src/data_contract_factory/data_contract_factory.rs +0 -1
- package/src/document/extended_document.rs +1 -0
- package/src/document/factory.rs +16 -20
- package/src/document/mod.rs +3 -0
- package/src/errors/consensus/consensus_error.rs +3 -7
- package/src/errors/consensus/state/identity/invalid_identity_contract_nonce_error.rs +1 -3
- package/src/errors/consensus/state/identity/mod.rs +0 -2
- package/src/errors/protocol_error.rs +0 -8
- package/src/identity/identity_facade.rs +0 -2
- package/src/identity/identity_factory.rs +0 -3
- package/src/identity/identity_public_key/mod.rs +2 -1
- package/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs +6 -6
- package/src/identity/state_transition/identity_public_key_transitions.rs +4 -1
- package/src/identity/state_transition/identity_update_transition/identity_update_transition.rs +0 -33
- package/src/identity/state_transition/identity_update_transition/to_object.rs +0 -3
- package/src/lib.rs +1 -1
- package/test/integration/identity/IdentityFacade.spec.js +0 -1
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +0 -34
- package/test/unit/identity/Identity.spec.js +2 -2
- package/test/unit/identity/IdentityFactory.spec.js +0 -1
- package/test/unit/identity/IdentityPublicKey.spec.js +3 -3
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +0 -21
- package/src/errors/consensus/state/identity/identity_public_key_disabled_at_window_violation_error.rs +0 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/wasm-dpp",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.8",
|
|
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.23.3",
|
|
45
45
|
"@babel/preset-env": "^7.23.3",
|
|
46
46
|
"@dashevo/dashcore-lib": "~0.21.1",
|
|
47
|
-
"@dashevo/dpns-contract": "1.0.0-dev.
|
|
47
|
+
"@dashevo/dpns-contract": "1.0.0-dev.8",
|
|
48
48
|
"@types/bs58": "^4.0.1",
|
|
49
49
|
"@types/node": "^14.6.0",
|
|
50
50
|
"@yarnpkg/pnpify": "^4.0.0-rc.42",
|
|
@@ -151,6 +151,7 @@ impl DataContractWasm {
|
|
|
151
151
|
let document_type = self
|
|
152
152
|
.inner
|
|
153
153
|
.document_type_for_name(doc_type)
|
|
154
|
+
.map_err(ProtocolError::DataContractError)
|
|
154
155
|
.with_js_error()?;
|
|
155
156
|
|
|
156
157
|
let mut binary_paths = BTreeMap::new();
|
|
@@ -234,7 +235,11 @@ impl DataContractWasm {
|
|
|
234
235
|
|
|
235
236
|
#[wasm_bindgen(js_name=getDocumentSchema)]
|
|
236
237
|
pub fn document_schema(&mut self, name: &str) -> Result<JsValue, JsValue> {
|
|
237
|
-
let document_type = self
|
|
238
|
+
let document_type = self
|
|
239
|
+
.inner
|
|
240
|
+
.document_type_for_name(name)
|
|
241
|
+
.map_err(ProtocolError::DataContractError)
|
|
242
|
+
.with_js_error()?;
|
|
238
243
|
|
|
239
244
|
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
|
240
245
|
|
|
@@ -8,7 +8,6 @@ use dpp::identifier::Identifier;
|
|
|
8
8
|
use crate::data_contract::state_transition::DataContractCreateTransitionWasm;
|
|
9
9
|
use crate::data_contract::state_transition::DataContractUpdateTransitionWasm;
|
|
10
10
|
use crate::data_contract::DataContractWasm;
|
|
11
|
-
use crate::entropy_generator::ExternalEntropyGenerator;
|
|
12
11
|
use crate::errors::protocol_error::from_protocol_error;
|
|
13
12
|
use crate::utils::{
|
|
14
13
|
get_bool_from_options, ToSerdeJSONExt, WithJsError, SKIP_VALIDATION_PROPERTY_NAME,
|
|
@@ -7,19 +7,8 @@ use wasm_bindgen::prelude::*;
|
|
|
7
7
|
pub use data_contract_generic_error::*;
|
|
8
8
|
use dpp::data_contract::errors::DataContractError;
|
|
9
9
|
|
|
10
|
-
pub use invalid_data_contract::*;
|
|
11
|
-
|
|
12
10
|
pub fn from_data_contract_to_js_error(e: DataContractError) -> JsValue {
|
|
13
11
|
match e {
|
|
14
|
-
DataContractError::InvalidDataContractError {
|
|
15
|
-
errors,
|
|
16
|
-
raw_data_contract,
|
|
17
|
-
} => InvalidDataContractError::new(
|
|
18
|
-
errors,
|
|
19
|
-
serde_wasm_bindgen::to_value(&raw_data_contract)
|
|
20
|
-
.expect("statically known structure should be a valid JSON"),
|
|
21
|
-
)
|
|
22
|
-
.into(),
|
|
23
12
|
DataContractError::InvalidDocumentTypeError(err) => {
|
|
24
13
|
invalid_document_type::InvalidDocumentTypeInDataContractError::new(
|
|
25
14
|
err.document_type(),
|
|
@@ -4,7 +4,6 @@ use dpp::data_contract::created_data_contract::CreatedDataContract;
|
|
|
4
4
|
use dpp::{data_contract::DataContractFactory, platform_value, prelude::Identifier, ProtocolError};
|
|
5
5
|
use wasm_bindgen::prelude::*;
|
|
6
6
|
|
|
7
|
-
use crate::entropy_generator::ExternalEntropyGenerator;
|
|
8
7
|
use crate::utils::{ToSerdeJSONExt, WithJsError};
|
|
9
8
|
|
|
10
9
|
use crate::data_contract::{DataContractCreateTransitionWasm, DataContractWasm};
|
|
@@ -19,6 +19,7 @@ use wasm_bindgen::prelude::*;
|
|
|
19
19
|
|
|
20
20
|
use crate::buffer::Buffer;
|
|
21
21
|
use crate::data_contract::DataContractWasm;
|
|
22
|
+
#[allow(deprecated)] // BinaryType is unsed in unused code below
|
|
22
23
|
use crate::document::BinaryType;
|
|
23
24
|
use crate::document::{ConversionOptions, DocumentWasm};
|
|
24
25
|
use crate::errors::RustConversionError;
|
package/src/document/factory.rs
CHANGED
|
@@ -312,33 +312,29 @@ fn extract_documents_of_action(
|
|
|
312
312
|
documents: &JsValue,
|
|
313
313
|
action: &str,
|
|
314
314
|
) -> Result<Vec<ExtendedDocument>, anyhow::Error> {
|
|
315
|
-
let mut extracted_documents: Vec<ExtendedDocument> = vec![];
|
|
316
|
-
|
|
317
315
|
let documents_with_action =
|
|
318
316
|
js_sys::Reflect::get(documents, &action.to_string().into()).unwrap_or(JsValue::NULL);
|
|
319
317
|
|
|
320
318
|
if documents_with_action.is_null() || documents_with_action.is_undefined() {
|
|
321
|
-
return Ok(
|
|
319
|
+
return Ok(vec![]);
|
|
322
320
|
}
|
|
323
321
|
|
|
324
322
|
let documents_array = js_sys::Array::try_from(documents_with_action)
|
|
325
323
|
.map_err(|e| anyhow!("property '{}' isn't an array: {}", action, e))?;
|
|
326
324
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
Ok(extracted_documents)
|
|
325
|
+
documents_array
|
|
326
|
+
.iter()
|
|
327
|
+
.map(|js_document| {
|
|
328
|
+
js_document
|
|
329
|
+
.to_wasm::<ExtendedDocumentWasm>("ExtendedDocument")
|
|
330
|
+
.map_err(|e| {
|
|
331
|
+
anyhow!(
|
|
332
|
+
"Element in '{}' isn't an Extended Document instance: {:#?}",
|
|
333
|
+
action,
|
|
334
|
+
e
|
|
335
|
+
)
|
|
336
|
+
})
|
|
337
|
+
.map(|wasm_doc| wasm_doc.clone().into())
|
|
338
|
+
})
|
|
339
|
+
.collect()
|
|
344
340
|
}
|
package/src/document/mod.rs
CHANGED
|
@@ -84,6 +84,7 @@ impl DocumentWasm {
|
|
|
84
84
|
let document_type = js_data_contract
|
|
85
85
|
.inner()
|
|
86
86
|
.document_type_for_name(document_type_name.as_str())
|
|
87
|
+
.map_err(ProtocolError::DataContractError)
|
|
87
88
|
.with_js_error()?;
|
|
88
89
|
|
|
89
90
|
let identifier_paths = document_type.identifier_paths().iter().map(|s| s.as_str());
|
|
@@ -298,6 +299,7 @@ impl DocumentWasm {
|
|
|
298
299
|
let document_type = data_contract
|
|
299
300
|
.inner()
|
|
300
301
|
.document_type_for_name(document_type_name.as_str())
|
|
302
|
+
.map_err(ProtocolError::DataContractError)
|
|
301
303
|
.with_js_error()?;
|
|
302
304
|
let bytes = self
|
|
303
305
|
.0
|
|
@@ -329,6 +331,7 @@ impl DocumentWasm {
|
|
|
329
331
|
let document_type = data_contract
|
|
330
332
|
.inner()
|
|
331
333
|
.document_type_for_name(document_type_name.as_str())
|
|
334
|
+
.map_err(ProtocolError::DataContractError)
|
|
332
335
|
.with_js_error()?;
|
|
333
336
|
|
|
334
337
|
if document_type.binary_paths().contains(path) {
|
|
@@ -91,10 +91,9 @@ use crate::errors::consensus::state::document::{
|
|
|
91
91
|
DuplicateUniqueIndexErrorWasm, InvalidDocumentRevisionErrorWasm,
|
|
92
92
|
};
|
|
93
93
|
use crate::errors::consensus::state::identity::{
|
|
94
|
-
IdentityAlreadyExistsErrorWasm,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
MaxIdentityPublicKeyLimitReachedErrorWasm,
|
|
94
|
+
IdentityAlreadyExistsErrorWasm, IdentityPublicKeyIsDisabledErrorWasm,
|
|
95
|
+
IdentityPublicKeyIsReadOnlyErrorWasm, InvalidIdentityPublicKeyIdErrorWasm,
|
|
96
|
+
InvalidIdentityRevisionErrorWasm, MaxIdentityPublicKeyLimitReachedErrorWasm,
|
|
98
97
|
};
|
|
99
98
|
|
|
100
99
|
use crate::errors::consensus::basic::data_contract::{
|
|
@@ -170,9 +169,6 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
|
|
|
170
169
|
StateError::InvalidIdentityRevisionError(e) => {
|
|
171
170
|
InvalidIdentityRevisionErrorWasm::from(e).into()
|
|
172
171
|
}
|
|
173
|
-
StateError::IdentityPublicKeyDisabledAtWindowViolationError(e) => {
|
|
174
|
-
IdentityPublicKeyDisabledAtWindowViolationErrorWasm::from(e).into()
|
|
175
|
-
}
|
|
176
172
|
StateError::IdentityPublicKeyIsReadOnlyError(e) => {
|
|
177
173
|
IdentityPublicKeyIsReadOnlyErrorWasm::from(e).into()
|
|
178
174
|
}
|
|
@@ -26,9 +26,7 @@ impl InvalidIdentityNonceErrorWasm {
|
|
|
26
26
|
|
|
27
27
|
#[wasm_bindgen(js_name=getCurrentIdentityContractNonce)]
|
|
28
28
|
pub fn current_identity_contract_nonce(&self) -> Option<u64> {
|
|
29
|
-
self.inner
|
|
30
|
-
.current_identity_contract_nonce()
|
|
31
|
-
.map(|nonce| *nonce)
|
|
29
|
+
self.inner.current_identity_contract_nonce().copied()
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
#[wasm_bindgen(js_name=getSettingIdentityContractNonce)]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
mod duplicated_identity_public_key_id_state_error;
|
|
2
2
|
mod duplicated_identity_public_key_state_error;
|
|
3
3
|
mod identity_already_exists_error;
|
|
4
|
-
mod identity_public_key_disabled_at_window_violation_error;
|
|
5
4
|
mod identity_public_key_is_disabled_error;
|
|
6
5
|
mod identity_public_key_is_read_only_error;
|
|
7
6
|
mod invalid_identity_contract_nonce_error;
|
|
@@ -13,7 +12,6 @@ mod missing_identity_public_key_ids_error;
|
|
|
13
12
|
pub use duplicated_identity_public_key_id_state_error::*;
|
|
14
13
|
pub use duplicated_identity_public_key_state_error::*;
|
|
15
14
|
pub use identity_already_exists_error::*;
|
|
16
|
-
pub use identity_public_key_disabled_at_window_violation_error::*;
|
|
17
15
|
pub use identity_public_key_is_disabled_error::*;
|
|
18
16
|
pub use identity_public_key_is_read_only_error::*;
|
|
19
17
|
pub use invalid_identity_contract_nonce_error::*;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
use crate::data_contract::errors::InvalidDataContractError;
|
|
2
1
|
use wasm_bindgen::JsValue;
|
|
3
2
|
|
|
4
3
|
use crate::errors::consensus::consensus_error::from_consensus_error;
|
|
@@ -8,13 +7,6 @@ pub fn from_protocol_error(protocol_error: dpp::ProtocolError) -> JsValue {
|
|
|
8
7
|
dpp::ProtocolError::ConsensusError(consensus_error) => {
|
|
9
8
|
from_consensus_error(*consensus_error)
|
|
10
9
|
}
|
|
11
|
-
dpp::ProtocolError::InvalidDataContractError(err) => {
|
|
12
|
-
let raw_data_contract = err.raw_data_contract();
|
|
13
|
-
let protocol = serde_wasm_bindgen::to_value(&raw_data_contract);
|
|
14
|
-
protocol.map_or_else(JsValue::from, |raw_contract| {
|
|
15
|
-
InvalidDataContractError::new(err.errors, raw_contract).into()
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
10
|
dpp::ProtocolError::Error(anyhow_error) => {
|
|
19
11
|
format!("Non-protocol error: {}", anyhow_error).into()
|
|
20
12
|
}
|
|
@@ -257,7 +257,6 @@ impl IdentityFacadeWasm {
|
|
|
257
257
|
) -> Result<IdentityUpdateTransitionWasm, JsValue> {
|
|
258
258
|
let (add_public_keys, disable_public_keys) =
|
|
259
259
|
super::factory_utils::parse_create_identity_update_transition_keys(public_keys)?;
|
|
260
|
-
let now = js_sys::Date::now() as u64;
|
|
261
260
|
|
|
262
261
|
self.0
|
|
263
262
|
.create_identity_update_transition(
|
|
@@ -265,7 +264,6 @@ impl IdentityFacadeWasm {
|
|
|
265
264
|
identity_nonce,
|
|
266
265
|
add_public_keys,
|
|
267
266
|
disable_public_keys,
|
|
268
|
-
Some(now),
|
|
269
267
|
)
|
|
270
268
|
.map(Into::into)
|
|
271
269
|
.with_js_error()
|
|
@@ -243,15 +243,12 @@ impl IdentityFactoryWasm {
|
|
|
243
243
|
let (add_public_keys, disable_public_keys) =
|
|
244
244
|
super::factory_utils::parse_create_identity_update_transition_keys(public_keys)?;
|
|
245
245
|
|
|
246
|
-
let now = js_sys::Date::now() as u64;
|
|
247
|
-
|
|
248
246
|
self.0
|
|
249
247
|
.create_identity_update_transition(
|
|
250
248
|
identity.to_owned().into(),
|
|
251
249
|
identity_nonce,
|
|
252
250
|
add_public_keys,
|
|
253
251
|
disable_public_keys,
|
|
254
|
-
Some(now),
|
|
255
252
|
)
|
|
256
253
|
.map(Into::into)
|
|
257
254
|
.with_js_error()
|
|
@@ -12,6 +12,7 @@ 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
14
|
use dpp::serialization::ValueConvertible;
|
|
15
|
+
use dpp::ProtocolError;
|
|
15
16
|
|
|
16
17
|
use dpp::version::PlatformVersion;
|
|
17
18
|
mod purpose;
|
|
@@ -97,7 +98,7 @@ impl IdentityPublicKeyWasm {
|
|
|
97
98
|
self.0.set_security_level(
|
|
98
99
|
security_level
|
|
99
100
|
.try_into()
|
|
100
|
-
.map_err(|e:
|
|
101
|
+
.map_err(|e: ProtocolError| e.to_string())?,
|
|
101
102
|
);
|
|
102
103
|
Ok(())
|
|
103
104
|
}
|
|
@@ -46,7 +46,7 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
46
46
|
let platform_version =
|
|
47
47
|
&PlatformVersion::get(platform_version).map_err(|e| JsValue::from(e.to_string()))?;
|
|
48
48
|
|
|
49
|
-
IdentityCreditWithdrawalTransition::default_versioned(
|
|
49
|
+
IdentityCreditWithdrawalTransition::default_versioned(platform_version)
|
|
50
50
|
.map(Into::into)
|
|
51
51
|
.map_err(from_dpp_err)
|
|
52
52
|
}
|
|
@@ -78,7 +78,7 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
78
78
|
|
|
79
79
|
#[wasm_bindgen(js_name=getAmount)]
|
|
80
80
|
pub fn get_amount(&self) -> u64 {
|
|
81
|
-
self.0.amount()
|
|
81
|
+
self.0.amount()
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
#[wasm_bindgen(js_name=setAmount)]
|
|
@@ -88,12 +88,12 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
88
88
|
|
|
89
89
|
#[wasm_bindgen(js_name=getCoreFeePerByte)]
|
|
90
90
|
pub fn get_core_fee_per_byte(&self) -> u32 {
|
|
91
|
-
self.0.core_fee_per_byte()
|
|
91
|
+
self.0.core_fee_per_byte()
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
#[wasm_bindgen(js_name=setCoreFeePerByte)]
|
|
95
95
|
pub fn set_core_fee_per_byte(&mut self, core_fee_per_byte: u32) {
|
|
96
|
-
self.0.set_core_fee_per_byte(core_fee_per_byte
|
|
96
|
+
self.0.set_core_fee_per_byte(core_fee_per_byte);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
#[wasm_bindgen(js_name=getPooling)]
|
|
@@ -126,7 +126,7 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
126
126
|
|
|
127
127
|
#[wasm_bindgen(js_name=getNonce)]
|
|
128
128
|
pub fn get_nonce(&self) -> u64 {
|
|
129
|
-
self.0.nonce()
|
|
129
|
+
self.0.nonce()
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
#[wasm_bindgen(js_name=setNonce)]
|
|
@@ -385,7 +385,7 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
385
385
|
#[wasm_bindgen(js_name=setSignature)]
|
|
386
386
|
pub fn set_signature(&mut self, signature: Option<Vec<u8>>) {
|
|
387
387
|
self.0
|
|
388
|
-
.set_signature(BinaryData::new(signature.
|
|
388
|
+
.set_signature(BinaryData::new(signature.unwrap_or_default()))
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
#[wasm_bindgen]
|
|
@@ -9,6 +9,7 @@ use dpp::state_transition::public_key_in_creation::IdentityPublicKeyInCreation;
|
|
|
9
9
|
use js_sys::Reflect::delete_property;
|
|
10
10
|
pub use serde::{Deserialize, Serialize};
|
|
11
11
|
|
|
12
|
+
use dpp::ProtocolError;
|
|
12
13
|
use std::convert::TryInto;
|
|
13
14
|
use wasm_bindgen::prelude::*;
|
|
14
15
|
|
|
@@ -19,6 +20,8 @@ use dpp::version::PlatformVersion;
|
|
|
19
20
|
#[derive(Deserialize, Default)]
|
|
20
21
|
#[serde(rename_all = "camelCase")]
|
|
21
22
|
struct ToObjectOptions {
|
|
23
|
+
#[allow(dead_code)]
|
|
24
|
+
#[deprecated(note = "This function is marked as unused.")]
|
|
22
25
|
pub skip_signature: Option<bool>,
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -94,7 +97,7 @@ impl IdentityPublicKeyWithWitnessWasm {
|
|
|
94
97
|
self.0.set_security_level(
|
|
95
98
|
security_level
|
|
96
99
|
.try_into()
|
|
97
|
-
.map_err(|e:
|
|
100
|
+
.map_err(|e: ProtocolError| e.to_string())?,
|
|
98
101
|
);
|
|
99
102
|
Ok(())
|
|
100
103
|
}
|
package/src/identity/state_transition/identity_update_transition/identity_update_transition.rs
CHANGED
|
@@ -144,23 +144,6 @@ impl IdentityUpdateTransitionWasm {
|
|
|
144
144
|
self.0.set_public_key_ids_to_disable(keys);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
#[wasm_bindgen(js_name=getPublicKeysDisabledAt)]
|
|
148
|
-
pub fn get_public_keys_disabled_at(&self) -> Option<js_sys::Date> {
|
|
149
|
-
self.0
|
|
150
|
-
.public_keys_disabled_at()
|
|
151
|
-
.map(|timestamp| js_sys::Date::new(&JsValue::from_f64(timestamp as f64)))
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
#[wasm_bindgen(js_name=setPublicKeysDisabledAt)]
|
|
155
|
-
pub fn set_public_keys_disabled_at(&mut self, timestamp: Option<js_sys::Date>) {
|
|
156
|
-
if let Some(timestamp) = timestamp {
|
|
157
|
-
self.0
|
|
158
|
-
.set_public_keys_disabled_at(Some(timestamp.get_time() as TimestampMillis));
|
|
159
|
-
} else {
|
|
160
|
-
self.0.set_public_keys_disabled_at(None);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
147
|
#[wasm_bindgen(js_name=getType)]
|
|
165
148
|
pub fn get_type(&self) -> u8 {
|
|
166
149
|
self.0.state_transition_type() as u8
|
|
@@ -231,14 +214,6 @@ impl IdentityUpdateTransitionWasm {
|
|
|
231
214
|
)?;
|
|
232
215
|
}
|
|
233
216
|
|
|
234
|
-
if let Some(timestamp) = object.public_keys_disabled_at {
|
|
235
|
-
js_sys::Reflect::set(
|
|
236
|
-
&js_object,
|
|
237
|
-
&"publicKeysDisabledAt".to_owned().into(),
|
|
238
|
-
&js_sys::Date::new(&JsValue::from_f64(timestamp as f64)).into(),
|
|
239
|
-
)?;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
217
|
if let Some(public_keys_to_add) = object.public_keys_to_add {
|
|
243
218
|
let keys_objects = public_keys_to_add
|
|
244
219
|
.into_iter()
|
|
@@ -325,14 +300,6 @@ impl IdentityUpdateTransitionWasm {
|
|
|
325
300
|
)?;
|
|
326
301
|
}
|
|
327
302
|
|
|
328
|
-
if let Some(timestamp) = object.public_keys_disabled_at {
|
|
329
|
-
js_sys::Reflect::set(
|
|
330
|
-
&js_object,
|
|
331
|
-
&"publicKeysDisabledAt".to_owned().into(),
|
|
332
|
-
&JsValue::from_f64(timestamp as f64),
|
|
333
|
-
)?;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
303
|
if let Some(public_keys_to_add) = object.public_keys_to_add {
|
|
337
304
|
let keys_objects = public_keys_to_add
|
|
338
305
|
.into_iter()
|
|
@@ -19,7 +19,6 @@ pub struct ToObject {
|
|
|
19
19
|
pub revision: u32,
|
|
20
20
|
pub signature: Option<Vec<u8>>,
|
|
21
21
|
pub signature_public_key_id: KeyID,
|
|
22
|
-
pub public_keys_disabled_at: Option<u64>,
|
|
23
22
|
pub public_keys_to_add: Option<Vec<IdentityPublicKeyInCreation>>,
|
|
24
23
|
pub public_key_ids_to_disable: Option<Vec<KeyID>>,
|
|
25
24
|
pub identity_id: Identifier,
|
|
@@ -46,8 +45,6 @@ pub fn to_object_struct(
|
|
|
46
45
|
to_object.signature = signature;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
to_object.public_keys_disabled_at = transition.public_keys_disabled_at();
|
|
50
|
-
|
|
51
48
|
let public_keys_to_add = transition.public_keys_to_add();
|
|
52
49
|
if !public_keys_to_add.is_empty() {
|
|
53
50
|
to_object.public_keys_to_add = Some(public_keys_to_add.to_owned());
|
package/src/lib.rs
CHANGED
|
@@ -192,7 +192,6 @@ describe('IdentityFacade', () => {
|
|
|
192
192
|
stateTransition.getPublicKeysToAdd().map((pk) => pk.toObject()),
|
|
193
193
|
).to.deep.equal(publicKeys.add.map((k) => k.toObject()));
|
|
194
194
|
expect(stateTransition.getPublicKeyIdsToDisable()).to.deep.equal([]);
|
|
195
|
-
expect(stateTransition.getPublicKeysDisabledAt()).to.equal(undefined);
|
|
196
195
|
});
|
|
197
196
|
});
|
|
198
197
|
|
|
@@ -24,7 +24,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
24
24
|
let IdentityPublicKeyIsDisabledError;
|
|
25
25
|
let InvalidIdentityPublicKeyIdError;
|
|
26
26
|
let MissingMasterPublicKeyError;
|
|
27
|
-
let IdentityPublicKeyDisabledAtWindowViolationError;
|
|
28
27
|
let MaxIdentityPublicKeyLimitReachedError;
|
|
29
28
|
let StateTransitionExecutionContext;
|
|
30
29
|
let IdentityUpdateTransitionStateValidator;
|
|
@@ -37,7 +36,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
37
36
|
IdentityPublicKeyIsReadOnlyError,
|
|
38
37
|
IdentityPublicKeyIsDisabledError,
|
|
39
38
|
InvalidIdentityPublicKeyIdError,
|
|
40
|
-
IdentityPublicKeyDisabledAtWindowViolationError,
|
|
41
39
|
MaxIdentityPublicKeyLimitReachedError,
|
|
42
40
|
StateTransitionExecutionContext,
|
|
43
41
|
IdentityUpdateTransitionStateValidator,
|
|
@@ -68,7 +66,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
68
66
|
|
|
69
67
|
stateTransition.setRevision(identity.getRevision() + 1);
|
|
70
68
|
stateTransition.setPublicKeyIdsToDisable(undefined);
|
|
71
|
-
stateTransition.setPublicKeysDisabledAt(undefined);
|
|
72
69
|
|
|
73
70
|
const privateKey = '9b67f852093bc61cea0eeca38599dbfba0de28574d2ed9b99d10d33dc1bde7b2';
|
|
74
71
|
|
|
@@ -116,35 +113,8 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
116
113
|
expect(error.getPublicKeyIndex()).to.equal(0);
|
|
117
114
|
});
|
|
118
115
|
|
|
119
|
-
it('should return invalid result if disabledAt has violated time window', async () => {
|
|
120
|
-
stateTransition.setPublicKeyIdsToDisable([1]);
|
|
121
|
-
// blockTime - 10 minutes
|
|
122
|
-
const disabledAt = new Date(blockTime - 1000 * 60 * 60 * 10);
|
|
123
|
-
stateTransition.setPublicKeysDisabledAt(disabledAt);
|
|
124
|
-
|
|
125
|
-
const timeWindowStart = new Date(blockTime);
|
|
126
|
-
timeWindowStart.setMinutes(
|
|
127
|
-
timeWindowStart.getMinutes() - 5,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const timeWindowEnd = new Date(blockTime);
|
|
131
|
-
timeWindowEnd.setMinutes(
|
|
132
|
-
timeWindowEnd.getMinutes() + 5,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
const result = await validateIdentityUpdateTransitionState(stateTransition);
|
|
136
|
-
|
|
137
|
-
await expectValidationError(result, IdentityPublicKeyDisabledAtWindowViolationError);
|
|
138
|
-
|
|
139
|
-
const [error] = result.getErrors();
|
|
140
|
-
expect(error.getDisabledAt()).to.deep.equal(disabledAt);
|
|
141
|
-
expect(error.getTimeWindowStart()).to.be.instanceOf(Date);
|
|
142
|
-
expect(error.getTimeWindowEnd()).to.be.instanceOf(Date);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
116
|
it('should throw InvalidIdentityPublicKeyIdError if identity does not contain public key with disabling ID', async () => {
|
|
146
117
|
stateTransition.setPublicKeyIdsToDisable([3]);
|
|
147
|
-
stateTransition.setPublicKeysDisabledAt(new Date());
|
|
148
118
|
|
|
149
119
|
const result = await validateIdentityUpdateTransitionState(stateTransition);
|
|
150
120
|
|
|
@@ -156,7 +126,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
156
126
|
|
|
157
127
|
it('should pass when disabling public key', async function () {
|
|
158
128
|
stateTransition.setPublicKeyIdsToDisable([1]);
|
|
159
|
-
stateTransition.setPublicKeysDisabledAt(new Date());
|
|
160
129
|
stateTransition.setPublicKeysToAdd(undefined);
|
|
161
130
|
|
|
162
131
|
const result = await validateIdentityUpdateTransitionState(stateTransition);
|
|
@@ -176,7 +145,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
176
145
|
|
|
177
146
|
it('should pass when adding public key', async function () {
|
|
178
147
|
stateTransition.setPublicKeyIdsToDisable(undefined);
|
|
179
|
-
stateTransition.setPublicKeysDisabledAt(undefined);
|
|
180
148
|
|
|
181
149
|
const result = await validateIdentityUpdateTransitionState(stateTransition);
|
|
182
150
|
|
|
@@ -195,7 +163,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
195
163
|
|
|
196
164
|
it('should pass when both adding and disabling public keys', async function () {
|
|
197
165
|
stateTransition.setPublicKeyIdsToDisable([1]);
|
|
198
|
-
stateTransition.setPublicKeysDisabledAt(new Date());
|
|
199
166
|
|
|
200
167
|
const result = await validateIdentityUpdateTransitionState(stateTransition);
|
|
201
168
|
|
|
@@ -262,7 +229,6 @@ describe.skip('validateIdentityUpdateTransitionStateFactory', () => {
|
|
|
262
229
|
|
|
263
230
|
it('should return valid result on dry run', async function () {
|
|
264
231
|
stateTransition.setPublicKeyIdsToDisable([3]);
|
|
265
|
-
stateTransition.setPublicKeysDisabledAt(new Date());
|
|
266
232
|
|
|
267
233
|
// Make code that executes after dry run check to fail
|
|
268
234
|
stateRepositoryMock.fetchLatestPlatformBlockTime.resolves({});
|
|
@@ -80,7 +80,7 @@ describe('Identity', () => {
|
|
|
80
80
|
type: KeyType.ECDSA_SECP256K1,
|
|
81
81
|
data: Buffer.alloc(36).fill('a'),
|
|
82
82
|
purpose: KeyPurpose.AUTHENTICATION,
|
|
83
|
-
securityLevel: KeySecurityLevel.
|
|
83
|
+
securityLevel: KeySecurityLevel.HIGH,
|
|
84
84
|
readOnly: false,
|
|
85
85
|
disabledAt: null,
|
|
86
86
|
contractBounds: null,
|
|
@@ -159,7 +159,7 @@ describe('Identity', () => {
|
|
|
159
159
|
type: KeyType.ECDSA_SECP256K1,
|
|
160
160
|
data: rawIdentity.publicKeys[0].data.toString('base64'),
|
|
161
161
|
purpose: KeyPurpose.AUTHENTICATION,
|
|
162
|
-
securityLevel: KeySecurityLevel.
|
|
162
|
+
securityLevel: KeySecurityLevel.HIGH,
|
|
163
163
|
readOnly: false,
|
|
164
164
|
disabledAt: null,
|
|
165
165
|
contractBounds: null,
|
|
@@ -250,7 +250,6 @@ describe('IdentityFactory', () => {
|
|
|
250
250
|
expect(stateTransition.getPublicKeysToAdd().map((k) => k.toObject()))
|
|
251
251
|
.to.deep.equal(addPublicKeys.map((k) => k.toObject()));
|
|
252
252
|
expect(stateTransition.getPublicKeyIdsToDisable()).to.deep.equal([0]);
|
|
253
|
-
expect(stateTransition.getPublicKeysDisabledAt()).to.deep.equal(new Date());
|
|
254
253
|
});
|
|
255
254
|
});
|
|
256
255
|
|
|
@@ -12,7 +12,7 @@ describe('IdentityPublicKey', () => {
|
|
|
12
12
|
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
13
13
|
data: keyData,
|
|
14
14
|
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
15
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.
|
|
15
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.HIGH,
|
|
16
16
|
readOnly: false,
|
|
17
17
|
contractBounds: null,
|
|
18
18
|
};
|
|
@@ -194,7 +194,7 @@ describe('IdentityPublicKey', () => {
|
|
|
194
194
|
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
195
195
|
data: 'AkVuTKyF3YgKLAQlLEtaUL2HTditwGILfWUVqjzYnIgH',
|
|
196
196
|
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
197
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.
|
|
197
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.HIGH,
|
|
198
198
|
readOnly: false,
|
|
199
199
|
disabledAt: now.getTime(),
|
|
200
200
|
contractBounds: null,
|
|
@@ -215,7 +215,7 @@ describe('IdentityPublicKey', () => {
|
|
|
215
215
|
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
216
216
|
data: Buffer.from('AkVuTKyF3YgKLAQlLEtaUL2HTditwGILfWUVqjzYnIgH', 'base64'),
|
|
217
217
|
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
218
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.
|
|
218
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.HIGH,
|
|
219
219
|
readOnly: false,
|
|
220
220
|
disabledAt: now.getTime(),
|
|
221
221
|
contractBounds: null,
|
package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js
CHANGED
|
@@ -99,23 +99,6 @@ describe('IdentityUpdateTransition', () => {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
describe('#getPublicKeysDisabledAt', () => {
|
|
103
|
-
it('should return time to disable public keys', () => {
|
|
104
|
-
expect(stateTransition.getPublicKeysDisabledAt())
|
|
105
|
-
.to.deep.equal(rawStateTransition.publicKeysDisabledAt);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('#setPublicKeysDisabledAt', () => {
|
|
110
|
-
it('should set time to disable public keys', () => {
|
|
111
|
-
const now = new Date();
|
|
112
|
-
|
|
113
|
-
stateTransition.setPublicKeysDisabledAt(now);
|
|
114
|
-
|
|
115
|
-
expect(stateTransition.getPublicKeysDisabledAt()).to.deep.equal(new Date(now));
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
102
|
describe('#toObject', () => {
|
|
120
103
|
it('should return raw state transition', () => {
|
|
121
104
|
rawStateTransition = stateTransition.toObject();
|
|
@@ -126,7 +109,6 @@ describe('IdentityUpdateTransition', () => {
|
|
|
126
109
|
signature: undefined,
|
|
127
110
|
identityId: rawStateTransition.identityId,
|
|
128
111
|
revision: rawStateTransition.revision,
|
|
129
|
-
publicKeysDisabledAt: rawStateTransition.publicKeysDisabledAt,
|
|
130
112
|
addPublicKeys: rawStateTransition.addPublicKeys,
|
|
131
113
|
disablePublicKeys: rawStateTransition.disablePublicKeys,
|
|
132
114
|
signaturePublicKeyId: 0,
|
|
@@ -141,7 +123,6 @@ describe('IdentityUpdateTransition', () => {
|
|
|
141
123
|
type: StateTransitionTypes.IdentityUpdate,
|
|
142
124
|
identityId: rawStateTransition.identityId,
|
|
143
125
|
revision: rawStateTransition.revision,
|
|
144
|
-
publicKeysDisabledAt: rawStateTransition.publicKeysDisabledAt,
|
|
145
126
|
addPublicKeys: rawStateTransition.addPublicKeys,
|
|
146
127
|
disablePublicKeys: rawStateTransition.disablePublicKeys,
|
|
147
128
|
});
|
|
@@ -149,7 +130,6 @@ describe('IdentityUpdateTransition', () => {
|
|
|
149
130
|
|
|
150
131
|
it('should return raw state transition without optional properties', () => {
|
|
151
132
|
stateTransition.setPublicKeyIdsToDisable(undefined);
|
|
152
|
-
stateTransition.setPublicKeysDisabledAt(undefined);
|
|
153
133
|
stateTransition.setPublicKeysToAdd(undefined);
|
|
154
134
|
|
|
155
135
|
rawStateTransition = stateTransition.toObject();
|
|
@@ -175,7 +155,6 @@ describe('IdentityUpdateTransition', () => {
|
|
|
175
155
|
signature: undefined,
|
|
176
156
|
identityId: stateTransition.getIdentityId().toString(),
|
|
177
157
|
revision: rawStateTransition.revision,
|
|
178
|
-
publicKeysDisabledAt: rawStateTransition.publicKeysDisabledAt.getTime(),
|
|
179
158
|
addPublicKeys: stateTransition.getPublicKeysToAdd().map((k) => k.toJSON()),
|
|
180
159
|
disablePublicKeys: rawStateTransition.disablePublicKeys,
|
|
181
160
|
signaturePublicKeyId: 0,
|