pshenmic-dpp 1.0.4 → 1.0.6

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 (152) hide show
  1. package/.github/workflows/build.yml +9 -1
  2. package/.github/workflows/publish.yml +9 -1
  3. package/Cargo.lock +222 -76
  4. package/Cargo.toml +28 -19
  5. package/README.md +75 -23
  6. package/babel.config.json +19 -0
  7. package/dist/wasm/index.d.ts +52 -0
  8. package/dist/wasm/pshenmic_dpp.d.ts +962 -0
  9. package/dist/wasm/pshenmic_dpp.js +5565 -966
  10. package/dist/wasm/pshenmic_dpp_bg.js +1 -1
  11. package/dist/wasm/pshenmic_dpp_bg.wasm.d.ts +440 -0
  12. package/docs/AssetLockProof.md +107 -0
  13. package/docs/Building.md +50 -0
  14. package/docs/ChainLockProof.md +63 -0
  15. package/docs/CoreScript.md +17 -0
  16. package/docs/DataContract.md +192 -0
  17. package/docs/DataContractCreateTransition.md +84 -0
  18. package/docs/DataContractUpdateTransition.md +84 -0
  19. package/docs/Document.md +396 -0
  20. package/docs/DocumentBaseTransition.md +111 -0
  21. package/docs/DocumentCreateTransition.md +132 -0
  22. package/docs/DocumentDeleteTransition.md +82 -0
  23. package/docs/DocumentPurchaseTransition.md +109 -0
  24. package/docs/DocumentReplaceTransition.md +112 -0
  25. package/docs/DocumentTransferTransition.md +96 -0
  26. package/docs/DocumentTransition.md +125 -0
  27. package/docs/DocumentUpdatePriceTransition.md +109 -0
  28. package/docs/DocumentsBatch.md +133 -0
  29. package/docs/Enums.md +103 -0
  30. package/docs/Home.md +28 -0
  31. package/docs/Identifier.md +37 -0
  32. package/docs/Identity.md +140 -0
  33. package/docs/IdentityCreateTransition.md +155 -0
  34. package/docs/IdentityCreditTransfer.md +187 -0
  35. package/docs/IdentityCreditWithdrawalTransition.md +244 -0
  36. package/docs/IdentityPublicKey.md +348 -0
  37. package/docs/IdentityPublicKeyInCreation.md +141 -0
  38. package/docs/IdentityTopUpTransition.md +166 -0
  39. package/docs/IdentityUpdateTransition.md +234 -0
  40. package/docs/InstantAssetLockProof.md +117 -0
  41. package/docs/InstantLock.md +100 -0
  42. package/docs/OutPoint.md +80 -0
  43. package/docs/PrefundedVotingBalance.md +48 -0
  44. package/docs/PrivateKey.md +112 -0
  45. package/docs/TxOut.md +93 -0
  46. package/package.json +15 -8
  47. package/packages/asset_lock_proof/Cargo.toml +19 -0
  48. package/packages/asset_lock_proof/src/chain/mod.rs +79 -0
  49. package/packages/asset_lock_proof/src/instant/instant_lock.rs +111 -0
  50. package/packages/asset_lock_proof/src/instant/mod.rs +115 -0
  51. package/packages/asset_lock_proof/src/lib.rs +133 -0
  52. package/packages/asset_lock_proof/src/outpoint/mod.rs +79 -0
  53. package/packages/asset_lock_proof/src/tx_out/mod.rs +80 -0
  54. package/packages/cbor_conversation/Cargo.toml +2 -2
  55. package/packages/core_script/Cargo.toml +13 -0
  56. package/packages/core_script/src/lib.rs +69 -0
  57. package/packages/data_contract/Cargo.toml +4 -3
  58. package/packages/data_contract/src/lib.rs +209 -33
  59. package/packages/data_contract_transitions/Cargo.toml +2 -2
  60. package/packages/data_contract_transitions/src/create/mod.rs +23 -16
  61. package/packages/data_contract_transitions/src/update/mod.rs +21 -12
  62. package/packages/document/Cargo.toml +3 -2
  63. package/packages/document/src/lib.rs +14 -13
  64. package/packages/document/src/methods/mod.rs +373 -2
  65. package/packages/{document_batch → documents_batch}/Cargo.toml +7 -4
  66. package/packages/documents_batch/src/document_base_transition/mod.rs +88 -0
  67. package/packages/documents_batch/src/document_transition/mod.rs +166 -0
  68. package/packages/documents_batch/src/generators.rs +122 -0
  69. package/packages/documents_batch/src/lib.rs +195 -0
  70. package/packages/documents_batch/src/prefunded_voting_balance/mod.rs +45 -0
  71. package/packages/documents_batch/src/transitions/create/mod.rs +126 -0
  72. package/packages/documents_batch/src/transitions/delete/mod.rs +67 -0
  73. package/packages/documents_batch/src/transitions/mod.rs +6 -0
  74. package/packages/documents_batch/src/transitions/purchase/mod.rs +91 -0
  75. package/packages/documents_batch/src/transitions/replace/mod.rs +93 -0
  76. package/packages/documents_batch/src/transitions/transfer/mod.rs +84 -0
  77. package/packages/documents_batch/src/transitions/update_price/mod.rs +75 -0
  78. package/packages/enums/Cargo.toml +4 -4
  79. package/packages/enums/src/batch/batch_enum.rs +75 -10
  80. package/packages/enums/src/keys/key_type.rs +46 -0
  81. package/packages/enums/src/keys/purpose.rs +55 -0
  82. package/packages/enums/src/keys/security_level.rs +46 -0
  83. package/packages/enums/src/lib.rs +3 -0
  84. package/packages/enums/src/lock_types/mod.rs +65 -0
  85. package/packages/enums/src/network/mod.rs +67 -0
  86. package/packages/enums/src/platform/mod.rs +68 -8
  87. package/packages/enums/src/withdrawal/mod.rs +72 -0
  88. package/packages/identifier/Cargo.toml +9 -0
  89. package/packages/identifier/src/lib.rs +105 -0
  90. package/packages/identity/Cargo.toml +5 -5
  91. package/packages/identity/src/lib.rs +31 -25
  92. package/packages/{public_key → identity_public_key}/Cargo.toml +2 -2
  93. package/packages/{public_key → identity_public_key}/src/lib.rs +74 -27
  94. package/packages/identity_transitions/Cargo.toml +8 -4
  95. package/packages/identity_transitions/src/create_transition/mod.rs +102 -37
  96. package/packages/identity_transitions/src/credit_withdrawal_transition/mod.rs +212 -0
  97. package/packages/identity_transitions/src/identity_credit_transfer_transition/mod.rs +169 -0
  98. package/packages/identity_transitions/src/lib.rs +6 -1
  99. package/packages/identity_transitions/src/public_key_in_creation/mod.rs +197 -0
  100. package/packages/identity_transitions/src/top_up_transition/mod.rs +141 -0
  101. package/packages/identity_transitions/src/update_transition/mod.rs +213 -0
  102. package/packages/mock_bls/Cargo.toml +1 -1
  103. package/packages/private_key/Cargo.toml +4 -3
  104. package/packages/private_key/src/lib.rs +44 -6
  105. package/packages/state_transition/Cargo.toml +6 -4
  106. package/packages/state_transition/src/lib.rs +102 -36
  107. package/packages/utils/Cargo.toml +3 -4
  108. package/packages/utils/src/lib.rs +17 -18
  109. package/scripts/build-js.sh +22 -5
  110. package/scripts/build.sh +27 -2
  111. package/src/lib.rs +8 -1
  112. package/tests/AssetLockProof.spec.js +80 -0
  113. package/tests/ChainLockProof.spec.js +69 -0
  114. package/tests/CoreScript.spec.js +37 -0
  115. package/tests/DataContract.spec.js +178 -0
  116. package/tests/DataContractCreateStateTransition.spec.js +109 -0
  117. package/tests/DataContractUpdateStateTransition.spec.js +109 -0
  118. package/tests/Document.spec.js +238 -0
  119. package/tests/DocumentBatchTransition.spec.js +109 -0
  120. package/tests/DocumentTransition.spec.js +97 -0
  121. package/tests/DocumentsTransitions.spec.js +705 -0
  122. package/tests/Identifier.spec.js +84 -0
  123. package/tests/Identity.spec.js +113 -0
  124. package/tests/IdentityCreateTransition.spec.js +93 -0
  125. package/tests/IdentityCreditTransferTransition.spec.js +146 -0
  126. package/tests/IdentityCreditWithdrawalTransition.spec.js +192 -0
  127. package/tests/IdentityPublicKey.spec.js +132 -0
  128. package/tests/IdentityTopUpTransition.spec.js +131 -0
  129. package/tests/IdentityUpdateTransition.spec.js +147 -0
  130. package/tests/InstantLockProof.spec.js +97 -0
  131. package/tests/OutPoint.spec.js +55 -0
  132. package/tests/PrivateKey.spec.js +73 -0
  133. package/tests/PublicKeyInCreation.spec.js +258 -0
  134. package/tests/TxOut.spec.js +76 -0
  135. package/tests/mocks/DataContract/DataContract.json +153 -0
  136. package/tests/mocks/DataContract/index.js +6 -0
  137. package/tests/mocks/Document/DataContract.json +23 -0
  138. package/tests/mocks/Document/document.json +3 -0
  139. package/tests/mocks/Document/document2.json +3 -0
  140. package/tests/mocks/Document/index.js +11 -0
  141. package/tests/mocks/Identity/index.js +7 -0
  142. package/tests/mocks/Locks/index.js +5 -0
  143. package/tests/mocks/PrivateKey/index.js +5 -0
  144. package/tests/mocks/PublicKey/index.js +14 -0
  145. package/tests/utils/hex.js +15 -0
  146. package/tests/utils/wasm.js +14 -0
  147. package/typings/index.d.ts +52 -0
  148. package/packages/document/src/methods/js.rs +0 -260
  149. package/packages/document/src/methods/rust.rs +0 -92
  150. package/packages/document_batch/src/generators.rs +0 -63
  151. package/packages/document_batch/src/lib.rs +0 -228
  152. package/packages/identity_transitions/src/create_transition/public_key_in_creation/mod.rs +0 -146
