@dashevo/dpns-contract 0.3.0 → 0.21.6

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
@@ -1,9 +1,9 @@
1
1
  # DPNS Contract
2
2
 
3
- [![Build Status](https://img.shields.io/travis/com/dashevo/dpns-contract.svg?branch=master&style=flat-square)](https://travis-ci.com/dashevo/dpns-contract)
3
+ [![Build Status](https://github.com/dashevo/dpns-contract/actions/workflows/test_and_release.yml/badge.svg)](https://github.com/dashevo/dpns-contract/actions/workflows/test_and_release.yml)
4
4
  [![NPM version](https://img.shields.io/npm/v/@dashevo/dpns-contract.svg?style=flat-square)](https://npmjs.org/package/@dashevo/dpns-contract)
5
5
 
6
- > JSON Contracts for Dash Platform Name Service
6
+ JSON Contracts for Dash Platform Name Service
7
7
 
8
8
  ## Table of Contents
9
9
 
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@dashevo/dpns-contract",
3
- "version": "0.3.0",
3
+ "version": "0.21.6",
4
4
  "description": "A contract and helper scripts for DPNS DApp",
5
5
  "scripts": {
6
- "check-package": "npm run check-package:name && npm run check-package:version",
7
- "check-package:name": "test $(jq -r .name package.json) = $(jq -r .name package-lock.json)",
8
- "check-package:version": "test $(jq -r .version package.json) = $(jq -r .version package-lock.json)",
9
6
  "lint": "eslint .",
10
- "test": "npm run test:unit",
7
+ "test": "yarn run test:unit",
11
8
  "test:unit": "mocha 'test/unit/**/*.spec.js'"
12
9
  },
13
10
  "contributors": [
@@ -34,14 +31,14 @@
34
31
  ],
35
32
  "license": "MIT",
36
33
  "devDependencies": {
37
- "@dashevo/dpp": "~0.17.0",
38
- "chai": "^4.2.0",
34
+ "@dashevo/dpp": "~0.21.6",
35
+ "chai": "^4.3.4",
39
36
  "dirty-chai": "^2.0.1",
40
- "eslint": "^6.7.2",
41
- "eslint-config-airbnb-base": "^14.0.0",
42
- "eslint-plugin-import": "^2.19.1",
43
- "mocha": "^8.1.1",
44
- "sinon": "^8.0.1",
45
- "sinon-chai": "^3.4.0"
37
+ "eslint": "^7.32.0",
38
+ "eslint-config-airbnb-base": "^14.2.1",
39
+ "eslint-plugin-import": "^2.24.2",
40
+ "mocha": "^9.1.2",
41
+ "sinon": "^11.1.2",
42
+ "sinon-chai": "^3.7.0"
46
43
  }
47
- }
44
+ }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "domain": {
3
+ "type": "object",
3
4
  "indices": [
4
5
  {
5
6
  "properties": [
@@ -31,21 +32,21 @@
31
32
  "properties": {
32
33
  "label": {
33
34
  "type": "string",
34
- "pattern": "^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9])$",
35
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$",
35
36
  "minLength": 3,
36
37
  "maxLength": 63,
37
38
  "description": "Domain label. e.g. 'Bob'."
38
39
  },
39
40
  "normalizedLabel": {
40
41
  "type": "string",
41
- "pattern": "^((?!-)[a-z0-9-]{0,62}[a-z0-9])$",
42
+ "pattern": "^[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$",
42
43
  "maxLength": 63,
43
44
  "description": "Domain label in lowercase for case-insensitive uniqueness validation. e.g. 'bob'",
44
45
  "$comment": "Must be equal to the label in lowercase. This property will be deprecated due to case insensitive indices"
45
46
  },
46
47
  "normalizedParentDomainName": {
47
48
  "type": "string",
48
- "pattern": "^$|^((?!-)[a-z0-9-\\.]{0,189}[a-z0-9])$",
49
+ "pattern": "^$|^[[a-z0-9][a-z0-9-\\.]{0,188}[a-z0-9]$",
49
50
  "minLength": 0,
50
51
  "maxLength": 190,
51
52
  "description": "A full parent domain name in lowercase for case-insensitive uniqueness validation. e.g. 'dash'",
@@ -111,6 +112,7 @@
111
112
  "$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"
112
113
  },
113
114
  "preorder": {
115
+ "type": "object",
114
116
  "indices": [
115
117
  {
116
118
  "properties": [
@@ -11,7 +11,7 @@ describe('DPNS Contract', () => {
11
11
  let dataContract;
12
12
  let identityId;
13
13
 
14
- beforeEach(function beforeEach() {
14
+ beforeEach(async function beforeEach() {
15
15
  const fetchContractStub = this.sinon.stub();
16
16
 
17
17
  dpp = new DashPlatformProtocol({
@@ -20,6 +20,8 @@ describe('DPNS Contract', () => {
20
20
  },
21
21
  });
22
22
 
23
+ await dpp.initialize();
24
+
23
25
  identityId = generateRandomIdentifier();
24
26
 
25
27
  dataContract = dpp.dataContract.create(identityId, dpnsContractDocumentsSchema);
@@ -27,7 +29,9 @@ describe('DPNS Contract', () => {
27
29
  fetchContractStub.resolves(dataContract);
28
30
  });
29
31
 
30
- it('should have a valid contract definition', async () => {
32
+ it('should have a valid contract definition', async function shouldHaveValidContract() {
33
+ this.timeout(5000);
34
+
31
35
  const validationResult = await dpp.dataContract.validate(dataContract);
32
36
 
33
37
  expect(validationResult.isValid()).to.be.true();
@@ -78,7 +82,7 @@ describe('DPNS Contract', () => {
78
82
 
79
83
  expect(error.name).to.equal('JsonSchemaError');
80
84
  expect(error.keyword).to.equal('minItems');
81
- expect(error.dataPath).to.equal('.saltedDomainHash');
85
+ expect(error.instancePath).to.equal('/saltedDomainHash');
82
86
  }
83
87
  });
84
88
 
@@ -97,7 +101,7 @@ describe('DPNS Contract', () => {
97
101
 
98
102
  expect(error.name).to.equal('JsonSchemaError');
99
103
  expect(error.keyword).to.equal('minItems');
100
- expect(error.dataPath).to.equal('.saltedDomainHash');
104
+ expect(error.instancePath).to.equal('/saltedDomainHash');
101
105
  }
102
106
  });
103
107
 
@@ -116,7 +120,7 @@ describe('DPNS Contract', () => {
116
120
 
117
121
  expect(error.name).to.equal('JsonSchemaError');
118
122
  expect(error.keyword).to.equal('maxItems');
119
- expect(error.dataPath).to.equal('.saltedDomainHash');
123
+ expect(error.instancePath).to.equal('/saltedDomainHash');
120
124
  }
121
125
  });
122
126
  });
@@ -202,7 +206,7 @@ describe('DPNS Contract', () => {
202
206
 
203
207
  expect(error.name).to.equal('JsonSchemaError');
204
208
  expect(error.keyword).to.equal('pattern');
205
- expect(error.dataPath).to.equal('.label');
209
+ expect(error.instancePath).to.equal('/label');
206
210
  }
207
211
  });
208
212
 
@@ -221,7 +225,7 @@ describe('DPNS Contract', () => {
221
225
 
222
226
  expect(error.name).to.equal('JsonSchemaError');
223
227
  expect(error.keyword).to.equal('minLength');
224
- expect(error.dataPath).to.equal('.label');
228
+ expect(error.instancePath).to.equal('/label');
225
229
  }
226
230
  });
227
231
 
@@ -240,7 +244,7 @@ describe('DPNS Contract', () => {
240
244
 
241
245
  expect(error.name).to.equal('JsonSchemaError');
242
246
  expect(error.keyword).to.equal('maxLength');
243
- expect(error.dataPath).to.equal('.label');
247
+ expect(error.instancePath).to.equal('/label');
244
248
  }
245
249
  });
246
250
  });
@@ -280,7 +284,7 @@ describe('DPNS Contract', () => {
280
284
 
281
285
  expect(error.name).to.equal('JsonSchemaError');
282
286
  expect(error.keyword).to.equal('pattern');
283
- expect(error.dataPath).to.equal('.normalizedLabel');
287
+ expect(error.instancePath).to.equal('/normalizedLabel');
284
288
  }
285
289
  });
286
290
 
@@ -299,7 +303,7 @@ describe('DPNS Contract', () => {
299
303
 
300
304
  expect(error.name).to.equal('JsonSchemaError');
301
305
  expect(error.keyword).to.equal('maxLength');
302
- expect(error.dataPath).to.equal('.normalizedLabel');
306
+ expect(error.instancePath).to.equal('/normalizedLabel');
303
307
  }
304
308
  });
305
309
  });
@@ -339,7 +343,7 @@ describe('DPNS Contract', () => {
339
343
 
340
344
  expect(error.name).to.equal('JsonSchemaError');
341
345
  expect(error.keyword).to.equal('maxLength');
342
- expect(error.dataPath).to.equal('.normalizedParentDomainName');
346
+ expect(error.instancePath).to.equal('/normalizedParentDomainName');
343
347
  }
344
348
  });
345
349
 
@@ -358,7 +362,7 @@ describe('DPNS Contract', () => {
358
362
 
359
363
  expect(error.name).to.equal('JsonSchemaError');
360
364
  expect(error.keyword).to.equal('pattern');
361
- expect(error.dataPath).to.equal('.normalizedParentDomainName');
365
+ expect(error.instancePath).to.equal('/normalizedParentDomainName');
362
366
  }
363
367
  });
364
368
  });
@@ -398,7 +402,7 @@ describe('DPNS Contract', () => {
398
402
 
399
403
  expect(error.name).to.equal('JsonSchemaError');
400
404
  expect(error.keyword).to.equal('minItems');
401
- expect(error.dataPath).to.equal('.preorderSalt');
405
+ expect(error.instancePath).to.equal('/preorderSalt');
402
406
  }
403
407
  });
404
408
 
@@ -417,7 +421,7 @@ describe('DPNS Contract', () => {
417
421
 
418
422
  expect(error.name).to.equal('JsonSchemaError');
419
423
  expect(error.keyword).to.equal('minItems');
420
- expect(error.dataPath).to.equal('.preorderSalt');
424
+ expect(error.instancePath).to.equal('/preorderSalt');
421
425
  }
422
426
  });
423
427
 
@@ -436,7 +440,7 @@ describe('DPNS Contract', () => {
436
440
 
437
441
  expect(error.name).to.equal('JsonSchemaError');
438
442
  expect(error.keyword).to.equal('maxItems');
439
- expect(error.dataPath).to.equal('.preorderSalt');
443
+ expect(error.instancePath).to.equal('/preorderSalt');
440
444
  }
441
445
  });
442
446
  });
@@ -503,7 +507,7 @@ describe('DPNS Contract', () => {
503
507
 
504
508
  expect(error.name).to.equal('JsonSchemaError');
505
509
  expect(error.keyword).to.equal('minProperties');
506
- expect(error.dataPath).to.equal('.records');
510
+ expect(error.instancePath).to.equal('/records');
507
511
  }
508
512
  });
