@dashevo/dpns-contract 5.1.0-dev.1 → 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/README.md CHANGED
@@ -9,6 +9,7 @@ JSON Contracts for Dash Platform Name Service
9
9
 
10
10
  - [Install](#install)
11
11
  - [Usage](#usage)
12
+ - [Giving up a name](#giving-up-a-name)
12
13
  - [Contributing](#contributing)
13
14
  - [License](#license)
14
15
 
@@ -24,6 +25,15 @@ npm install @dashevo/dpns-contract
24
25
  # TODO ...
25
26
  ```
26
27
 
28
+ ## Giving up a name
29
+
30
+ From contract v3 (protocol version 15) the identity holding a name can throw it away, in one of two ways:
31
+
32
+ - **Delete** the `domain` document. The name is free again and anybody may register it. A contested name (a normalized label of 3 to 19 `a-z`, `0`, `1` or `-` characters, awarded by a masternode vote) can not be deleted.
33
+ - **Tombstone** it: create a `tombstone` document holding the name's `normalizedLabel` and `normalizedParentDomainName`. The create deletes the creator's own `domain` of that name, and nobody can register the name while the tombstone exists. Any name can be tombstoned, a contested one included.
34
+
35
+ Nobody can replace, delete or transfer a tombstone, the identity that created it included. A tombstoned name may later be brought back and redistributed through a direct or indirect will of the DAO.
36
+
27
37
  ## Contributing
28
38
 
29
39
  Feel free to dive in! [Open an issue](https://github.com/dashpay/platform/issues/new/choose) or submit PRs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dpns-contract",
3
- "version": "5.1.0-dev.1",
3
+ "version": "5.1.0-dev.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": "5.1.0-dev.1",
34
+ "@dashevo/wasm-dpp": "5.1.0-dev.2",
35
35
  "chai": "^4.3.10",
36
36
  "dirty-chai": "^2.0.1",
37
37
  "eslint": "^9.18.0",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "domain": {
3
3
  "documentsMutable": false,
4
- "canBeDeleted": false,
4
+ "canBeDeleted": true,
5
5
  "transferable": 1,
6
6
  "tradeMode": 1,
7
7
  "keepsTransferHistory": true,
@@ -175,6 +175,20 @@
175
175
  "preorderSalt"
176
176
  ],
177
177
  "propertyConstraints": {
178
+ "nameIsNotTombstoned": {
179
+ "equal": [
180
+ {
181
+ "countOf": [
182
+ "tombstone",
183
+ {
184
+ "normalizedParentDomainName": "normalizedParentDomainName",
185
+ "normalizedLabel": "normalizedLabel"
186
+ }
187
+ ]
188
+ },
189
+ 0
190
+ ]
191
+ },
178
192
  "recordsIdentityIsOwner": {
179
193
  "ifThen": [
180
194
  {
@@ -269,5 +283,59 @@
269
283
  }
270
284
  },
271
285
  "additionalProperties": false
286
+ },
287
+ "tombstone": {
288
+ "description": "A name its owner gave up for good: creating one deletes the owner's domain of that name, and nobody can register the name while the tombstone exists. Nobody can delete or change a tombstone. A tombstoned name may later be brought back and redistributed through a direct or indirect will of the DAO",
289
+ "documentsMutable": false,
290
+ "canBeDeleted": false,
291
+ "transferable": 0,
292
+ "tradeMode": 0,
293
+ "type": "object",
294
+ "indices": [
295
+ {
296
+ "name": "parentNameAndLabel",
297
+ "properties": [
298
+ {
299
+ "normalizedParentDomainName": "asc"
300
+ },
301
+ {
302
+ "normalizedLabel": "asc"
303
+ }
304
+ ],
305
+ "countable": "countable"
306
+ }
307
+ ],
308
+ "properties": {
309
+ "normalizedLabel": {
310
+ "type": "string",
311
+ "maxLength": 63,
312
+ "refersTo": {
313
+ "type": "deletableDocument",
314
+ "documentType": "domain",
315
+ "findBy": {
316
+ "normalizedParentDomainName": "normalizedParentDomainName",
317
+ "normalizedLabel": "."
318
+ },
319
+ "where": {
320
+ "$ownerId": "$ownerId"
321
+ },
322
+ "consume": true
323
+ },
324
+ "position": 0,
325
+ "description": "Normalized label of the tombstoned name, e.g. 'b0b': the creator's own domain of that name, which the create deletes"
326
+ },
327
+ "normalizedParentDomainName": {
328
+ "type": "string",
329
+ "maxLength": 63,
330
+ "position": 1,
331
+ "description": "Normalized parent domain name of the tombstoned name, e.g. 'dash'"
332
+ }
333
+ },
334
+ "required": [
335
+ "$createdAt",
336
+ "normalizedLabel",
337
+ "normalizedParentDomainName"
338
+ ],
339
+ "additionalProperties": false
272
340
  }
273
341
  }
package/src/v3/mod.rs CHANGED
@@ -3,6 +3,19 @@ use serde_json::Value;
3
3
 
4
4
  /// The names v3 adds; every other name is v1's ([`crate::v1::document_types`]).
5
5
  pub mod document_types {
6
+ pub mod tombstone {
7
+ /// A name its owner gave up for good.
8
+ pub const NAME: &str = "tombstone";
9
+
10
+ pub mod properties {
11
+ /// The normalized label of the tombstoned name, which finds the creator's own
12
+ /// `domain` of that name: the create deletes it.
13
+ pub const NORMALIZED_LABEL: &str = "normalizedLabel";
14
+ /// The normalized parent domain name of the tombstoned name.
15
+ pub const NORMALIZED_PARENT_DOMAIN_NAME: &str = "normalizedParentDomainName";
16
+ }
17
+ }
18
+
6
19
  pub mod preorder {
7
20
  pub mod properties {
8
21
  /// The double SHA-256 of the owner's id, the normalized label, "." and the
@@ -27,13 +40,29 @@ pub mod document_types {
27
40
  /// `minimumAgeBlocks` and `consume`, which needs the preorder to record
28
41
  /// `$createdAtBlockHeight`), and refuses it while another identity holds a valid
29
42
  /// preorder of the name from an earlier block (`chooseFirst` by creation height, a
30
- /// preorder counting when it holds the same hash with its owner's id first), and the
43
+ /// preorder counting when it holds the same hash with its owner's id first), unless the
44
+ /// create opens or joins the name's contest, which the masternode vote decides (held to the
45
+ /// order, an identity holding preorders of a name easy to guess older than a rival's could
46
+ /// delay the rival's reveal; each contender still reveals its own preorder, a block old at
47
+ /// least), and the
31
48
  /// `recordsIdentityIsOwner` rule holds a new domain's identity record to its owner. A
32
49
  /// preorder holds both hashes (`nameHash`, unique per owner and indexed with the
33
50
  /// creation height, and `ownerNameHash`) and lives an hour (`ttl`). The protocol
34
- /// upgrade deletes the v2 preorders and rebuilds the type. Domains can no longer be
35
- /// deleted (`canBeDeleted: false`).
51
+ /// upgrade deletes the v2 preorders and rebuilds the type.
36
52
  /// The parent domain checks stay in the create trigger.
53
+ ///
54
+ /// A name's owner can give the name up, two ways. A delete of the `domain` frees the
55
+ /// name: anybody may register it again (`canBeDeleted: true`; the delete trigger refuses
56
+ /// a contested name, which a masternode vote awarded and which is never contested
57
+ /// again). A `tombstone` create deletes the creator's own `domain` of that name with it
58
+ /// (its `normalizedLabel` carries a `refersTo` with `consume`, found through the domain's
59
+ /// unique index and held to the creator's own by the `where` entry) and keeps the name
60
+ /// from being registered while the tombstone exists: the `domain` rule
61
+ /// `nameIsNotTombstoned` counts the tombstones of the name through the tombstone's
62
+ /// countable index and refuses a create, one opening a contest included, unless there is
63
+ /// none. Any name can be tombstoned, a contested one too. A tombstone can not be
64
+ /// replaced, deleted or transferred; the type's description says a tombstoned name may
65
+ /// later be brought back and redistributed through a direct or indirect will of the DAO.
37
66
  pub fn load_documents_schemas() -> Result<Value, Error> {
38
67
  serde_json::from_str(include_str!("../../schema/v3/dpns-contract-documents.json"))
39
68
  .map_err(Error::InvalidSchemaJson)