Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fd546be
dpns usernames in rust sdk
Jul 10, 2025
ddca52a
dpns improvements
Jul 10, 2025
72d8197
more dpns improvements
QuantumExplorer Jul 10, 2025
84fb154
more dpns improvements
QuantumExplorer Jul 10, 2025
0964da3
more dpns improvements
QuantumExplorer Jul 10, 2025
bcacb00
more dpns improvements
QuantumExplorer Jul 10, 2025
9b0adf5
dpns improvements
Jul 10, 2025
ef11969
more work
Jul 10, 2025
647da0c
more work
Jul 10, 2025
69ac84a
more work
Jul 10, 2025
057b618
more work
Jul 11, 2025
5d71bd1
more fixes
Jul 11, 2025
26e4d25
fix
QuantumExplorer Jul 11, 2025
37a3ca4
fix
QuantumExplorer Jul 11, 2025
30215df
more fixes
Jul 11, 2025
ff8ff6d
Merge branch 'feat/dpnsImprovements' of github.com:dashpay/platform i…
Jul 11, 2025
a53b9cf
another fix
QuantumExplorer Jul 11, 2025
6aac9cf
Potential fix for code scanning alert no. 24: DOM text reinterpreted …
QuantumExplorer Jul 12, 2025
0f6be17
fixes
Jul 12, 2025
5ef0fdd
more work
Jul 12, 2025
4a1cf37
more work
Jul 12, 2025
a0867a9
improvement
QuantumExplorer Jul 12, 2025
09313ff
Merge branch 'feat/dpnsImprovements' of github.com:dashpay/platform i…
QuantumExplorer Jul 12, 2025
ba65988
improvement
QuantumExplorer Jul 12, 2025
36c3a4f
fix
QuantumExplorer Jul 12, 2025
b2c07f5
fix
QuantumExplorer Jul 12, 2025
1b55f53
fix
Jul 12, 2025
47403bc
Merge branch 'feat/dpnsImprovements' of github.com:dashpay/platform i…
Jul 12, 2025
8a3c931
more work
QuantumExplorer Jul 12, 2025
61e4d9c
fix
Jul 12, 2025
da06af1
fix
QuantumExplorer Jul 12, 2025
4778678
Merge branch 'feat/dpnsImprovements' of github.com:dashpay/platform i…
QuantumExplorer Jul 12, 2025
a64b739
fixes
Jul 12, 2025
5b08754
Merge branch 'feat/dpnsImprovements' of github.com:dashpay/platform i…
Jul 12, 2025
d47bfd8
fixes
Jul 12, 2025
2b80447
fixes
Jul 12, 2025
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions packages/data-contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,31 @@ edition = "2021"
rust-version.workspace = true
license = "MIT"

[features]
default = ["all-contracts"]
# Include all contracts
all-contracts = ["withdrawals", "masternode-rewards", "dpns", "dashpay", "feature-flags", "wallet-utils", "token-history", "keyword-search"]

# Individual contract features
withdrawals = ["dep:withdrawals-contract"]
masternode-rewards = ["dep:masternode-reward-shares-contract"]
dpns = ["dep:dpns-contract"]
dashpay = ["dep:dashpay-contract"]
feature-flags = ["dep:feature-flags-contract"]
wallet-utils = ["dep:wallet-utils-contract"]
token-history = ["dep:token-history-contract"]
keyword-search = ["dep:keyword-search-contract"]