509
513
 
@@ -524,7 +528,7 @@ describe('DPNS Contract', () => {
524
528
 
525
529
  expect(error.name).to.equal('JsonSchemaError');
526
530
  expect(error.keyword).to.equal('additionalProperties');
527
- expect(error.dataPath).to.equal('.records');
531
+ expect(error.instancePath).to.equal('/records');
528
532
  expect(error.params.additionalProperty).to.equal('someOtherProperty');
529
533
  }
530
534
  });
@@ -548,7 +552,7 @@ describe('DPNS Contract', () => {
548
552
 
549
553
  expect(error.name).to.equal('JsonSchemaError');
550
554
  expect(error.keyword).to.equal('maxProperties');
551
- expect(error.dataPath).to.equal('.records');
555
+ expect(error.instancePath).to.equal('/records');
552
556
  }
553
557
  });
554
558
 
@@ -570,7 +574,7 @@ describe('DPNS Contract', () => {
570
574
 
571
575
  expect(error.name).to.equal('JsonSchemaError');
572
576
  expect(error.keyword).to.equal('minItems');
573
- expect(error.dataPath).to.equal('.records.dashUniqueIdentityId');
577
+ expect(error.instancePath).to.equal('/records/dashUniqueIdentityId');
574
578
  }
575
579
  });