@@ -1,146 +0,0 @@
1
- use dpp::identity::identity_public_key::v0::IdentityPublicKeyV0;
2
- use dpp::identity::{IdentityPublicKey, KeyType, Purpose, SecurityLevel};
3
- use dpp::platform_value::BinaryData;
4
- use dpp::platform_value::string_encoding::Encoding::Hex;
5
- use dpp::state_transition::public_key_in_creation::IdentityPublicKeyInCreation;
6
- use dpp::state_transition::public_key_in_creation::accessors::{
7
- IdentityPublicKeyInCreationV0Getters, IdentityPublicKeyInCreationV0Setters,
8
- };
9
- use dpp::state_transition::public_key_in_creation::v0::IdentityPublicKeyInCreationV0;
10
- use pshenmic_dpp_enums::keys::key_type::KeyTypeWASM;
11
- use pshenmic_dpp_enums::keys::purpose::PurposeWASM;
12
- use pshenmic_dpp_enums::keys::security_level::SecurityLevelWASM;
13
- use pshenmic_dpp_public_key::IdentityPublicKeyWASM;
14
- use wasm_bindgen::prelude::wasm_bindgen;
15
-
16
- #[wasm_bindgen(js_name = "IdentityPublicKeyInCreationWASM")]
17
- pub struct IdentityPublicKeyInCreationWASM(IdentityPublicKeyInCreation);
18
-
19
- impl From<IdentityPublicKeyInCreation> for IdentityPublicKeyInCreationWASM {
20
- fn from(value: IdentityPublicKeyInCreation) -> Self {
21
- IdentityPublicKeyInCreationWASM(value)
22
- }
23
- }
24
-
25
- impl From<IdentityPublicKeyInCreationWASM> for IdentityPublicKeyInCreation {
26
- fn from(value: IdentityPublicKeyInCreationWASM) -> Self {
27
- value.0
28
- }
29
- }
30
-
31
- impl From<IdentityPublicKeyInCreationWASM> for IdentityPublicKey {
32
- fn from(value: IdentityPublicKeyInCreationWASM) -> Self {
33
- let contract_bounds = match value.0.contract_bounds() {
34
- None => None,
35
- Some(bounds) => Some(bounds.clone()),
36
- };
37
-
38
- IdentityPublicKey::V0(IdentityPublicKeyV0 {
39
- id: value.0.id(),
40
- purpose: value.0.purpose(),
41
- security_level: value.0.security_level(),
42
- contract_bounds,
43
- key_type: value.0.key_type(),
44
- read_only: value.0.read_only(),
45
- data: value.0.data().clone(),
46
- disabled_at: None,
47
- })
48
- }
49
- }
50
-
51
- #[wasm_bindgen]
52
- impl IdentityPublicKeyInCreationWASM {
53
- #[wasm_bindgen(constructor)]
54
- pub fn new(
55
- id: u32,
56
- purpose: PurposeWASM,
57
- security_level: SecurityLevelWASM,
58
- key_type: KeyTypeWASM,
59
- read_only: bool,
60
- binary_data: &str,
61
- signature: &str,
62
- ) -> IdentityPublicKeyInCreationWASM {
63
- IdentityPublicKeyInCreationWASM(IdentityPublicKeyInCreation::V0(
64
- IdentityPublicKeyInCreationV0 {
65
- id,
66
- key_type: KeyType::from(key_type),
67
- purpose: Purpose::from(purpose),
68
- security_level: SecurityLevel::from(security_level),
69
- contract_bounds: None,
70
- read_only,
71
- data: BinaryData::from_string(binary_data, Hex).unwrap(),
72
- signature: BinaryData::from_string(signature, Hex).unwrap(),
73
- },
74
- ))
75
- }
76
-
77
- #[wasm_bindgen(js_name = toIdentityPublicKey)]
78
- pub fn to_identity_public_key(&self) -> IdentityPublicKeyWASM {
79
- IdentityPublicKeyWASM::new(
80
- self.0.id(),
81
- self.0.purpose().into(),
82
- self.0.security_level().into(),
83
- self.0.key_type().into(),
84
- self.0.read_only(),
85
- self.0.data().to_string(Hex).as_str(),
86
- None,
87
- )
88
- }
89
-
90
- #[wasm_bindgen(js_name = getKeyId)]
91
- pub fn get_key_id(&self) -> u32 {
92
- self.0.id()
93
- }
94
-
95
- #[wasm_bindgen(js_name = getPurpose)]
96
- pub fn get_purpose(&self) -> PurposeWASM {
97
- PurposeWASM::from(self.0.purpose())
98
- }
99
-
100
- #[wasm_bindgen(js_name = getSecurityLevel)]
101
- pub fn get_security_level(&self) -> SecurityLevelWASM {
102
- SecurityLevelWASM::from(self.0.security_level())
103
- }
104
-
105
- #[wasm_bindgen(js_name = getKeyType)]
106
- pub fn get_key_type(&self) -> KeyTypeWASM {
107
- KeyTypeWASM::from(self.0.key_type())
108
- }
109
-
110
- #[wasm_bindgen(js_name = getReadOnly)]
111
- pub fn get_read_only(&self) -> bool {
112
- self.0.read_only()
113
- }
114
-
115
- #[wasm_bindgen(js_name = getData)]
116
- pub fn get_data(&self) -> String {
117
- self.0.data().to_string(Hex)
118
- }
119
-
120
- #[wasm_bindgen(js_name = setKeyId)]
121
- pub fn set_key_id(&mut self, key_id: u32) {
122
- self.0.set_id(key_id)
123
- }
124
-
125
- #[wasm_bindgen(js_name = setPurpose)]
126
- pub fn set_purpose(&mut self, purpose: PurposeWASM) {
127
- self.0.set_purpose(Purpose::from(purpose))
128
- }
129
-
130
- #[wasm_bindgen(js_name = setSecurityLevel)]
131
- pub fn set_security_level(&mut self, security_level: SecurityLevelWASM) {
132
- self.0
133
- .set_security_level(SecurityLevel::from(security_level))
134
- }
135
-
136
- #[wasm_bindgen(js_name = setReadOnly)]
137
- pub fn set_read_only(&mut self, read_only: bool) {
138
- self.0.set_read_only(read_only)
139
- }
140
-
141
- #[wasm_bindgen(js_name = setData)]
142
- pub fn set_data(&mut self, binary_data: &str) {
143
- let data = BinaryData::from_string(binary_data, Hex).unwrap();
144
- self.0.set_data(data)
145
- }
146
- }