Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updates needed for compatibility with nfts in the tui #1833

Merged
merged 11 commits into from
May 9, 2024
Merged
3 changes: 3 additions & 0 deletions packages/rs-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ all_features = [
"identity-value-conversion",
"identity-json-conversion",
"identity-cbor-conversion",
"index-serde-conversion",
"state-transition-serde-conversion",
"state-transition-value-conversion",
"state-transition-json-conversion",
Expand Down Expand Up @@ -158,6 +159,7 @@ all_features_without_client = [
"identity-value-conversion",
"identity-json-conversion",
"identity-cbor-conversion",
"index-serde-conversion",
"state-transition-serde-conversion",
"state-transition-value-conversion",
"state-transition-json-conversion",
Expand Down Expand Up @@ -224,6 +226,7 @@ identity-cbor-conversion = [
"cbor",
"platform-value-cbor",
]
index-serde-conversion = []
state-transition-serde-conversion = ["data-contract-serde-conversion"]
state-transition-value-conversion = [
"platform-value",
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-dpp/src/data_contract/document_type/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod random_index;

// Indices documentation: https://dashplatform.readme.io/docs/reference-data-contracts#document-indices
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "index-serde-conversion", derive(Serialize, Deserialize))]
pub struct Index {
pub name: String,
pub properties: Vec<IndexProperty>,
Expand Down Expand Up @@ -54,6 +55,7 @@ impl Index {
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "index-serde-conversion", derive(Serialize, Deserialize))]
pub struct IndexProperty {
pub name: String,
pub ascending: bool,
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive/src/error/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub enum QuerySyntaxError {

/// Where clause on non indexed property error
#[error("where clause on non indexed property error: {0}")]
WhereClauseOnNonIndexedProperty(&'static str),
WhereClauseOnNonIndexedProperty(String),
/// Query is too far from index error
#[error("query is too far from index: {0}")]
QueryTooFarFromIndex(&'static str),
Expand Down
7 changes: 4 additions & 3 deletions packages/rs-drive/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
document::{
document_methods::DocumentMethodsV0,
serialization_traits::DocumentPlatformConversionMethodsV0, Document, DocumentV0Getters,

Check warning on line 24 in packages/rs-drive/src/query/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dash-sdk) / Linting

unused import: `serialization_traits::DocumentPlatformConversionMethodsV0`

warning: unused import: `serialization_traits::DocumentPlatformConversionMethodsV0` --> packages/rs-drive/src/query/mod.rs:24:13 | 24 | serialization_traits::DocumentPlatformConversionMethodsV0, Document, DocumentV0Getters, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
},
platform_value::{btreemap_extensions::BTreeValueRemoveFromMapHelper, Value},
version::PlatformVersion,
Expand All @@ -37,7 +37,7 @@
};

#[cfg(feature = "verify")]
use crate::drive::verify::RootHash;

Check warning on line 40 in packages/rs-drive/src/query/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dash-sdk) / Linting

unused import: `crate::drive::verify::RootHash`

warning: unused import: `crate::drive::verify::RootHash` --> packages/rs-drive/src/query/mod.rs:40:5 | 40 | use crate::drive::verify::RootHash; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#[cfg(feature = "server")]
pub use grovedb::{
Expand Down Expand Up @@ -234,7 +234,7 @@
#[cfg(any(feature = "server", feature = "verify"))]
impl QueryResultEncoding {
/// Encode the value based on the encoding desired
pub fn encode_value(&self, value: &Value) -> Result<Vec<u8>, Error> {

Check warning on line 237 in packages/rs-drive/src/query/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dash-sdk) / Linting

unused variable: `value`

warning: unused variable: `value` --> packages/rs-drive/src/query/mod.rs:237:32 | 237 | pub fn encode_value(&self, value: &Value) -> Result<Vec<u8>, Error> { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_value` | = note: `#[warn(unused_variables)]` on by default
match self {
#[cfg(feature = "ciborium")]
QueryResultEncoding::CborEncodedQueryResult => {
Expand Down Expand Up @@ -1135,9 +1135,10 @@
platform_version,
)?
.ok_or(Error::Query(
QuerySyntaxError::WhereClauseOnNonIndexedProperty(
"query must be for valid indexes",
),
QuerySyntaxError::WhereClauseOnNonIndexedProperty(format!(
"query must be for valid indexes, valid indexes are: {:?}",
self.document_type.indices()
)),
))?;
if difference > defaults::MAX_INDEX_DIFFERENCE {
return Err(Error::Query(QuerySyntaxError::QueryTooFarFromIndex(
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive/src/query/test_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ mod tests {
.find_best_index(platform_version)
.expect_err("expected to not find index");
assert!(
matches!(error, Error::Query(QuerySyntaxError::WhereClauseOnNonIndexedProperty(message)) if message == "query must be for valid indexes")
matches!(error, Error::Query(QuerySyntaxError::WhereClauseOnNonIndexedProperty(message)) if message.contains("query must be for valid indexes"))
)
}
}
4 changes: 2 additions & 2 deletions packages/rs-sdk/src/platform/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ pub(crate) mod broadcast_identity;
pub mod broadcast_request;
pub(crate) mod context;
pub mod purchase_document;
mod put_contract;
pub mod put_contract;
pub mod put_document;
pub mod put_identity;
pub mod put_settings;
pub mod top_up_identity;
pub mod transfer_document;
mod txid;
mod update_price_of_document;
pub mod update_price_of_document;
pub mod withdraw_from_identity;

pub use context::*;
Expand Down
Loading