@dashevo/dashpay-contract 1.0.0 → 1.0.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/.eslintrc +2 -1
- package/.mocharc.yml +1 -2
- package/CHANGELOG.md +18 -0
- package/Cargo.toml +13 -0
- package/README.md +6 -6
- package/lib/systemIds.js +4 -0
- package/lib/test/.eslintrc +12 -0
- package/lib/test/bootstrap.js +29 -0
- package/package.json +12 -16
- package/schema/{dashpay.schema.json → v1/dashpay.schema.json} +73 -12
- package/src/error.rs +17 -0
- package/src/lib.rs +38 -0
- package/src/v1/mod.rs +17 -0
- package/test/.eslintrc +12 -0
- package/test/unit/schema.spec.js +795 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -32
- package/.travis.yml +0 -40
- package/REAMDE.md +0 -68
- package/bin/travis-deploy.sh +0 -31
- package/bootstrap.test.js +0 -22
- package/schema/dashpay.schema.spec.js +0 -428
package/.eslintrc
CHANGED
package/.mocharc.yml
CHANGED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# [0.4.0](https://github.com/dashevo/dashpay-contract/compare/v0.3.0...v0.4.0) (2021-08-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update contract to work with DPP 0.20 ([#12](https://github.com/dashevo/dashpay-contract/issues/12))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# [0.2.0](https://github.com/dashevo/dashpay-contract/compare/v0.1.0...v0.2.0) (2021-02-02)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* update contract ([#7](https://github.com/dashevo/dashpay-contract/issues/7))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
package/Cargo.toml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "dashpay-contract"
|
|
3
|
+
description = "DashPay data contract schema and tools"
|
|
4
|
+
version = "1.0.1"
|
|
5
|
+
edition = "2021"
|
|
6
|
+
rust-version = "1.76"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
|
|
9
|
+
[dependencies]
|
|
10
|
+
platform-version = { path = "../rs-platform-version" }
|
|
11
|
+
thiserror = "1.0.58"
|
|
12
|
+
serde_json = { version = "1.0" }
|
|
13
|
+
platform-value = { path = "../rs-platform-value" }
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# DashPay Contract
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@dashevo/dashpay-contract)
|
|
4
|
-
[](https://github.com/dashpay/platform/actions/workflows/release.yml)
|
|
5
|
+
[](https://github.com/dashpay/platform/releases/latest)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://github.com/RichardLitt/standard-readme)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Reference contract of the DashPay Application Contract
|
|
10
10
|
|
|
11
11
|
DashPay allows Dash user to create a DashPay profile on the Platform chain.
|
|
12
12
|
This profile can be used to interact with other DashPay profiles, may it be for the purpose of sending/receiving transactions without having to go around the process of querying the public address of the recipient.
|
|
@@ -61,8 +61,8 @@ npm test
|
|
|
61
61
|
|
|
62
62
|
## Contributing
|
|
63
63
|
|
|
64
|
-
Feel free to dive in! [Open an issue](https://github.com/
|
|
64
|
+
Feel free to dive in! [Open an issue](https://github.com/dashpay/platform/issues/new/choose) or submit PRs.
|
|
65
65
|
|
|
66
|
-
##
|
|
66
|
+
## License
|
|
67
67
|
|
|
68
|
-
[MIT](
|
|
68
|
+
[MIT](LICENSE) © Dash Core Group, Inc.
|
package/lib/systemIds.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const sinon = require('sinon');
|
|
2
|
+
const sinonChai = require('sinon-chai');
|
|
3
|
+
|
|
4
|
+
const { expect, use } = require('chai');
|
|
5
|
+
const dirtyChai = require('dirty-chai');
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
default: loadWasmDpp,
|
|
9
|
+
} = require('@dashevo/wasm-dpp');
|
|
10
|
+
|
|
11
|
+
use(dirtyChai);
|
|
12
|
+
use(sinonChai);
|
|
13
|
+
|
|
14
|
+
exports.mochaHooks = {
|
|
15
|
+
beforeAll: loadWasmDpp,
|
|
16
|
+
beforeEach() {
|
|
17
|
+
if (!this.sinon) {
|
|
18
|
+
this.sinon = sinon.createSandbox();
|
|
19
|
+
} else {
|
|
20
|
+
this.sinon.restore();
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
afterEach() {
|
|
25
|
+
this.sinon.restore();
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
global.expect = expect;
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dashpay-contract",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Reference contract of the DashPay DPA on Dash Evolution",
|
|
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": "
|
|
11
|
-
"test:unit": "mocha '
|
|
7
|
+
"test": "yarn run test:unit",
|
|
8
|
+
"test:unit": "mocha 'test/unit/*.spec.js'"
|
|
12
9
|
},
|
|
13
10
|
"repository": {
|
|
14
11
|
"type": "git",
|
|
@@ -28,15 +25,14 @@
|
|
|
28
25
|
},
|
|
29
26
|
"homepage": "https://github.com/dashevo/dashpay-contract#readme",
|
|
30
27
|
"devDependencies": {
|
|
31
|
-
"@dashevo/
|
|
32
|
-
"
|
|
33
|
-
"chai": "^4.2.0",
|
|
28
|
+
"@dashevo/wasm-dpp": "1.0.1",
|
|
29
|
+
"chai": "^4.3.10",
|
|
34
30
|
"dirty-chai": "^2.0.1",
|
|
35
|
-
"eslint": "^
|
|
36
|
-
"eslint-config-airbnb-base": "^
|
|
37
|
-
"eslint-plugin-import": "^2.
|
|
38
|
-
"mocha": "^
|
|
39
|
-
"sinon": "^
|
|
40
|
-
"sinon-chai": "^3.
|
|
31
|
+
"eslint": "^8.53.0",
|
|
32
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
33
|
+
"eslint-plugin-import": "^2.29.0",
|
|
34
|
+
"mocha": "^10.2.0",
|
|
35
|
+
"sinon": "^17.0.1",
|
|
36
|
+
"sinon-chai": "^3.7.0"
|
|
41
37
|
}
|
|
42
|
-
}
|
|
38
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"profile": {
|
|
3
|
+
"type": "object",
|
|
3
4
|
"indices": [
|
|
4
5
|
{
|
|
6
|
+
"name": "ownerId",
|
|
5
7
|
"properties": [
|
|
6
8
|
{
|
|
7
9
|
"$ownerId": "asc"
|
|
@@ -10,6 +12,7 @@
|
|
|
10
12
|
"unique": true
|
|
11
13
|
},
|
|
12
14
|
{
|
|
15
|
+
"name": "ownerIdAndUpdatedAt",
|
|
13
16
|
"properties": [
|
|
14
17
|
{
|
|
15
18
|
"$ownerId": "asc"
|
|
@@ -23,18 +26,46 @@
|
|
|
23
26
|
"properties": {
|
|
24
27
|
"avatarUrl": {
|
|
25
28
|
"type": "string",
|
|
26
|
-
"format": "
|
|
27
|
-
"
|
|
29
|
+
"format": "uri",
|
|
30
|
+
"minLength": 1,
|
|
31
|
+
"maxLength": 2048,
|
|
32
|
+
"position": 0
|
|
33
|
+
},
|
|
34
|
+
"avatarHash": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"byteArray": true,
|
|
37
|
+
"minItems": 32,
|
|
38
|
+
"maxItems": 32,
|
|
39
|
+
"description": "SHA256 hash of the bytes of the image specified by avatarUrl",
|
|
40
|
+
"position": 1
|
|
41
|
+
},
|
|
42
|
+
"avatarFingerprint": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"byteArray": true,
|
|
45
|
+
"minItems": 8,
|
|
46
|
+
"maxItems": 8,
|
|
47
|
+
"description": "dHash the image specified by avatarUrl",
|
|
48
|
+
"position": 2
|
|
28
49
|
},
|
|
29
50
|
"publicMessage": {
|
|
30
51
|
"type": "string",
|
|
31
|
-
"
|
|
52
|
+
"minLength": 1,
|
|
53
|
+
"maxLength": 140,
|
|
54
|
+
"position": 3
|
|
32
55
|
},
|
|
33
56
|
"displayName": {
|
|
34
57
|
"type": "string",
|
|
35
|
-
"
|
|
58
|
+
"minLength": 1,
|
|
59
|
+
"maxLength": 25,
|
|
60
|
+
"position": 4
|
|
36
61
|
}
|
|
37
62
|
},
|
|
63
|
+
"minProperties": 1,
|
|
64
|
+
"dependentRequired": {
|
|
65
|
+
"avatarUrl": ["avatarHash", "avatarFingerprint"],
|
|
66
|
+
"avatarHash": ["avatarUrl", "avatarFingerprint"],
|
|
67
|
+
"avatarFingerprint": ["avatarUrl", "avatarHash"]
|
|
68
|
+
},
|
|
38
69
|
"required": [
|
|
39
70
|
"$createdAt",
|
|
40
71
|
"$updatedAt"
|
|
@@ -42,8 +73,10 @@
|
|
|
42
73
|
"additionalProperties": false
|
|
43
74
|
},
|
|
44
75
|
"contactInfo": {
|
|
76
|
+
"type": "object",
|
|
45
77
|
"indices": [
|
|
46
78
|
{
|
|
79
|
+
"name": "ownerIdAndKeys",
|
|
47
80
|
"properties": [
|
|
48
81
|
{
|
|
49
82
|
"$ownerId": "asc"
|
|
@@ -58,6 +91,7 @@
|
|
|
58
91
|
"unique": true
|
|
59
92
|
},
|
|
60
93
|
{
|
|
94
|
+
"name": "ownerIdAndUpdatedAt",
|
|
61
95
|
"properties": [
|
|
62
96
|
{
|
|
63
97
|
"$ownerId": "asc"
|
|
@@ -73,21 +107,25 @@
|
|
|
73
107
|
"type": "array",
|
|
74
108
|
"byteArray": true,
|
|
75
109
|
"minItems": 32,
|
|
76
|
-
"maxItems": 32
|
|
110
|
+
"maxItems": 32,
|
|
111
|
+
"position": 0
|
|
77
112
|
},
|
|
78
113
|
"rootEncryptionKeyIndex": {
|
|
79
114
|
"type": "integer",
|
|
80
|
-
"minimum": 0
|
|
115
|
+
"minimum": 0,
|
|
116
|
+
"position": 1
|
|
81
117
|
},
|
|
82
118
|
"derivationEncryptionKeyIndex": {
|
|
83
119
|
"type": "integer",
|
|
84
|
-
"minimum": 0
|
|
120
|
+
"minimum": 0,
|
|
121
|
+
"position": 2
|
|
85
122
|
},
|
|
86
123
|
"privateData": {
|
|
87
124
|
"type": "array",
|
|
88
125
|
"byteArray": true,
|
|
89
126
|
"minItems": 48,
|
|
90
127
|
"maxItems": 2048,
|
|
128
|
+
"position": 3,
|
|
91
129
|
"description": "This is the encrypted values of aliasName + note + displayHidden encoded as an array in cbor"
|
|
92
130
|
}
|
|
93
131
|
},
|
|
@@ -102,8 +140,14 @@
|
|
|
102
140
|
"additionalProperties": false
|
|
103
141
|
},
|
|
104
142
|
"contactRequest": {
|
|
143
|
+
"documentsMutable": false,
|
|
144
|
+
"canBeDeleted": false,
|
|
145
|
+
"requiresIdentityEncryptionBoundedKey": 2,
|
|
146
|
+
"requiresIdentityDecryptionBoundedKey": 2,
|
|
147
|
+
"type": "object",
|
|
105
148
|
"indices": [
|
|
106
149
|
{
|
|
150
|
+
"name": "ownerIdUserIdAndAccountRef",
|
|
107
151
|
"properties": [
|
|
108
152
|
{
|
|
109
153
|
"$ownerId": "asc"
|
|
@@ -118,6 +162,7 @@
|
|
|
118
162
|
"unique": true
|
|
119
163
|
},
|
|
120
164
|
{
|
|
165
|
+
"name": "ownerIdUserId",
|
|
121
166
|
"properties": [
|
|
122
167
|
{
|
|
123
168
|
"$ownerId": "asc"
|
|
@@ -128,6 +173,7 @@
|
|
|
128
173
|
]
|
|
129
174
|
},
|
|
130
175
|
{
|
|
176
|
+
"name": "userIdCreatedAt",
|
|
131
177
|
"properties": [
|
|
132
178
|
{
|
|
133
179
|
"toUserId": "asc"
|
|
@@ -138,6 +184,7 @@
|
|
|
138
184
|
]
|
|
139
185
|
},
|
|
140
186
|
{
|
|
187
|
+
"name": "ownerIdCreatedAt",
|
|
141
188
|
"properties": [
|
|
142
189
|
{
|
|
143
190
|
"$ownerId": "asc"
|
|
@@ -154,35 +201,49 @@
|
|
|
154
201
|
"byteArray": true,
|
|
155
202
|
"minItems": 32,
|
|
156
203
|
"maxItems": 32,
|
|
204
|
+
"position": 0,
|
|
157
205
|
"contentMediaType": "application/x.dash.dpp.identifier"
|
|
158
206
|
},
|
|
159
207
|
"encryptedPublicKey": {
|
|
160
208
|
"type": "array",
|
|
161
209
|
"byteArray": true,
|
|
162
210
|
"minItems": 96,
|
|
163
|
-
"maxItems": 96
|
|
211
|
+
"maxItems": 96,
|
|
212
|
+
"position": 1
|
|
164
213
|
},
|
|
165
214
|
"senderKeyIndex": {
|
|
166
215
|
"type": "integer",
|
|
167
|
-
"minimum": 0
|
|
216
|
+
"minimum": 0,
|
|
217
|
+
"position": 2
|
|
168
218
|
},
|
|
169
219
|
"recipientKeyIndex": {
|
|
170
220
|
"type": "integer",
|
|
171
|
-
"minimum": 0
|
|
221
|
+
"minimum": 0,
|
|
222
|
+
"position": 3
|
|
172
223
|
},
|
|
173
224
|
"accountReference": {
|
|
174
225
|
"type": "integer",
|
|
175
|
-
"minimum": 0
|
|
226
|
+
"minimum": 0,
|
|
227
|
+
"position": 4
|
|
176
228
|
},
|
|
177
229
|
"encryptedAccountLabel": {
|
|
178
230
|
"type": "array",
|
|
179
231
|
"byteArray": true,
|
|
180
232
|
"minItems": 48,
|
|
181
|
-
"maxItems": 80
|
|
233
|
+
"maxItems": 80,
|
|
234
|
+
"position": 5
|
|
235
|
+
},
|
|
236
|
+
"autoAcceptProof": {
|
|
237
|
+
"type": "array",
|
|
238
|
+
"byteArray": true,
|
|
239
|
+
"minItems": 38,
|
|
240
|
+
"maxItems": 102,
|
|
241
|
+
"position": 6
|
|
182
242
|
}
|
|
183
243
|
},
|
|
184
244
|
"required": [
|
|
185
245
|
"$createdAt",
|
|
246
|
+
"$createdAtCoreBlockHeight",
|
|
186
247
|
"toUserId",
|
|
187
248
|
"encryptedPublicKey",
|
|
188
249
|
"senderKeyIndex",
|
package/src/error.rs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
use platform_version::version::FeatureVersion;
|
|
2
|
+
|
|
3
|
+
#[derive(thiserror::Error, Debug)]
|
|
4
|
+
pub enum Error {
|
|
5
|
+
/// Platform expected some specific versions
|
|
6
|
+
#[error("platform unknown version on {method}, received: {received}")]
|
|
7
|
+
UnknownVersionMismatch {
|
|
8
|
+
/// method
|
|
9
|
+
method: String,
|
|
10
|
+
/// the allowed versions for this method
|
|
11
|
+
known_versions: Vec<FeatureVersion>,
|
|
12
|
+
/// requested core height
|
|
13
|
+
received: FeatureVersion,
|
|
14
|
+
},
|
|
15
|
+
#[error("schema deserialize error: {0}")]
|
|
16
|
+
InvalidSchemaJson(#[from] serde_json::Error),
|
|
17
|
+
}
|
package/src/lib.rs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
mod error;
|
|
2
|
+
pub mod v1;
|
|
3
|
+
|
|
4
|
+
pub use crate::error::Error;
|
|
5
|
+
use platform_value::{Identifier, IdentifierBytes32};
|
|
6
|
+
use platform_version::version::PlatformVersion;
|
|
7
|
+
use serde_json::Value;
|
|
8
|
+
|
|
9
|
+
pub const ID_BYTES: [u8; 32] = [
|
|
10
|
+
162, 161, 180, 172, 111, 239, 34, 234, 42, 26, 104, 232, 18, 54, 68, 179, 87, 135, 95, 107, 65,
|
|
11
|
+
44, 24, 16, 146, 129, 193, 70, 231, 178, 113, 188,
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
pub const OWNER_ID_BYTES: [u8; 32] = [0; 32];
|
|
15
|
+
|
|
16
|
+
pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
|
|
17
|
+
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
|
|
18
|
+
|
|
19
|
+
pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
|
|
20
|
+
match platform_version.system_data_contracts.dashpay {
|
|
21
|
+
1 => Ok(None),
|
|
22
|
+
version => Err(Error::UnknownVersionMismatch {
|
|
23
|
+
method: "dashpay_contract::load_definitions".to_string(),
|
|
24
|
+
known_versions: vec![1],
|
|
25
|
+
received: version,
|
|
26
|
+
}),
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
|
|
30
|
+
match platform_version.system_data_contracts.dashpay {
|
|
31
|
+
1 => v1::load_documents_schemas(),
|
|
32
|
+
version => Err(Error::UnknownVersionMismatch {
|
|
33
|
+
method: "dashpay_contract::load_documents_schemas".to_string(),
|
|
34
|
+
known_versions: vec![1],
|
|
35
|
+
received: version,
|
|
36
|
+
}),
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/v1/mod.rs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
use crate::error::Error;
|
|
2
|
+
use serde_json::Value;
|
|
3
|
+
|
|
4
|
+
pub mod document_types {
|
|
5
|
+
pub mod contact_request {
|
|
6
|
+
pub const NAME: &str = "contactRequest";
|
|
7
|
+
|
|
8
|
+
pub mod properties {
|
|
9
|
+
pub const TO_USER_ID: &str = "toUserId";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
pub fn load_documents_schemas() -> Result<Value, Error> {
|
|
15
|
+
serde_json::from_str(include_str!("../../schema/v1/dashpay.schema.json"))
|
|
16
|
+
.map_err(Error::InvalidSchemaJson)
|
|
17
|
+
}
|