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.
Files changed (40) hide show
  1. package/.editorconfig +10 -0
  2. package/.gitattributes +4 -0
  3. package/.github/workflows/build.yml +46 -0
  4. package/.github/workflows/publish.yml +42 -0
  5. package/Cargo.lock +2241 -0
  6. package/Cargo.toml +18 -0
  7. package/README.md +74 -0
  8. package/dist/wasm/pshenmic_dpp.js +1130 -0
  9. package/package.json +25 -0
  10. package/packages/cbor-conversation/Cargo.toml +17 -0
  11. package/packages/cbor-conversation/src/lib.rs +26 -0
  12. package/packages/document/Cargo.toml +15 -0
  13. package/packages/document/src/lib.rs +58 -0
  14. package/packages/document/src/methods/js.rs +204 -0
  15. package/packages/document/src/methods/mod.rs +2 -0
  16. package/packages/document/src/methods/rust.rs +92 -0
  17. package/packages/document_batch/Cargo.toml +20 -0
  18. package/packages/document_batch/src/generators.rs +63 -0
  19. package/packages/document_batch/src/lib.rs +326 -0
  20. package/packages/enums/Cargo.toml +13 -0
  21. package/packages/enums/src/batch/batch_enum.rs +19 -0
  22. package/packages/enums/src/batch/mod.rs +1 -0
  23. package/packages/enums/src/keys/key_type.rs +36 -0
  24. package/packages/enums/src/keys/mod.rs +3 -0
  25. package/packages/enums/src/keys/purpose.rs +41 -0
  26. package/packages/enums/src/keys/security_level.rs +32 -0
  27. package/packages/enums/src/lib.rs +2 -0
  28. package/packages/mock_bls/Cargo.toml +12 -0
  29. package/packages/mock_bls/src/lib.rs +26 -0
  30. package/packages/private_key/Cargo.toml +13 -0
  31. package/packages/private_key/src/lib.rs +35 -0
  32. package/packages/public_key/Cargo.toml +15 -0
  33. package/packages/public_key/src/lib.rs +125 -0
  34. package/packages/utils/Cargo.toml +20 -0
  35. package/packages/utils/src/buffer.rs +29 -0
  36. package/packages/utils/src/lib.rs +351 -0
  37. package/scripts/build-js.sh +38 -0
  38. package/scripts/build.sh +35 -0
  39. package/src/lib.rs +2 -0
  40. package/tsconfig.json +18 -0
package/Cargo.toml ADDED
@@ -0,0 +1,18 @@
1
+ [workspace]
2
+ resolver = "2"
3
+ members = ["packages/document", "packages/document_batch", "packages/cbor-conversation", "packages/enums", "packages/mock_bls", "packages/private_key", "packages/public_key", "packages/utils"]
4
+
5
+ [lib]
6
+ crate-type = ["cdylib", "lib"]
7
+
8
+ [package]
9
+ name = "pshenmic-dpp"
10
+ version = "1.0.0"
11
+ edition = "2024"
12
+ rust-version = "1.85"
13
+
14
+ [dependencies]
15
+ bincode = {version = "=2.0.0-rc.3"}
16
+ bincode_derive = {version = "=2.0.0-rc.3"}
17
+ pshenmic_dpp_document_batch = {path = "packages/document_batch"}
18
+ pshenmic_dpp_document_search = {path = "packages/cbor-conversation" }
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # PSHENMIC-DPP
2
+
3
+
4
+
5
+ That module uses [rs-dpp](https://github.com/dashpay/platform) and creates bindings for JavaScript.
6
+ Each structure from rs-dpp is represented by a separate package, so you can build not the whole module, but only a part of it
7
+
8
+ **At this moment available structs:**
9
+ - `Document`
10
+ - `DocumentsBatch`
11
+ - `IdentityPublicKey`
12
+ - `PrivateKey`
13
+
14
+ ## How to build
15
+ Default scripts allows to build full module
16
+ ```
17
+ yarn
18
+ yarn build:full
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```js
24
+ import * as wasm from '../wasm/pshenmic_dpp';
25
+ import wasmBytes from "../wasm/pshenmic_dpp_bg"
26
+
27
+ function toHexString(byteArray) {
28
+ return Array.prototype.map.call(byteArray, function(byte) {
29
+ return ('0' + (byte & 0xFF).toString(16)).slice(-2);
30
+ }).join('');
31
+ }
32
+
33
+ let binaryString = atob(wasmBytes);
34
+ let bytes = new Uint8Array(binaryString.length);
35
+ for (let i = 0; i < binaryString.length; i++) {
36
+ bytes[i] = binaryString.charCodeAt(i);
37
+ }
38
+
39
+ wasm.initSync({module: bytes.buffer})
40
+
41
+ const document = wasm.DocumentWASM.new(
42
+ {
43
+ "name": "MyPool",
44
+ "type": "EVONODE",
45
+ "status": "INACTIVE",
46
+ "description": "test pool"
47
+ },
48
+ 'pool',
49
+ BigInt(1),
50
+ "6QMfQTdKpC3Y9uWBcTwXeY3KdzRLDqASUsDnQ4MEc9XC",
51
+ "B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH"
52
+ )
53
+
54
+ const pubKey = wasm.IdentityPublicKeyWASM.new(
55
+ 1,
56
+ wasm.Purpose.AUTHENTICATION,
57
+ wasm.SecurityLevel.HIGH,
58
+ wasm.KeyType.ECDSA_SECP256K1,
59
+ false,
60
+ 'your_binary_data_in_hex'
61
+ )
62
+
63
+ const privKey = wasm.PrivateKeyWASM.new('wif_key')
64
+
65
+ const batch = wasm.DocumentBatchWASM.new(
66
+ wasm.BatchType.CREATE,
67
+ document,
68
+ BigInt(3),
69
+ )
70
+
71
+ batch.sign(privKey, pubKey)
72
+
73
+ console.log(toHexString(batch.toBuffer()))
74
+ ```