@dashevo/dpns-contract 0.25.0-dev.9 → 0.25.0
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 +2 -1
- package/package.json +3 -3
- package/schema/dpns-contract-documents.json +13 -6
- package/src/lib.rs +22 -0
- package/test/unit/dpnsContract.spec.js +1 -1
package/Cargo.toml
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "dpns-contract"
|
|
3
3
|
description = "DPNS data contract schema and tools"
|
|
4
|
-
version = "0.
|
|
4
|
+
version = "0.25.0"
|
|
5
5
|
edition = "2021"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
|
|
8
8
|
[dependencies]
|
|
9
9
|
serde_json = { version = "1.0" }
|
|
10
|
+
platform-value = { path = "../rs-platform-value" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dpns-contract",
|
|
3
|
-
"version": "0.25.0
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "A contract and helper scripts for DPNS DApp",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
],
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@dashevo/dpp": "0.25.0
|
|
35
|
-
"chai": "^4.3.
|
|
34
|
+
"@dashevo/dpp": "0.25.0",
|
|
35
|
+
"chai": "^4.3.9",
|
|
36
36
|
"dirty-chai": "^2.0.1",
|
|
37
37
|
"eslint": "^7.32.0",
|
|
38
38
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
@@ -42,18 +42,25 @@
|
|
|
42
42
|
},
|
|
43
43
|
"normalizedLabel": {
|
|
44
44
|
"type": "string",
|
|
45
|
-
"pattern": "^[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$",
|
|
45
|
+
"pattern": "^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-]{0,61}[a-hj-km-np-z0-9]$",
|
|
46
46
|
"maxLength": 63,
|
|
47
|
-
"description": "Domain label
|
|
48
|
-
"$comment": "Must be equal to the label in lowercase.
|
|
47
|
+
"description": "Domain label converted to lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'b0b'",
|
|
48
|
+
"$comment": "Must be equal to the label in lowercase. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\"."
|
|
49
|
+
},
|
|
50
|
+
"parentDomainName": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"pattern": "^$|^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$",
|
|
53
|
+
"minLength": 0,
|
|
54
|
+
"maxLength": 63,
|
|
55
|
+
"description": "A full parent domain name. e.g. 'dash'."
|
|
49
56
|
},
|
|
50
57
|
"normalizedParentDomainName": {
|
|
51
58
|
"type": "string",
|
|
52
|
-
"pattern": "^$|^[a-z0-9][a-z0-9-\\.]{0,61}[a-z0-9]$",
|
|
59
|
+
"pattern": "^$|^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-\\.]{0,61}[a-hj-km-np-z0-9]$",
|
|
53
60
|
"minLength": 0,
|
|
54
61
|
"maxLength": 63,
|
|
55
|
-
"description": "A
|
|
56
|
-
"$comment": "Must either be equal to an existing domain or empty to create a top level domain. Only the data contract owner can create top level domains."
|
|
62
|
+
"description": "A parent domain name in lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'dash'",
|
|
63
|
+
"$comment": "Must either be equal to an existing domain or empty to create a top level domain. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\". Only the data contract owner can create top level domains."
|
|
57
64
|
},
|
|
58
65
|
"preorderSalt": {
|
|
59
66
|
"type": "array",
|
package/src/lib.rs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
use platform_value::{Identifier, IdentifierBytes32};
|
|
1
2
|
use serde_json::{Error, Value};
|
|
2
3
|
|
|
3
4
|
pub const ID_BYTES: [u8; 32] = [
|
|
@@ -10,6 +11,27 @@ pub const OWNER_ID_BYTES: [u8; 32] = [
|
|
|
10
11
|
67, 4, 181, 246, 153, 65, 68, 40, 110, 253, 172,
|
|
11
12
|
];
|
|
12
13
|
|
|
14
|
+
pub mod document_types {
|
|
15
|
+
pub mod domain {
|
|
16
|
+
pub const NAME: &str = "domain";
|
|
17
|
+
|
|
18
|
+
pub mod properties {
|
|
19
|
+
pub const LABEL: &str = "label";
|
|
20
|
+
pub const NORMALIZED_LABEL: &str = "normalizedLabel";
|
|
21
|
+
pub const PARENT_DOMAIN_NAME: &str = "parentDomainName";
|
|
22
|
+
pub const NORMALIZED_PARENT_DOMAIN_NAME: &str = "normalizedParentDomainName";
|
|
23
|
+
pub const PREORDER_SALT: &str = "preorderSalt";
|
|
24
|
+
pub const ALLOW_SUBDOMAINS: &str = "subdomainRules.allowSubdomains";
|
|
25
|
+
pub const RECORDS: &str = "records";
|
|
26
|
+
pub const DASH_UNIQUE_IDENTITY_ID: &str = "dashUniqueIdentityId";
|
|
27
|
+
pub const DASH_ALIAS_IDENTITY_ID: &str = "dashAliasIdentityId";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
|
|
33
|
+
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
|
|
34
|
+
|
|
13
35
|
pub fn load_documents_schemas() -> Result<Value, Error> {
|
|
14
36
|
serde_json::from_str(include_str!("../schema/dpns-contract-documents.json"))
|
|
15
37
|
}
|
|
@@ -159,7 +159,7 @@ describe('DPNS Contract', () => {
|
|
|
159
159
|
beforeEach(() => {
|
|
160
160
|
rawDomainDocument = {
|
|
161
161
|
label: 'Wallet',
|
|
162
|
-
normalizedLabel: '
|
|
162
|
+
normalizedLabel: 'wa11et', // lower case and base58 chars only
|
|
163
163
|
normalizedParentDomainName: 'dash',
|
|
164
164
|
preorderSalt: crypto.randomBytes(32),
|
|
165
165
|
records: {
|