@dashevo/dashpay-contract 5.0.3 → 5.1.0-dev.2
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/v3/dashpay.schema.json +365 -0
- package/src/lib.rs +5 -3
- package/src/v3/mod.rs +42 -0
- package/test/unit/schema.spec.js +39 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dashpay-contract",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.1.0-dev.2",
|
|
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": "5.0.
|
|
28
|
+
"@dashevo/wasm-dpp": "5.1.0-dev.2",
|
|
29
29
|
"chai": "^4.3.10",
|
|
30
30
|
"dirty-chai": "^2.0.1",
|
|
31
31
|
"eslint": "^9.18.0",
|
|
@@ -0,0 +1,365 @@
|
|
|
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 corePaymentAddressType rule holds the type byte; 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 platformPaymentAddressType rule holds the type byte.",
|
|
76
|
+
"position": 6
|
|
77
|
+
},
|
|
78
|
+
"shieldedAddress": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"byteArray": true,
|
|
81
|
+
"minItems": 43,
|
|
82
|
+
"maxItems": 43,
|
|
83
|
+
"description": "Raw Orchard receiving address: 11-byte diversifier followed by 32-byte diversified transmission key. Clients validate before payment; wallets should use a dedicated tip account.",
|
|
84
|
+
"position": 7
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"minProperties": 1,
|
|
88
|
+
"dependentRequired": {
|
|
89
|
+
"avatarUrl": ["avatarHash", "avatarFingerprint"],
|
|
90
|
+
"avatarHash": ["avatarUrl", "avatarFingerprint"],
|
|
91
|
+
"avatarFingerprint": ["avatarUrl", "avatarHash"]
|
|
92
|
+
},
|
|
93
|
+
"propertyConstraints": {
|
|
94
|
+
"corePaymentAddressType": { "in": [{ "byteAt": ["corePaymentAddress", 0] }, [0, 1]] },
|
|
95
|
+
"platformPaymentAddressType": { "in": [{ "byteAt": ["platformPaymentAddress", 0] }, [0, 1]] }
|
|
96
|
+
},
|
|
97
|
+
"required": [
|
|
98
|
+
"$createdAt",
|
|
99
|
+
"$updatedAt"
|
|
100
|
+
],
|
|
101
|
+
"additionalProperties": false
|
|
102
|
+
},
|
|
103
|
+
"contactInfo": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"indices": [
|
|
106
|
+
{
|
|
107
|
+
"name": "ownerIdAndKeys",
|
|
108
|
+
"properties": [
|
|
109
|
+
{
|
|
110
|
+
"$ownerId": "asc"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"rootEncryptionKeyIndex": "asc"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"derivationEncryptionKeyIndex": "asc"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"unique": true
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "ownerIdAndUpdatedAt",
|
|
123
|
+
"properties": [
|
|
124
|
+
{
|
|
125
|
+
"$ownerId": "asc"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"$updatedAt": "asc"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"properties": {
|
|
134
|
+
"encToUserId": {
|
|
135
|
+
"type": "array",
|
|
136
|
+
"byteArray": true,
|
|
137
|
+
"minItems": 32,
|
|
138
|
+
"maxItems": 32,
|
|
139
|
+
"position": 0
|
|
140
|
+
},
|
|
141
|
+
"rootEncryptionKeyIndex": {
|
|
142
|
+
"type": "integer",
|
|
143
|
+
"minimum": 0,
|
|
144
|
+
"position": 1
|
|
145
|
+
},
|
|
146
|
+
"derivationEncryptionKeyIndex": {
|
|
147
|
+
"type": "integer",
|
|
148
|
+
"minimum": 0,
|
|
149
|
+
"position": 2
|
|
150
|
+
},
|
|
151
|
+
"privateData": {
|
|
152
|
+
"type": "array",
|
|
153
|
+
"byteArray": true,
|
|
154
|
+
"minItems": 48,
|
|
155
|
+
"maxItems": 2048,
|
|
156
|
+
"position": 3,
|
|
157
|
+
"description": "This is the encrypted values of aliasName + note + displayHidden encoded as an array in cbor"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"required": [
|
|
161
|
+
"$createdAt",
|
|
162
|
+
"$updatedAt",
|
|
163
|
+
"encToUserId",
|
|
164
|
+
"privateData",
|
|
165
|
+
"rootEncryptionKeyIndex",
|
|
166
|
+
"derivationEncryptionKeyIndex"
|
|
167
|
+
],
|
|
168
|
+
"additionalProperties": false
|
|
169
|
+
},
|
|
170
|
+
"contactRequest": {
|
|
171
|
+
"documentsMutable": false,
|
|
172
|
+
"canBeDeleted": false,
|
|
173
|
+
"requiresIdentityEncryptionBoundedKey": 2,
|
|
174
|
+
"requiresIdentityDecryptionBoundedKey": 2,
|
|
175
|
+
"type": "object",
|
|
176
|
+
"indices": [
|
|
177
|
+
{
|
|
178
|
+
"name": "ownerIdUserIdAndAccountRef",
|
|
179
|
+
"properties": [
|
|
180
|
+
{
|
|
181
|
+
"$ownerId": "asc"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"toUserId": "asc"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"accountReference": "asc"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"unique": true
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "ownerIdUserId",
|
|
194
|
+
"properties": [
|
|
195
|
+
{
|
|
196
|
+
"$ownerId": "asc"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"toUserId": "asc"
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"name": "userIdCreatedAt",
|
|
205
|
+
"properties": [
|
|
206
|
+
{
|
|
207
|
+
"toUserId": "asc"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"$createdAt": "asc"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "ownerIdCreatedAt",
|
|
216
|
+
"properties": [
|
|
217
|
+
{
|
|
218
|
+
"$ownerId": "asc"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"$createdAt": "asc"
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"properties": {
|
|
227
|
+
"toUserId": {
|
|
228
|
+
"type": "array",
|
|
229
|
+
"byteArray": true,
|
|
230
|
+
"minItems": 32,
|
|
231
|
+
"maxItems": 32,
|
|
232
|
+
"position": 0,
|
|
233
|
+
"contentMediaType": "application/x.dash.dpp.identifier",
|
|
234
|
+
"refersTo": {
|
|
235
|
+
"type": "identity"
|
|
236
|
+
},
|
|
237
|
+
"distinctFrom": "$ownerId"
|
|
238
|
+
},
|
|
239
|
+
"encryptedPublicKey": {
|
|
240
|
+
"type": "array",
|
|
241
|
+
"byteArray": true,
|
|
242
|
+
"minItems": 96,
|
|
243
|
+
"maxItems": 96,
|
|
244
|
+
"encryptedFor": {
|
|
245
|
+
"recipient": "toUserId",
|
|
246
|
+
"recipientKey": "recipientKeyIndex",
|
|
247
|
+
"senderKey": "senderKeyIndex",
|
|
248
|
+
"scheme": "ecdh-secp256k1-aes256-cbc"
|
|
249
|
+
},
|
|
250
|
+
"position": 1
|
|
251
|
+
},
|
|
252
|
+
"senderKeyIndex": {
|
|
253
|
+
"type": "integer",
|
|
254
|
+
"minimum": 0,
|
|
255
|
+
"maximum": 4294967295,
|
|
256
|
+
"position": 2
|
|
257
|
+
},
|
|
258
|
+
"recipientKeyIndex": {
|
|
259
|
+
"type": "integer",
|
|
260
|
+
"minimum": 0,
|
|
261
|
+
"maximum": 4294967295,
|
|
262
|
+
"position": 3
|
|
263
|
+
},
|
|
264
|
+
"accountReference": {
|
|
265
|
+
"type": "integer",
|
|
266
|
+
"minimum": 0,
|
|
267
|
+
"position": 4
|
|
268
|
+
},
|
|
269
|
+
"encryptedAccountLabel": {
|
|
270
|
+
"type": "array",
|
|
271
|
+
"byteArray": true,
|
|
272
|
+
"minItems": 48,
|
|
273
|
+
"maxItems": 80,
|
|
274
|
+
"encryptedFor": {
|
|
275
|
+
"recipient": "toUserId",
|
|
276
|
+
"recipientKey": "recipientKeyIndex",
|
|
277
|
+
"senderKey": "senderKeyIndex",
|
|
278
|
+
"scheme": "ecdh-secp256k1-aes256-cbc"
|
|
279
|
+
},
|
|
280
|
+
"position": 5
|
|
281
|
+
},
|
|
282
|
+
"autoAcceptProof": {
|
|
283
|
+
"type": "array",
|
|
284
|
+
"byteArray": true,
|
|
285
|
+
"minItems": 38,
|
|
286
|
+
"maxItems": 102,
|
|
287
|
+
"position": 6
|
|
288
|
+
},
|
|
289
|
+
"encryptedShieldedAddress": {
|
|
290
|
+
"type": "array",
|
|
291
|
+
"byteArray": true,
|
|
292
|
+
"minItems": 64,
|
|
293
|
+
"maxItems": 80,
|
|
294
|
+
"encryptedFor": {
|
|
295
|
+
"recipient": "toUserId",
|
|
296
|
+
"recipientKey": "recipientKeyIndex",
|
|
297
|
+
"senderKey": "senderKeyIndex",
|
|
298
|
+
"scheme": "ecdh-secp256k1-aes256-cbc"
|
|
299
|
+
},
|
|
300
|
+
"position": 7,
|
|
301
|
+
"description": "Sender's per-contact shielded payment address (43 bytes), encrypted to the contact with the DIP-15 shared key"
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
"required": [
|
|
305
|
+
"$createdAt",
|
|
306
|
+
"$createdAtCoreBlockHeight",
|
|
307
|
+
"toUserId",
|
|
308
|
+
"encryptedPublicKey",
|
|
309
|
+
"senderKeyIndex",
|
|
310
|
+
"recipientKeyIndex",
|
|
311
|
+
"accountReference"
|
|
312
|
+
],
|
|
313
|
+
"additionalProperties": false
|
|
314
|
+
},
|
|
315
|
+
"privateContactRequest": {
|
|
316
|
+
"type": "object",
|
|
317
|
+
"description": "A contact request nobody else can see: an entry encrypted to the recipient's DashPay decryption key and appended, without an identity, by a transition paid from the shielded pool. These properties describe the plaintext the recipient decrypts; the chain never reads it.",
|
|
318
|
+
"private": {
|
|
319
|
+
"entrySize": 589
|
|
320
|
+
},
|
|
321
|
+
"documentsMutable": false,
|
|
322
|
+
"canBeDeleted": false,
|
|
323
|
+
"properties": {
|
|
324
|
+
"accountReference": {
|
|
325
|
+
"type": "integer",
|
|
326
|
+
"minimum": 0,
|
|
327
|
+
"maximum": 4294967295,
|
|
328
|
+
"position": 0
|
|
329
|
+
},
|
|
330
|
+
"extendedPublicKey": {
|
|
331
|
+
"type": "array",
|
|
332
|
+
"byteArray": true,
|
|
333
|
+
"minItems": 69,
|
|
334
|
+
"maxItems": 69,
|
|
335
|
+
"description": "The DIP-15 compact extended public key the recipient pays to: the parent fingerprint (4 bytes), the chain code (32) and the public key (33).",
|
|
336
|
+
"position": 1
|
|
337
|
+
},
|
|
338
|
+
"accountLabel": {
|
|
339
|
+
"type": "string",
|
|
340
|
+
"maxBytes": 63,
|
|
341
|
+
"position": 2
|
|
342
|
+
},
|
|
343
|
+
"autoAcceptProof": {
|
|
344
|
+
"type": "array",
|
|
345
|
+
"byteArray": true,
|
|
346
|
+
"minItems": 38,
|
|
347
|
+
"maxItems": 102,
|
|
348
|
+
"position": 3
|
|
349
|
+
},
|
|
350
|
+
"shieldedAddress": {
|
|
351
|
+
"type": "array",
|
|
352
|
+
"byteArray": true,
|
|
353
|
+
"minItems": 43,
|
|
354
|
+
"maxItems": 43,
|
|
355
|
+
"description": "Raw Orchard receiving address for this contact: 11-byte diversifier followed by 32-byte diversified transmission key.",
|
|
356
|
+
"position": 4
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
"required": [
|
|
360
|
+
"accountReference",
|
|
361
|
+
"extendedPublicKey"
|
|
362
|
+
],
|
|
363
|
+
"additionalProperties": false
|
|
364
|
+
}
|
|
365
|
+
}
|
package/src/lib.rs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
mod error;
|
|
2
2
|
pub mod v1;
|
|
3
3
|
pub mod v2;
|
|
4
|
+
pub mod v3;
|
|
4
5
|
|
|
5
6
|
pub use crate::error::Error;
|
|
6
7
|
use platform_value::{Identifier, IdentifierBytes32};
|
|
@@ -19,10 +20,10 @@ pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
|
|
|
19
20
|
|
|
20
21
|
pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
|
|
21
22
|
match platform_version.system_data_contracts.dashpay {
|
|
22
|
-
1
|
|
23
|
+
1..=3 => Ok(None),
|
|
23
24
|
version => Err(Error::UnknownVersionMismatch {
|
|
24
25
|
method: "dashpay_contract::load_definitions".to_string(),
|
|
25
|
-
known_versions: vec![1, 2],
|
|
26
|
+
known_versions: vec![1, 2, 3],
|
|
26
27
|
received: version,
|
|
27
28
|
}),
|
|
28
29
|
}
|
|
@@ -31,9 +32,10 @@ pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Valu
|
|
|
31
32
|
match platform_version.system_data_contracts.dashpay {
|
|
32
33
|
1 => v1::load_documents_schemas(),
|
|
33
34
|
2 => v2::load_documents_schemas(),
|
|
35
|
+
3 => v3::load_documents_schemas(),
|
|
34
36
|
version => Err(Error::UnknownVersionMismatch {
|
|
35
37
|
method: "dashpay_contract::load_documents_schemas".to_string(),
|
|
36
|
-
known_versions: vec![1, 2],
|
|
38
|
+
known_versions: vec![1, 2, 3],
|
|
37
39
|
received: version,
|
|
38
40
|
}),
|
|
39
41
|
}
|
package/src/v3/mod.rs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
// v3 keeps every name and property v2 declares, stored as v2 stores it, and adds
|
|
6
|
+
// declarations only:
|
|
7
|
+
//
|
|
8
|
+
// - `contactRequest.toUserId` refers to an identity and must differ from the
|
|
9
|
+
// writer (`refersTo` identity, `distinctFrom` `$ownerId`), the two checks the
|
|
10
|
+
// contact request data trigger made up to protocol version 14.
|
|
11
|
+
// - `contactRequest.encryptedPublicKey` and `encryptedAccountLabel` name their
|
|
12
|
+
// encryption (`encryptedFor`, ECDH between the sender's `senderKeyIndex` key and
|
|
13
|
+
// the recipient's `recipientKeyIndex` key, then AES-256-CBC with the IV first),
|
|
14
|
+
// so each must be an IV plus whole AES blocks. Both key indexes gain the u32
|
|
15
|
+
// `maximum` that `encryptedFor` requires of a key id; DashPay keeps sized integer
|
|
16
|
+
// types off, so they are still stored as i64.
|
|
17
|
+
// - `profile`'s `corePaymentAddressType` and `platformPaymentAddressType` rules
|
|
18
|
+
// hold the first byte of each DIP-33 payment address to the address type, the
|
|
19
|
+
// check the profile data trigger made up to protocol version 14. Their descriptions say
|
|
20
|
+
// so in place of v2's mention of the data trigger.
|
|
21
|
+
//
|
|
22
|
+
// It adds one property:
|
|
23
|
+
//
|
|
24
|
+
// - `contactRequest.encryptedShieldedAddress`, optional and last in position: the
|
|
25
|
+
// sender's shielded payment address for this contact (43 bytes), encrypted as
|
|
26
|
+
// `encryptedPublicKey` is (`encryptedFor`). That is 64 bytes, an IV and three AES
|
|
27
|
+
// blocks. The contract also accepts 80 bytes, an IV and four blocks, which wallets
|
|
28
|
+
// keep for a later encoding. A contact request stored before the property existed
|
|
29
|
+
// ends before it and reads back without it.
|
|
30
|
+
//
|
|
31
|
+
// And it adds one type:
|
|
32
|
+
//
|
|
33
|
+
// - `privateContactRequest`, a private type of 589-byte entries: a contact request
|
|
34
|
+
// encrypted to the recipient and appended by `PrivateDocumentCreateFromShieldedPool`
|
|
35
|
+
// without an identity. Its properties describe the plaintext the recipient decrypts.
|
|
36
|
+
// At their largest they take 290 bytes (`accountReference` is an i64, as DashPay
|
|
37
|
+
// stores every integer), which with the envelope's 299 bytes fill an entry.
|
|
38
|
+
|
|
39
|
+
pub fn load_documents_schemas() -> Result<Value, Error> {
|
|
40
|
+
serde_json::from_str(include_str!("../../schema/v3/dashpay.schema.json"))
|
|
41
|
+
.map_err(Error::InvalidSchemaJson)
|
|
42
|
+
}
|
package/test/unit/schema.spec.js
CHANGED
|
@@ -104,11 +104,11 @@ describe('Dashpay Contract', () => {
|
|
|
104
104
|
|
|
105
105
|
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
106
106
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
107
|
-
const error = expectJsonSchemaError(validationResult
|
|
107
|
+
const error = expectJsonSchemaError(validationResult);
|
|
108
108
|
|
|
109
109
|
expect(error.keyword)
|
|
110
110
|
.to
|
|
111
|
-
.equal('
|
|
111
|
+
.equal('minLength');
|
|
112
112
|
expect(error.instancePath)
|
|
113
113
|
.to
|
|
114
114
|
.deep
|
|
@@ -163,7 +163,7 @@ describe('Dashpay Contract', () => {
|
|
|
163
163
|
|
|
164
164
|
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
165
165
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
166
|
-
|
|
166
|
+
const error = expectJsonSchemaError(validationResult);
|
|
167
167
|
|
|
168
168
|
expect(error.keyword)
|
|
169
169
|
.to
|
|
@@ -172,8 +172,16 @@ describe('Dashpay Contract', () => {
|
|
|
172
172
|
.to
|
|
173
173
|
.deep
|
|
174
174
|
.equal({ missingProperty: 'avatarUrl' });
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should require the other avatar properties when present alone', async () => {
|
|
178
|
+
profileData = {
|
|
179
|
+
avatarUrl: 'https://github.com/dashpay/dash.jpg',
|
|
180
|
+
};
|
|
175
181
|
|
|
176
|
-
|
|
182
|
+
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
183
|
+
const validationResult = document.validate(dpp.protocolVersion);
|
|
184
|
+
const error = expectJsonSchemaError(validationResult);
|
|
177
185
|
|
|
178
186
|
expect(error.keyword)
|
|
179
187
|
.to
|
|
@@ -181,7 +189,7 @@ describe('Dashpay Contract', () => {
|
|
|
181
189
|
expect(error.params)
|
|
182
190
|
.to
|
|
183
191
|
.deep
|
|
184
|
-
.equal({ missingProperty: '
|
|
192
|
+
.equal({ missingProperty: 'avatarHash' });
|
|
185
193
|
});
|
|
186
194
|
});
|
|
187
195
|
|
|
@@ -235,7 +243,7 @@ describe('Dashpay Contract', () => {
|
|
|
235
243
|
|
|
236
244
|
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
237
245
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
238
|
-
const error = expectJsonSchemaError(validationResult
|
|
246
|
+
const error = expectJsonSchemaError(validationResult);
|
|
239
247
|
|
|
240
248
|
expect(error.keyword)
|
|
241
249
|
.to
|
|
@@ -254,7 +262,7 @@ describe('Dashpay Contract', () => {
|
|
|
254
262
|
|
|
255
263
|
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
256
264
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
257
|
-
|
|
265
|
+
const error = expectJsonSchemaError(validationResult);
|
|
258
266
|
|
|
259
267
|
expect(error.keyword)
|
|
260
268
|
.to
|
|
@@ -263,8 +271,16 @@ describe('Dashpay Contract', () => {
|
|
|
263
271
|
.to
|
|
264
272
|
.deep
|
|
265
273
|
.equal({ missingProperty: 'avatarHash' });
|
|
274
|
+
});
|
|
266
275
|
|
|
267
|
-
|
|
276
|
+
it('should require the other avatar properties when present alone', async () => {
|
|
277
|
+
profileData = {
|
|
278
|
+
avatarHash: Buffer.alloc(32),
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
282
|
+
const validationResult = document.validate(dpp.protocolVersion);
|
|
283
|
+
const error = expectJsonSchemaError(validationResult);
|
|
268
284
|
|
|
269
285
|
expect(error.keyword)
|
|
270
286
|
.to
|
|
@@ -272,7 +288,7 @@ describe('Dashpay Contract', () => {
|
|
|
272
288
|
expect(error.params)
|
|
273
289
|
.to
|
|
274
290
|
.deep
|
|
275
|
-
.equal({ missingProperty: '
|
|
291
|
+
.equal({ missingProperty: 'avatarUrl' });
|
|
276
292
|
});
|
|
277
293
|
});
|
|
278
294
|
|
|
@@ -326,7 +342,7 @@ describe('Dashpay Contract', () => {
|
|
|
326
342
|
|
|
327
343
|
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
328
344
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
329
|
-
const error = expectJsonSchemaError(validationResult
|
|
345
|
+
const error = expectJsonSchemaError(validationResult);
|
|
330
346
|
|
|
331
347
|
expect(error.keyword)
|
|
332
348
|
.to
|
|
@@ -345,7 +361,7 @@ describe('Dashpay Contract', () => {
|
|
|
345
361
|
|
|
346
362
|
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
347
363
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
348
|
-
|
|
364
|
+
const error = expectJsonSchemaError(validationResult);
|
|
349
365
|
|
|
350
366
|
expect(error.keyword)
|
|
351
367
|
.to
|
|
@@ -354,8 +370,16 @@ describe('Dashpay Contract', () => {
|
|
|
354
370
|
.to
|
|
355
371
|
.deep
|
|
356
372
|
.equal({ missingProperty: 'avatarFingerprint' });
|
|
373
|
+
});
|
|
357
374
|
|
|
358
|
-
|
|
375
|
+
it('should require the other avatar properties when present alone', async () => {
|
|
376
|
+
profileData = {
|
|
377
|
+
avatarFingerprint: Buffer.alloc(8),
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const document = dpp.document.create(contract, identityId, 'profile', profileData);
|
|
381
|
+
const validationResult = document.validate(dpp.protocolVersion);
|
|
382
|
+
const error = expectJsonSchemaError(validationResult);
|
|
359
383
|
|
|
360
384
|
expect(error.keyword)
|
|
361
385
|
.to
|
|
@@ -363,7 +387,7 @@ describe('Dashpay Contract', () => {
|
|
|
363
387
|
expect(error.params)
|
|
364
388
|
.to
|
|
365
389
|
.deep
|
|
366
|
-
.equal({ missingProperty: '
|
|
390
|
+
.equal({ missingProperty: 'avatarUrl' });
|
|
367
391
|
});
|
|
368
392
|
});
|
|
369
393
|
|
|
@@ -681,7 +705,7 @@ describe('Dashpay Contract', () => {
|
|
|
681
705
|
|
|
682
706
|
const document = dpp.document.create(contract, identityId, 'contactRequest', contactRequestData);
|
|
683
707
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
684
|
-
const error = expectJsonSchemaError(validationResult
|
|
708
|
+
const error = expectJsonSchemaError(validationResult);
|
|
685
709
|
|
|
686
710
|
expect(error.keyword)
|
|
687
711
|
.to
|
|
@@ -731,7 +755,7 @@ describe('Dashpay Contract', () => {
|
|
|
731
755
|
|
|
732
756
|
const document = dpp.document.create(contract, identityId, 'contactRequest', contactRequestData);
|
|
733
757
|
const validationResult = document.validate(dpp.protocolVersion);
|
|
734
|
-
const error = expectJsonSchemaError(validationResult
|
|
758
|
+
const error = expectJsonSchemaError(validationResult);
|
|
735
759
|
|
|
736
760
|
expect(error.keyword)
|
|
737
761
|
.to
|