@dashevo/dashpay-contract 1.0.0-dev.2 → 1.0.0-dev.4
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/Cargo.toml +3 -1
- package/package.json +2 -2
- package/src/error.rs +17 -0
- package/src/lib.rs +24 -15
- package/src/v1/mod.rs +19 -0
- package/test/unit/schema.spec.js +1 -1
- /package/schema/{dashpay.schema.json → v1/dashpay.schema.json} +0 -0
package/Cargo.toml
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "dashpay-contract"
|
|
3
3
|
description = "DashPay data contract schema and tools"
|
|
4
|
-
version = "1.0.0-dev.
|
|
4
|
+
version = "1.0.0-dev.4"
|
|
5
5
|
edition = "2021"
|
|
6
6
|
rust-version = "1.73"
|
|
7
7
|
license = "MIT"
|
|
8
8
|
|
|
9
9
|
[dependencies]
|
|
10
|
+
platform-version = { path = "../rs-platform-version" }
|
|
11
|
+
thiserror = "1.0.56"
|
|
10
12
|
serde_json = { version = "1.0" }
|
|
11
13
|
platform-value = { path = "../rs-platform-value" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dashpay-contract",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.4",
|
|
4
4
|
"description": "Reference contract of the DashPay DPA on Dash Evolution",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/dashevo/dashpay-contract#readme",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@dashevo/wasm-dpp": "1.0.0-dev.
|
|
28
|
+
"@dashevo/wasm-dpp": "1.0.0-dev.4",
|
|
29
29
|
"chai": "^4.3.10",
|
|
30
30
|
"dirty-chai": "^2.0.1",
|
|
31
31
|
"eslint": "^8.53.0",
|
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
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
mod error;
|
|
2
|
+
pub mod v1;
|
|
3
|
+
|
|
4
|
+
pub use crate::error::Error;
|
|
1
5
|
use platform_value::{Identifier, IdentifierBytes32};
|
|
2
|
-
use
|
|
6
|
+
use platform_version::version::PlatformVersion;
|
|
3
7
|
use serde_json::Value;
|
|
4
8
|
|
|
5
9
|
pub const ID_BYTES: [u8; 32] = [
|
|
@@ -12,21 +16,26 @@ pub const OWNER_ID_BYTES: [u8; 32] = [
|
|
|
12
16
|
215, 90, 101, 229, 15, 115, 5, 44, 117, 182, 217,
|
|
13
17
|
];
|
|
14
18
|
|
|
15
|
-
pub mod document_types {
|
|
16
|
-
pub mod contact_request {
|
|
17
|
-
pub const NAME: &str = "contactRequest";
|
|
18
|
-
|
|
19
|
-
pub mod properties {
|
|
20
|
-
pub const TO_USER_ID: &str = "toUserId";
|
|
21
|
-
pub const CORE_HEIGHT_CREATED_AT: &str = "coreHeightCreatedAt";
|
|
22
|
-
pub const CORE_CHAIN_LOCKED_HEIGHT: &str = "coreChainLockedHeight";
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
|
|
28
20
|
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
|
|
29
21
|
|
|
30
|
-
pub fn
|
|
31
|
-
|
|
22
|
+
pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
|
|
23
|
+
match platform_version.system_data_contracts.dashpay {
|
|
24
|
+
1 => Ok(None),
|
|
25
|
+
version => Err(Error::UnknownVersionMismatch {
|
|
26
|
+
method: "dashpay_contract::load_definitions".to_string(),
|
|
27
|
+
known_versions: vec![1],
|
|
28
|
+
received: version,
|
|
29
|
+
}),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
|
|
33
|
+
match platform_version.system_data_contracts.dashpay {
|
|
34
|
+
1 => v1::load_documents_schemas(),
|
|
35
|
+
version => Err(Error::UnknownVersionMismatch {
|
|
36
|
+
method: "dashpay_contract::load_documents_schemas".to_string(),
|
|
37
|
+
known_versions: vec![1],
|
|
38
|
+
received: version,
|
|
39
|
+
}),
|
|
40
|
+
}
|
|
32
41
|
}
|
package/src/v1/mod.rs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
pub const CORE_HEIGHT_CREATED_AT: &str = "coreHeightCreatedAt";
|
|
11
|
+
pub const CORE_CHAIN_LOCKED_HEIGHT: &str = "coreChainLockedHeight";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
pub fn load_documents_schemas() -> Result<Value, Error> {
|
|
17
|
+
serde_json::from_str(include_str!("../../schema/v1/dashpay.schema.json"))
|
|
18
|
+
.map_err(Error::InvalidSchemaJson)
|
|
19
|
+
}
|
package/test/unit/schema.spec.js
CHANGED
|
@@ -2,7 +2,7 @@ const { expect } = require('chai');
|
|
|
2
2
|
const crypto = require('crypto');
|
|
3
3
|
const { DashPlatformProtocol, JsonSchemaError } = require('@dashevo/wasm-dpp');
|
|
4
4
|
const generateRandomIdentifier = require('@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync');
|
|
5
|
-
const schema = require('../../schema/dashpay.schema.json');
|
|
5
|
+
const schema = require('../../schema/v1/dashpay.schema.json');
|
|
6
6
|
|
|
7
7
|
const whitepaperMasternodeText = 'Full nodes are servers running on a P2P network that allow peers to use them to receive updates about the events on the network. These nodes utilize significant amounts of traffic and other resources that incur a substantial cost. As a result, a steady decrease in the amount of these nodes has been observed for some time on the Bitcoin network and as a result, block propagation times have been upwards of 40 seconds. Many solutions have been proposed such as a new reward scheme by Microsoft Research and the Bitnodes incentive program';
|
|
8
8
|
const encoded32Chars = '4fafc98bbfe597f7ba2c9f767d52036d';
|
|
File without changes
|