576
580
 
@@ -591,7 +595,7 @@ describe('DPNS Contract', () => {
591
595
 
592
596
  expect(error.name).to.equal('JsonSchemaError');
593
597
  expect(error.keyword).to.equal('maxItems');
594
- expect(error.dataPath).to.equal('.records.dashUniqueIdentityId');
598
+ expect(error.instancePath).to.equal('/records/dashUniqueIdentityId');
595
599
  }
596
600
  });
597
601
  });
@@ -614,7 +618,7 @@ describe('DPNS Contract', () => {
614
618
 
615
619
  expect(error.name).to.equal('JsonSchemaError');
616
620
  expect(error.keyword).to.equal('minItems');
617
- expect(error.dataPath).to.equal('.records.dashAliasIdentityId');
621
+ expect(error.instancePath).to.equal('/records/dashAliasIdentityId');
618
622
  }
619
623
  });
620
624
 
@@ -635,7 +639,7 @@ describe('DPNS Contract', () => {
635
639
 
636
640
  expect(error.name).to.equal('JsonSchemaError');
637
641
  expect(error.keyword).to.equal('maxItems');
638
- expect(error.dataPath).to.equal('.records.dashAliasIdentityId');
642
+ expect(error.instancePath).to.equal('/records/dashAliasIdentityId');
639
643
  }
640
644
  });
