@dashevo/dpns-contract 1.0.0-pr.1937.B.3 → 1.0.0-rc.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/Cargo.toml +1 -1
- package/lib/systemIds.js +2 -1
- package/package.json +2 -2
- package/schema/v1/dpns-contract-documents.json +21 -29
- package/src/lib.rs +10 -3
- package/test/unit/dpnsContract.spec.js +4 -48
package/Cargo.toml
CHANGED
package/lib/systemIds.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dpns-contract",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "A contract and helper scripts for DPNS DApp",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@dashevo/wasm-dpp": "1.0.0-
|
|
34
|
+
"@dashevo/wasm-dpp": "1.0.0-rc.2",
|
|
35
35
|
"chai": "^4.3.10",
|
|
36
36
|
"dirty-chai": "^2.0.1",
|
|
37
37
|
"eslint": "^8.53.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"domain": {
|
|
3
|
-
"documentsMutable":
|
|
3
|
+
"documentsMutable": false,
|
|
4
4
|
"canBeDeleted": true,
|
|
5
5
|
"transferable": 1,
|
|
6
6
|
"tradeMode": 1,
|
|
@@ -16,22 +16,24 @@
|
|
|
16
16
|
"normalizedLabel": "asc"
|
|
17
17
|
}
|
|
18
18
|
],
|
|
19
|
-
"unique": true
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
"unique": true,
|
|
20
|
+
"contested": {
|
|
21
|
+
"fieldMatches": [
|
|
22
|
+
{
|
|
23
|
+
"field": "normalizedLabel",
|
|
24
|
+
"regexPattern": "^[a-zA-Z01-]{3,19}$"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"resolution": 0,
|
|
28
|
+
"description": "If the normalized label part of this index is less than 20 characters (all alphabet a-z, A-Z, 0, 1, and -) then a masternode vote contest takes place to give out the name"
|
|
29
|
+
}
|
|
29
30
|
},
|
|
30
31
|
{
|
|
31
|
-
"name": "
|
|
32
|
+
"name": "identityId",
|
|
33
|
+
"nullSearchable": false,
|
|
32
34
|
"properties": [
|
|
33
35
|
{
|
|
34
|
-
"records.
|
|
36
|
+
"records.identity": "asc"
|
|
35
37
|
}
|
|
36
38
|
]
|
|
37
39
|
}
|
|
@@ -81,32 +83,19 @@
|
|
|
81
83
|
"records": {
|
|
82
84
|
"type": "object",
|
|
83
85
|
"properties": {
|
|
84
|
-
"
|
|
85
|
-
"type": "array",
|
|
86
|
-
"byteArray": true,
|
|
87
|
-
"minItems": 32,
|
|
88
|
-
"maxItems": 32,
|
|
89
|
-
"position": 0,
|
|
90
|
-
"contentMediaType": "application/x.dash.dpp.identifier",
|
|
91
|
-
"description": "Identity ID to be used to create the primary name the Identity",
|
|
92
|
-
"$comment": "Must be equal to the document owner"
|
|
93
|
-
},
|
|
94
|
-
"dashAliasIdentityId": {
|
|
86
|
+
"identity": {
|
|
95
87
|
"type": "array",
|
|
96
88
|
"byteArray": true,
|
|
97
89
|
"minItems": 32,
|
|
98
90
|
"maxItems": 32,
|
|
99
91
|
"position": 1,
|
|
100
92
|
"contentMediaType": "application/x.dash.dpp.identifier",
|
|
101
|
-
"description": "
|
|
102
|
-
"$comment": "Must be equal to the document owner"
|
|
93
|
+
"description": "Identifier name record that refers to an Identity"
|
|
103
94
|
}
|
|
104
95
|
},
|
|
105
96
|
"minProperties": 1,
|
|
106
|
-
"maxProperties": 1,
|
|
107
97
|
"position": 5,
|
|
108
|
-
"additionalProperties": false
|
|
109
|
-
"$comment": "Constraint with max and min properties ensure that only one identity record is used - either a `dashUniqueIdentityId` or a `dashAliasIdentityId`"
|
|
98
|
+
"additionalProperties": false
|
|
110
99
|
},
|
|
111
100
|
"subdomainRules": {
|
|
112
101
|
"type": "object",
|
|
@@ -135,6 +124,9 @@
|
|
|
135
124
|
"records",
|
|
136
125
|
"subdomainRules"
|
|
137
126
|
],
|
|
127
|
+
"transient": [
|
|
128
|
+
"preorderSalt"
|
|
129
|
+
],
|
|
138
130
|
"additionalProperties": false,
|
|
139
131
|
"$comment": "In order to register a domain you need to create a preorder. The preorder step is needed to prevent man-in-the-middle attacks. normalizedLabel + '.' + normalizedParentDomain must not be longer than 253 chars length as defined by RFC 1035. Domain documents are immutable: modification and deletion are restricted"
|
|
140
132
|
},
|
package/src/lib.rs
CHANGED
|
@@ -11,9 +11,16 @@ pub const ID_BYTES: [u8; 32] = [
|
|
|
11
11
|
196, 13, 87, 33, 246, 34, 191, 83, 197, 49, 85,
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
-
pub const OWNER_ID_BYTES: [u8; 32] = [
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
pub const OWNER_ID_BYTES: [u8; 32] = [0; 32];
|
|
15
|
+
|
|
16
|
+
pub const DPNS_DASH_TLD_DOCUMENT_ID: [u8; 32] = [
|
|
17
|
+
215, 242, 197, 63, 70, 169, 23, 171, 110, 91, 57, 162, 215, 188, 38, 11, 100, 146, 137, 69, 55,
|
|
18
|
+
68, 209, 224, 212, 242, 106, 141, 142, 255, 55, 207,
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
pub const DPNS_DASH_TLD_PREORDER_SALT: [u8; 32] = [
|
|
22
|
+
224, 181, 8, 197, 163, 104, 37, 162, 6, 105, 58, 31, 65, 74, 161, 62, 219, 236, 244, 60, 65,
|
|
23
|
+
227, 199, 153, 234, 158, 115, 123, 79, 154, 162, 38,
|
|
17
24
|
];
|
|
18
25
|
|
|
19
26
|
pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
|
|
@@ -158,7 +158,7 @@ describe('DPNS Contract', () => {
|
|
|
158
158
|
normalizedParentDomainName: 'dash',
|
|
159
159
|
preorderSalt: crypto.randomBytes(32),
|
|
160
160
|
records: {
|
|
161
|
-
|
|
161
|
+
identity: await generateRandomIdentifier(),
|
|
162
162
|
},
|
|
163
163
|
subdomainRules: {
|
|
164
164
|
allowSubdomains: false,
|
|
@@ -468,54 +468,10 @@ describe('DPNS Contract', () => {
|
|
|
468
468
|
});
|
|
469
469
|
|
|
470
470
|
describe('Dash Identity', () => {
|
|
471
|
-
|
|
472
|
-
rawDomainDocument.records = {
|
|
473
|
-
dashUniqueIdentityId: identityId,
|
|
474
|
-
dashAliasIdentityId: identityId,
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
const document = dpp.document.create(dataContract, identityId, 'domain', rawDomainDocument);
|
|
478
|
-
const validationResult = document.validate(dpp.protocolVersion);
|
|
479
|
-
const error = expectJsonSchemaError(validationResult);
|
|
480
|
-
|
|
481
|
-
expect(error.keyword)
|
|
482
|
-
.to
|
|
483
|
-
.equal('maxProperties');
|
|
484
|
-
expect(error.instancePath)
|
|
485
|
-
.to
|
|
486
|
-
.equal('/records');
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
describe('dashUniqueIdentityId', () => {
|
|
490
|
-
it('should no less than 32 bytes', async () => {
|
|
491
|
-
rawDomainDocument.records = {
|
|
492
|
-
dashUniqueIdentityId: crypto.randomBytes(30),
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
expect(() => {
|
|
496
|
-
dpp.document.create(dataContract, identityId, 'domain', rawDomainDocument);
|
|
497
|
-
})
|
|
498
|
-
.to
|
|
499
|
-
.throw();
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
it('should no more than 32 bytes', async () => {
|
|
503
|
-
rawDomainDocument.records = {
|
|
504
|
-
dashUniqueIdentityId: crypto.randomBytes(64),
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
expect(() => {
|
|
508
|
-
dpp.document.create(dataContract, identityId, 'domain', rawDomainDocument);
|
|
509
|
-
})
|
|
510
|
-
.to
|
|
511
|
-
.throw();
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
describe('dashAliasIdentityId', () => {
|
|
471
|
+
describe('identity record', () => {
|
|
516
472
|
it('should no less than 32 bytes', async () => {
|
|
517
473
|
rawDomainDocument.records = {
|
|
518
|
-
|
|
474
|
+
identity: crypto.randomBytes(30),
|
|
519
475
|
};
|
|
520
476
|
|
|
521
477
|
expect(() => {
|
|
@@ -527,7 +483,7 @@ describe('DPNS Contract', () => {
|
|
|
527
483
|
|
|
528
484
|
it('should no more than 32 bytes', async () => {
|
|
529
485
|
rawDomainDocument.records = {
|
|
530
|
-
|
|
486
|
+
identity: crypto.randomBytes(64),
|
|
531
487
|
};
|
|
532
488
|
|
|
533
489
|
expect(() => {
|