@dashevo/wasm-dpp 2.0.0-rc.1 → 2.0.0-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/wasm-dpp",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.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": "2.0.0-rc.1",
47
+ "@dashevo/dpns-contract": "2.0.0-rc.2",
48
48
  "@types/bs58": "^4.0.1",
49
49
  "@types/node": "^14.6.0",
50
50
  "@yarnpkg/pnpify": "^4.0.0-rc.42",
@@ -1 +1,2 @@
1
1
  pub mod invalid_state_transition_error;
2
+ pub mod state_transition_is_not_active_error;
@@ -0,0 +1,79 @@
1
+ use dpp::version::ProtocolVersion;
2
+ use std::ops::RangeInclusive;
3
+ use wasm_bindgen::prelude::*;
4
+
5
+ #[wasm_bindgen(js_name = StateTransitionIsNotActiveError)]
6
+ pub struct StateTransitionIsNotActiveErrorWasm {
7
+ state_transition_type: String,
8
+ active_version_range_start: ProtocolVersion,
9
+ active_version_range_end: ProtocolVersion,
10
+ current_protocol_version: ProtocolVersion,
11
+ }
12
+
13
+ impl StateTransitionIsNotActiveErrorWasm {
14
+ pub fn new(
15
+ state_transition_type: String,
16
+ active_version_range: RangeInclusive<ProtocolVersion>,
17
+ current_protocol_version: ProtocolVersion,
18
+ ) -> Self {
19
+ Self {
20
+ state_transition_type,
21
+ active_version_range_start: *active_version_range.start(),
22
+ active_version_range_end: *active_version_range.end(),
23
+ current_protocol_version,
24
+ }
25
+ }
26
+ }
27
+
28
+ #[wasm_bindgen(js_class = StateTransitionIsNotActiveError)]
29
+ impl StateTransitionIsNotActiveErrorWasm {
30
+ #[wasm_bindgen(js_name = getStateTransitionType)]
31
+ pub fn get_state_transition_type(&self) -> String {
32
+ self.state_transition_type.clone()
33
+ }
34
+
35
+ #[wasm_bindgen(js_name = getActiveVersionRangeStart)]
36
+ pub fn get_active_version_range_start(&self) -> u32 {
37
+ self.active_version_range_start
38
+ }
39
+
40
+ #[wasm_bindgen(js_name = getActiveVersionRangeEnd)]
41
+ pub fn get_active_version_range_end(&self) -> u32 {
42
+ self.active_version_range_end
43
+ }
44
+
45
+ #[wasm_bindgen(js_name = getCurrentProtocolVersion)]
46
+ pub fn get_current_protocol_version(&self) -> u32 {
47
+ self.current_protocol_version
48
+ }
49
+
50
+ #[wasm_bindgen(js_name = toObject)]
51
+ pub fn to_object(&self) -> JsValue {
52
+ let object = js_sys::Object::new();
53
+ js_sys::Reflect::set(
54
+ &object,
55
+ &"stateTransitionType".into(),
56
+ &self.state_transition_type.clone().into(),
57
+ )
58
+ .unwrap();
59
+ js_sys::Reflect::set(
60
+ &object,
61
+ &"activeVersionRangeStart".into(),
62
+ &JsValue::from(self.active_version_range_start),
63
+ )
64
+ .unwrap();
65
+ js_sys::Reflect::set(
66
+ &object,
67
+ &"activeVersionRangeEnd".into(),
68
+ &JsValue::from(self.active_version_range_end),
69
+ )
70
+ .unwrap();
71
+ js_sys::Reflect::set(
72
+ &object,
73
+ &"currentProtocolVersion".into(),
74
+ &JsValue::from(self.current_protocol_version),
75
+ )
76
+ .unwrap();
77
+ object.into()
78
+ }
79
+ }
@@ -7,6 +7,7 @@ use crate::identity::state_transition::{
7
7
  IdentityUpdateTransitionWasm,
8
8
  };
9
9
  use crate::state_transition::errors::invalid_state_transition_error::InvalidStateTransitionErrorWasm;
10
+ use crate::state_transition::errors::state_transition_is_not_active_error::StateTransitionIsNotActiveErrorWasm;
10
11
  use crate::voting::state_transition::masternode_vote_transition::MasternodeVoteTransitionWasm;
11
12
  use dpp::state_transition::errors::StateTransitionError;
12
13
  use dpp::state_transition::state_transition_factory::StateTransitionFactory;
@@ -70,6 +71,16 @@ impl StateTransitionFactoryWasm {
70
71
  serde_wasm_bindgen::to_value(&raw_state_transition)?,
71
72
  )
72
73
  .into()),
74
+ StateTransitionError::StateTransitionIsNotActiveError {
75
+ state_transition_type,
76
+ active_version_range,
77
+ current_protocol_version,
78
+ } => Err(StateTransitionIsNotActiveErrorWasm::new(
79
+ state_transition_type,
80
+ active_version_range,
81
+ current_protocol_version,
82
+ )
83
+ .into()),
73
84
  },
74
85
  Err(other) => Err(from_dpp_err(other)),
75
86
  }