641
645
  });
@@ -677,7 +681,7 @@ describe('DPNS Contract', () => {
677
681
 
678
682
  expect(error.name).to.equal('JsonSchemaError');
679
683
  expect(error.keyword).to.equal('additionalProperties');
680
- expect(error.dataPath).to.equal('.subdomainRules');
684
+ expect(error.instancePath).to.equal('/subdomainRules');
681
685
  }
682
686
  });
683
687
 
@@ -697,7 +701,7 @@ describe('DPNS Contract', () => {
697
701
 
698
702
  expect(error.name).to.equal('JsonSchemaError');
699
703
  expect(error.keyword).to.equal('type');
700
- expect(error.dataPath).to.equal('.subdomainRules.allowSubdomains');
704
+ expect(error.instancePath).to.equal('/subdomainRules/allowSubdomains');
701
705
  }
702
706
  });
703
707
  });
@@ -1,38 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: ''
5
- labels: 'bug'
6
- assignees: ''
7
-
8
- ---
9
-
10
- <!--- Provide a general summary of the issue in the Title above -->
11
-
12
- ## Expected Behavior
13
- <!--- Tell us what should happen -->
14
-
15
- ## Current Behavior
16
- <!--- Tell us what happens instead of the expected behavior -->
17
-
18
- ## Possible Solution
19
- <!--- Not obligatory, but suggest a fix/reason for the bug -->
20
-
21
- ## Steps to Reproduce (for bugs)
22
- <!--- Provide a link to a live example, or an unambiguous set of steps to -->
23
- <!--- reproduce this bug. Include code to reproduce, if relevant -->
24
- 1.
25
- 2.
26
- 3.
27
- 4.
28
-
29
- ## Context
30
- <!--- How has this issue affected you? What are you trying to accomplish? -->
31
- <!--- Providing context helps us come up with a solution that is most useful in the real world -->
32
-
33
- ## Your Environment
34
- <!--- Include as many relevant details about the environment you experienced the bug in -->
35
- * Version used:
36
- * Environment name and version (e.g. Chrome 39, node.js 5.4):
37
- * Operating System and version (desktop, server, or mobile):
38
- * Link to your project:
@@ -1,26 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for this project
4
- title: ''
5
- labels: 'enhancement'
6
- assignees: ''
7
-
8
- ---
9
-
10
- <!--- Provide a general summary of the feature request in the Title above -->
11
-
12
- ## Expected Behavior
13
- <!--- A clear and concise description of what you want to happen -->
14
-
15
- ## Current Behavior
16
- <!--- Explain the difference from current behavior -->
17
-
18
- ## Possible Solution
19
- <!--- Suggest ideas of how to implement the addition or change -->
20
-
21
- ## Alternatives Considered
22
- <!--- A clear and concise description of any alternative solutions or features you've considered -->
23
-
24
- ## Additional Context
25
- <!--- Add any other context or screenshots about the feature request here. -->
26
-
@@ -1,32 +0,0 @@
1
- <!--- Provide a general summary of your changes in the Title above -->
2
- <!--- Pull request titles must use the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format -->
3
-
4
- ## Issue being fixed or feature implemented
5
- <!--- Why is this change required? What problem does it solve? -->
6
- <!--- If it fixes an open issue, please link to the issue here. -->
7
-
8
-
9
- ## What was done?
10
- <!--- Describe your changes in detail -->
11
-
12
-
13
- ## How Has This Been Tested?
14
- <!--- Please describe in detail how you tested your changes. -->
15
- <!--- Include details of your testing environment, and the tests you ran to -->
16
- <!--- see how your change affects other areas of the code, etc. -->
17
-
18
-
19
- ## Breaking Changes
20
- <!--- Please describe any breaking changes your code introduces and verify that -->
21
- <!--- the title includes "!" following the conventional commit type (e.g. "feat!: ..."-->
22
-
23
-
24
- ## Checklist:
25
- <!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
26
- - [ ] I have performed a self-review of my own code
27
- - [ ] I have commented my code, particularly in hard-to-understand areas
28
- - [ ] I have added or updated relevant unit/integration/functional/e2e tests
29
- - [ ] I have made corresponding changes to the documentation
30
-
31
- **For repository code-owners and collaborators only**
32
- - [ ] I have assigned this pull request to a milestone
package/.travis.yml DELETED
@@ -1,42 +0,0 @@
1
- sudo: false
2
- dist: trusty
3
- language: node_js
4
-
5
- node_js:
6
- - '12'
7
- - '14'
8
-
9
- branches:
10
- only:
11
- - master
12
- - /^v(0|[1-9]\d*)\.(0|[1-9]\d*)$/
13
- - /^v(0|[1-9]\d*)\.(0|[1-9]\d*)-dev$/
14
- - /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
15
-
16
- services:
17
- - docker
18
-
19
- addons:
20
- apt:
21
- packages:
22
- - docker-ce
23
-
24
- before_install:
25
- # Login to NPM registry
26
- - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
27
-
28
- install:
29
- - npm ci
30
-
31
- script:
32
- - npm run check-package
33
- - npm run lint
34
- - npm run test
35
-
36
- deploy:
37
- provider: script
38
- skip_cleanup: true
39
- script: bash bin/travis-deploy.sh
40
- on:
41
- tags: true
42
- repo: dashevo/dpns-contract
@@ -1,31 +0,0 @@
1
- #! /bin/sh
2
-
3
- set -xe
4
-
5
- # Update this whenever the latest Node.js LTS version changes (~ every year).
6
- # Do not forget to add this version to .travis.yml config also.
7
- LATEST_LTS_VERSION="14"
8
-
9
- # We want this command to succeed whether or not the Node.js version is the
10
- # latest (so that the build does not show as failed), but _only_ the latest
11
- # should be used to publish the module.
12
- if [ "$TRAVIS_NODE_VERSION" != "$LATEST_LTS_VERSION" ]; then
13
- echo "Node.js v$TRAVIS_NODE_VERSION is not latest LTS version -- will not deploy with this version."
14
- exit 0
15
- fi
16
-
17
- # Ensure the tag matches the one in package.json, otherwise abort.
18
- PACKAGE_TAG=v"$(jq -r .version package.json)"
19
- if [ "$PACKAGE_TAG" != "$TRAVIS_TAG" ]; then
20
- echo "Travis tag (\"$TRAVIS_TAG\") is not equal to package.json tag (\"$PACKAGE_TAG\"). Please push a correct tag and try again."
21
- exit 1
22
- fi
23
-
24
- # Use regex pattern matching to check if "dev" exists in tag
25
- NPM_TAG="latest"
26
- if [[ $PACKAGE_TAG =~ dev ]]; then
27
- NPM_TAG="dev"
28
- fi
29
-
30
- # Now that checks have been passed, publish the module
31
- npm publish --tag $NPM_TAG