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
@@ -0,0 +1,63 @@
1
+ # ChainAssetLockProofWASM
2
+ This class allows to create and interact with ChainAssetLockProof struct
3
+
4
+ `ChainAssetLockProofWASM` can be created via constructor and `fromRawObject`
5
+
6
+ Constructor arguments:
7
+ - `coreChainLockedHeight -> Number`
8
+ - `outPoint -> OutPointWASM`
9
+
10
+ ___
11
+
12
+ ## Navigation
13
+
14
+ - [Example](#Example)
15
+ - [Fields](#fields)
16
+ - [Static](#static)
17
+
18
+ ___
19
+
20
+ ### Example
21
+
22
+ ```js
23
+ const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
24
+
25
+ const chainlock = new wasm.ChainAssetLockProofWASM(11, outpoint)
26
+ // or
27
+ const chainlock = wasm.ChainAssetLockProofWASM.fromRawObject({
28
+ coreChainLockedHeight: 11,
29
+ outPoint: Array.from(outpoint.toBytes())
30
+ })
31
+ ```
32
+
33
+ ___
34
+
35
+
36
+ ## Fields
37
+ All fields are readable and writable.
38
+
39
+ ### `coreChainLockedHeight`
40
+ Contains core chain locked height in `Number`
41
+
42
+ ```js
43
+ chainlock.coreChainLockedHeight = 1111
44
+
45
+ chainlock.coreChainLockedHeight // -> Number
46
+ ```
47
+
48
+ ___
49
+
50
+ ### `outPoint`
51
+ Contains out point for chain asset lock proof in `OutPointWASM`
52
+
53
+ ```js
54
+ const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
55
+
56
+ chainlock.outPoint = 1111
57
+
58
+ chainlock.outPoint // -> OutPointWASM
59
+ ```
60
+
61
+ ___
62
+
63
+ ## Static
@@ -0,0 +1,17 @@
1
+ # CoreScriptWASM
2
+
3
+ This class allows to create and interact with CoreScript struct.
4
+
5
+ `CoreScriptWASM` can be created via 3 methods or from other classes
6
+
7
+ ```js
8
+ const script = wasm.CoreScriptWASM.fromBytes([118, 169, 20, 195, 219, 253, 64, 231, 248, 164, 132, 92, 47, 142, 134, 138, 22, 124, 152, 64, 73, 118, 73, 136, 172])
9
+ // or
10
+ const script = wasm.CoreScriptWASM.newP2PKH([195, 219, 253, 64, 231, 248, 164, 132, 92, 47, 142, 134, 138, 22, 124, 152, 64, 73, 118, 73])
11
+ // or
12
+ const script = wasm.CoreScriptWASM.newP2SH([195, 219, 253, 64, 231, 248, 164, 132, 92, 47, 142, 134, 138, 22, 124, 152, 64, 73, 118, 73])
13
+
14
+ script.toASMString() // -> ASM String
15
+
16
+ script.toBytes() // -> Uint8Array
17
+ ```
@@ -0,0 +1,192 @@
1
+ # DataContractWASM
2
+
3
+ This class allows to create instance of DataContract and interact with him.
4
+
5
+ You can create `DataContractWASM` via constructor, bytes and from raw value
6
+
7
+ Arguments in constructor:
8
+
9
+ - `ownerId -> IdentifierWASM | String | ArrayLike`
10
+ - `identityNonce -> BigInt`
11
+ - `schema -> Object`
12
+ - `definitions -> Object | undefined`
13
+ - `fullValidation -> Boolean`
14
+ - `platformVersion -> ?PlatformVersionEnum`
15
+
16
+ If you want to create DataContract from bytes,
17
+ you need to use serialized to bytes DataContract from `rs-dpp` or `pshenmic-dpp`
18
+
19
+ This class also contains static method for DataContract id generation:
20
+
21
+ - `generateId`
22
+ - `ownerId -> IdentifierWASM | String | ArrayLike`
23
+ - `nonce -> BigInt`
24
+
25
+ ___
26
+
27
+ ## Navigation
28
+
29
+ - [Example](#example)
30
+ - [Getters methods](#getters-methods)
31
+ - [getSchema](#getschema)
32
+ - [getVersion](#getversion)
33
+ - [getId](#getid)
34
+ - [getOwnerId](#getownerid)
35
+ - [getConfig](#getconfig)
36
+ - [Setters methods](#setters-methods)
37
+ - [setSchema](#setschema)
38
+ - [setVersion](#setversion)
39
+ - [setId](#setid)
40
+ - [setOwnerId](#setownerid)
41
+ - [setConfig](#setconfig)
42
+
43
+ ___
44
+
45
+ ## Example
46
+
47
+ ```js
48
+ const identifier = new IdentifierWASM('11111111111111111111111111111111')
49
+ const schema = {
50
+ "note": {
51
+ "type": "object",
52
+ "properties": {
53
+ "message": {
54
+ "type": "string",
55
+ "position": 0
56
+ }
57
+ },
58
+ "additionalProperties": false
59
+ }
60
+ }
61
+
62
+ const dataContract = new DataContractWASM(identifier, BigInt(2), schema, null, false)
63
+ ```
64
+
65
+ ___
66
+
67
+ ## Getters methods
68
+
69
+ ### `getSchema`
70
+
71
+ Returns DataContract schema as `Object`
72
+
73
+ ```js
74
+ dataContractInstance.getSchema() // -> Object
75
+ ```
76
+
77
+ ___
78
+
79
+ ### `getVersion`
80
+
81
+ Returns DataContract version in `Number`
82
+
83
+ ```js
84
+ dataContractInstance.getVersion() // -> Number
85
+ ```
86
+
87
+ ___
88
+
89
+ ### `getId`
90
+
91
+ Returns DataContract identifier in `IdentifierWASM`
92
+
93
+ ```js
94
+ dataContractInstance.getId() // -> IdentifierWASM
95
+ ```
96
+
97
+ ___
98
+
99
+ ### `getOwnerId`
100
+
101
+ Returns DataContract owner identifier in `IdentifierWASM`
102
+
103
+ ```js
104
+ dataContractInstance.getOwnerId() // -> IdentifierWASM
105
+ ```
106
+
107
+ ___
108
+
109
+ ### `getConfig`
110
+
111
+ Returns DataContract config in `Object`
112
+
113
+ ```js
114
+ dataContractInstance.getConfig() // -> Object
115
+ ```
116
+
117
+ ___
118
+
119
+ ## Setters methods
120
+
121
+ ### `setSchema`
122
+
123
+ Allows to set DataContract schema in `Object`
124
+
125
+ ```js
126
+ const schema = {
127
+ "note": {
128
+ "type": "object",
129
+ "properties": {
130
+ "message": {
131
+ "type": "string",
132
+ "position": 0
133
+ }
134
+ },
135
+ "additionalProperties": false
136
+ }
137
+ }
138
+
139
+ dataContractInstance.setSchema(schema)
140
+ ```
141
+
142
+ ___
143
+
144
+ ### `setVersion`
145
+
146
+ Allows to set DataContract version in `Number`
147
+
148
+ ```js
149
+ dataContractInstance.setVersion(11)
150
+ ```
151
+
152
+ ___
153
+
154
+ ### `setId`
155
+
156
+ Allows to set DataContract identifier in `IdentifierWASM | String | ArrayLike`
157
+
158
+ ```js
159
+ dataContractInstance.setId('GgZekwh38XcWQTyWWWvmw6CEYFnLU7yiZFPWZEjqKHit')
160
+ ```
161
+
162
+ ___
163
+
164
+ ### `setOwnerId`
165
+
166
+ Allows to set DataContract owner identifier in `IdentifierWASM | String | ArrayLike`
167
+
168
+ ```js
169
+ dataContractInstance.setOwnerId('GgZekwh38XcWQTyWWWvmw6CEYFnLU7yiZFPWZEjqKHit')
170
+ ```
171
+
172
+ ___
173
+
174
+ ### `setConfig`
175
+
176
+ Allows to set DataContract config in `Object`
177
+
178
+ ```js
179
+ const config = {
180
+ "$format_version": "0",
181
+ "canBeDeleted": false,
182
+ "readonly": false,
183
+ "keepsHistory": false,
184
+ "documentsKeepHistoryContractDefault": false,
185
+ "documentsMutableContractDefault": true,
186
+ "documentsCanBeDeletedContractDefault": true,
187
+ "requiresIdentityEncryptionBoundedKey": null,
188
+ "requiresIdentityDecryptionBoundedKey": null
189
+ }
190
+
191
+ dataContractInstance.setConfig(config)
192
+ ```
@@ -0,0 +1,84 @@
1
+ # DataContractCreateTransitionWASM
2
+
3
+ This class allows to create DataContractCreateTransition and interact
4
+
5
+ `DataContractCreateTransitionWASM` can be created via constructor, bytes and state transition
6
+
7
+ Constructor arguments:
8
+
9
+ - `dataContract -> DataContractWASM`
10
+ - `identityContractNonce -> BigInt`
11
+ - `platformVersion -> ?PlatformVersionEnum`
12
+
13
+ ___
14
+
15
+ ## Navigation
16
+
17
+ - [Example](#example)
18
+ - [Getters methods](#getters-methods)
19
+ - [getFeatureVersion](#getfeatureversion)
20
+ - [verifyProtocolVersion](#verifyprotocolversion)
21
+ - [getDataContract](#getdatacontract)
22
+ - [Setters methods](#setters-methods)
23
+ - [setDataContract](#setdatacontract)
24
+
25
+ ___
26
+
27
+ ## Example
28
+
29
+ ```js
30
+ const dataContract = DataContractWASM.fromValue(value, false, PlatformVersionWASM.PLATFORM_V1)
31
+
32
+ const dataContractTransition = new DataContractCreateTransitionWASM(dataContract, BigInt(1))
33
+ ```
34
+
35
+ ___
36
+
37
+ ## Getters methods
38
+
39
+ ### `getFeatureVersion`
40
+
41
+ Returns feature version of transition in `Number`
42
+
43
+ ```js
44
+ dataContractTransition.getFeatureVersion() // -> Number
45
+ ```
46
+
47
+ ___
48
+
49
+ ### `verifyProtocolVersion`
50
+
51
+ Returns `Boolean` if selected protocol version equal protocol version in transition
52
+
53
+ ```js
54
+ dataContractTransition.verifyProtocolVersion(1) // -> Boolean
55
+ ```
56
+
57
+ ___
58
+
59
+ ### `getDataContract`
60
+
61
+ Returns DataContract in `DataContractWASM`
62
+
63
+ Arguments:
64
+
65
+ - `pltaformVersion -> PlatformVersionEnum`
66
+ - `fullValidation -> Boolean`
67
+
68
+ ```js
69
+ dataContractTransition.getDataContract('PLATFORM_V1', true) // -> DataContractWASM
70
+ ```
71
+
72
+ ___
73
+
74
+ ## Setters methods
75
+
76
+ ### `setDataContract`
77
+
78
+ Allows to set DataContract in `DataContractWASM` with `PlatformVersionEnum`
79
+
80
+ ```js
81
+ const dataContract = DataContractWASM.fromValue(value, false, PlatformVersionWASM.PLATFORM_V1)
82
+
83
+ dataContractTransition.setDataContract('PLATFORM_V1')
84
+ ```
@@ -0,0 +1,84 @@
1
+ # DataContractUpdateTransitionWASM
2
+
3
+ This class allows to create DataContractUpdateTransition and interact
4
+
5
+ `DataContractUpdateTransitionWASM` can be created via constructor, bytes and state transition
6
+
7
+ Constructor arguments:
8
+
9
+ - `dataContract -> DataContractWASM`
10
+ - `identityContractNonce -> BigInt`
11
+ - `platformVersion -> ?PlatformVersionEnum`
12
+
13
+ ___
14
+
15
+ ## Navigation
16
+
17
+ - [Example](#example)
18
+ - [Getters methods](#getters-methods)
19
+ - [getFeatureVersion](#getfeatureversion)
20
+ - [verifyProtocolVersion](#verifyprotocolversion)
21
+ - [getDataContract](#getdatacontract)
22
+ - [Setters methods](#setters-methods)
23
+ - [setDataContract](#setdatacontract)
24
+
25
+ ___
26
+
27
+ ## Example
28
+
29
+ ```js
30
+ const dataContract = DataContractWASM.fromValue(value, false, PlatformVersionWASM.PLATFORM_V1)
31
+
32
+ const dataContractTransition = new DataContractUpdateTransitionWASM(dataContract, BigInt(1))
33
+ ```
34
+
35
+ ___
36
+
37
+ ## Getters methods
38
+
39
+ ### `getFeatureVersion`
40
+
41
+ Returns feature version of transition in `Number`
42
+
43
+ ```js
44
+ dataContractTransition.getFeatureVersion() // -> Number
45
+ ```
46
+
47
+ ___
48
+
49
+ ### `verifyProtocolVersion`
50
+
51
+ Returns `Boolean` if selected protocol version equal protocol version in transition
52
+
53
+ ```js
54
+ dataContractTransition.verifyProtocolVersion(1) // -> Boolean
55
+ ```
56
+
57
+ ___
58
+
59
+ ### `getDataContract`
60
+
61
+ Returns DataContract in `DataContractWASM`
62
+
63
+ Arguments:
64
+
65
+ - `pltaformVersion -> PlatformVersionEnum`
66
+ - `fullValidation -> Boolean`
67
+
68
+ ```js
69
+ dataContractTransition.getDataContract('PLATFORM_V1', true) // -> DataContractWASM
70
+ ```
71
+
72
+ ___
73
+
74
+ ## Setters methods
75
+
76
+ ### `setDataContract`
77
+
78
+ Allows to set DataContract in `DataContractWASM` with `PlatformVersionEnum`
79
+
80
+ ```js
81
+ const dataContract = DataContractWASM.fromValue(value, false, PlatformVersionWASM.PLATFORM_V1)
82
+
83
+ dataContractTransition.setDataContract('PLATFORM_V1')
84
+ ```