diff --git a/packages/keyword-search-contract/schema/v1/keyword-search-contract-documents.json b/packages/keyword-search-contract/schema/v1/keyword-search-contract-documents.json index 1dd4d55478f..fac5cc55d30 100644 --- a/packages/keyword-search-contract/schema/v1/keyword-search-contract-documents.json +++ b/packages/keyword-search-contract/schema/v1/keyword-search-contract-documents.json @@ -2,7 +2,7 @@ "contractKeywords": { "type": "object", "documentsMutable": false, - "canBeDeleted": true, + "canBeDeleted": false, "creationRestrictionMode": 2, "indices": [ { @@ -48,7 +48,7 @@ "shortDescription": { "type": "object", "documentsMutable": true, - "canBeDeleted": true, + "canBeDeleted": false, "creationRestrictionMode": 2, "indices": [ { @@ -87,7 +87,7 @@ "fullDescription": { "type": "object", "documentsMutable": true, - "canBeDeleted": true, + "canBeDeleted": false, "creationRestrictionMode": 2, "indices": [ { diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs index 1f8534a43f1..0d1e3180b86 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs @@ -1,8 +1,12 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use dpp::block::block_info::BlockInfo; +use dpp::data_contract::associated_token::token_configuration::accessors::v0::TokenConfigurationV0Getters; use dpp::data_contract::associated_token::token_configuration::v0::TokenConfigurationV0; +use dpp::data_contract::associated_token::token_configuration_convention::accessors::v0::TokenConfigurationConventionV0Getters; use dpp::data_contract::associated_token::token_configuration_convention::v0::TokenConfigurationConventionV0; +use dpp::data_contract::associated_token::token_configuration_localization::v0::TokenConfigurationLocalizationV0; +use dpp::data_contract::associated_token::token_configuration_localization::TokenConfigurationLocalization; use dpp::data_contract::associated_token::token_distribution_rules::v0::TokenDistributionRulesV0; use dpp::data_contract::associated_token::token_keeps_history_rules::v0::TokenKeepsHistoryRulesV0; use dpp::data_contract::change_control_rules::authorized_action_takers::AuthorizedActionTakers; @@ -30,10 +34,6 @@ use drive::grovedb::TransactionArg; use rand::rngs::StdRng; use rand::SeedableRng; use std::sync::LazyLock; -use dpp::data_contract::associated_token::token_configuration::accessors::v0::TokenConfigurationV0Getters; -use dpp::data_contract::associated_token::token_configuration_convention::accessors::v0::TokenConfigurationConventionV0Getters; -use dpp::data_contract::associated_token::token_configuration_localization::TokenConfigurationLocalization; -use dpp::data_contract::associated_token::token_configuration_localization::v0::TokenConfigurationLocalizationV0; const IDENTITY_ID_1: Identifier = Identifier::new([1; 32]); const IDENTITY_ID_2: Identifier = Identifier::new([2; 32]); @@ -271,14 +271,17 @@ impl Platform { description: Some("Some token description".to_string()), }); - token_configuration.conventions_mut().localizations_mut().insert( - "en".to_string(), - TokenConfigurationLocalization::V0(TokenConfigurationLocalizationV0 { - should_capitalize: false, - singular_form: "cat".to_string(), - plural_form: "cats".to_string(), - }), - ); + token_configuration + .conventions_mut() + .localizations_mut() + .insert( + "en".to_string(), + TokenConfigurationLocalization::V0(TokenConfigurationLocalizationV0 { + should_capitalize: false, + singular_form: "cat".to_string(), + plural_form: "cats".to_string(), + }), + ); let tokens = [ (0, token_configuration.clone()), diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs index 81717e7c1b1..121e9cf348c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs @@ -1,7 +1,10 @@ -use std::collections::HashSet; -use dpp::consensus::basic::BasicError; use crate::error::Error; -use dpp::consensus::basic::data_contract::{DuplicateKeywordsError, InvalidDataContractVersionError, InvalidDescriptionLengthError, InvalidKeywordLengthError, InvalidTokenBaseSupplyError, NonContiguousContractTokenPositionsError, TooManyKeywordsError}; +use dpp::consensus::basic::data_contract::{ + DuplicateKeywordsError, InvalidDataContractVersionError, InvalidDescriptionLengthError, + InvalidKeywordLengthError, InvalidTokenBaseSupplyError, + NonContiguousContractTokenPositionsError, TooManyKeywordsError, +}; +use dpp::consensus::basic::BasicError; use dpp::consensus::ConsensusError; use dpp::data_contract::associated_token::token_configuration::accessors::v0::TokenConfigurationV0Getters; use dpp::data_contract::{TokenContractPosition, INITIAL_DATA_CONTRACT_VERSION}; @@ -10,6 +13,7 @@ use dpp::state_transition::data_contract_create_transition::accessors::DataContr use dpp::state_transition::data_contract_create_transition::DataContractCreateTransition; use dpp::validation::SimpleConsensusValidationResult; use dpp::version::PlatformVersion; +use std::collections::HashSet; pub(in crate::execution::validation::state_transition::state_transitions::data_contract_create) trait DataContractCreateStateTransitionBasicStructureValidationV0 { @@ -78,16 +82,15 @@ impl DataContractCreateStateTransitionBasicStructureValidationV0 for DataContrac } } - // Validate there are no more than 20 keywords if self.data_contract().keywords().len() > 20 { return Ok(SimpleConsensusValidationResult::new_with_error( - ConsensusError::BasicError( - BasicError::TooManyKeywordsError(TooManyKeywordsError::new( + ConsensusError::BasicError(BasicError::TooManyKeywordsError( + TooManyKeywordsError::new( self.data_contract().id(), self.data_contract().keywords().len() as u8, - )) - ) + ), + )), )); } @@ -97,24 +100,21 @@ impl DataContractCreateStateTransitionBasicStructureValidationV0 for DataContrac // First check keyword length if keyword.len() < 3 || keyword.len() > 50 { return Ok(SimpleConsensusValidationResult::new_with_error( - ConsensusError::BasicError( - BasicError::InvalidKeywordLengthError(InvalidKeywordLengthError::new( + ConsensusError::BasicError(BasicError::InvalidKeywordLengthError( + InvalidKeywordLengthError::new( self.data_contract().id(), keyword.to_string(), - )), - ) + ), + )), )); } // Then check uniqueness if !seen_keywords.insert(keyword) { return Ok(SimpleConsensusValidationResult::new_with_error( - ConsensusError::BasicError( - BasicError::DuplicateKeywordsError(DuplicateKeywordsError::new( - self.data_contract().id(), - keyword.to_string(), - )), - ) + ConsensusError::BasicError(BasicError::DuplicateKeywordsError( + DuplicateKeywordsError::new(self.data_contract().id(), keyword.to_string()), + )), )); } } @@ -123,19 +123,16 @@ impl DataContractCreateStateTransitionBasicStructureValidationV0 for DataContrac if let Some(description) = self.data_contract().description() { if !(description.len() >= 3 && description.len() <= 100) { return Ok(SimpleConsensusValidationResult::new_with_error( - ConsensusError::BasicError( - BasicError::InvalidDescriptionLengthError( - InvalidDescriptionLengthError::new( - self.data_contract().id(), - description.to_string(), - ), + ConsensusError::BasicError(BasicError::InvalidDescriptionLengthError( + InvalidDescriptionLengthError::new( + self.data_contract().id(), + description.to_string(), ), - ) + )), )); } } - Ok(SimpleConsensusValidationResult::new()) } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs index 46dd89558a3..f61111ab945 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs @@ -1298,7 +1298,7 @@ mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![tx_bytes], + &[tx_bytes], &platform_state, &BlockInfo::default(), &transaction, @@ -1488,7 +1488,7 @@ mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![tx_bytes], + &[tx_bytes], &platform_state, &BlockInfo::default(), &transaction, @@ -1973,7 +1973,7 @@ mod tests { .unwrap(); assert_eq!( *fetched.contract.keywords(), - vec!["newA", "newB", "newC"] + ["newA", "newB", "newC"] .iter() .map(|&s| s.to_string()) .collect::>() @@ -2301,8 +2301,8 @@ mod tests { &identity, &signer, &key, - &"old1", - &platform_version, + "old1", + platform_version, ); // verify initial docs @@ -2316,15 +2316,15 @@ mod tests { &identity, &signer, &key, - &"newA", - &platform_version, + "newA", + platform_version, ) .expect("update should succeed"); // fetch contract – description updated? let fetched = platform .drive - .fetch_contract(cid.into(), None, None, None, &platform_version) + .fetch_contract(cid.into(), None, None, None, platform_version) .value .unwrap() .unwrap(); @@ -2334,7 +2334,7 @@ mod tests { ); // search‑contract docs updated? - let docs_after = description_docs_for_contract(&platform, cid, &platform_version); + let docs_after = description_docs_for_contract(&platform, cid, platform_version); assert_eq!(docs_after, "newA".to_string()); // old docs gone assert!(!docs_after.contains(&"old1".to_string())); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs index 5e128f17220..8b6d9f0061b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs @@ -313,6 +313,7 @@ pub(in crate::execution) mod tests { (identity, signer, master_key) } + #[allow(clippy::too_many_arguments)] pub(crate) fn setup_add_key_to_identity( platform: &mut TempPlatform, identity: &mut Identity, @@ -971,6 +972,7 @@ pub(in crate::execution) mod tests { (identity_1_info.0, identity_2_info.0, dpns_contract) } + #[allow(clippy::too_many_arguments)] fn create_dpns_name_contest_on_identities( platform: &mut TempPlatform, identity_1: &(Identity, SimpleSigner, IdentityPublicKey), @@ -1189,10 +1191,8 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![ - documents_batch_create_serialized_preorder_transition_1.clone(), - documents_batch_create_serialized_preorder_transition_2.clone(), - ], + &[documents_batch_create_serialized_preorder_transition_1.clone(), + documents_batch_create_serialized_preorder_transition_2.clone()], platform_state, &BlockInfo::default_with_time( platform_state @@ -1234,10 +1234,8 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![ - documents_batch_create_serialized_transition_1.clone(), - documents_batch_create_serialized_transition_2.clone(), - ], + &[documents_batch_create_serialized_transition_1.clone(), + documents_batch_create_serialized_transition_2.clone()], platform_state, &BlockInfo::default_with_time( platform_state @@ -1279,6 +1277,7 @@ pub(in crate::execution) mod tests { ) } + #[allow(clippy::too_many_arguments)] fn create_dpns_name_contest_on_identities_for_contract_records( platform: &mut TempPlatform, identity_1: &(Identity, SimpleSigner, IdentityPublicKey), @@ -1505,10 +1504,8 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![ - documents_batch_create_serialized_preorder_transition_1.clone(), - documents_batch_create_serialized_preorder_transition_2.clone(), - ], + &[documents_batch_create_serialized_preorder_transition_1.clone(), + documents_batch_create_serialized_preorder_transition_2.clone()], platform_state, &BlockInfo::default_with_time( platform_state @@ -1537,10 +1534,8 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![ - documents_batch_create_serialized_transition_1.clone(), - documents_batch_create_serialized_transition_2.clone(), - ], + &[documents_batch_create_serialized_transition_1.clone(), + documents_batch_create_serialized_transition_2.clone()], platform_state, &BlockInfo::default_with_time( platform_state @@ -1688,7 +1683,7 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![documents_batch_create_serialized_preorder_transition_1.clone()], + &[documents_batch_create_serialized_preorder_transition_1.clone()], platform_state, &BlockInfo::default_with_time( platform_state @@ -1717,7 +1712,7 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![documents_batch_create_serialized_transition_1.clone()], + &[documents_batch_create_serialized_transition_1.clone()], platform_state, &BlockInfo::default_with_time( platform_state @@ -1961,6 +1956,7 @@ pub(in crate::execution) mod tests { assert_eq!(second_contender.vote_tally(), Some(0)); } + #[allow(clippy::too_many_arguments)] pub(in crate::execution) fn perform_vote( platform: &mut TempPlatform, platform_state: &Guard>, @@ -2011,7 +2007,7 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![masternode_vote_serialized_transition.clone()], + &[masternode_vote_serialized_transition.clone()], platform_state, &BlockInfo::default(), &transaction, @@ -2040,6 +2036,7 @@ pub(in crate::execution) mod tests { } } + #[allow(clippy::too_many_arguments)] pub(in crate::execution) fn perform_votes( platform: &mut TempPlatform, dpns_contract: &DataContract, @@ -2105,6 +2102,7 @@ pub(in crate::execution) mod tests { masternodes_by_vote_choice } + #[allow(clippy::too_many_arguments)] pub(in crate::execution) fn get_vote_states( platform: &TempPlatform, platform_state: &PlatformState, @@ -2211,6 +2209,7 @@ pub(in crate::execution) mod tests { ) } + #[allow(clippy::too_many_arguments)] pub(in crate::execution) fn get_proved_vote_states( platform: &TempPlatform, platform_state: &PlatformState, @@ -2493,8 +2492,8 @@ pub(in crate::execution) mod tests { let processing_result = platform .platform .process_raw_state_transitions( - &vec![serialized_state_transition], - &platform_state, + &[serialized_state_transition], + platform_state, &BlockInfo::default(), &transaction, platform_version, @@ -2514,6 +2513,9 @@ pub(in crate::execution) mod tests { } mod keyword_search_contract { + use dpp::consensus::basic::BasicError; + use dpp::consensus::ConsensusError; + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::PaidConsensusError; use super::*; // // ────────────────────────────────────────────────────────────────────────── @@ -2891,7 +2893,7 @@ pub(in crate::execution) mod tests { } #[test] - fn owner_can_delete_keyword_document() { + fn owner_can_not_delete_keyword_document() { let platform_version = PlatformVersion::latest(); let mut platform = TestPlatformBuilder::new() .build_with_mock_rpc() @@ -2951,10 +2953,12 @@ pub(in crate::execution) mod tests { None, ) .expect("process"); - assert_matches!( - processing_result.into_execution_results().remove(0), - SuccessfulExecution(..) + processing_result.execution_results().as_slice(), + [PaidConsensusError( + ConsensusError::BasicError(BasicError::InvalidDocumentTransitionActionError { .. }), + _ + )] ); } } diff --git a/packages/rs-drive/src/drive/contract/insert/add_description/mod.rs b/packages/rs-drive/src/drive/contract/insert/add_description/mod.rs index 5b179a9fa35..7a30de4169a 100644 --- a/packages/rs-drive/src/drive/contract/insert/add_description/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/add_description/mod.rs @@ -11,7 +11,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -mod v1; +mod v0; impl Drive { /// Creates the documents in the Keyword Search contract for the contract description and @@ -31,12 +31,9 @@ impl Drive { .methods .contract .insert - .insert_contract + .add_description { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract descriptions are not supported in this version", - ))), - 1 => self.add_new_contract_description_v1( + 0 => self.add_new_contract_description_v0( contract_id, owner_id, description, @@ -47,7 +44,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_new_contract_description".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -71,12 +68,9 @@ impl Drive { .methods .contract .insert - .insert_contract + .add_description { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract descriptions are not supported in this version", - ))), - 1 => self.add_new_contract_description_add_to_operations_v1( + 0 => self.add_new_contract_description_add_to_operations_v0( contract_id, owner_id, description, @@ -88,7 +82,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_new_contract_description_add_to_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -113,12 +107,9 @@ impl Drive { .methods .contract .insert - .insert_contract + .add_description { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract descriptions are not supported in this version", - ))), - 1 => self.add_new_contract_description_operations_v1( + 0 => self.add_new_contract_description_operations_v0( contract_id, owner_id, description, @@ -130,7 +121,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_new_contract_description_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } diff --git a/packages/rs-drive/src/drive/contract/insert/add_description/v1/mod.rs b/packages/rs-drive/src/drive/contract/insert/add_description/v0/mod.rs similarity index 91% rename from packages/rs-drive/src/drive/contract/insert/add_description/v1/mod.rs rename to packages/rs-drive/src/drive/contract/insert/add_description/v0/mod.rs index 65181745dbd..2c730f8e158 100644 --- a/packages/rs-drive/src/drive/contract/insert/add_description/v1/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/add_description/v0/mod.rs @@ -5,6 +5,7 @@ use crate::util::object_size_info::DocumentInfo::DocumentOwnedInfo; use crate::util::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contracts::keyword_search_contract; use dpp::document::{Document, DocumentV0}; use dpp::fee::fee_result::FeeResult; use dpp::identifier::Identifier; @@ -16,7 +17,7 @@ use std::collections::{BTreeMap, HashMap}; impl Drive { /// Creates the documents in the Keyword Search contract for the contract description and /// returns the fee result - pub(super) fn add_new_contract_description_v1( + pub(super) fn add_new_contract_description_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -27,7 +28,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { let mut drive_operations: Vec = vec![]; - self.add_new_contract_description_add_to_operations_v1( + self.add_new_contract_description_add_to_operations_v0( contract_id, owner_id, description, @@ -50,7 +51,7 @@ impl Drive { /// Creates and applies the LowLeveLDriveOperations needed to create /// the documents in the Keyword Search contract for the contract description - pub(super) fn add_new_contract_description_add_to_operations_v1( + pub(super) fn add_new_contract_description_add_to_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -88,7 +89,7 @@ impl Drive { /// Creates and returns the LowLeveLDriveOperations needed to create /// the documents in the Keyword Search contract for the contract description - pub(crate) fn add_new_contract_description_operations_v1( + pub(crate) fn add_new_contract_description_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -107,7 +108,7 @@ impl Drive { let short_description_document_type = contract.document_type_for_name("shortDescription")?; - let short_description_document = self.build_contract_description_document_owned_v1( + let short_description_document = self.build_contract_description_document_owned_v0( contract_id, owner_id, description, @@ -137,7 +138,7 @@ impl Drive { if !short_only { let full_description_document_type = contract.document_type_for_name("fullDescription")?; - let full_description_document = self.build_contract_description_document_owned_v1( + let full_description_document = self.build_contract_description_document_owned_v0( contract_id, owner_id, description, @@ -167,7 +168,7 @@ impl Drive { } /// Creates and returns a contract `description` document for the Keyword Search contract - pub(super) fn build_contract_description_document_owned_v1( + fn build_contract_description_document_owned_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -175,13 +176,6 @@ impl Drive { full_description: bool, block_info: &BlockInfo, ) -> Result { - let owner_nonce = - match self.fetch_identity_nonce(owner_id.into(), true, None, PlatformVersion::latest()) - { - Ok(maybe_nonce) => maybe_nonce.unwrap_or(1), - Err(e) => return Err(e), - }; - let document_type_name = if full_description { "fullDescription".to_string() } else { @@ -189,10 +183,10 @@ impl Drive { }; let document_id = Document::generate_document_id_v0( - &contract_id, + &keyword_search_contract::ID_BYTES.into(), &owner_id, &document_type_name, - &owner_nonce.to_be_bytes(), + contract_id.as_slice(), ); let properties = BTreeMap::from([ @@ -208,7 +202,7 @@ impl Drive { created_at: Some(block_info.time_ms), updated_at: None, transferred_at: None, - created_at_block_height: Some(block_info.height), + created_at_block_height: None, updated_at_block_height: None, transferred_at_block_height: None, created_at_core_block_height: None, diff --git a/packages/rs-drive/src/drive/contract/insert/add_new_keywords/mod.rs b/packages/rs-drive/src/drive/contract/insert/add_new_keywords/mod.rs index 26425f07479..0f89e9043c0 100644 --- a/packages/rs-drive/src/drive/contract/insert/add_new_keywords/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/add_new_keywords/mod.rs @@ -11,7 +11,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -mod v1; +mod v0; impl Drive { /// Creates the documents in the Keyword Search contract for the contract keywords and @@ -26,17 +26,8 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - match platform_version - .drive - .methods - .contract - .insert - .insert_contract - { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract keywords are not supported in this version", - ))), - 1 => self.add_new_contract_keywords_v1( + match platform_version.drive.methods.contract.insert.add_keywords { + 0 => self.add_new_contract_keywords_v0( contract_id, owner_id, keywords, @@ -47,7 +38,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_new_keywords".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -66,17 +57,8 @@ impl Drive { drive_operations: &mut Vec, platform_version: &PlatformVersion, ) -> Result<(), Error> { - match platform_version - .drive - .methods - .contract - .insert - .insert_contract - { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract keywords are not supported in this version", - ))), - 1 => self.add_new_contract_keywords_add_to_operations_v1( + match platform_version.drive.methods.contract.insert.add_keywords { + 0 => self.add_new_contract_keywords_add_to_operations_v0( contract_id, owner_id, keywords, @@ -88,7 +70,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_new_keywords_add_to_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -108,17 +90,8 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - match platform_version - .drive - .methods - .contract - .insert - .insert_contract - { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract keywords are not supported in this version", - ))), - 1 => self.add_new_contract_keywords_operations_v1( + match platform_version.drive.methods.contract.insert.add_keywords { + 0 => self.add_new_contract_keywords_operations_v0( contract_id, owner_id, keywords, @@ -129,7 +102,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_new_keywords_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } diff --git a/packages/rs-drive/src/drive/contract/insert/add_new_keywords/v1/mod.rs b/packages/rs-drive/src/drive/contract/insert/add_new_keywords/v0/mod.rs similarity index 85% rename from packages/rs-drive/src/drive/contract/insert/add_new_keywords/v1/mod.rs rename to packages/rs-drive/src/drive/contract/insert/add_new_keywords/v0/mod.rs index 9c49185a9cb..5f83da58b5e 100644 --- a/packages/rs-drive/src/drive/contract/insert/add_new_keywords/v1/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/add_new_keywords/v0/mod.rs @@ -5,6 +5,7 @@ use crate::util::object_size_info::DocumentInfo::DocumentOwnedInfo; use crate::util::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contracts::keyword_search_contract; use dpp::document::{Document, DocumentV0}; use dpp::fee::fee_result::FeeResult; use dpp::identifier::Identifier; @@ -16,7 +17,7 @@ use std::collections::{BTreeMap, HashMap}; impl Drive { /// Creates the documents in the Keyword Search contract for the contract keywords and /// returns the fee result - pub(super) fn add_new_contract_keywords_v1( + pub(super) fn add_new_contract_keywords_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -27,7 +28,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { let mut drive_operations: Vec = vec![]; - self.add_new_contract_keywords_add_to_operations_v1( + self.add_new_contract_keywords_add_to_operations_v0( contract_id, owner_id, keywords, @@ -50,7 +51,7 @@ impl Drive { /// Creates and applies the LowLeveLDriveOperations needed to create /// the documents in the Keyword Search contract for the contract keywords - pub(super) fn add_new_contract_keywords_add_to_operations_v1( + pub(super) fn add_new_contract_keywords_add_to_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -88,7 +89,7 @@ impl Drive { /// Creates and returns the LowLeveLDriveOperations needed to create /// the documents in the Keyword Search contract for the contract keywords - pub(crate) fn add_new_contract_keywords_operations_v1( + pub(crate) fn add_new_contract_keywords_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -100,17 +101,16 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - let mut operations: Vec = vec![]; + let mut drive_operations: Vec = vec![]; let contract = self.cache.system_data_contracts.load_keyword_search(); let document_type = contract.document_type_for_name("contractKeywords")?; for keyword in keywords.iter() { - let document = self.build_contract_keyword_document_owned_v1( + let document = self.build_contract_keyword_document_owned_v0( contract_id, owner_id, keyword, // since keywords are unique in the contract, we can use it as entropy - block_info, )?; let ops = self.add_document_for_contract_operations( @@ -124,31 +124,34 @@ impl Drive { }, true, block_info, - &mut None, + &mut Some(&mut drive_operations), estimated_costs_only_with_layer_info, transaction, platform_version, )?; - operations.extend(ops); + drive_operations.extend(ops); } - Ok(operations) + Ok(drive_operations) } /// Creates and returns a `contractKeyword` document for the Keyword Search contract - pub(super) fn build_contract_keyword_document_owned_v1( + pub(super) fn build_contract_keyword_document_owned_v0( &self, contract_id: Identifier, owner_id: Identifier, keyword: &String, - block_info: &BlockInfo, ) -> Result { + let mut entropy = Vec::with_capacity(contract_id.len() + keyword.len()); + entropy.extend_from_slice(contract_id.as_slice()); + entropy.extend_from_slice(keyword.as_bytes()); + let document_id = Document::generate_document_id_v0( - &contract_id, + &keyword_search_contract::ID_BYTES.into(), &owner_id, "contractKeywords", - keyword.as_bytes(), + entropy.as_slice(), ); let properties = BTreeMap::from([ @@ -161,10 +164,10 @@ impl Drive { owner_id, properties, revision: None, - created_at: Some(block_info.time_ms), + created_at: None, updated_at: None, transferred_at: None, - created_at_block_height: Some(block_info.height), + created_at_block_height: None, updated_at_block_height: None, transferred_at_block_height: None, created_at_core_block_height: None, diff --git a/packages/rs-drive/src/drive/contract/update/mod.rs b/packages/rs-drive/src/drive/contract/update/mod.rs index c24eb531f5c..d50a7e7d905 100644 --- a/packages/rs-drive/src/drive/contract/update/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/mod.rs @@ -1 +1,4 @@ mod update_contract; +mod update_description; + +mod update_keywords; diff --git a/packages/rs-drive/src/drive/contract/update/update_contract/v1/mod.rs b/packages/rs-drive/src/drive/contract/update/update_contract/v1/mod.rs index 57263f111b2..b3965fe69b6 100644 --- a/packages/rs-drive/src/drive/contract/update/update_contract/v1/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_contract/v1/mod.rs @@ -20,11 +20,6 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -#[allow(clippy::too_many_arguments)] -mod update_description; -#[allow(clippy::too_many_arguments)] -mod update_keywords; - impl Drive { /// Updates a data contract. /// @@ -230,7 +225,7 @@ impl Drive { for (token_pos, configuration) in contract.tokens() { let token_id = contract.token_id(*token_pos).ok_or(Error::DataContract( DataContractError::CorruptedDataContract(format!( - "data contract has a token at position {}, but can not find it", + "data contract has a token at position {}, but it can not be found", token_pos )), ))?; diff --git a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/mod.rs b/packages/rs-drive/src/drive/contract/update/update_description/mod.rs similarity index 81% rename from packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/mod.rs rename to packages/rs-drive/src/drive/contract/update/update_description/mod.rs index edcecc128a1..4493ee88822 100644 --- a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_description/mod.rs @@ -11,7 +11,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -mod v1; +mod v0; impl Drive { /// Updates the documents in the Keyword Search contract for the contract @@ -31,12 +31,9 @@ impl Drive { .methods .contract .update - .update_contract + .update_description { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract descriptions are not supported in this version", - ))), - 1 => self.update_contract_description_v1( + 0 => self.update_contract_description_v0( contract_id, owner_id, description, @@ -70,13 +67,10 @@ impl Drive { .drive .methods .contract - .insert - .insert_contract + .update + .update_description { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract descriptions are not supported in this version", - ))), - 1 => self.update_contract_description_add_to_operations_v1( + 0 => self.update_contract_description_add_to_operations_v0( contract_id, owner_id, description, @@ -88,7 +82,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "update_contract_description_add_to_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -112,13 +106,10 @@ impl Drive { .drive .methods .contract - .insert - .insert_contract + .update + .update_description { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract descriptions are not supported in this version", - ))), - 1 => self.update_contract_description_operations_v1( + 0 => self.update_contract_description_operations_v0( contract_id, owner_id, description, @@ -129,7 +120,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "update_contract_description_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } diff --git a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs b/packages/rs-drive/src/drive/contract/update/update_description/v0/mod.rs similarity index 90% rename from packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs rename to packages/rs-drive/src/drive/contract/update/update_description/v0/mod.rs index b7eecd11331..e9439504fb9 100644 --- a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_description/v1/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_description/v0/mod.rs @@ -19,7 +19,8 @@ use std::collections::HashMap; impl Drive { /// Updates the documents in the Keyword Search contract for the contract /// update description and returns the fee result - pub(super) fn update_contract_description_v1( + #[allow(clippy::too_many_arguments)] + pub(super) fn update_contract_description_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -30,7 +31,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { let mut drive_operations: Vec = vec![]; - self.update_contract_description_add_to_operations_v1( + self.update_contract_description_add_to_operations_v0( contract_id, owner_id, description, @@ -53,7 +54,8 @@ impl Drive { /// Creates and applies the LowLeveLDriveOperations needed to update /// the documents in the Keyword Search contract for the contract description - pub(super) fn update_contract_description_add_to_operations_v1( + #[allow(clippy::too_many_arguments)] + pub(super) fn update_contract_description_add_to_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -91,7 +93,8 @@ impl Drive { /// Creates and returns the LowLeveLDriveOperations needed to update /// the documents in the Keyword Search contract for the contract description - pub(super) fn update_contract_description_operations_v1( + #[allow(clippy::too_many_arguments)] + pub(super) fn update_contract_description_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -105,11 +108,7 @@ impl Drive { ) -> Result, Error> { let mut operations: Vec = vec![]; - let contract = self - .cache - .system_data_contracts - .load_keyword_search() - .clone(); + let contract = self.cache.system_data_contracts.load_keyword_search(); let document_type = contract.document_type_for_name("shortDescription")?; let mut query = DriveDocumentQuery::all_items_query(&contract, document_type, None); @@ -131,7 +130,7 @@ impl Drive { Some(platform_version.protocol_version), )?; - let existing_documents = query_outcome.documents(); + let mut existing_documents = query_outcome.documents_owned(); if existing_documents.len() > 1 { return Err(Error::Drive(DriveError::CorruptedContractIndexes( @@ -141,7 +140,7 @@ impl Drive { if existing_documents.is_empty() { // Add the new one - operations.extend(self.add_new_contract_description_operations_v1( + operations.extend(self.add_new_contract_description_operations_v0( contract_id, owner_id, description, @@ -153,9 +152,9 @@ impl Drive { )?); } else { // Replace the existing one - let document = existing_documents.first().expect("Document should exist"); - let mut new_document = document.clone(); + let mut new_document = existing_documents.remove(0); new_document.set("description", Value::Text(description.clone())); + new_document.set_updated_at(Some(block_info.time_ms)); let info = DocumentAndContractInfo { owned_document_info: OwnedDocumentInfo { diff --git a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_keywords/mod.rs b/packages/rs-drive/src/drive/contract/update/update_keywords/mod.rs similarity index 80% rename from packages/rs-drive/src/drive/contract/update/update_contract/v1/update_keywords/mod.rs rename to packages/rs-drive/src/drive/contract/update/update_keywords/mod.rs index 3b65b078997..9c10581861d 100644 --- a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_keywords/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_keywords/mod.rs @@ -11,7 +11,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -mod v1; +mod v0; impl Drive { /// Updates the documents in the Keyword Search contract for the contract @@ -30,13 +30,10 @@ impl Drive { .drive .methods .contract - .insert - .insert_contract + .update + .update_keywords { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract keywords are not supported in this version", - ))), - 1 => self.update_contract_keywords_v1( + 0 => self.update_contract_keywords_v0( contract_id, owner_id, keywords, @@ -47,7 +44,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "update_keywords".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -71,12 +68,9 @@ impl Drive { .methods .contract .update - .update_contract + .update_keywords { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract keywords are not supported in this version", - ))), - 1 => self.update_contract_keywords_add_to_operations_v1( + 0 => self.update_contract_keywords_add_to_operations_v0( contract_id, owner_id, keywords, @@ -88,7 +82,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "update_keywords_add_to_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } @@ -113,12 +107,9 @@ impl Drive { .methods .contract .update - .update_contract + .update_keywords { - 0 => Err(Error::Drive(DriveError::NotSupported( - "Contract keywords are not supported in this version", - ))), - 1 => self.update_contract_keywords_operations_v1( + 0 => self.update_contract_keywords_operations_v0( contract_id, owner_id, keywords, @@ -129,7 +120,7 @@ impl Drive { ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "update_keywords_operations".to_string(), - known_versions: vec![0, 1], + known_versions: vec![0], received: version, })), } diff --git a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_keywords/v1/mod.rs b/packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs similarity index 82% rename from packages/rs-drive/src/drive/contract/update/update_contract/v1/update_keywords/v1/mod.rs rename to packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs index a219ba93900..bf0687bd92a 100644 --- a/packages/rs-drive/src/drive/contract/update/update_contract/v1/update_keywords/v1/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_keywords/v0/mod.rs @@ -1,6 +1,5 @@ use crate::drive::document::query::QueryDocumentsOutcomeV0Methods; use crate::drive::Drive; -use crate::error::drive::DriveError; use crate::error::Error; use crate::fees::op::LowLevelDriveOperation; use crate::query::{DriveDocumentQuery, WhereClause, WhereOperator}; @@ -9,16 +8,17 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::document::DocumentV0Getters; use dpp::fee::fee_result::FeeResult; use dpp::identifier::Identifier; +use dpp::platform_value::btreemap_extensions::BTreeValueMapHelper; use dpp::platform_value::Value; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; impl Drive { /// Updates the documents in the Keyword Search contract for the contract /// update keywords and returns the fee result - pub(super) fn update_contract_keywords_v1( + pub(super) fn update_contract_keywords_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -29,7 +29,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { let mut drive_operations: Vec = vec![]; - self.update_contract_keywords_add_to_operations_v1( + self.update_contract_keywords_add_to_operations_v0( contract_id, owner_id, keywords, @@ -52,7 +52,7 @@ impl Drive { /// Creates and applies the LowLeveLDriveOperations needed to update /// the documents in the Keyword Search contract for the contract keywords - pub(super) fn update_contract_keywords_add_to_operations_v1( + pub(super) fn update_contract_keywords_add_to_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -90,7 +90,7 @@ impl Drive { /// Creates and returns the LowLeveLDriveOperations needed to update /// the documents in the Keyword Search contract for the contract keywords - pub(super) fn update_contract_keywords_operations_v1( + pub(super) fn update_contract_keywords_operations_v0( &self, contract_id: Identifier, owner_id: Identifier, @@ -105,11 +105,7 @@ impl Drive { let mut operations: Vec = vec![]; // First get the existing keywords so we know which ones we need to delete and which new ones we need to add - let contract = self - .cache - .system_data_contracts - .load_keyword_search() - .clone(); + let contract = self.cache.system_data_contracts.load_keyword_search(); let document_type = contract.document_type_for_name("contractKeywords")?; let mut query = DriveDocumentQuery::all_items_query(&contract, document_type, None); @@ -131,24 +127,16 @@ impl Drive { Some(platform_version.protocol_version), )?; - let mut existing: Vec<(String, Identifier)> = Vec::new(); - for doc in query_outcome.documents() { - let kw = doc - .get("keyword") - .and_then(|v| v.as_str()) - .ok_or_else(|| { - Error::Drive(DriveError::CorruptedDriveState( - "keyword should exist".to_string(), - )) - })? - .to_string(); - existing.push((kw, doc.id())); + let mut existing: BTreeMap = BTreeMap::new(); + for doc in query_outcome.documents_owned() { + let kw = doc.properties().get_string("keyword")?; + existing.insert(kw, doc.id()); } // If an existing keyword is not in the new keyword set, we delete it for (kw, doc_id) in &existing { - if !keywords.iter().any(|k| k == kw) { - operations.extend(self.delete_document_for_contract_operations( + if !keywords.contains(kw) { + operations.extend(self.force_delete_document_for_contract_operations( *doc_id, &contract, document_type, @@ -163,7 +151,7 @@ impl Drive { // Finally, add the new ones let mut keywords_to_add: Vec = Vec::new(); for kw in keywords { - if !existing.iter().any(|(e_kw, _)| e_kw == kw) { + if !existing.contains_key(kw) { keywords_to_add.push(kw.clone()); } } diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs index 919e1631d0d..74fefe304d9 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/mod.rs @@ -65,4 +65,56 @@ impl Drive { })), } } + + /// Prepares the operations for deleting a document and will delete even if the contract does + /// not allow for deletion, this is reserved for system data contracts. + /// + /// # Parameters + /// * `document_id`: The ID of the document to delete. + /// * `contract`: The contract that contains the document. + /// * `document_type`: The type of the document. + /// * `previous_batch_operations`: Previous batch operations to include. + /// * `estimated_costs_only_with_layer_info`: Estimated costs with layer info. + /// * `transaction`: The transaction argument. + /// * `drive_version`: The drive version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(Vec)` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + #[allow(clippy::too_many_arguments)] + pub(crate) fn force_delete_document_for_contract_operations( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + previous_batch_operations: Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .document + .delete + .delete_document_for_contract_operations + { + 0 => self.force_delete_document_for_contract_operations_v0( + document_id, + contract, + document_type, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "force_delete_document_for_contract_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } } diff --git a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v0/mod.rs index 97291e4e8e9..740e760e366 100644 --- a/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/delete_document_for_contract_operations/v0/mod.rs @@ -49,14 +49,32 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - let mut batch_operations: Vec = vec![]; - if !document_type.documents_can_be_deleted() { return Err(Error::Drive(DriveError::UpdatingReadOnlyImmutableDocument( "this document type is not mutable and can not be deleted", ))); } + self.force_delete_document_for_contract_operations_v0(document_id, contract, document_type, previous_batch_operations, estimated_costs_only_with_layer_info, transaction, platform_version) + } + + /// Prepares the operations for deleting a document. + #[inline(always)] + #[allow(clippy::too_many_arguments)] + pub(super) fn force_delete_document_for_contract_operations_v0( + &self, + document_id: Identifier, + contract: &DataContract, + document_type: DocumentTypeRef, + previous_batch_operations: Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut batch_operations: Vec = vec![]; + if document_type.documents_keep_history() { return Err(Error::Drive( DriveError::InvalidDeletionOfDocumentThatKeepsHistory( diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs index a216992f698..a9fc9cbe44f 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/mod.rs @@ -30,11 +30,15 @@ pub struct DriveContractApplyMethodVersions { pub struct DriveContractInsertMethodVersions { pub add_contract_to_storage: FeatureVersion, pub insert_contract: FeatureVersion, + pub add_description: FeatureVersion, + pub add_keywords: FeatureVersion, } #[derive(Clone, Debug, Default)] pub struct DriveContractUpdateMethodVersions { pub update_contract: FeatureVersion, + pub update_description: FeatureVersion, + pub update_keywords: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs index 67824dafea1..f8f8f3291b4 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v1.rs @@ -18,8 +18,14 @@ pub const DRIVE_CONTRACT_METHOD_VERSIONS_V1: DriveContractMethodVersions = insert: DriveContractInsertMethodVersions { add_contract_to_storage: 0, insert_contract: 0, + add_description: 0, + add_keywords: 0, + }, + update: DriveContractUpdateMethodVersions { + update_contract: 0, + update_description: 0, + update_keywords: 0, }, - update: DriveContractUpdateMethodVersions { update_contract: 0 }, costs: DriveContractCostsMethodVersions { add_estimation_costs_for_contract_insertion: 0, }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs index 9f4565afee3..9ba0cd15ef4 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_contract_method_versions/v2.rs @@ -18,8 +18,14 @@ pub const DRIVE_CONTRACT_METHOD_VERSIONS_V2: DriveContractMethodVersions = insert: DriveContractInsertMethodVersions { add_contract_to_storage: 0, insert_contract: 1, // <--- changed to v1 (for token insertion) + add_description: 0, + add_keywords: 0, + }, + update: DriveContractUpdateMethodVersions { + update_contract: 1, // <--- changed to v1 (for token insertion) + update_description: 0, + update_keywords: 0, }, - update: DriveContractUpdateMethodVersions { update_contract: 1 }, // <--- changed to v1 (for token insertion) costs: DriveContractCostsMethodVersions { add_estimation_costs_for_contract_insertion: 0, },