pshenmic-dpp 1.0.2 → 1.0.3

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": "pshenmic-dpp",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "dist/wasm/pshenmic_dpp.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,5 +20,6 @@
20
20
  "babel": "^6.23.0",
21
21
  "babel-cli": "^6.26.0",
22
22
  "typescript": "^5.8.2"
23
- }
23
+ },
24
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
24
25
  }
@@ -0,0 +1,21 @@
1
+ [package]
2
+ name = "pshenmic_dpp_data_contract"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+
6
+ [lib]
7
+ crate-type = ["cdylib", "lib"]
8
+
9
+ [dependencies]
10
+ wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] }
11
+ pshenmic_dpp_utils = {path = "../utils"}
12
+ pshenmic_dpp_enums = {path = "../enums"}
13
+ dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
14
+ "data-contract-json-conversion"
15
+ ]}
16
+ serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
17
+ #serde = { version = "1.0.219", features = ["derive"] }
18
+
19
+ [profile.release]
20
+ lto = true
21
+ opt-level = 'z'
@@ -0,0 +1,147 @@
1
+ use dpp::dashcore::hashes::serde::Serialize;
2
+ use dpp::data_contract::accessors::v0::DataContractV0Getters;
3
+ use dpp::data_contract::conversion::json::DataContractJsonConversionMethodsV0;
4
+ use dpp::data_contract::conversion::value::v0::DataContractValueConversionMethodsV0;
5
+ use dpp::data_contract::document_type::DocumentTypeRef;
6
+ use dpp::data_contract::errors::DataContractError;
7
+ use dpp::data_contract::schema::DataContractSchemaMethodsV0;
8
+ use dpp::data_contract::{DataContract, DataContractV0};
9
+ use dpp::platform_value::string_encoding::Encoding::Base58;
10
+ use dpp::serialization::{
11
+ PlatformDeserializableWithPotentialValidationFromVersionedStructure,
12
+ PlatformSerializableWithPlatformVersion,
13
+ };
14
+ use pshenmic_dpp_enums::platform::PlatformVersionWASM;
15
+ use pshenmic_dpp_utils::{ToSerdeJSONExt, WithJsError};
16
+ use wasm_bindgen::JsValue;
17
+ use wasm_bindgen::prelude::wasm_bindgen;
18
+
19
+ #[wasm_bindgen(js_name = "DataContractWASM")]
20
+ #[derive(Clone)]
21
+ pub struct DataContractWASM(DataContract);
22
+
23
+ impl From<DataContract> for DataContractWASM {
24
+ fn from(v: DataContract) -> Self {
25
+ DataContractWASM(v)
26
+ }
27
+ }
28
+
29
+ impl From<DataContractWASM> for DataContract {
30
+ fn from(v: DataContractWASM) -> Self {
31
+ v.0
32
+ }
33
+ }
34
+
35
+ #[wasm_bindgen]
36
+ impl DataContractWASM {
37
+ #[wasm_bindgen(constructor)]
38
+ pub fn new(
39
+ js_value: JsValue,
40
+ full_validation: bool,
41
+ platform_version: PlatformVersionWASM,
42
+ ) -> Result<DataContractWASM, JsValue> {
43
+ let value = js_value.with_serde_to_platform_value();
44
+
45
+ match value {
46
+ Ok(v) => {
47
+ let v0_contract =
48
+ DataContractV0::from_value(v, full_validation, &platform_version.into())
49
+ .with_js_error()?;
50
+
51
+ Ok(DataContractWASM(DataContract::V0(v0_contract)))
52
+ }
53
+ Err(err) => Err(err),
54
+ }
55
+ }
56
+
57
+ #[wasm_bindgen(js_name = "fromBytes")]
58
+ pub fn from_bytes(
59
+ bytes: Vec<u8>,
60
+ full_validation: bool,
61
+ platform_version: PlatformVersionWASM,
62
+ ) -> Result<DataContractWASM, JsValue> {
63
+ let rs_data_contract = DataContract::versioned_deserialize(
64
+ &bytes.as_slice(),
65
+ full_validation,
66
+ &platform_version.into(),
67
+ )
68
+ .with_js_error();
69
+
70
+ match rs_data_contract {
71
+ Ok(rs_data_contract) => Ok(DataContractWASM(rs_data_contract)),
72
+ Err(err) => Err(err),
73
+ }
74
+ }
75
+
76
+ #[wasm_bindgen(js_name = "toBytes")]
77
+ pub fn to_bytes(&self, platform_version: PlatformVersionWASM) -> Result<Vec<u8>, JsValue> {
78
+ let rs_data_contract: DataContract = self.0.clone();
79
+
80
+ rs_data_contract
81
+ .serialize_to_bytes_with_platform_version(&platform_version.into())
82
+ .with_js_error()
83
+ }
84
+
85
+ #[wasm_bindgen(js_name = "toValue")]
86
+ pub fn to_value(&self, platform_version: PlatformVersionWASM) -> Result<JsValue, JsValue> {
87
+ let value = self
88
+ .0
89
+ .clone()
90
+ .to_value(&platform_version.into())
91
+ .with_js_error();
92
+
93
+ match value {
94
+ Ok(v) => Ok(serde_wasm_bindgen::to_value(&v).unwrap()),
95
+ Err(err) => Err(err),
96
+ }
97
+ }
98
+
99
+ #[wasm_bindgen(js_name = "getSchema")]
100
+ pub fn get_schema(&self) -> JsValue {
101
+ let serializer = serde_wasm_bindgen::Serializer::json_compatible();
102
+
103
+ self.0.document_schemas().serialize(&serializer).unwrap()
104
+ }
105
+
106
+ #[wasm_bindgen(js_name = "getDataContractVersion")]
107
+ pub fn get_data_contract_version(&self) -> u32 {
108
+ self.0.version()
109
+ }
110
+
111
+ #[wasm_bindgen(js_name = "getDataContractIdentifier")]
112
+ pub fn get_data_contract_identifier(&self) -> JsValue {
113
+ JsValue::from_str(&*self.0.id().to_string(Base58))
114
+ }
115
+
116
+ #[wasm_bindgen(js_name = "getOwnerId")]
117
+ pub fn get_owner_id(&self) -> JsValue {
118
+ JsValue::from_str(&*self.0.owner_id().to_string(Base58))
119
+ }
120
+
121
+ #[wasm_bindgen(js_name = "getConfig")]
122
+ pub fn get_config(&self) -> JsValue {
123
+ self.0
124
+ .config()
125
+ .serialize(&serde_wasm_bindgen::Serializer::json_compatible())
126
+ .unwrap()
127
+ }
128
+
129
+ #[wasm_bindgen(js_name = "toJson")]
130
+ pub fn to_json(&self, platform_version: PlatformVersionWASM) -> Result<JsValue, JsValue> {
131
+ let json = self.0.to_json(&platform_version.into()).with_js_error();
132
+
133
+ match json {
134
+ Ok(json) => Ok(json.serialize(&serde_wasm_bindgen::Serializer::json_compatible())?),
135
+ Err(err) => Err(err),
136
+ }
137
+ }
138
+ }
139
+
140
+ impl DataContractWASM {
141
+ pub fn get_document_type_ref_by_name(
142
+ &self,
143
+ name: String,
144
+ ) -> Result<DocumentTypeRef, DataContractError> {
145
+ self.0.document_type_for_name(name.as_str()).clone()
146
+ }
147
+ }
@@ -9,9 +9,12 @@ crate-type = ["cdylib", "lib"]
9
9
  [dependencies]
