Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 271 additions & 0 deletions packages/dashpay-contract/schema/v2/dashpay.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
{
"profile": {
"type": "object",
"indices": [
{
"name": "ownerId",
"properties": [
{
"$ownerId": "asc"
}
],
"unique": true
},
{
"name": "ownerIdAndUpdatedAt",
"properties": [
{
"$ownerId": "asc"
},
{
"$updatedAt": "asc"
}
]
}
],
"properties": {
"avatarUrl": {
"type": "string",
"format": "uri",
"minLength": 1,
"maxLength": 2048,
"position": 0
},
"avatarHash": {
"type": "array",
"byteArray": true,
"minItems": 32,
"maxItems": 32,
"description": "SHA256 hash of the bytes of the image specified by avatarUrl",
"position": 1
},
"avatarFingerprint": {
"type": "array",
"byteArray": true,
"minItems": 8,
"maxItems": 8,
"description": "dHash the image specified by avatarUrl",
"position": 2
},
"publicMessage": {
"type": "string",
"minLength": 1,
"maxLength": 140,
"position": 3
},
"displayName": {
"type": "string",
"minLength": 1,
"maxLength": 25,
"position": 4
},
"corePaymentAddress": {
"type": "array",
"byteArray": true,
"minItems": 21,
"maxItems": 21,
"description": "Core chain address in storage form (type byte 0x00 P2PKH / 0x01 P2SH followed by the 20-byte HASH160, i.e. RIPEMD160 of SHA256, of the public key or redeem script) for public payments. The type byte is consensus-enforced by a data trigger; clients render the address as Base58Check for the network they are on. Payments to it are publicly linkable to this profile.",
"position": 5
},
"platformPaymentAddress": {
"type": "array",
"byteArray": true,
"minItems": 21,
"maxItems": 21,
"description": "Platform address in storage form (type byte 0x00 P2PKH / 0x01 P2SH followed by the 20-byte HASH160, i.e. RIPEMD160 of SHA256, of the public key or redeem script) for public payments. The type byte is consensus-enforced by a data trigger.",
"position": 6
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
QuantumExplorer marked this conversation as resolved.
}
},
"minProperties": 1,
"dependentRequired": {
"avatarUrl": ["avatarHash", "avatarFingerprint"],
"avatarHash": ["avatarUrl", "avatarFingerprint"],
"avatarFingerprint": ["avatarUrl", "avatarHash"]
},
"required": [
"$createdAt",
"$updatedAt"
],
"additionalProperties": false
},
"contactInfo": {
"type": "object",
"indices": [
{
"name": "ownerIdAndKeys",
"properties": [
{
"$ownerId": "asc"
},
{
"rootEncryptionKeyIndex": "asc"
},
{
"derivationEncryptionKeyIndex": "asc"
}
],
"unique": true
},
{
"name": "ownerIdAndUpdatedAt",
"properties": [
{
"$ownerId": "asc"
},
{
"$updatedAt": "asc"
}
]
}
],
"properties": {
"encToUserId": {
"type": "array",
"byteArray": true,
"minItems": 32,
"maxItems": 32,
"position": 0
},
"rootEncryptionKeyIndex": {
"type": "integer",
"minimum": 0,
"position": 1
},
"derivationEncryptionKeyIndex": {
"type": "integer",
"minimum": 0,
"position": 2
},
"privateData": {
"type": "array",
"byteArray": true,
"minItems": 48,
"maxItems": 2048,
"position": 3,
"description": "This is the encrypted values of aliasName + note + displayHidden encoded as an array in cbor"
}
},
"required": [
"$createdAt",
"$updatedAt",
"encToUserId",
"privateData",
"rootEncryptionKeyIndex",
"derivationEncryptionKeyIndex"
],
"additionalProperties": false
},
"contactRequest": {
"documentsMutable": false,
"canBeDeleted": false,
"requiresIdentityEncryptionBoundedKey": 2,
"requiresIdentityDecryptionBoundedKey": 2,
"type": "object",
"indices": [
{
"name": "ownerIdUserIdAndAccountRef",
"properties": [
{
"$ownerId": "asc"
},
{
"toUserId": "asc"
},
{
"accountReference": "asc"
}
],
"unique": true
},
{
"name": "ownerIdUserId",
"properties": [
{
"$ownerId": "asc"
},
{
"toUserId": "asc"
}
]
},
{
"name": "userIdCreatedAt",
"properties": [
{
"toUserId": "asc"
},
{
"$createdAt": "asc"
}
]
},
{
"name": "ownerIdCreatedAt",
"properties": [
{
"$ownerId": "asc"
},
{
"$createdAt": "asc"
}
]
}
],
"properties": {
"toUserId": {
"type": "array",
"byteArray": true,
"minItems": 32,
"maxItems": 32,
"position": 0,
"contentMediaType": "application/x.dash.dpp.identifier"
},
"encryptedPublicKey": {
"type": "array",
"byteArray": true,
"minItems": 96,
"maxItems": 96,
"position": 1
},
"senderKeyIndex": {
"type": "integer",
"minimum": 0,
"position": 2
},
"recipientKeyIndex": {
"type": "integer",
"minimum": 0,
"position": 3
},
"accountReference": {
"type": "integer",
"minimum": 0,
"position": 4
},
"encryptedAccountLabel": {
"type": "array",
"byteArray": true,
"minItems": 48,
"maxItems": 80,
"position": 5
},
"autoAcceptProof": {
"type": "array",
"byteArray": true,
"minItems": 38,
"maxItems": 102,
"position": 6
}
},
"required": [
"$createdAt",
"$createdAtCoreBlockHeight",
"toUserId",
"encryptedPublicKey",
"senderKeyIndex",
"recipientKeyIndex",
"accountReference"
],
"additionalProperties": false
}
}
8 changes: 5 additions & 3 deletions packages/dashpay-contract/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod error;
pub mod v1;
pub mod v2;

