@dashevo/dpns-contract 4.0.0 → 4.1.0-beta.1
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/dpns-contract-documents.json +169 -0
- package/src/lib.rs +7 -5
- package/src/v1/mod.rs +1 -0
- package/src/v2/mod.rs +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dpns-contract",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.1.0-beta.1",
|
|
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": "4.0.
|
|
34
|
+
"@dashevo/wasm-dpp": "4.1.0-beta.1",
|
|
35
35
|
"chai": "^4.3.10",
|
|
36
36
|
"dirty-chai": "^2.0.1",
|
|
37
37
|
"eslint": "^9.18.0",
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domain": {
|
|
3
|
+
"documentsMutable": false,
|
|
4
|
+
"canBeDeleted": true,
|
|
5
|
+
"transferable": 1,
|
|
6
|
+
"tradeMode": 1,
|
|
7
|
+
"keepsTransferHistory": true,
|
|
8
|
+
"keepsPurchaseHistory": true,
|
|
9
|
+
"keepsPricingHistory": true,
|
|
10
|
+
"type": "object",
|
|
11
|
+
"indices": [
|
|
12
|
+
{
|
|
13
|
+
"name": "parentNameAndLabel",
|
|
14
|
+
"properties": [
|
|
15
|
+
{
|
|
16
|
+
"normalizedParentDomainName": "asc"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"normalizedLabel": "asc"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"unique": true,
|
|
23
|
+
"contested": {
|
|
24
|
+
"fieldMatches": [
|
|
25
|
+
{
|
|
26
|
+
"field": "normalizedLabel",
|
|
27
|
+
"regexPattern": "^[a-zA-Z01-]{3,19}$"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"resolution": 0,
|
|
31
|
+
"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"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "identityId",
|
|
36
|
+
"nullSearchable": false,
|
|
37
|
+
"properties": [
|
|
38
|
+
{
|
|
39
|
+
"records.identity": "asc"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"properties": {
|
|
45
|
+
"label": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$",
|
|
48
|
+
"minLength": 3,
|
|
49
|
+
"maxLength": 63,
|
|
50
|
+
"position": 0,
|
|
51
|
+
"description": "Domain label. e.g. 'Bob'."
|
|
52
|
+
},
|
|
53
|
+
"normalizedLabel": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"pattern": "^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-]{0,61}[a-hj-km-np-z0-9]$",
|
|
56
|
+
"maxLength": 63,
|
|
57
|
+
"position": 1,
|
|
58
|
+
"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'",
|
|
59
|
+
"$comment": "Must be equal to the label in lowercase. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\"."
|
|
60
|
+
},
|
|
61
|
+
"parentDomainName": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"pattern": "^$|^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$",
|
|
64
|
+
"minLength": 0,
|
|
65
|
+
"maxLength": 63,
|
|
66
|
+
"position": 2,
|
|
67
|
+
"description": "A full parent domain name. e.g. 'dash'."
|
|
68
|
+
},
|
|
69
|
+
"normalizedParentDomainName": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"pattern": "^$|^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-\\.]{0,61}[a-hj-km-np-z0-9]$",
|
|
72
|
+
"minLength": 0,
|
|
73
|
+
"maxLength": 63,
|
|
74
|
+
"position": 3,
|
|
75
|
+
"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'",
|
|
76
|
+
"$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."
|
|
77
|
+
},
|
|
78
|
+
"preorderSalt": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"byteArray": true,
|
|
81
|
+
"minItems": 32,
|
|
82
|
+
"maxItems": 32,
|
|
83
|
+
"position": 4,
|
|
84
|
+
"description": "Salt used in the preorder document"
|
|
85
|
+
},
|
|
86
|
+
"records": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"properties": {
|
|
89
|
+
"identity": {
|
|
90
|
+
"type": "array",
|
|
91
|
+
"byteArray": true,
|
|
92
|
+
"minItems": 32,
|
|
93
|
+
"maxItems": 32,
|
|
94
|
+
"position": 1,
|
|
95
|
+
"contentMediaType": "application/x.dash.dpp.identifier",
|
|
96
|
+
"description": "Identifier name record that refers to an Identity"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"minProperties": 1,
|
|
100
|
+
"position": 5,
|
|
101
|
+
"additionalProperties": false
|
|
102
|
+
},
|
|
103
|
+
"subdomainRules": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"properties": {
|
|
106
|
+
"allowSubdomains": {
|
|
107
|
+
"type": "boolean",
|
|
108
|
+
"description": "This option defines who can create subdomains: true - anyone; false - only the domain owner",
|
|
109
|
+
"$comment": "Only the domain owner is allowed to create subdomains for non top-level domains",
|
|
110
|
+
"position": 0
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"position": 6,
|
|
114
|
+
"description": "Subdomain rules allow domain owners to define rules for subdomains",
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"required": [
|
|
117
|
+
"allowSubdomains"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"required": [
|
|
122
|
+
"$createdAt",
|
|
123
|
+
"$updatedAt",
|
|
124
|
+
"$transferredAt",
|
|
125
|
+
"label",
|
|
126
|
+
"normalizedLabel",
|
|
127
|
+
"normalizedParentDomainName",
|
|
128
|
+
"preorderSalt",
|
|
129
|
+
"records",
|
|
130
|
+
"subdomainRules"
|
|
131
|
+
],
|
|
132
|
+
"transient": [
|
|
133
|
+
"preorderSalt"
|
|
134
|
+
],
|
|
135
|
+
"additionalProperties": false,
|
|
136
|
+
"$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"
|
|
137
|
+
},
|
|
138
|
+
"preorder": {
|
|
139
|
+
"documentsMutable": false,
|
|
140
|
+
"canBeDeleted": true,
|
|
141
|
+
"type": "object",
|
|
142
|
+
"indices": [
|
|
143
|
+
{
|
|
144
|
+
"name": "saltedHash",
|
|
145
|
+
"properties": [
|
|
146
|
+
{
|
|
147
|
+
"saltedDomainHash": "asc"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"unique": true
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"properties": {
|
|
154
|
+
"saltedDomainHash": {
|
|
155
|
+
"type": "array",
|
|
156
|
+
"byteArray": true,
|
|
157
|
+
"minItems": 32,
|
|
158
|
+
"maxItems": 32,
|
|
159
|
+
"position": 0,
|
|
160
|
+
"description": "Double sha-256 of the concatenation of a 32 byte random salt and a normalized domain name"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"required": [
|
|
164
|
+
"saltedDomainHash"
|
|
165
|
+
],
|
|
166
|
+
"additionalProperties": false,
|
|
167
|
+
"$comment": "Preorder documents are immutable: modification and deletion are restricted"
|
|
168
|
+
}
|
|
169
|
+
}
|
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};
|
|
@@ -26,21 +27,22 @@ pub const DPNS_DASH_TLD_PREORDER_SALT: [u8; 32] = [
|
|
|
26
27
|
pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
|
|
27
28
|
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
|
|
28
29
|
pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
|
|
29
|
-
match platform_version.system_data_contracts.
|
|
30
|
-
1 => Ok(None),
|
|
30
|
+
match platform_version.system_data_contracts.dpns {
|
|
31
|
+
1 | 2 => Ok(None),
|
|
31
32
|
version => Err(Error::UnknownVersionMismatch {
|
|
32
33
|
method: "dpns_contract::load_definitions".to_string(),
|
|
33
|
-
known_versions: vec![1],
|
|
34
|
+
known_versions: vec![1, 2],
|
|
34
35
|
received: version,
|
|
35
36
|
}),
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
|
|
39
|
-
match platform_version.system_data_contracts.
|
|
40
|
+
match platform_version.system_data_contracts.dpns {
|
|
40
41
|
1 => v1::load_documents_schemas(),
|
|
42
|
+
2 => v2::load_documents_schemas(),
|
|
41
43
|
version => Err(Error::UnknownVersionMismatch {
|
|
42
44
|
method: "dpns_contract::load_documents_schemas".to_string(),
|
|
43
|
-
known_versions: vec![1],
|
|
45
|
+
known_versions: vec![1, 2],
|
|
44
46
|
received: version,
|
|
45
47
|
}),
|
|
46
48
|
}
|
package/src/v1/mod.rs
CHANGED
|
@@ -13,6 +13,7 @@ pub mod document_types {
|
|
|
13
13
|
pub const PREORDER_SALT: &str = "preorderSalt";
|
|
14
14
|
pub const ALLOW_SUBDOMAINS: &str = "subdomainRules.allowSubdomains";
|
|
15
15
|
pub const RECORDS: &str = "records";
|
|
16
|
+
pub const IDENTITY: &str = "identity";
|
|
16
17
|
pub const DASH_UNIQUE_IDENTITY_ID: &str = "dashUniqueIdentityId";
|
|
17
18
|
pub const DASH_ALIAS_IDENTITY_ID: &str = "dashAliasIdentityId";
|
|
18
19
|
}
|
package/src/v2/mod.rs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
use crate::Error;
|
|
2
|
+
use serde_json::Value;
|
|
3
|
+
|
|
4
|
+
/// The document type names and property names are unchanged from v1 — see
|
|
5
|
+
/// [`crate::v1::document_types`]. v2 only subscribes the `domain` document
|
|
6
|
+
/// type to the document history system contract via the
|
|
7
|
+
/// `keepsTransferHistory`, `keepsPurchaseHistory` and `keepsPricingHistory`
|
|
8
|
+
/// configuration flags.
|
|
9
|
+
pub fn load_documents_schemas() -> Result<Value, Error> {
|
|
10
|
+
serde_json::from_str(include_str!("../../schema/v2/dpns-contract-documents.json"))
|
|
11
|
+
.map_err(Error::InvalidSchemaJson)
|
|
12
|
+
}
|