10
10
  wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] }
11
11
  pshenmic_dpp_utils = {path = "../utils"}
12
+ pshenmic_dpp_enums = {path = "../enums"}
13
+ pshenmic_dpp_data_contract = {path = "../data_contract"}
12
14
  dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
13
- "document-json-conversion"
15
+ "document-value-conversion"
14
16
  ]}
17
+ #serde = { version = "1.0.197", features = ["derive"] }
15
18
  serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
16
19
 
17
20
  [profile.release]
@@ -1,6 +1,6 @@
1
1
  mod methods;
2
2
 
3
- use dpp::document::{Document, DocumentV0Getters};
3
+ use dpp::document::{Document, DocumentV0, DocumentV0Getters};
4
4
  use dpp::identifier::Identifier;
5
5
  use dpp::identity::TimestampMillis;
6
6
  use dpp::platform_value::Value;
@@ -29,6 +29,49 @@ pub struct DocumentWASM {
29
29
  entropy: Option<[u8; 32]>,
30
30
  }
31
31
 
32
+ impl From<DocumentWASM> for Document {
33
+ fn from(wasm_doc: DocumentWASM) -> Self {
34
+ Document::V0(DocumentV0 {
35
+ id: wasm_doc.id,
36
+ owner_id: wasm_doc.owner_id,
37
+ properties: wasm_doc.properties,
38
+ revision: wasm_doc.revision,
39
+ created_at: wasm_doc.created_at,
40
+ updated_at: wasm_doc.updated_at,
41
+ transferred_at: wasm_doc.transferred_at,
42
+ created_at_block_height: wasm_doc.created_at_block_height,
43
+ updated_at_block_height: wasm_doc.updated_at_block_height,
44
+ transferred_at_block_height: wasm_doc.transferred_at_block_height,
45
+ created_at_core_block_height: wasm_doc.created_at_core_block_height,
46
+ updated_at_core_block_height: wasm_doc.updated_at_core_block_height,
47
+ transferred_at_core_block_height: wasm_doc.transferred_at_core_block_height,
48
+ })
49
+ }
50
+ }
51
+
52
+ impl From<Document> for DocumentWASM {
53
+ fn from(doc: Document) -> Self {
54
+ DocumentWASM {
55
+ id: doc.id(),
56
+ owner_id: doc.owner_id(),
57
+ revision: doc.revision(),
58
+ data_contract_id: Default::default(),
59
+ document_type_name: "".to_string(),
60
+ properties: doc.properties().clone(),
61
+ created_at: doc.created_at(),
62
+ updated_at: doc.updated_at(),
63
+ transferred_at: doc.transferred_at(),
64
+ created_at_block_height: doc.created_at_block_height(),
65
+ updated_at_block_height: doc.updated_at_block_height(),
66
+ transferred_at_block_height: doc.transferred_at_block_height(),
67
+ created_at_core_block_height: doc.created_at_core_block_height(),
68
+ updated_at_core_block_height: doc.updated_at_core_block_height(),
69
+ transferred_at_core_block_height: doc.transferred_at_core_block_height(),
70
+ entropy: None,
71
+ }
72
+ }
73
+ }
74
+
32
75
  impl DocumentWASM {
33
76
  pub fn from_batch(
34
77
  document: Document,
@@ -1,14 +1,21 @@
1
1
  use crate::DocumentWASM;
2
+ use dpp::ProtocolError;
3
+ use dpp::dashcore::hashes::serde::Serialize;
4
+ use dpp::data_contract::JsonValue;
5
+ use dpp::document::Document;
6
+ use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0;
2
7
  use dpp::platform_value::converter::serde_json::BTreeValueJsonConverter;
3
8
  use dpp::platform_value::string_encoding::Encoding::Base58;
4
9
  use dpp::prelude::Revision;
5
- use pshenmic_dpp_utils::{ToSerdeJSONExt, identifier_from_js_value};
10
+ use pshenmic_dpp_data_contract::DataContractWASM;
11
+ use pshenmic_dpp_enums::platform::PlatformVersionWASM;
12
+ use pshenmic_dpp_utils::{ToSerdeJSONExt, WithJsError, identifier_from_js_value};
6
13
  use wasm_bindgen::JsValue;
7
14
  use wasm_bindgen::prelude::wasm_bindgen;
8
15
 
9
16
  #[wasm_bindgen]
10
17
  impl DocumentWASM {
11
- #[wasm_bindgen(js_name=new)]
18
+ #[wasm_bindgen(constructor)]
12
19
  pub fn js_new(
13
20
  js_raw_document: JsValue,
14
21
  js_document_type_name: &str,
@@ -50,12 +57,15 @@ impl DocumentWASM {
50
57
  }
51
58
 
52
59
  #[wasm_bindgen(js_name=getProperties)]
53
- pub fn js_get_properties(&self) -> JsValue {
54
- let json = &self.properties.to_json_value().unwrap();
55
-
56
- let obj = json.as_object().unwrap();
57
-
58
- serde_wasm_bindgen::to_value(obj).unwrap()
60
+ pub fn js_get_properties(&self) -> Result<JsValue, JsValue> {
61
+ let json_value: JsonValue = self
62
+ .properties
63
+ .to_json_value()
64
+ .map_err(ProtocolError::ValueError)
65
+ .with_js_error()?;
66
+
67
+ let js_value = json_value.serialize(&serde_wasm_bindgen::Serializer::json_compatible())?;
68
+ Ok(js_value)
59
69
  }
60
70
 
61
71
  #[wasm_bindgen(js_name=getRevision)]
@@ -201,4 +211,50 @@ impl DocumentWASM {
201
211
  pub fn set_document_type_name(&mut self, document_type_name: &str) {
202
212
  self.document_type_name = document_type_name.to_string();
203
213
  }
214
+
215
+ #[wasm_bindgen(js_name=toBytes)]
216
+ pub fn to_bytes(
217
+ &self,
218
+ data_contract: &DataContractWASM,
219
+ type_name: String,
220
+ platform_version: PlatformVersionWASM,
221
+ ) -> Result<Vec<u8>, JsValue> {
222
+ let rs_document: Document = Document::from(self.clone());
223
+
224
+ let document_type_ref = data_contract
225
+ .get_document_type_ref_by_name(type_name)
226
+ .map_err(|err| JsValue::from_str(err.to_string().as_str()))?;
227
+
228
+ DocumentPlatformConversionMethodsV0::serialize(
229
+ &rs_document,
230
+ document_type_ref,
231
+ &platform_version.into(),
232
+ )
233
+ .with_js_error()
234
+ }
235
+
236
+ #[wasm_bindgen(js_name=fromBytes)]
237
+ pub fn from_bytes(
238
+ bytes: Vec<u8>,
239
+ data_contract: &DataContractWASM,
240
+ type_name: String,
241
+ platform_version: PlatformVersionWASM,
242
+ ) -> Result<DocumentWASM, JsValue> {
243
+ let document_type_ref = match data_contract.get_document_type_ref_by_name(type_name) {
244
+ Ok(type_ref) => Ok(type_ref),
245
+ Err(err) => Err(JsValue::from_str(err.to_string().as_str())),
246
+ }?;
247
+
248
+ let rs_document = Document::from_bytes(
249
+ bytes.as_slice(),
250
+ document_type_ref,
251
+ &platform_version.into(),
252
+ )
253
+ .with_js_error();
254
+
255
+ match rs_document {
256
+ Ok(doc) => Ok(DocumentWASM::from(doc)),
257
+ Err(err) => Err(err),
258
+ }
259
+ }
204
260
  }
@@ -12,10 +12,8 @@ pshenmic_dpp_document = {path = "../document"}
12
12
  pshenmic_dpp_enums = {path = "../enums"}
13
13
  pshenmic_dpp_utils = {path = "../utils"}
14
14
  pshenmic_dpp_state_transition = {path = "../state_transition"}
15
- pshenmic_dpp_mock_bls = {path = "../mock_bls"}
16
15
  dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
17
16
  "document-json-conversion",
18
- "state-transition-signing"
19
17
  ]}
20
18
 
21
19
 
@@ -83,7 +83,7 @@ impl From<(DocumentTransition, DocumentsBatchTransition)> for DocumentBatchWASM
83
83
 
84
84
  #[wasm_bindgen]
85
85
  impl DocumentBatchWASM {
86
- #[wasm_bindgen(js_name=new)]
86
+ #[wasm_bindgen(constructor)]
87
87
  pub fn new(
88
88
  batch_type: BatchType,
89
89
  document: DocumentWASM,
@@ -163,8 +163,8 @@ impl DocumentBatchWASM {
163
163
  StateTransitionWASM::from(st)
164
164
  }
165
165
 
166
- #[wasm_bindgen(js_name=toBuffer)]
167
- pub fn to_buffer(&self) -> Result<JsValue, JsValue> {
166
+ #[wasm_bindgen(js_name=toBytes)]
167
+ pub fn to_bytes(&self) -> Result<JsValue, JsValue> {
168
168
  let bytes = self.batch.serialize_to_bytes().with_js_error();
169
169
 
170
170
  match bytes {
@@ -195,7 +195,8 @@ impl DocumentBatchWASM {
195
195
  }
196
196
  }
197
197
 
198
- pub fn from_buffer(bytes: Vec<u8>) -> Result<DocumentBatchWASM, JsValue> {
198
+ #[wasm_bindgen(js_name=fromBytes)]
199
+ pub fn from_bytes(bytes: Vec<u8>) -> Result<DocumentBatchWASM, JsValue> {
199
200
  let batch_transition =
200
201
  DocumentsBatchTransition::deserialize_from_bytes(bytes.as_slice()).with_js_error();
201
202
 
@@ -11,7 +11,6 @@ wasm-bindgen = "0.2.100"
11
11
  dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
12
12
  "identity-value-conversion",
13
13
  ]}
14
-
15
14
  [profile.release]
16
15
  lto = true
17
16
  opt-level = 'z'
@@ -1,2 +1,3 @@
1
1
  pub mod batch;
2
2
  pub mod keys;
3
+ pub mod platform;
@@ -0,0 +1,38 @@
1
+ use dpp::version::PlatformVersion;
2
+ use dpp::version::v1::PLATFORM_V1;
3
+ use dpp::version::v2::PLATFORM_V2;
4
+ use dpp::version::v3::PLATFORM_V3;
5
+ use dpp::version::v4::PLATFORM_V4;
6
+ use dpp::version::v5::PLATFORM_V5;
7
+ use dpp::version::v6::PLATFORM_V6;
8
+ use dpp::version::v7::PLATFORM_V7;
9
+ use dpp::version::v8::PLATFORM_V8;
10
+ use wasm_bindgen::prelude::wasm_bindgen;
11
+
12
+ #[wasm_bindgen(js_name = "PlatformVersionWASM")]
13
+ #[allow(non_camel_case_types)]
14
+ pub enum PlatformVersionWASM {
15
+ PLATFORM_V1,
16
+ PLATFORM_V2,
17
+ PLATFORM_V3,
18
+ PLATFORM_V4,
19
+ PLATFORM_V5,
20
+ PLATFORM_V6,
21
+ PLATFORM_V7,
22
+ PLATFORM_V8,
23
+ }
24
+
25
+ impl From<PlatformVersionWASM> for PlatformVersion {
26
+ fn from(value: PlatformVersionWASM) -> Self {
27
+ match value {
28
+ PlatformVersionWASM::PLATFORM_V1 => PLATFORM_V1,
29
+ PlatformVersionWASM::PLATFORM_V2 => PLATFORM_V2,
30
+ PlatformVersionWASM::PLATFORM_V3 => PLATFORM_V3,
31
+ PlatformVersionWASM::PLATFORM_V4 => PLATFORM_V4,
32
+ PlatformVersionWASM::PLATFORM_V5 => PLATFORM_V5,
33
+ PlatformVersionWASM::PLATFORM_V6 => PLATFORM_V6,
34
+ PlatformVersionWASM::PLATFORM_V7 => PLATFORM_V7,
35
+ PlatformVersionWASM::PLATFORM_V8 => PLATFORM_V8,
36
+ }
37
+ }
38
+ }
@@ -8,9 +8,12 @@ crate-type = ["cdylib", "lib"]
8
8
 
9
9
  [dependencies]
10
10
  wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] }
11
- dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false}
11
+ dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
12
+ "identity-serialization"
13
+ ]}
12
14
  serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
13
15
  pshenmic_dpp_public_key = { path = "../public_key" }
16
+ pshenmic_dpp_utils = { path = "../utils" }
14
17
 
15
18
  [profile.release]
16
19
  lto = true
@@ -2,8 +2,10 @@ use dpp::identifier::Identifier;
2
2
  use dpp::identity::accessors::{IdentityGettersV0, IdentitySettersV0};
3
3
  use dpp::identity::{Identity, KeyID};
4
4
  use dpp::platform_value::string_encoding::Encoding::Base58;
5
+ use dpp::serialization::{PlatformDeserializable, PlatformSerializable};
5
6
  use dpp::version::PlatformVersion;
6
7
  use pshenmic_dpp_public_key::IdentityPublicKeyWASM;
8
+ use pshenmic_dpp_utils::WithJsError;
7
9
  use wasm_bindgen::JsValue;
8
10
  use wasm_bindgen::prelude::wasm_bindgen;
9
11
 
@@ -13,13 +15,17 @@ pub struct IdentityWASM(Identity);
13
15
  #[wasm_bindgen]
14
16
  impl IdentityWASM {
15
17
  #[wasm_bindgen(constructor)]
16
- pub fn new(js_identifier: String) -> IdentityWASM {
18
+ pub fn new(js_identifier: String) -> Result<IdentityWASM, JsValue> {
17
19
  let identifier = Identifier::from_string(&*js_identifier, Base58);
18
20
 
19
21
  let identity =
20
- Identity::create_basic_identity(identifier.unwrap(), PlatformVersion::first()).unwrap();
22
+ Identity::create_basic_identity(identifier.unwrap(), PlatformVersion::first())
23
+ .with_js_error();
21
24
 
22
- IdentityWASM(identity)
25
+ match identity {
26
+ Ok(identity) => Ok(IdentityWASM(identity)),
27
+ Err(err) => Err(err),
28
+ }
23
29
  }
24
30
 
25
31
  #[wasm_bindgen(js_name = "setId")]
@@ -72,6 +78,20 @@ impl IdentityWASM {
72
78
  #[wasm_bindgen(js_name = "getPublicKeys")]
73
79
  pub fn get_public_keys(&self) -> JsValue {
74
80
  let keys = self.0.public_keys();
81
+
75
82
  serde_wasm_bindgen::to_value(keys).unwrap()
76
83
  }
84
+
85
+ #[wasm_bindgen(js_name = "toBytes")]
86
+ pub fn to_bytes(&self) -> Result<Vec<u8>, JsValue> {
87
+ self.0.serialize_to_bytes().with_js_error()
88
+ }
89
+
90
+ #[wasm_bindgen(js_name = "fromBytes")]
91
+ pub fn from_bytes(bytes: Vec<u8>) -> Result<IdentityWASM, JsValue> {
92
+ match Identity::deserialize_from_bytes(bytes.as_slice()).with_js_error() {
93
+ Ok(identity) => Ok(IdentityWASM(identity)),
94
+ Err(err) => Err(err),
95
+ }
96
+ }
77
97
  }
@@ -64,8 +64,8 @@ impl IdentityCreateTransitionWASM {
64
64
  StateTransitionWASM::from(StateTransition::IdentityCreate(self.clone().0))
65
65
  }
66
66
 
67
- #[wasm_bindgen(js_name = "toBuffer")]
68
- pub fn to_buffer(&self) -> Result<JsValue, JsValue> {
67
+ #[wasm_bindgen(js_name = "toBytes")]
68
+ pub fn to_bytes(&self) -> Result<JsValue, JsValue> {
69
69
  let bytes = self.0.serialize_to_bytes().with_js_error();
70
70
 
71
71
  match bytes {
@@ -86,8 +86,8 @@ impl IdentityCreateTransitionWASM {
86
86
  }
87
87
  }
88
88
 
89
- #[wasm_bindgen(js_name = "fromBuffer")]
90
- pub fn from_buffer(bytes: Vec<u8>) -> Result<IdentityCreateTransitionWASM, JsValue> {
89
+ #[wasm_bindgen(js_name = "fromBytes")]
90
+ pub fn from_bytes(bytes: Vec<u8>) -> Result<IdentityCreateTransitionWASM, JsValue> {
91
91
  let rs_transition =
92
92
  IdentityCreateTransition::deserialize_from_bytes(bytes.as_slice()).with_js_error();
93
93
 
@@ -7,7 +7,7 @@ pub struct PrivateKeyWASM(PrivateKey);
7
7
 
8
8
  #[wasm_bindgen]
9
9
  impl PrivateKeyWASM {
10
- #[wasm_bindgen(js_name = "new")]
10
+ #[wasm_bindgen(constructor)]
11
11
  pub fn new(wif: &str) -> Result<Self, JsValue> {
12
12
  let pk = PrivateKey::from_wif(wif).map_err(|err| JsValue::from_str(&*err.to_string()));
13
13
 
@@ -128,16 +128,14 @@ impl IdentityPublicKeyWASM {
128
128
  self.0.set_disabled_at(disabled_at)
129
129
  }
130
130
 
131
- #[wasm_bindgen(js_name = toBuffer)]
132
- pub fn to_buffer(&self) -> Result<Vec<u8>, JsValue> {
131
+ #[wasm_bindgen(js_name = toBytes)]
132
+ pub fn to_byes(&self) -> Result<Vec<u8>, JsValue> {
133
133
  self.0.serialize_to_bytes().with_js_error()
134
134
  }
135
135
 
136
- #[wasm_bindgen(js_name = fromBuffer)]
137
- pub fn from_buffer(buffer: Vec<u8>) -> Result<IdentityPublicKeyWASM, JsValue> {
138
- let rs_pk = IdentityPublicKey::deserialize_from_bytes(buffer.as_slice()).with_js_error();
139
-
140
- match rs_pk {
136
+ #[wasm_bindgen(js_name = fromBytes)]
137
+ pub fn from_bytes(bytes: Vec<u8>) -> Result<IdentityPublicKeyWASM, JsValue> {
138
+ match IdentityPublicKey::deserialize_from_bytes(bytes.as_slice()).with_js_error() {
141
139
  Ok(pk) => Ok(IdentityPublicKeyWASM(pk)),
142
140
  Err(e) => Err(e),
143
141
  }
@@ -77,15 +77,16 @@ impl StateTransitionWASM {
77
77
  }
78
78
  }
79
79
 
80
- #[wasm_bindgen(js_name=toBuffer)]
81
- pub fn to_buffer(&self) -> Result<JsValue, JsValue> {
80
+ #[wasm_bindgen(js_name=toBytes)]
81
+ pub fn to_bytes(&self) -> Result<JsValue, JsValue> {
82
82
  let bytes = self.0.serialize_to_bytes().expect("Serialization failed");
83
83
 
84
84
  Ok(JsValue::from(bytes.clone()))
85
85
  }
86
86
 
87
- pub fn from_buffer(buffer: Vec<u8>) -> Result<StateTransitionWASM, JsValue> {
88
- let st = StateTransition::deserialize_from_bytes(buffer.as_slice());
87
+ #[wasm_bindgen(js_name=fromBytes)]
88
+ pub fn from_bytes(bytes: Vec<u8>) -> Result<StateTransitionWASM, JsValue> {
89
+ let st = StateTransition::deserialize_from_bytes(bytes.as_slice());
89
90
 
90
91
  match st {
91
92
  Err(err) => Err(JsValue::from_str(err.to_string().as_str())),
package/src/lib.rs CHANGED
@@ -1,5 +1,10 @@
1
- pub use pshenmic_dpp_document_batch::DocumentBatchWASM;
1
+ #![no_std]
2
+ #![no_main]
3
+
4
+ pub use pshenmic_dpp_data_contract;
5
+ pub use pshenmic_dpp_document_batch;
2
6
  pub use pshenmic_dpp_document_search;
7
+ pub use pshenmic_dpp_enums;
3
8
  pub use pshenmic_dpp_identity;
4
9
  pub use pshenmic_dpp_identity_transitions;
5
10
  pub use pshenmic_dpp_state_transition;