@dashevo/dashpay-contract 4.2.0-dev.1 → 4.2.0-dev.11
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 +2 -2
- package/schema/v2/dashpay.schema.json +271 -0
- package/src/lib.rs +5 -3
- package/src/v2/mod.rs +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dashpay-contract",
|
|
3
|
-
"version": "4.2.0-dev.
|
|
3
|
+
"version": "4.2.0-dev.11",
|
|
4
4
|
"description": "Reference contract of the DashPay DPA on Dash Evolution",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/dashevo/dashpay-contract#readme",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@dashevo/wasm-dpp": "4.2.0-dev.
|
|
28
|
+
"@dashevo/wasm-dpp": "4.2.0-dev.11",
|
|
29
29
|
"chai": "^4.3.10",
|
|
30
30
|
"dirty-chai": "^2.0.1",
|
|
31
31
|
"eslint": "^9.18.0",
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
{
|
|
2
|
+
"profile": {
|
|
3
|
+
"type": "object",
|
|
4
|
+
"indices": [
|
|
5
|
+
{
|
|
6
|
+
"name": "ownerId",
|
|
7
|
+
"properties": [
|
|
8
|
+
{
|
|
9
|
+
"$ownerId": "asc"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"unique": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "ownerIdAndUpdatedAt",
|
|
16
|
+
"properties": [
|
|
17
|
+
{
|
|
18
|
+
"$ownerId": "asc"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"$updatedAt": "asc"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"properties": {
|
|
27
|
+
"avatarUrl": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "uri",
|
|
30
|
+
"minLength": 1,
|
|
31
|
+
"maxLength": 2048,
|
|
32
|
+
"position": 0
|
|
33
|
+
},
|
|
34
|
+
"avatarHash": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"byteArray": true,
|
|
37
|
+
"minItems": 32,
|
|
38
|
+
"maxItems": 32,
|
|
39
|
+
"description": "SHA256 hash of the bytes of the image specified by avatarUrl",
|
|
40
|
+
"position": 1
|
|
41
|
+
},
|
|
42
|
+
"avatarFingerprint": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"byteArray": true,
|
|
45
|
+
"minItems": 8,
|
|
46
|
+
"maxItems": 8,
|
|
47
|
+
"description": "dHash the image specified by avatarUrl",
|
|
48
|
+
"position": 2
|
|
49
|
+
},
|
|
50
|
+
"publicMessage": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"minLength": 1,
|
|
53
|
+
"maxLength": 140,
|
|
54
|
+
"position": 3
|
|
55
|
+
},
|
|
56
|
+
"displayName": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"minLength": 1,
|
|
59
|
+
"maxLength": 25,
|
|
60
|
+
"position": 4
|
|
61
|
+
},
|
|
62
|
+
"corePaymentAddress": {
|
|
63
|
+
"type": "array",
|
|
64
|
+
"byteArray": true,
|
|
65
|
+
"minItems": 21,
|
|
66
|
+
"maxItems": 21,
|
|
67
|
+
"description": "Core chain address in storage form (type byte 0x00 P2PKH / 0x01 P2SH followed by the 20-byte HASH160, i.e. RIPEMD160 of SHA256, of the public key or redeem script) for public payments. The type byte is consensus-enforced by a data trigger; clients render the address as Base58Check for the network they are on. Payments to it are publicly linkable to this profile.",
|
|
68
|
+
"position": 5
|
|
69
|
+
},
|
|
70
|
+
"platformPaymentAddress": {
|
|
71
|
+
"type": "array",
|
|
72
|
+
"byteArray": true,
|
|
73
|
+
"minItems": 21,
|
|
74
|
+
"maxItems": 21,
|
|
75
|
+
"description": "Platform address in storage form (type byte 0x00 P2PKH / 0x01 P2SH followed by the 20-byte HASH160, i.e. RIPEMD160 of SHA256, of the public key or redeem script) for public payments. The type byte is consensus-enforced by a data trigger.",
|
|
76
|
+
"position": 6
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"minProperties": 1,
|
|
80
|
+
"dependentRequired": {
|
|
81
|
+
"avatarUrl": ["avatarHash", "avatarFingerprint"],
|
|
82
|
+
"avatarHash": ["avatarUrl", "avatarFingerprint"],
|
|
83
|
+
"avatarFingerprint": ["avatarUrl", "avatarHash"]
|
|
84
|
+
},
|
|
85
|
+
"required": [
|
|
86
|
+
"$createdAt",
|
|
87
|
+
"$updatedAt"
|
|
88
|
+
],
|
|
89
|
+
"additionalProperties": false
|
|
90
|
+
},
|
|
91
|
+
"contactInfo": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"indices": [
|
|
94
|
+
{
|
|
95
|
+
"name": "ownerIdAndKeys",
|
|
96
|
+
"properties": [
|
|
97
|
+
{
|
|
98
|
+
"$ownerId": "asc"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"rootEncryptionKeyIndex": "asc"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"derivationEncryptionKeyIndex": "asc"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"unique": true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "ownerIdAndUpdatedAt",
|
|
111
|
+
"properties": [
|
|
112
|
+
{
|
|
113
|
+
"$ownerId": "asc"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"$updatedAt": "asc"
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"properties": {
|
|
122
|
+
"encToUserId": {
|
|
123
|
+
"type": "array",
|
|
124
|
+
"byteArray": true,
|
|
125
|
+
"minItems": 32,
|
|
126
|
+
"maxItems": 32,
|
|
127
|
+
"position": 0
|
|
128
|
+
},
|
|
129
|
+
"rootEncryptionKeyIndex": {
|
|
130
|
+
"type": "integer",
|
|
131
|
+
"minimum": 0,
|
|
132
|
+
"position": 1
|
|
133
|
+
},
|
|
134
|
+
"derivationEncryptionKeyIndex": {
|
|
135
|
+
"type": "integer",
|
|
136
|
+
"minimum": 0,
|
|
137
|
+
"position": 2
|
|
138
|
+
},
|
|
139
|
+
"privateData": {
|
|
140
|
+
"type": "array",
|
|
141
|
+
"byteArray": true,
|
|
142
|
+
"minItems": 48,
|
|
143
|
+
"maxItems": 2048,
|
|
144
|
+
"position": 3,
|
|
145
|
+
"description": "This is the encrypted values of aliasName + note + displayHidden encoded as an array in cbor"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"required": [
|
|
149
|
+
"$createdAt",
|
|
150
|
+
"$updatedAt",
|
|
151
|
+
"encToUserId",
|
|
152
|
+
"privateData",
|
|
153
|
+
"rootEncryptionKeyIndex",
|
|
154
|
+
"derivationEncryptionKeyIndex"
|
|
155
|
+
],
|
|
156
|
+
"additionalProperties": false
|
|
157
|
+
},
|
|
158
|
+
"contactRequest": {
|
|
159
|
+
"documentsMutable": false,
|
|
160
|
+
"canBeDeleted": false,
|
|
161
|
+
"requiresIdentityEncryptionBoundedKey": 2,
|
|
162
|
+
"requiresIdentityDecryptionBoundedKey": 2,
|
|
163
|
+
"type": "object",
|
|
164
|
+
"indices": [
|
|
165
|
+
{
|
|
166
|
+
"name": "ownerIdUserIdAndAccountRef",
|
|
167
|
+
"properties": [
|
|
168
|
+
{
|
|
169
|
+
"$ownerId": "asc"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"toUserId": "asc"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"accountReference": "asc"
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"unique": true
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "ownerIdUserId",
|
|
182
|
+
"properties": [
|
|
183
|
+
{
|
|
184
|
+
"$ownerId": "asc"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"toUserId": "asc"
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "userIdCreatedAt",
|
|
193
|
+
"properties": [
|
|
194
|
+
{
|
|
195
|
+
"toUserId": "asc"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"$createdAt": "asc"
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "ownerIdCreatedAt",
|
|
204
|
+
"properties": [
|
|
205
|
+
{
|
|
206
|
+
"$ownerId": "asc"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"$createdAt": "asc"
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"properties": {
|
|
215
|
+
"toUserId": {
|
|
216
|
+
"type": "array",
|
|
217
|
+
"byteArray": true,
|
|
218
|
+
"minItems": 32,
|
|
219
|
+
"maxItems": 32,
|
|
220
|
+
"position": 0,
|
|
221
|
+
"contentMediaType": "application/x.dash.dpp.identifier"
|
|
222
|
+
},
|
|
223
|
+
"encryptedPublicKey": {
|
|
224
|
+
"type": "array",
|
|
225
|
+
"byteArray": true,
|
|
226
|
+
"minItems": 96,
|
|
227
|
+
"maxItems": 96,
|
|
228
|
+
"position": 1
|
|
229
|
+
},
|
|
230
|
+
"senderKeyIndex": {
|
|
231
|
+
"type": "integer",
|
|
232
|
+
"minimum": 0,
|
|
233
|
+
"position": 2
|
|
234
|
+
},
|
|
235
|
+
"recipientKeyIndex": {
|
|
236
|
+
"type": "integer",
|
|
237
|
+
"minimum": 0,
|
|
238
|
+
"position": 3
|
|
239
|
+
},
|
|
240
|
+
"accountReference": {
|
|
241
|
+
"type": "integer",
|
|
242
|
+
"minimum": 0,
|
|
243
|
+
"position": 4
|
|
244
|
+
},
|
|
245
|
+
"encryptedAccountLabel": {
|
|
246
|
+
"type": "array",
|
|
247
|
+
"byteArray": true,
|
|
248
|
+
"minItems": 48,
|
|
249
|
+
"maxItems": 80,
|
|
250
|
+
"position": 5
|
|
251
|
+
},
|
|
252
|
+
"autoAcceptProof": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"byteArray": true,
|
|
255
|
+
"minItems": 38,
|
|
256
|
+
"maxItems": 102,
|
|
257
|
+
"position": 6
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
"required": [
|
|
261
|
+
"$createdAt",
|
|
262
|
+
"$createdAtCoreBlockHeight",
|
|
263
|
+
"toUserId",
|
|
264
|
+
"encryptedPublicKey",
|
|
265
|
+
"senderKeyIndex",
|
|
266
|
+
"recipientKeyIndex",
|
|
267
|
+
"accountReference"
|
|
268
|
+
],
|
|
269
|
+
"additionalProperties": false
|
|
270
|
+
}
|
|
271
|
+
}
|
package/src/lib.rs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
mod error;
|
|
2
2
|
pub mod v1;
|
|
3
|
+
pub mod v2;
|
|
3
4
|
|
|
4
5
|
pub use crate::error::Error;
|
|
5
6
|
use platform_value::{Identifier, IdentifierBytes32};
|
|
@@ -18,10 +19,10 @@ pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
|
|
|
18
19
|
|
|
19
20
|
pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
|
|
20
21
|
match platform_version.system_data_contracts.dashpay {
|
|
21
|
-
1 => Ok(None),
|
|
22
|
+
1 | 2 => Ok(None),
|
|
22
23
|
version => Err(Error::UnknownVersionMismatch {
|
|
23
24
|
method: "dashpay_contract::load_definitions".to_string(),
|
|
24
|
-
known_versions: vec![1],
|
|
25
|
+
known_versions: vec![1, 2],
|
|
25
26
|
received: version,
|
|
26
27
|
}),
|
|
27
28
|
}
|
|
@@ -29,9 +30,10 @@ pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Val
|
|
|
29
30
|
pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
|
|
30
31
|
match platform_version.system_data_contracts.dashpay {
|
|
31
32
|
1 => v1::load_documents_schemas(),
|
|
33
|
+
2 => v2::load_documents_schemas(),
|
|
32
34
|
version => Err(Error::UnknownVersionMismatch {
|
|
33
35
|
method: "dashpay_contract::load_documents_schemas".to_string(),
|
|
34
|
-
known_versions: vec![1],
|
|
36
|
+
known_versions: vec![1, 2],
|
|
35
37
|
received: version,
|
|
36
38
|
}),
|
|
37
39
|
}
|
package/src/v2/mod.rs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
use crate::error::Error;
|
|
2
|
+
use serde_json::Value;
|
|
3
|
+
|
|
4
|
+
// Document-type name and property constants live in `crate::v1::document_types`;
|
|
5
|
+
// v2 does not change any names v1 defined, it only adds the optional
|
|
6
|
+
// `corePaymentAddress` / `platformPaymentAddress` properties to `profile`.
|
|
7
|
+
|
|
8
|
+
pub fn load_documents_schemas() -> Result<Value, Error> {
|
|
9
|
+
serde_json::from_str(include_str!("../../schema/v2/dashpay.schema.json"))
|
|
10
|
+
.map_err(Error::InvalidSchemaJson)
|
|
11
|
+
}
|