pshenmic-dpp 1.0.0
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/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/.github/workflows/build.yml +46 -0
- package/.github/workflows/publish.yml +42 -0
- package/Cargo.lock +2241 -0
- package/Cargo.toml +18 -0
- package/README.md +74 -0
- package/dist/wasm/pshenmic_dpp.js +1130 -0
- package/package.json +25 -0
- package/packages/cbor-conversation/Cargo.toml +17 -0
- package/packages/cbor-conversation/src/lib.rs +26 -0
- package/packages/document/Cargo.toml +15 -0
- package/packages/document/src/lib.rs +58 -0
- package/packages/document/src/methods/js.rs +204 -0
- package/packages/document/src/methods/mod.rs +2 -0
- package/packages/document/src/methods/rust.rs +92 -0
- package/packages/document_batch/Cargo.toml +20 -0
- package/packages/document_batch/src/generators.rs +63 -0
- package/packages/document_batch/src/lib.rs +326 -0
- package/packages/enums/Cargo.toml +13 -0
- package/packages/enums/src/batch/batch_enum.rs +19 -0
- package/packages/enums/src/batch/mod.rs +1 -0
- package/packages/enums/src/keys/key_type.rs +36 -0
- package/packages/enums/src/keys/mod.rs +3 -0
- package/packages/enums/src/keys/purpose.rs +41 -0
- package/packages/enums/src/keys/security_level.rs +32 -0
- package/packages/enums/src/lib.rs +2 -0
- package/packages/mock_bls/Cargo.toml +12 -0
- package/packages/mock_bls/src/lib.rs +26 -0
- package/packages/private_key/Cargo.toml +13 -0
- package/packages/private_key/src/lib.rs +35 -0
- package/packages/public_key/Cargo.toml +15 -0
- package/packages/public_key/src/lib.rs +125 -0
- package/packages/utils/Cargo.toml +20 -0
- package/packages/utils/src/buffer.rs +29 -0
- package/packages/utils/src/lib.rs +351 -0
- package/scripts/build-js.sh +38 -0
- package/scripts/build.sh +35 -0
- package/src/lib.rs +2 -0
- package/tsconfig.json +18 -0
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pshenmic-dpp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/wasm/pshenmic_dpp.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/owl352/pshemic-dpp"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"tsc": "tsc",
|
|
11
|
+
"build:bin": "./scripts/build.sh",
|
|
12
|
+
"build:js": "./scripts/build-js.sh",
|
|
13
|
+
"build:full": "./scripts/build.sh && ./scripts/build-js.sh",
|
|
14
|
+
"build:raw": "./scripts/build.sh && RAW=true ./scripts/build-js.sh"
|
|
15
|
+
},
|
|
16
|
+
"author": "owl352",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"description": "",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"babel": "^6.23.0",
|
|
21
|
+
"babel-cli": "^6.26.0",
|
|
22
|
+
"typescript": "^5.8.2"
|
|
23
|
+
},
|
|
24
|
+
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pshenmic_dpp_document_search"
|
|
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
|
+
dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
|
|
12
|
+
"cbor"
|
|
13
|
+
]}
|
|
14
|
+
pshenmic_dpp_utils = {path = "../utils"}
|
|
15
|
+
base64 = "0.22.1"
|
|
16
|
+
ciborium = "0.2.0"
|
|
17
|
+
serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
use base64::Engine;
|
|
2
|
+
use base64::prelude::BASE64_STANDARD;
|
|
3
|
+
use ciborium;
|
|
4
|
+
use ciborium::Value;
|
|
5
|
+
use dpp::util::cbor_serializer::serializable_value_to_cbor;
|
|
6
|
+
use pshenmic_dpp_utils::with_serde_to_platform_value;
|
|
7
|
+
use wasm_bindgen::JsValue;
|
|
8
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
9
|
+
|
|
10
|
+
#[wasm_bindgen(js_name = "objectToCbor")]
|
|
11
|
+
pub fn object_to_cbor(object: &JsValue) -> String {
|
|
12
|
+
let value_object = with_serde_to_platform_value(object).unwrap();
|
|
13
|
+
|
|
14
|
+
let cbor = serializable_value_to_cbor(&value_object, None).unwrap();
|
|
15
|
+
|
|
16
|
+
BASE64_STANDARD.encode(cbor)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#[wasm_bindgen(js_name = "cborToObject")]
|
|
20
|
+
pub fn cbor_to_object(cbor: String) -> JsValue {
|
|
21
|
+
let base64_bytes = BASE64_STANDARD.decode(cbor).unwrap();
|
|
22
|
+
|
|
23
|
+
let cbor: Value = ciborium::de::from_reader(base64_bytes.as_slice()).expect("REASON");
|
|
24
|
+
|
|
25
|
+
serde_wasm_bindgen::to_value(&cbor).unwrap()
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pshenmic_dpp_document"
|
|
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
|
+
dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
|
|
13
|
+
"document-json-conversion"
|
|
14
|
+
]}
|
|
15
|
+
serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
mod methods;
|
|
2
|
+
|
|
3
|
+
use dpp::document::{Document, DocumentV0Getters};
|
|
4
|
+
use dpp::identifier::Identifier;
|
|
5
|
+
use dpp::identity::TimestampMillis;
|
|
6
|
+
use dpp::platform_value::Value;
|
|
7
|
+
use dpp::prelude::{BlockHeight, CoreBlockHeight, Revision};
|
|
8
|
+
use std::collections::BTreeMap;
|
|
9
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
10
|
+
|
|
11
|
+
#[derive(Debug, Clone, PartialEq)]
|
|
12
|
+
#[wasm_bindgen(js_name = DocumentWASM)]
|
|
13
|
+
pub struct DocumentWASM {
|
|
14
|
+
id: Identifier,
|
|
15
|
+
owner_id: Identifier,
|
|
16
|
+
revision: Option<Revision>,
|
|
17
|
+
data_contract_id: Identifier,
|
|
18
|
+
document_type_name: String,
|
|
19
|
+
properties: BTreeMap<String, Value>,
|
|
20
|
+
created_at: Option<TimestampMillis>,
|
|
21
|
+
updated_at: Option<TimestampMillis>,
|
|
22
|
+
transferred_at: Option<TimestampMillis>,
|
|
23
|
+
created_at_block_height: Option<BlockHeight>,
|
|
24
|
+
updated_at_block_height: Option<BlockHeight>,
|
|
25
|
+
transferred_at_block_height: Option<BlockHeight>,
|
|
26
|
+
created_at_core_block_height: Option<CoreBlockHeight>,
|
|
27
|
+
updated_at_core_block_height: Option<CoreBlockHeight>,
|
|
28
|
+
transferred_at_core_block_height: Option<CoreBlockHeight>,
|
|
29
|
+
entropy: Option<[u8; 32]>,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
impl DocumentWASM {
|
|
33
|
+
pub fn from_batch(
|
|
34
|
+
document: Document,
|
|
35
|
+
data_contract_id: Identifier,
|
|
36
|
+
document_type_name: String,
|
|
37
|
+
entropy: Option<[u8; 32]>,
|
|
38
|
+
) -> Self {
|
|
39
|
+
DocumentWASM {
|
|
40
|
+
id: document.id(),
|
|
41
|
+
owner_id: document.owner_id(),
|
|
42
|
+
revision: document.revision(),
|
|
43
|
+
data_contract_id,
|
|
44
|
+
document_type_name,
|
|
45
|
+
properties: document.properties().clone(),
|
|
46
|
+
created_at: document.created_at(),
|
|
47
|
+
updated_at: document.updated_at(),
|
|
48
|
+
transferred_at: document.transferred_at(),
|
|
49
|
+
created_at_block_height: document.created_at_block_height(),
|
|
50
|
+
updated_at_block_height: document.updated_at_block_height(),
|
|
51
|
+
transferred_at_block_height: document.transferred_at_block_height(),
|
|
52
|
+
created_at_core_block_height: document.created_at_core_block_height(),
|
|
53
|
+
updated_at_core_block_height: document.updated_at_core_block_height(),
|
|
54
|
+
transferred_at_core_block_height: document.transferred_at_core_block_height(),
|
|
55
|
+
entropy,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
use crate::DocumentWASM;
|
|
2
|
+
use dpp::platform_value::converter::serde_json::BTreeValueJsonConverter;
|
|
3
|
+
use dpp::platform_value::string_encoding::Encoding::Base58;
|
|
4
|
+
use dpp::prelude::Revision;
|
|
5
|
+
use pshenmic_dpp_utils::{ToSerdeJSONExt, identifier_from_js_value};
|
|
6
|
+
use wasm_bindgen::JsValue;
|
|
7
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
8
|
+
|
|
9
|
+
#[wasm_bindgen]
|
|
10
|
+
impl DocumentWASM {
|
|
11
|
+
#[wasm_bindgen(js_name=new)]
|
|
12
|
+
pub fn js_new(
|
|
13
|
+
js_raw_document: JsValue,
|
|
14
|
+
js_document_type_name: &str,
|
|
15
|
+
js_revision: u64,
|
|
16
|
+
js_data_contract_id: &str,
|
|
17
|
+
js_owner_id: &str,
|
|
18
|
+
) -> Self {
|
|
19
|
+
let revision = Revision::from(js_revision);
|
|
20
|
+
|
|
21
|
+
let document = js_raw_document
|
|
22
|
+
.with_serde_to_platform_value_map()
|
|
23
|
+
.expect("cannot convert document to platform value map");
|
|
24
|
+
|
|
25
|
+
DocumentWASM::new(
|
|
26
|
+
document,
|
|
27
|
+
js_document_type_name,
|
|
28
|
+
revision,
|
|
29
|
+
js_data_contract_id,
|
|
30
|
+
js_owner_id,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#[wasm_bindgen(js_name=getId)]
|
|
35
|
+
pub fn js_get_id(&self) -> JsValue {
|
|
36
|
+
JsValue::from_str(self.id.to_string(Base58).as_str())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#[wasm_bindgen(js_name=getEntropy)]
|
|
40
|
+
pub fn js_get_entropy(&self) -> JsValue {
|
|
41
|
+
match self.entropy {
|
|
42
|
+
Some(_entropy) => JsValue::from(self.entropy.unwrap().to_vec()),
|
|
43
|
+
None => JsValue::undefined(),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#[wasm_bindgen(js_name=getOwnerId)]
|
|
48
|
+
pub fn js_get_owner_id(&self) -> JsValue {
|
|
49
|
+
JsValue::from_str(self.owner_id.to_string(Base58).as_str())
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[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()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[wasm_bindgen(js_name=getRevision)]
|
|
62
|
+
pub fn get_revision(&self) -> Option<u64> {
|
|
63
|
+
self.revision
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[wasm_bindgen(js_name=getCreatedAt)]
|
|
67
|
+
pub fn get_created_at(&self) -> Option<u64> {
|
|
68
|
+
self.created_at
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#[wasm_bindgen(js_name=getUpdatedAt)]
|
|
72
|
+
pub fn get_updated_at(&self) -> Option<u64> {
|
|
73
|
+
self.updated_at
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[wasm_bindgen(js_name=getTransferredAt)]
|
|
77
|
+
pub fn get_transferred_at(&self) -> Option<u64> {
|
|
78
|
+
self.transferred_at
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#[wasm_bindgen(js_name=getCreatedAtBlockHeight)]
|
|
82
|
+
pub fn get_created_at_block_height(&self) -> Option<u64> {
|
|
83
|
+
self.created_at_block_height
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[wasm_bindgen(js_name=getUpdatedAtBlockHeight)]
|
|
87
|
+
pub fn get_updated_at_block_height(&self) -> Option<u64> {
|
|
88
|
+
self.updated_at_block_height
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#[wasm_bindgen(js_name=getTransferredAtBlockHeight)]
|
|
92
|
+
pub fn get_transferred_at_block_height(&self) -> Option<u64> {
|
|
93
|
+
self.transferred_at_block_height
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#[wasm_bindgen(js_name=getCreatedAtCoreBlockHeight)]
|
|
97
|
+
pub fn get_created_at_core_block_height(&self) -> Option<u32> {
|
|
98
|
+
self.created_at_core_block_height
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#[wasm_bindgen(js_name=getUpdatedAtCoreBlockHeight)]
|
|
102
|
+
pub fn get_updated_at_core_block_height(&self) -> Option<u32> {
|
|
103
|
+
self.updated_at_core_block_height
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#[wasm_bindgen(js_name=getTransferredAtCoreBlockHeight)]
|
|
107
|
+
pub fn get_transferred_at_core_block_height(&self) -> Option<u32> {
|
|
108
|
+
self.transferred_at_core_block_height
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
#[wasm_bindgen(js_name=getDocumentTypeName)]
|
|
112
|
+
pub fn get_document_type_name(&self) -> String {
|
|
113
|
+
self.document_type_name.clone()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#[wasm_bindgen(js_name=setId)]
|
|
117
|
+
pub fn js_set_id(&mut self, id: JsValue) {
|
|
118
|
+
self.id = identifier_from_js_value(&id).unwrap()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#[wasm_bindgen(js_name=setEntropy)]
|
|
122
|
+
pub fn js_set_entropy(&mut self, entropy: JsValue) {
|
|
123
|
+
match entropy.is_undefined() {
|
|
124
|
+
false => {
|
|
125
|
+
let value = entropy.with_serde_to_platform_value().unwrap();
|
|
126
|
+
|
|
127
|
+
let mut entropy = [0u8; 32];
|
|
128
|
+
let bytes = value.as_bytes().unwrap();
|
|
129
|
+
let len = bytes.len().min(32);
|
|
130
|
+
entropy[..len].copy_from_slice(&bytes[..len]);
|
|
131
|
+
self.entropy = Some(entropy);
|
|
132
|
+
}
|
|
133
|
+
true => self.entropy = None,
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#[wasm_bindgen(js_name=setOwnerId)]
|
|
138
|
+
pub fn js_set_owner_id(&mut self, id: JsValue) {
|
|
139
|
+
self.owner_id = identifier_from_js_value(&id).unwrap()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#[wasm_bindgen(js_name=setProperties)]
|
|
143
|
+
pub fn js_set_properties(&mut self, properties: JsValue) {
|
|
144
|
+
self.properties = properties.with_serde_to_platform_value_map().unwrap()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#[wasm_bindgen(js_name=setRevision)]
|
|
148
|
+
pub fn set_revision(&mut self, revision: Option<u64>) {
|
|
149
|
+
self.revision = revision
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#[wasm_bindgen(js_name=setCreatedAt)]
|
|
153
|
+
pub fn set_created_at(&mut self, created_at: Option<u64>) {
|
|
154
|
+
self.created_at = created_at
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#[wasm_bindgen(js_name=setUpdatedAt)]
|
|
158
|
+
pub fn set_get_updated_at(&mut self, updated_at: Option<u64>) {
|
|
159
|
+
self.updated_at = updated_at
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#[wasm_bindgen(js_name=setTransferredAt)]
|
|
163
|
+
pub fn set_transferred_at(&mut self, transferred_at: Option<u64>) {
|
|
164
|
+
self.transferred_at = transferred_at
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#[wasm_bindgen(js_name=setCreatedAtBlockHeight)]
|
|
168
|
+
pub fn set_created_at_block_height(&mut self, created_at_block_height: Option<u64>) {
|
|
169
|
+
self.created_at_block_height = created_at_block_height
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#[wasm_bindgen(js_name=setUpdatedAtBlockHeight)]
|
|
173
|
+
pub fn set_updated_at_block_height(&mut self, updated_at_block_height: Option<u64>) {
|
|
174
|
+
self.updated_at_block_height = updated_at_block_height
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
#[wasm_bindgen(js_name=setTransferredAtBlockHeight)]
|
|
178
|
+
pub fn set_transferred_at_block_height(&mut self, transferred_at_block_height: Option<u64>) {
|
|
179
|
+
self.transferred_at_block_height = transferred_at_block_height
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
#[wasm_bindgen(js_name=setCreatedAtCoreBlockHeight)]
|
|
183
|
+
pub fn set_created_at_core_block_height(&mut self, created_at_core_block_height: Option<u32>) {
|
|
184
|
+
self.created_at_core_block_height = created_at_core_block_height
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#[wasm_bindgen(js_name=setUpdatedAtCoreBlockHeight)]
|
|
188
|
+
pub fn set_updated_at_core_block_height(&mut self, updated_at_core_block_height: Option<u32>) {
|
|
189
|
+
self.updated_at_core_block_height = updated_at_core_block_height
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#[wasm_bindgen(js_name=setTransferredAtCoreBlockHeight)]
|
|
193
|
+
pub fn set_transferred_at_core_block_height(
|
|
194
|
+
&mut self,
|
|
195
|
+
transferred_at_core_block_height: Option<u32>,
|
|
196
|
+
) {
|
|
197
|
+
self.transferred_at_core_block_height = transferred_at_core_block_height
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#[wasm_bindgen(js_name=setDocumentTypeName)]
|
|
201
|
+
pub fn set_document_type_name(&mut self, document_type_name: &str) {
|
|
202
|
+
self.document_type_name = document_type_name.to_string();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
use crate::DocumentWASM;
|
|
2
|
+
use dpp::identifier::Identifier;
|
|
3
|
+
use dpp::platform_value::Value;
|
|
4
|
+
use dpp::platform_value::string_encoding::Encoding::Base58;
|
|
5
|
+
use dpp::prelude::Revision;
|
|
6
|
+
use dpp::util::entropy_generator;
|
|
7
|
+
use dpp::util::entropy_generator::EntropyGenerator;
|
|
8
|
+
use std::collections::BTreeMap;
|
|
9
|
+
|
|
10
|
+
impl DocumentWASM {
|
|
11
|
+
pub fn new(
|
|
12
|
+
document: BTreeMap<String, Value>,
|
|
13
|
+
document_type_name: &str,
|
|
14
|
+
revision: u64,
|
|
15
|
+
data_contract_id: &str,
|
|
16
|
+
owner_id: &str,
|
|
17
|
+
) -> Self {
|
|
18
|
+
let owner_id = Identifier::from_string(owner_id, Base58).unwrap();
|
|
19
|
+
let data_contract_id = Identifier::from_string(data_contract_id, Base58).unwrap();
|
|
20
|
+
let revision = Revision::from(revision);
|
|
21
|
+
|
|
22
|
+
let entropy = entropy_generator::DefaultEntropyGenerator
|
|
23
|
+
.generate()
|
|
24
|
+
.unwrap();
|
|
25
|
+
|
|
26
|
+
let document_id = pshenmic_dpp_utils::generate_document_id_v0(
|
|
27
|
+
&data_contract_id,
|
|
28
|
+
&owner_id,
|
|
29
|
+
document_type_name,
|
|
30
|
+
&entropy,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
DocumentWASM {
|
|
34
|
+
owner_id,
|
|
35
|
+
entropy: Some(entropy),
|
|
36
|
+
id: document_id,
|
|
37
|
+
document_type_name: document_type_name.to_string(),
|
|
38
|
+
data_contract_id,
|
|
39
|
+
properties: document,
|
|
40
|
+
revision: Some(revision),
|
|
41
|
+
created_at: None,
|
|
42
|
+
updated_at: None,
|
|
43
|
+
transferred_at: None,
|
|
44
|
+
created_at_block_height: None,
|
|
45
|
+
updated_at_block_height: None,
|
|
46
|
+
transferred_at_block_height: None,
|
|
47
|
+
created_at_core_block_height: None,
|
|
48
|
+
updated_at_core_block_height: None,
|
|
49
|
+
transferred_at_core_block_height: None,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
pub fn get_id(&self) -> Identifier {
|
|
54
|
+
self.id
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
pub fn get_entropy(&self) -> Option<[u8; 32]> {
|
|
58
|
+
self.entropy
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
pub fn get_data_contract_id(&self) -> Identifier {
|
|
62
|
+
self.data_contract_id
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
pub fn get_owner_id(&self) -> Identifier {
|
|
66
|
+
self.owner_id
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
pub fn get_properties(&self) -> BTreeMap<String, Value> {
|
|
70
|
+
self.properties.clone()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
pub fn set_id(&mut self, id: Identifier) {
|
|
74
|
+
self.id = id
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
pub fn set_entropy(&mut self, entropy: Option<[u8; 32]>) {
|
|
78
|
+
self.entropy = entropy;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
pub fn set_data_contract_id(&mut self, data_contract_id: Identifier) {
|
|
82
|
+
self.data_contract_id = data_contract_id
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
pub fn set_owner_id(&mut self, id: Identifier) {
|
|
86
|
+
self.owner_id = id
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
pub fn set_properties(&mut self, properties: BTreeMap<String, Value>) {
|
|
90
|
+
self.properties = properties
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pshenmic_dpp_document_batch"
|
|
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_document = {path = "../document"}
|
|
12
|
+
pshenmic_dpp_enums = {path = "../enums"}
|
|
13
|
+
pshenmic_dpp_public_key = {path = "../public_key"}
|
|
14
|
+
pshenmic_dpp_private_key = {path = "../private_key"}
|
|
15
|
+
pshenmic_dpp_utils = {path = "../utils"}
|
|
16
|
+
pshenmic_dpp_mock_bls = {path = "../mock_bls"}
|
|
17
|
+
dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
|
|
18
|
+
"document-json-conversion",
|
|
19
|
+
"state-transition-signing"
|
|
20
|
+
]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
use dpp::prelude::{Identifier, IdentityNonce};
|
|
2
|
+
use dpp::state_transition::documents_batch_transition::document_base_transition::DocumentBaseTransition;
|
|
3
|
+
use dpp::state_transition::documents_batch_transition::document_base_transition::v0::DocumentBaseTransitionV0;
|
|
4
|
+
use dpp::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransitionV0;
|
|
5
|
+
use dpp::state_transition::documents_batch_transition::document_delete_transition::DocumentDeleteTransitionV0;
|
|
6
|
+
use dpp::state_transition::documents_batch_transition::document_replace_transition::DocumentReplaceTransitionV0;
|
|
7
|
+
use dpp::state_transition::documents_batch_transition::{
|
|
8
|
+
DocumentCreateTransition, DocumentDeleteTransition, DocumentReplaceTransition,
|
|
9
|
+
};
|
|
10
|
+
use pshenmic_dpp_document::DocumentWASM;
|
|
11
|
+
|
|
12
|
+
pub fn generate_create_transition(
|
|
13
|
+
document: DocumentWASM,
|
|
14
|
+
identity_contract_nonce: IdentityNonce,
|
|
15
|
+
document_type_name: String,
|
|
16
|
+
data_contract_id: Identifier,
|
|
17
|
+
) -> DocumentCreateTransition {
|
|
18
|
+
DocumentCreateTransition::V0(DocumentCreateTransitionV0 {
|
|
19
|
+
base: DocumentBaseTransition::V0(DocumentBaseTransitionV0 {
|
|
20
|
+
id: document.get_id(),
|
|
21
|
+
identity_contract_nonce,
|
|
22
|
+
document_type_name,
|
|
23
|
+
data_contract_id,
|
|
24
|
+
}),
|
|
25
|
+
entropy: document.get_entropy().unwrap(),
|
|
26
|
+
data: document.get_properties(),
|
|
27
|
+
prefunded_voting_balance: None,
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
pub fn generate_delete_transition(
|
|
32
|
+
document: DocumentWASM,
|
|
33
|
+
identity_contract_nonce: IdentityNonce,
|
|
34
|
+
document_type_name: String,
|
|
35
|
+
data_contract_id: Identifier,
|
|
36
|
+
) -> DocumentDeleteTransition {
|
|
37
|
+
DocumentDeleteTransition::V0(DocumentDeleteTransitionV0 {
|
|
38
|
+
base: DocumentBaseTransition::V0(DocumentBaseTransitionV0 {
|
|
39
|
+
id: document.get_id(),
|
|
40
|
+
identity_contract_nonce,
|
|
41
|
+
document_type_name,
|
|
42
|
+
data_contract_id,
|
|
43
|
+
}),
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pub fn generate_replace_transition(
|
|
48
|
+
document: DocumentWASM,
|
|
49
|
+
identity_contract_nonce: IdentityNonce,
|
|
50
|
+
document_type_name: String,
|
|
51
|
+
data_contract_id: Identifier,
|
|
52
|
+
) -> DocumentReplaceTransition {
|
|
53
|
+
DocumentReplaceTransition::V0(DocumentReplaceTransitionV0 {
|
|
54
|
+
base: DocumentBaseTransition::V0(DocumentBaseTransitionV0 {
|
|
55
|
+
id: document.get_id(),
|
|
56
|
+
identity_contract_nonce,
|
|
57
|
+
document_type_name,
|
|
58
|
+
data_contract_id,
|
|
59
|
+
}),
|
|
60
|
+
revision: document.get_revision().unwrap(),
|
|
61
|
+
data: document.get_properties(),
|
|
62
|
+
})
|
|
63
|
+
}
|