pub use crate::error::Error;
use platform_value::{Identifier, IdentifierBytes32};
Expand All @@ -18,20 +19,21 @@ pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));

pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
match platform_version.system_data_contracts.dashpay {
1 => Ok(None),
1 | 2 => Ok(None),
version => Err(Error::UnknownVersionMismatch {
method: "dashpay_contract::load_definitions".to_string(),
known_versions: vec![1],
known_versions: vec![1, 2],
received: version,
}),
}
}
pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
match platform_version.system_data_contracts.dashpay {
1 => v1::load_documents_schemas(),
2 => v2::load_documents_schemas(),
version => Err(Error::UnknownVersionMismatch {
method: "dashpay_contract::load_documents_schemas".to_string(),
known_versions: vec![1],
known_versions: vec![1, 2],
received: version,
}),
}
Expand Down
11 changes: 11 additions & 0 deletions packages/dashpay-contract/src/v2/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::error::Error;
use serde_json::Value;

// Document-type name and property constants live in `crate::v1::document_types`;
// v2 does not change any names v1 defined, it only adds the optional
// `corePaymentAddress` / `platformPaymentAddress` properties to `profile`.

pub fn load_documents_schemas() -> Result<Value, Error> {
serde_json::from_str(include_str!("../../schema/v2/dashpay.schema.json"))
.map_err(Error::InvalidSchemaJson)
}
10 changes: 5 additions & 5 deletions packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ mod tests {

assert_eq!(
processing_result.aggregated_fees().processing_fee,
24002489210
24002816630
);

let check_result = platform
Expand Down Expand Up @@ -1159,7 +1159,7 @@ mod tests {
// Plus we have 24_000_000_000 in base costs
assert_eq!(
processing_result.aggregated_fees().processing_fee,
24004978420
24005633260
);

let check_result = platform
Expand Down Expand Up @@ -1634,7 +1634,7 @@ mod tests {

assert_eq!(
processing_result.aggregated_fees().processing_fee,
24002489210
24002816630
);

platform
Expand Down Expand Up @@ -1721,7 +1721,7 @@ mod tests {

assert_eq!(
update_processing_result.aggregated_fees().processing_fee,
27002504030
27002879350
);

let check_result = platform
Expand Down Expand Up @@ -2093,7 +2093,7 @@ mod tests {

assert_eq!(
processing_result.aggregated_fees().processing_fee,
24002489210
24002816630
);

platform
Expand Down
Loading
Loading