Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/v0.3-dev' into v0.3-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Shuplenkov committed Aug 6, 2020
2 parents bff23c8 + 953c605 commit daa1ada
Show file tree
Hide file tree
Showing 8 changed files with 1,700 additions and 2,385 deletions.
3 changes: 3 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file:
- test/bootstrap.js
recursive: true
3,136 changes: 1,054 additions & 2,082 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 25 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,39 @@
"test": "npm run test:unit",
"test:unit": "mocha 'test/unit/**/*.spec.js'"
},
"authors": [
"Djavid Gabibiyan"
"contributors": [
{
"name": "Ivan Shumkov",
"email": "[email protected]",
"url": "https://github.com/shumkov"
},
{
"name": "Djavid Gabibiyan",
"email": "[email protected]",
"url": "https://github.com/jawid-h"
},
{
"name": "Anton Suprunchuk",
"email": "[email protected]",
"url": "https://github.com/antouhou"
},
{
"name": "Konstantin Shuplenkov",
"email": "[email protected]",
"url": "https://github.com/shuplenkov"
}
],
"license": "MIT",
"devDependencies": {
"@dashevo/dapi-client": "^0.9.0-dev.7",
"@dashevo/dashcore-lib": "^0.18.0",
"@dashevo/dp-services-ctl": "^v0.10.0-dev.7",
"@dashevo/dpp": "^0.11.0",
"@dashevo/dapi-client": "~0.15.0-dev.2",
"@dashevo/dashcore-lib": "~0.19.2",
"@dashevo/dpp": "~0.15.0-dev.3",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"eslint": "^6.7.2",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.19.1",
"mocha": "^6.2.2",
"mocha": "^8.1.1",
"multihashes": "^0.4.15",
"sinon": "^8.0.1",
"sinon-chai": "^3.4.0",
Expand Down
131 changes: 131 additions & 0 deletions schema/dpns-contract-documents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"domain": {
"indices": [
{
"properties": [
{
"normalizedParentDomainName": "asc"
},
{
"normalizedLabel": "asc"
}
],
"unique": true
},
{
"properties": [
{
"records.dashUniqueIdentityId": "asc"
}
],
"unique": true
}
],
"properties": {
"label": {
"type": "string",
"pattern": "^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9])$",
"minLength": 3,
"maxLength": 63,
"description": "Domain label. e.g. 'Bob'."
},
"normalizedLabel": {
"type": "string",
"pattern": "^((?!-)[a-z0-9-]{0,62}[a-z0-9])$",
"maxLength": 63,
"description": "Domain label in a lower case for case insensitive uniqueness validation. e.g. 'bob'",
"$comment": "This property will be deprecated due to case insensitive indices. Must be equal to lowered label."
},
"normalizedParentDomainName": {
"type": "string",
"pattern": "^$|^((?!-)[a-z0-9-\\.]{0,189}[a-z0-9])$",
"minLength": 0,
"maxLength": 190,
"description": "A full parent domain name in lower case for case insensitive uniqueness validation. e.g. 'dash'",
"$comment": "Must be equal to existing domain or can be empty if you want to create top level domain. Only the contract owner can create top level domains."
},
"preorderSalt": {
"type": "string",
"contentEncoding": "binary",
"minLength": 32,
"maxLength": 32,
"description": "Domain pre-order salt. 32 random bytes"
},
"records": {
"type": "object",
"properties": {
"dashUniqueIdentityId": {
"type": "string",
"minLength": 42,
"maxLength": 44,
"pattern": "^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$",
"description": "Identity ID string should be used to create a primary name for Identity",
"$comment": "base58 string. Should be equal to the document owner."
},
"dashAliasIdentityId": {
"type": "string",
"minLength": 42,
"maxLength": 44,
"pattern": "^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$",
"description": "Identity ID string should be used to create multiple alias names for Identity",
"$comment": "base58 string. Should be equal to the document owner"
}
},
"$comment": "Constraint with max and min properties ensure that only one identity record is used either `dashUniqueIdentityId` or `dashAliasIdentityId`",
"minProperties": 1,
"maxProperties": 1,
"additionalProperties": false
},
"subdomainRules": {
"type": "object",
"properties": {
"allowSubdomains": {
"type": "boolean",
"const": false,
"description": "This option defines who can create subdomains. Only domain owner is allowed at the moment"
}
},
"description": "Subdomain rules allows to define rules for subdomains",
"additionalProperties": false,
"required": ["allowSubdomains"]
}
},
"required": [
"label",
"normalizedLabel",
"normalizedParentDomainName",
"preorderSalt",
"records",
"subdomainRules"
],
"additionalProperties": false,
"$comment": "normalizedLabel + '.' + normalizedParentDomain must not be longer than 253 chars length as defined by RFC 1035"
},
"preorder": {
"indices": [
{
"properties": [
{
"saltedDomainHash": "asc"
}
],
"unique": true
}
],
"properties": {
"saltedDomainHash": {
"type": "string",
"contentEncoding": "binary",
"minLength": 32,
"maxLength": 32,
"description": "Double sha-256 of concatenated salt, `normalizedLabel` and `normalizedParentDomainName`. Salt should be 32 random bytes"
}
},
"required": [
"saltedDomainHash"
],
"additionalProperties": false,
"description": "This document is a temporary one and can be removed after domain creation.",
"$comment": "First we have a preorder registration step and then a domain registration step. The preorder step is needed to prevent man-in-the-middle attacks. The register step can begin once the preorder document is included in the platform state tree."
}
}
8 changes: 4 additions & 4 deletions scripts/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { argv } = require('yargs')
)
.demandOption(['dapiAddress', 'serializedIdentity', 'identityPrivateKey']);

const dpnsDocumentsSchema = require('../src/schema/dpns-documents.json');
const dpnsContractDocumentsSchema = require('../schema/dpns-contract-documents.json');

/**
* Execute DPNS contract registration
Expand All @@ -30,7 +30,7 @@ async function register() {
});

const validationlessDPP = new DashPlatformProtocol({
dataProvider: {},
stateRepository: {},
});

const identity = await validationlessDPP.identity.createFromSerialized(
Expand All @@ -39,7 +39,7 @@ async function register() {
);

const dpp = new DashPlatformProtocol({
dataProvider: {
stateRepository: {
fetchIdentity: async () => identity,
},
});
Expand All @@ -52,7 +52,7 @@ async function register() {

const dataContract = dpp.dataContract.create(
identity.getId(),
dpnsDocumentsSchema,
dpnsContractDocumentsSchema,
);

const dataContractST = dpp.dataContract.createStateTransition(dataContract);
Expand Down
103 changes: 0 additions & 103 deletions src/schema/dpns-documents.json

This file was deleted.

1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

Loading

0 comments on commit daa1ada

Please sign in to comment.