[dependencies]
thiserror = "2.0.12"
platform-version = { path = "../rs-platform-version" }
serde_json = { version = "1.0" }
withdrawals-contract = { path = "../withdrawals-contract" }
masternode-reward-shares-contract = { path = "../masternode-reward-shares-contract" }
dpns-contract = { path = "../dpns-contract" }
dashpay-contract = { path = "../dashpay-contract" }
feature-flags-contract = { path = "../feature-flags-contract" }
withdrawals-contract = { path = "../withdrawals-contract", optional = true }
masternode-reward-shares-contract = { path = "../masternode-reward-shares-contract", optional = true }
dpns-contract = { path = "../dpns-contract", optional = true }
dashpay-contract = { path = "../dashpay-contract", optional = true }
feature-flags-contract = { path = "../feature-flags-contract", optional = true }
platform-value = { path = "../rs-platform-value" }
wallet-utils-contract = { path = "../wallet-utils-contract" }
token-history-contract = { path = "../token-history-contract" }
keyword-search-contract = { path = "../keyword-search-contract" }
wallet-utils-contract = { path = "../wallet-utils-contract", optional = true }
token-history-contract = { path = "../token-history-contract", optional = true }
keyword-search-contract = { path = "../keyword-search-contract", optional = true }
10 changes: 10 additions & 0 deletions packages/data-contracts/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ pub enum Error {
},
#[error("schema deserialize error: {0}")]
InvalidSchemaJson(#[from] serde_json::Error),
#[error("contract '{0}' not included in build (enable feature '{0}')")]
ContractNotIncluded(&'static str),
}

#[cfg(feature = "withdrawals")]
impl From<withdrawals_contract::Error> for Error {
fn from(e: withdrawals_contract::Error) -> Self {
match e {
Expand All @@ -33,6 +36,7 @@ impl From<withdrawals_contract::Error> for Error {
}
}

#[cfg(feature = "dashpay")]
impl From<dashpay_contract::Error> for Error {
fn from(e: dashpay_contract::Error) -> Self {
match e {
Expand All @@ -50,6 +54,7 @@ impl From<dashpay_contract::Error> for Error {
}
}

#[cfg(feature = "dpns")]
impl From<dpns_contract::Error> for Error {
fn from(e: dpns_contract::Error) -> Self {
match e {
Expand All @@ -67,6 +72,7 @@ impl From<dpns_contract::Error> for Error {
}
}

#[cfg(feature = "masternode-rewards")]
impl From<masternode_reward_shares_contract::Error> for Error {
fn from(e: masternode_reward_shares_contract::Error) -> Self {
match e {
Expand All @@ -86,6 +92,7 @@ impl From<masternode_reward_shares_contract::Error> for Error {
}
}

#[cfg(feature = "feature-flags")]
impl From<feature_flags_contract::Error> for Error {
fn from(e: feature_flags_contract::Error) -> Self {
match e {
Expand All @@ -103,6 +110,7 @@ impl From<feature_flags_contract::Error> for Error {
}
}

#[cfg(feature = "wallet-utils")]
impl From<wallet_utils_contract::Error> for Error {
fn from(e: wallet_utils_contract::Error) -> Self {
match e {
Expand All @@ -120,6 +128,7 @@ impl From<wallet_utils_contract::Error> for Error {
}
}

#[cfg(feature = "token-history")]
impl From<token_history_contract::Error> for Error {
fn from(e: token_history_contract::Error) -> Self {
match e {
Expand All @@ -137,6 +146,7 @@ impl From<token_history_contract::Error> for Error {
}
}

#[cfg(feature = "keyword-search")]
impl From<keyword_search_contract::Error> for Error {
fn from(e: keyword_search_contract::Error) -> Self {
match e {
Expand Down
145 changes: 124 additions & 21 deletions packages/data-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,32 @@
use serde_json::Value;

use crate::error::Error;

#[cfg(feature = "dashpay")]
pub use dashpay_contract;

#[cfg(feature = "dpns")]
pub use dpns_contract;

#[cfg(feature = "feature-flags")]
pub use feature_flags_contract;

#[cfg(feature = "keyword-search")]
pub use keyword_search_contract;

#[cfg(feature = "masternode-rewards")]
pub use masternode_reward_shares_contract;

use platform_value::Identifier;
use platform_version::version::PlatformVersion;

#[cfg(feature = "token-history")]
pub use token_history_contract;

#[cfg(feature = "wallet-utils")]
pub use wallet_utils_contract;

#[cfg(feature = "withdrawals")]
pub use withdrawals_contract;

#[repr(u8)]
Expand All @@ -38,84 +55,170 @@
impl SystemDataContract {
pub fn id(&self) -> Identifier {
let bytes = match self {
#[cfg(feature = "withdrawals")]
SystemDataContract::Withdrawals => withdrawals_contract::ID_BYTES,
#[cfg(not(feature = "withdrawals"))]
SystemDataContract::Withdrawals => [
54, 98, 187, 97, 225, 127, 174, 62, 162, 148, 207, 96, 49, 151, 251, 10, 171, 109,
81, 24, 11, 216, 182, 16, 76, 73, 68, 166, 47, 226, 217, 127,
],

#[cfg(feature = "masternode-rewards")]
SystemDataContract::MasternodeRewards => masternode_reward_shares_contract::ID_BYTES,
#[cfg(not(feature = "masternode-rewards"))]
SystemDataContract::MasternodeRewards => [
12, 172, 226, 5, 36, 102, 147, 167, 200, 21, 101, 35, 98, 13, 170, 147, 125, 47,
34, 71, 147, 68, 99, 238, 176, 31, 247, 33, 149, 144, 149, 140,
],

#[cfg(feature = "feature-flags")]
SystemDataContract::FeatureFlags => feature_flags_contract::ID_BYTES,
#[cfg(not(feature = "feature-flags"))]
SystemDataContract::FeatureFlags => [
245, 172, 216, 200, 193, 110, 185, 172, 40, 110, 7, 132, 190, 86, 127, 80, 9, 244,
86, 26, 243, 212, 255, 2, 91, 7, 90, 243, 68, 55, 152, 34,
],

#[cfg(feature = "dpns")]
SystemDataContract::DPNS => dpns_contract::ID_BYTES,
#[cfg(not(feature = "dpns"))]
SystemDataContract::DPNS => [
230, 104, 198, 89, 175, 102, 174, 225, 231, 44, 24, 109, 222, 123, 91, 126, 10, 29,
113, 42, 9, 196, 13, 87, 33, 246, 34, 191, 83, 197, 49, 85,
],

#[cfg(feature = "dashpay")]
SystemDataContract::Dashpay => dashpay_contract::ID_BYTES,
#[cfg(not(feature = "dashpay"))]
SystemDataContract::Dashpay => [
162, 161, 180, 172, 111, 239, 34, 234, 42, 26, 104, 232, 18, 54, 68, 179, 87, 135,
95, 107, 65, 44, 24, 16, 146, 129, 193, 70, 231, 178, 113, 188,
],

#[cfg(feature = "wallet-utils")]
SystemDataContract::WalletUtils => wallet_utils_contract::ID_BYTES,
#[cfg(not(feature = "wallet-utils"))]
SystemDataContract::WalletUtils => [
92, 20, 14, 101, 92, 2, 101, 187, 194, 168, 8, 113, 109, 225, 132, 121, 133, 19,
89, 24, 173, 81, 205, 253, 11, 118, 102, 75, 169, 91, 163, 124,
],
Comment on lines +101 to +104
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Duplicate contract ID bytes detected.

WalletUtils and KeywordSearch have identical hardcoded ID bytes, which would cause conflicts. Each contract must have a unique identifier.

The KeywordSearch contract needs its own unique ID bytes. Please update one of these to use the correct values.

Also applies to: 117-120

🤖 Prompt for AI Agents
In packages/data-contracts/src/lib.rs around lines 101 to 104 and 117 to 120,
the hardcoded ID bytes for WalletUtils and KeywordSearch contracts are
duplicated, causing conflicts. Update the ID bytes for the KeywordSearch
contract to a unique set of values that do not overlap with WalletUtils or any
other contract IDs. Ensure each contract has a distinct identifier to avoid
conflicts.


#[cfg(feature = "token-history")]
SystemDataContract::TokenHistory => token_history_contract::ID_BYTES,
#[cfg(not(feature = "token-history"))]
SystemDataContract::TokenHistory => [
45, 67, 89, 21, 34, 216, 145, 78, 156, 243, 17, 58, 202, 190, 13, 92, 61, 40, 122,
201, 84, 99, 187, 110, 233, 128, 63, 48, 172, 29, 210, 108,
],

#[cfg(feature = "keyword-search")]
SystemDataContract::KeywordSearch => keyword_search_contract::ID_BYTES,
#[cfg(not(feature = "keyword-search"))]
SystemDataContract::KeywordSearch => [
92, 20, 14, 101, 92, 2, 101, 187, 194, 168, 8, 113, 109, 225, 132, 121, 133, 19,
89, 24, 173, 81, 205, 253, 11, 118, 102, 75, 169, 91, 163, 124,
],
};
Identifier::new(bytes)
}
/// Returns [DataContractSource]
pub fn source(self, platform_version: &PlatformVersion) -> Result<DataContractSource, Error> {

Check warning on line 125 in packages/data-contracts/src/lib.rs

View workflow job for this annotation

GitHub Actions / Rust packages (wasm-dpp) / Linting

unused variable: `platform_version`

warning: unused variable: `platform_version` --> packages/data-contracts/src/lib.rs:125:25 | 125 | pub fn source(self, platform_version: &PlatformVersion) -> Result<DataContractSource, Error> { | ^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_platform_version` | = note: `#[warn(unused_variables)]` on by default
let data = match self {
SystemDataContract::Withdrawals => DataContractSource {
match self {
#[cfg(feature = "withdrawals")]
SystemDataContract::Withdrawals => Ok(DataContractSource {
id_bytes: withdrawals_contract::ID_BYTES,
owner_id_bytes: withdrawals_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.withdrawals as u32,
definitions: withdrawals_contract::load_definitions(platform_version)?,
document_schemas: withdrawals_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::MasternodeRewards => DataContractSource {
}),
#[cfg(not(feature = "withdrawals"))]
SystemDataContract::Withdrawals => Err(Error::ContractNotIncluded("withdrawals")),

#[cfg(feature = "masternode-rewards")]
SystemDataContract::MasternodeRewards => Ok(DataContractSource {
id_bytes: masternode_reward_shares_contract::ID_BYTES,
owner_id_bytes: masternode_reward_shares_contract::OWNER_ID_BYTES,
version: platform_version
.system_data_contracts
.masternode_reward_shares as u32,
definitions: withdrawals_contract::load_definitions(platform_version)?,
definitions: masternode_reward_shares_contract::load_definitions(platform_version)?,
document_schemas: masternode_reward_shares_contract::load_documents_schemas(
platform_version,
)?,
},
SystemDataContract::FeatureFlags => DataContractSource {
}),
#[cfg(not(feature = "masternode-rewards"))]
SystemDataContract::MasternodeRewards => {
Err(Error::ContractNotIncluded("masternode-rewards"))
}

#[cfg(feature = "feature-flags")]
SystemDataContract::FeatureFlags => Ok(DataContractSource {
id_bytes: feature_flags_contract::ID_BYTES,
owner_id_bytes: feature_flags_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.feature_flags as u32,
definitions: feature_flags_contract::load_definitions(platform_version)?,
document_schemas: feature_flags_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::DPNS => DataContractSource {
}),
#[cfg(not(feature = "feature-flags"))]
SystemDataContract::FeatureFlags => Err(Error::ContractNotIncluded("feature-flags")),

#[cfg(feature = "dpns")]
SystemDataContract::DPNS => Ok(DataContractSource {
id_bytes: dpns_contract::ID_BYTES,
owner_id_bytes: dpns_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.dpns as u32,
definitions: dpns_contract::load_definitions(platform_version)?,
document_schemas: dpns_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::Dashpay => DataContractSource {
}),
#[cfg(not(feature = "dpns"))]
SystemDataContract::DPNS => Err(Error::ContractNotIncluded("dpns")),

#[cfg(feature = "dashpay")]
SystemDataContract::Dashpay => Ok(DataContractSource {
id_bytes: dashpay_contract::ID_BYTES,
owner_id_bytes: dashpay_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.dashpay as u32,
definitions: dashpay_contract::load_definitions(platform_version)?,
document_schemas: dashpay_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::WalletUtils => DataContractSource {
}),
#[cfg(not(feature = "dashpay"))]
SystemDataContract::Dashpay => Err(Error::ContractNotIncluded("dashpay")),

#[cfg(feature = "wallet-utils")]
SystemDataContract::WalletUtils => Ok(DataContractSource {
id_bytes: wallet_utils_contract::ID_BYTES,
owner_id_bytes: wallet_utils_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.wallet as u32,
definitions: wallet_utils_contract::load_definitions(platform_version)?,
document_schemas: wallet_utils_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::TokenHistory => DataContractSource {
}),
#[cfg(not(feature = "wallet-utils"))]
SystemDataContract::WalletUtils => Err(Error::ContractNotIncluded("wallet-utils")),

#[cfg(feature = "token-history")]
SystemDataContract::TokenHistory => Ok(DataContractSource {
id_bytes: token_history_contract::ID_BYTES,
owner_id_bytes: token_history_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.token_history as u32,
definitions: token_history_contract::load_definitions(platform_version)?,
document_schemas: token_history_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::KeywordSearch => DataContractSource {
}),
#[cfg(not(feature = "token-history"))]
SystemDataContract::TokenHistory => Err(Error::ContractNotIncluded("token-history")),

#[cfg(feature = "keyword-search")]
SystemDataContract::KeywordSearch => Ok(DataContractSource {
id_bytes: keyword_search_contract::ID_BYTES,
owner_id_bytes: keyword_search_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.keyword_search as u32,
definitions: keyword_search_contract::load_definitions(platform_version)?,
document_schemas: keyword_search_contract::load_documents_schemas(
platform_version,
)?,
},
};

Ok(data)
}),
#[cfg(not(feature = "keyword-search"))]
SystemDataContract::KeywordSearch => Err(Error::ContractNotIncluded("keyword-search")),
}
}
}
Loading
Loading